1 /*******************************************************************************
2 * Copyright (c) 2010, 2013 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.editors
;
15 import org
.eclipse
.core
.resources
.IFile
;
16 import org
.eclipse
.core
.runtime
.content
.IContentType
;
17 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
19 import org
.eclipse
.ui
.IEditorInput
;
20 import org
.eclipse
.ui
.IPersistableElement
;
21 import org
.eclipse
.ui
.PlatformUI
;
22 import org
.eclipse
.ui
.ide
.IDE
;
25 * The input interface for TMF editors.
28 * @author Patrick Tasse
30 public class TmfEditorInput
implements IEditorInput
{
32 private final IFile fFile
;
33 private final ITmfTrace fTrace
;
36 * Standard constructor
38 * @param file The IFile pointer
39 * @param trace Reference to the trace
41 public TmfEditorInput(IFile file
, ITmfTrace trace
) {
47 public Object
getAdapter(Class adapter
) {
52 public boolean exists() {
53 /* prevent this input from appearing in "Files Most Recently Used" list,
54 * as this causes lingering reference to ITmfTrace in the platform */
59 public ImageDescriptor
getImageDescriptor() {
60 IContentType contentType
= IDE
.getContentType(fFile
);
61 return PlatformUI
.getWorkbench().getEditorRegistry()
62 .getImageDescriptor(fFile
.getName(), contentType
);
66 public String
getName() {
67 return fTrace
.getName();
71 public IPersistableElement
getPersistable() {
76 public String
getToolTipText() {
77 return fFile
.getFullPath().makeRelative().toString();
81 * Get this editor input's file object
85 public IFile
getFile() {
90 * Get this editor input's trace
94 public ITmfTrace
getTrace() {
99 public int hashCode() {
100 final int prime
= 31;
102 result
= prime
* result
+ ((fFile
== null) ?
0 : fFile
.getLocation().hashCode());
103 result
= prime
* result
+ ((fTrace
== null) ?
0 : fTrace
.getName().hashCode());
108 public boolean equals(Object obj
) {
115 if (getClass() != obj
.getClass()) {
118 TmfEditorInput other
= (TmfEditorInput
) obj
;
120 if (other
.fFile
!= null) {
123 } else if (!fFile
.getLocation().equals(other
.fFile
.getLocation())) {
126 if (fTrace
== null) {
127 if (other
.fTrace
!= null) {
130 } else if (!fTrace
.getName().equals(other
.fTrace
.getName())) {
This page took 0.034614 seconds and 6 git commands to generate.