Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeEditorInput.java139
1 files changed, 85 insertions, 54 deletions
diff --git a/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeEditorInput.java b/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeEditorInput.java
index 6f3d734817c..98978a5bfa8 100644
--- a/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeEditorInput.java
+++ b/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeEditorInput.java
@@ -3,6 +3,7 @@ package org.eclipse.papyrus.infra.core.sasheditor.tests.texteditor;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider;
import org.eclipse.ui.IEditorInput;
@@ -12,28 +13,29 @@ import org.eclipse.ui.part.FileEditorInput;
/**
* A fake {@link IEditorInput} suitable for creating TextEditor.
* This IEditorInput allows to carry the {@link ISashWindowsContentProvider} to the created Editor.
- *
- *
- * @copy Copied from org.eclipse.ui.internal.part.NullEditorInput v3.8
+ *
+ *
+ * @copy Copied from org.eclipse.ui.internal.part.NullEditorInput v3.8
*/
public class FakeEditorInput extends FileEditorInput implements IEditorInput {
protected ISashWindowsContentProvider contentProvider;
-
- static int count =0;
-
+
+ static int count = 0;
+
/**
* Create a temporary file to pass to the texteditor.
+ *
* @return
*/
static IFile createIFile() {
// the name used is no important as nothing is created.
IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject("org.eclipse.papyrus.tests.tmp");
- IFile model1File = p.getFile("tmp/model" + count++ +".txt");
-// System.err.println("file: " + model1File.getName());
+ IFile model1File = p.getFile("tmp/model" + count++ + ".txt");
+ // System.err.println("file: " + model1File.getName());
return model1File;
}
-
+
/**
* Creates a <code>FakeEditorInput</code>.
*/
@@ -44,7 +46,7 @@ public class FakeEditorInput extends FileEditorInput implements IEditorInput {
/**
* Constructor.
* Carry the contentProvider to the created editor.
- *
+ *
* @param contentProvider
*/
public FakeEditorInput(ISashWindowsContentProvider contentProvider) {
@@ -53,7 +55,7 @@ public class FakeEditorInput extends FileEditorInput implements IEditorInput {
}
/**
- *
+ *
* @return
*/
public ISashWindowsContentProvider getContentProvider() {
@@ -61,54 +63,83 @@ public class FakeEditorInput extends FileEditorInput implements IEditorInput {
}
/**
- *
+ *
* @param contentProvider
*/
public void setContentProvider(ISashWindowsContentProvider contentProvider) {
this.contentProvider = contentProvider;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#exists()
- */
- public boolean exists() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
- */
- public ImageDescriptor getImageDescriptor() {
- return ImageDescriptor.getMissingImageDescriptor();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getName()
- */
-// public String getName() {
-// String result = null;
-// return ""; //$NON-NLS-1$
-// }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getPersistable()
- */
- public IPersistableElement getPersistable() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getToolTipText()
- */
- public String getToolTipText() {
- return ""; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- return null;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IEditorInput#exists()
+ */
+ @Override
+ public boolean exists() {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return ImageDescriptor.getMissingImageDescriptor();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IEditorInput#getName()
+ */
+ // public String getName() {
+ // String result = null;
+ // return ""; //$NON-NLS-1$
+ // }
+
+ /**
+ * We need to implement this method to avoid possible exceptions.
+ * Moreover, we get easier way to get the file path.
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.part.FileEditorInput#getPath()
+ */
+ @Override
+ public IPath getPath() {
+ return getFile().getFullPath();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IEditorInput#getPersistable()
+ */
+ @Override
+ public IPersistableElement getPersistable() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IEditorInput#getToolTipText()
+ */
+ @Override
+ public String getToolTipText() {
+ return ""; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ return null;
+ }
}

Back to the top