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
) {
37 public Object
getAdapter(@SuppressWarnings("rawtypes") Class adapter
) {
41 public boolean exists() {
42 return fResource
.exists();
45 public ImageDescriptor
getImageDescriptor() {
46 if (fResource
instanceof IFile
) {
47 IFile file
= (IFile
) fResource
;
48 IContentType contentType
= IDE
.getContentType(file
);
49 return PlatformUI
.getWorkbench().getEditorRegistry()
50 .getImageDescriptor(file
.getName(), contentType
);
55 public String
getName() {
56 return fResource
.getName();
59 public IPersistableElement
getPersistable() {
63 public String
getToolTipText() {
64 return fResource
.getFullPath().makeRelative().toString();
67 public IResource
getResource() {
71 public ITmfTrace
getTrace() {
76 public boolean equals(Object obj
) {
77 if (obj
instanceof TmfEditorInput
) {
78 return fResource
.equals(((TmfEditorInput
) obj
).fResource
);
79 } else if (obj
instanceof IFileEditorInput
) {
80 return ((IFileEditorInput
) obj
).getFile().equals(fResource
);
81 } else if (obj
instanceof FileStoreEditorInput
) {
82 return ((FileStoreEditorInput
) obj
).getURI().equals(fResource
.getRawLocationURI());
This page took 0.033546 seconds and 5 git commands to generate.