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
.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 fResource
.getName();
64 public IPersistableElement
getPersistable() {
69 public String
getToolTipText() {
70 return fResource
.getFullPath().makeRelative().toString();
73 public IResource
getResource() {
77 public ITmfTrace
getTrace() {
82 public boolean equals(Object obj
) {
83 if (obj
instanceof TmfEditorInput
) {
84 return fResource
.equals(((TmfEditorInput
) obj
).fResource
);
85 } else if (obj
instanceof IFileEditorInput
) {
86 return ((IFileEditorInput
) obj
).getFile().equals(fResource
);
87 } else if (obj
instanceof FileStoreEditorInput
) {
88 return ((FileStoreEditorInput
) obj
).getURI().equals(fResource
.getRawLocationURI());
This page took 0.031583 seconds and 5 git commands to generate.