Author: scabanovich
Date: 2007-10-16 07:50:31 -0400 (Tue, 16 Oct 2007)
New Revision: 4218
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/NullEditorPart.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/core/resources/XModelObjectEditorInput.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/core/resources/XModelObjectEditorInputFactory.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/EditorPartWrapper.java
Log:
JBIDE-765
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF 2007-10-16
11:10:30 UTC (rev 4217)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF 2007-10-16
11:50:31 UTC (rev 4218)
@@ -111,6 +111,7 @@
org.eclipse.jdt.launching,
org.eclipse.ant.ui,
org.eclipse.core.expressions,
+ org.eclipse.core.filesystem,
org.eclipse.wst.html.core
Bundle-Version: 2.0.0
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/core/resources/XModelObjectEditorInput.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/core/resources/XModelObjectEditorInput.java 2007-10-16
11:10:30 UTC (rev 4217)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/core/resources/XModelObjectEditorInput.java 2007-10-16
11:50:31 UTC (rev 4218)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.common.core.resources;
-import java.io.File;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URI;
@@ -22,6 +21,7 @@
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.*;
import org.eclipse.ui.editors.text.ILocationProvider;
+import org.eclipse.ui.internal.part.NullEditorInput;
import org.eclipse.ui.part.FileEditorInput;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.impl.*;
@@ -233,7 +233,7 @@
String jarFile = entryInfo[0];
String entry = entryInfo[1];
IEditorInput result = createJarEntryEditorInput(jarFile, entry);
- return (result == null) ? input : result;
+ return (result == null || result instanceof NullEditorInput) ? input : result;
}
public static String[] parseJarEntryFileInput(IStorageEditorInput input) {
@@ -266,9 +266,10 @@
return (n == null) ? null : n.getModel().getByPath("/" + entry);
}
- public static IEditorInput createJarEntryEditorInput(String jarFile, String entry) {
+ public static IEditorInput createJarEntryEditorInput(String jarFile, final String entry)
{
XModelObject o = getJarEntryObject(jarFile, entry);
- return (o != null) ? new ModelObjectJarEntryEditorInput(o, jarFile, entry) : null;
+ if(o != null) return new ModelObjectJarEntryEditorInput(o, jarFile, entry);
+ return XModelObjectEditorInputFactory.createNullEditorInput(entry);
}
public String getFactoryId() {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/core/resources/XModelObjectEditorInputFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/core/resources/XModelObjectEditorInputFactory.java 2007-10-16
11:10:30 UTC (rev 4217)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/core/resources/XModelObjectEditorInputFactory.java 2007-10-16
11:50:31 UTC (rev 4218)
@@ -11,9 +11,11 @@
package org.jboss.tools.common.core.resources;
import java.io.File;
+
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.ui.*;
+import org.eclipse.ui.internal.part.NullEditorInput;
import org.eclipse.ui.part.*;
import org.jboss.tools.common.model.*;
import org.jboss.tools.common.model.filesystems.impl.FileSystemImpl;
@@ -53,6 +55,7 @@
private IAdaptable createStorageElement(IMemento memento) {
String projectPath = memento.getString(TAG_PROJECT);
XModelObject object = null;
+ String missingName = "";
if(projectPath == null) {
String fileLocation = memento.getString(TAG_FILE_LOCATION);
if(fileLocation != null) {
@@ -60,6 +63,8 @@
if(f.isFile()) {
object = EclipseResourceUtil.createObjectForLocation(fileLocation);
return (object == null) ? null : new ModelObjectLocationEditorInput(object, new
Path(f.getAbsolutePath()));
+ } else {
+ missingName = f.getName();
}
}
} else if(memento.getString(TAG_ENTRY) != null) {
@@ -71,12 +76,15 @@
String objectPath = memento.getString(TAG_PATH);
IModelNature nature = EclipseResourceUtil.getModelNature(project);
if(nature == null) {
+ missingName = "" + objectPath;
} else {
XModel model = nature.getModel();
object = model.getByPath(objectPath);
}
}
- if(object == null) return null;
+ if(object == null) {
+ return createNullEditorInput(missingName);
+ }
return new ModelObjectStorageEditorInput(object);
}
@@ -129,5 +137,20 @@
}
return null;
}
+
+ public static IEditorInput createNullEditorInput(final String entry) {
+ return new NullEditorInput() {
+ public String getName() {
+ if(entry != null) {
+ int i = entry.lastIndexOf('/');
+ if(i > 0) return entry.substring(i + 1);
+ }
+ return entry;
+ }
+ public String getToolTipText() {
+ return entry;
+ }
+ };
+ }
}
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/NullEditorPart.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/NullEditorPart.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/NullEditorPart.java 2007-10-16
11:50:31 UTC (rev 4218)
@@ -0,0 +1,51 @@
+package org.jboss.tools.common.editor;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.part.EditorPart;
+
+public class NullEditorPart extends EditorPart {
+
+ public NullEditorPart() {}
+
+ public void doSave(IProgressMonitor monitor) {
+ }
+
+ public void doSaveAs() {
+ }
+
+ public void createPartControl(Composite parent) {
+ Composite c = new Composite(parent, SWT.NONE);
+ c.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
+ c.setLayout(new GridLayout());
+ c.setLayoutData(new GridData(GridData.FILL_BOTH));
+ Label label = new Label(c, SWT.NONE);
+ label.setText("Resource has been externally removed.");
+ label.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
+ }
+
+ public void init(IEditorSite site, IEditorInput input) {
+ setSite(site);
+ setInput(input);
+ setPartName(input.getName());
+ }
+
+ public boolean isDirty() {
+ return false;
+ }
+
+ public boolean isSaveAsAllowed() {
+ return false;
+ }
+
+ public void setFocus() {
+ }
+
+}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/EditorPartWrapper.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/EditorPartWrapper.java 2007-10-16
11:10:30 UTC (rev 4217)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/EditorPartWrapper.java 2007-10-16
11:50:31 UTC (rev 4218)
@@ -16,6 +16,7 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
import org.jboss.tools.common.core.resources.XModelObjectEditorInput;
+import org.jboss.tools.common.editor.NullEditorPart;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
@@ -25,6 +26,7 @@
import org.eclipse.ui.IReusableEditor;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.internal.part.NullEditorInput;
import org.eclipse.ui.part.EditorPart;
import org.eclipse.ui.part.WorkbenchPart;
@@ -68,6 +70,14 @@
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
input = XModelObjectEditorInput.checkInput(input);
+ if(input instanceof NullEditorInput) {
+ entity = "";
+ editor = new NullEditorPart();
+ editor.init(site, input);
+ setSite(site);
+ setInput(input);
+ return;
+ }
entity = computeEntity(input);
EditorPartWrapperExtension extension = EditorPartWrapperExtension.getInstance();
EditorPartFactory f = extension.getFactory(entity);