-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.editors;\r
-\r
-import org.eclipse.core.resources.IFile;\r
-import org.eclipse.core.runtime.content.IContentType;\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-import org.eclipse.ui.IEditorInput;\r
-import org.eclipse.ui.IPersistableElement;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.eclipse.ui.ide.IDE;\r
-\r
-/**\r
- * The input interface for TMF editors.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TmfEditorInput implements IEditorInput {\r
-\r
- private final IFile fFile;\r
- private final ITmfTrace fTrace;\r
-\r
- /**\r
- * Standard constructor\r
- *\r
- * @param file The IFile pointer\r
- * @param trace Reference to the trace\r
- */\r
- public TmfEditorInput(IFile file, ITmfTrace trace) {\r
- fFile = file;\r
- fTrace = trace;\r
- }\r
-\r
- @Override\r
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {\r
- return null;\r
- }\r
-\r
- @Override\r
- public boolean exists() {\r
- return fFile.exists();\r
- }\r
-\r
- @Override\r
- public ImageDescriptor getImageDescriptor() {\r
- IContentType contentType = IDE.getContentType(fFile);\r
- return PlatformUI.getWorkbench().getEditorRegistry()\r
- .getImageDescriptor(fFile.getName(), contentType);\r
- }\r
-\r
- @Override\r
- public String getName() {\r
- return fTrace.getName();\r
- }\r
-\r
- @Override\r
- public IPersistableElement getPersistable() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public String getToolTipText() {\r
- return fFile.getFullPath().makeRelative().toString();\r
- }\r
-\r
- /**\r
- * Get this editor input's file object\r
- *\r
- * @return The IFile\r
- */\r
- public IFile getFile() {\r
- return fFile;\r
- }\r
-\r
- /**\r
- * Get this editor input's trace\r
- *\r
- * @return The trace\r
- */\r
- public ITmfTrace getTrace() {\r
- return fTrace;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see java.lang.Object#hashCode()\r
- */\r
- @Override\r
- public int hashCode() {\r
- final int prime = 31;\r
- int result = 1;\r
- result = prime * result + ((fFile == null) ? 0 : fFile.getLocation().hashCode());\r
- result = prime * result + ((fTrace == null) ? 0 : fTrace.getName().hashCode());\r
- return result;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see java.lang.Object#equals(java.lang.Object)\r
- */\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (this == obj) {\r
- return true;\r
- }\r
- if (obj == null) {\r
- return false;\r
- }\r
- if (getClass() != obj.getClass()) {\r
- return false;\r
- }\r
- TmfEditorInput other = (TmfEditorInput) obj;\r
- if (fFile == null) {\r
- if (other.fFile != null) {\r
- return false;\r
- }\r
- } else if (!fFile.getLocation().equals(other.fFile.getLocation())) {\r
- return false;\r
- }\r
- if (fTrace == null) {\r
- if (other.fTrace != null) {\r
- return false;\r
- }\r
- } else if (!fTrace.getName().equals(other.fTrace.getName())) {\r
- return false;\r
- }\r
- return true;\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.editors;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+/**
+ * The input interface for TMF editors.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TmfEditorInput implements IEditorInput {
+
+ private final IFile fFile;
+ private final ITmfTrace fTrace;
+
+ /**
+ * Standard constructor
+ *
+ * @param file The IFile pointer
+ * @param trace Reference to the trace
+ */
+ public TmfEditorInput(IFile file, ITmfTrace trace) {
+ fFile = file;
+ fTrace = trace;
+ }
+
+ @Override
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+
+ @Override
+ public boolean exists() {
+ /* prevent this input from appearing in "Files Most Recently Used" list,
+ * as this causes lingering reference to ITmfTrace in the platform */
+ return false;
+ }
+
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ IContentType contentType = IDE.getContentType(fFile);
+ return PlatformUI.getWorkbench().getEditorRegistry()
+ .getImageDescriptor(fFile.getName(), contentType);
+ }
+
+ @Override
+ public String getName() {
+ return fTrace.getName();
+ }
+
+ @Override
+ public IPersistableElement getPersistable() {
+ return null;
+ }
+
+ @Override
+ public String getToolTipText() {
+ return fFile.getFullPath().makeRelative().toString();
+ }
+
+ /**
+ * Get this editor input's file object
+ *
+ * @return The IFile
+ */
+ public IFile getFile() {
+ return fFile;
+ }
+
+ /**
+ * Get this editor input's trace
+ *
+ * @return The trace
+ */
+ public ITmfTrace getTrace() {
+ return fTrace;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((fFile == null) ? 0 : fFile.getLocation().hashCode());
+ result = prime * result + ((fTrace == null) ? 0 : fTrace.getName().hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TmfEditorInput other = (TmfEditorInput) obj;
+ if (fFile == null) {
+ if (other.fFile != null) {
+ return false;
+ }
+ } else if (!fFile.getLocation().equals(other.fFile.getLocation())) {
+ return false;
+ }
+ if (fTrace == null) {
+ if (other.fTrace != null) {
+ return false;
+ }
+ } else if (!fTrace.getName().equals(other.fTrace.getName())) {
+ return false;
+ }
+ return true;
+ }
+
+}