1 /*******************************************************************************
2 * Copyright (c) 2010, 2012 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 * @see java.lang.Object#hashCode()
102 public int hashCode() {
103 final int prime
= 31;
105 result
= prime
* result
+ ((fFile
== null) ?
0 : fFile
.getLocation().hashCode());
106 result
= prime
* result
+ ((fTrace
== null) ?
0 : fTrace
.getName().hashCode());
111 * @see java.lang.Object#equals(java.lang.Object)
114 public boolean equals(Object obj
) {
121 if (getClass() != obj
.getClass()) {
124 TmfEditorInput other
= (TmfEditorInput
) obj
;
126 if (other
.fFile
!= null) {
129 } else if (!fFile
.getLocation().equals(other
.fFile
.getLocation())) {
132 if (fTrace
== null) {
133 if (other
.fTrace
!= null) {
136 } else if (!fTrace
.getName().equals(other
.fTrace
.getName())) {
This page took 0.038764 seconds and 6 git commands to generate.