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
.resources
.IResource
;
17 import org
.eclipse
.core
.runtime
.content
.IContentType
;
18 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
20 import org
.eclipse
.ui
.IEditorInput
;
21 import org
.eclipse
.ui
.IFileEditorInput
;
22 import org
.eclipse
.ui
.IPersistableElement
;
23 import org
.eclipse
.ui
.PlatformUI
;
24 import org
.eclipse
.ui
.ide
.FileStoreEditorInput
;
25 import org
.eclipse
.ui
.ide
.IDE
;
27 public class TmfEditorInput
implements IEditorInput
{
29 private IResource fResource
;
30 private ITmfTrace
<?
> fTrace
;
32 public TmfEditorInput(IResource resource
, ITmfTrace
<?
> trace
) {
38 public Object
getAdapter(@SuppressWarnings("rawtypes") Class adapter
) {
43 public boolean exists() {
44 return fResource
.exists();
48 public ImageDescriptor
getImageDescriptor() {
49 if (fResource
instanceof IFile
) {
50 IFile file
= (IFile
) fResource
;
51 IContentType contentType
= IDE
.getContentType(file
);
52 return PlatformUI
.getWorkbench().getEditorRegistry()
53 .getImageDescriptor(file
.getName(), contentType
);
59 public String
getName() {
60 return fTrace
.getName();
64 public IPersistableElement
getPersistable() {
69 public String
getToolTipText() {
70 return fResource
.getFullPath().makeRelative().toString();
73 public IResource
getResource() {
77 public ITmfTrace
<?
> getTrace() {
82 * @see java.lang.Object#hashCode()
85 public int hashCode() {
88 result
= prime
* result
+ ((fResource
== null) ?
0 : fResource
.hashCode());
89 result
= prime
* result
+ ((fTrace
== null) ?
0 : fTrace
.hashCode());
94 * @see java.lang.Object#equals(java.lang.Object)
97 public boolean equals(Object obj
) {
104 if (obj
instanceof TmfEditorInput
) {
105 return fResource
.equals(((TmfEditorInput
) obj
).fResource
);
106 } else if (obj
instanceof IFileEditorInput
) {
107 return ((IFileEditorInput
) obj
).getFile().equals(fResource
);
108 } else if (obj
instanceof FileStoreEditorInput
) {
109 return ((FileStoreEditorInput
) obj
).getURI().equals(fResource
.getRawLocationURI());
This page took 0.034688 seconds and 6 git commands to generate.