1 /*******************************************************************************
2 * Copyright (c) 2010 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(@SuppressWarnings("rawtypes") Class adapter
) {
52 public boolean exists() {
53 return fFile
.exists();
57 public ImageDescriptor
getImageDescriptor() {
58 IContentType contentType
= IDE
.getContentType(fFile
);
59 return PlatformUI
.getWorkbench().getEditorRegistry()
60 .getImageDescriptor(fFile
.getName(), contentType
);
64 public String
getName() {
65 return fTrace
.getName();
69 public IPersistableElement
getPersistable() {
74 public String
getToolTipText() {
75 return fFile
.getFullPath().makeRelative().toString();
79 * Get this editor input's file object
83 public IFile
getFile() {
88 * Get this editor input's trace
92 public ITmfTrace
getTrace() {
97 * @see java.lang.Object#hashCode()
100 public int hashCode() {
101 final int prime
= 31;
103 result
= prime
* result
+ ((fFile
== null) ?
0 : fFile
.getLocation().hashCode());
104 result
= prime
* result
+ ((fTrace
== null) ?
0 : fTrace
.getName().hashCode());
109 * @see java.lang.Object#equals(java.lang.Object)
112 public boolean equals(Object obj
) {
119 if (getClass() != obj
.getClass()) {
122 TmfEditorInput other
= (TmfEditorInput
) obj
;
124 if (other
.fFile
!= null) {
127 } else if (!fFile
.getLocation().equals(other
.fFile
.getLocation())) {
130 if (fTrace
== null) {
131 if (other
.fTrace
!= null) {
134 } else if (!fTrace
.getName().equals(other
.fTrace
.getName())) {
This page took 0.034626 seconds and 6 git commands to generate.