[159196] Opening remote schema from within local schema file opens empty document
diff --git a/bundles/org.eclipse.wst.xsd.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.wst.xsd.ui/META-INF/MANIFEST.MF
index 1c8a6af..e79f930 100644
--- a/bundles/org.eclipse.wst.xsd.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.wst.xsd.ui/META-INF/MANIFEST.MF
@@ -79,6 +79,7 @@
org.eclipse.ltk.ui.refactoring;bundle-version="[3.2.0,4.0.0)",
org.eclipse.wst.xsd.core;bundle-version="[1.1.0,1.2.0)",
org.eclipse.search;bundle-version="[3.2.0,4.0.0)",
- com.ibm.icu;bundle-version="[3.4.4,4.0.0)"
+ com.ibm.icu;bundle-version="[3.4.4,4.0.0)",
+ org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)"
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/TopLevelComponentEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/TopLevelComponentEditPart.java
index 195cbce..13f918f 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/TopLevelComponentEditPart.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/TopLevelComponentEditPart.java
@@ -39,7 +39,6 @@
import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter;
import org.eclipse.wst.xsd.ui.internal.adapters.XSDSchemaDirectiveAdapter;
-import org.eclipse.wst.xsd.ui.internal.adt.actions.SetInputToGraphView;
import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseEditPart;
import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.INamedEditPart;
import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart;
@@ -49,6 +48,7 @@
import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.IADTUpdateCommand;
import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.SimpleDirectEditPolicy;
import org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.figures.FieldFigure;
+import org.eclipse.wst.xsd.ui.internal.common.actions.OpenInNewEditor;
import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand;
import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils;
import org.eclipse.wst.xsd.ui.internal.design.editpolicies.SelectionHandlesEditPolicyImpl;
@@ -268,7 +268,7 @@
schemaLocation = URIHelper.removePlatformResourceProtocol(dir.getResolvedSchema().getSchemaLocation());
if (schemaLocation != null)
{
- OpenOnSelectionHelper.openXSDEditor(schemaLocation);
+ OpenOnSelectionHelper.openXSDEditor(dir.getResolvedSchema());
}
}
}
@@ -294,9 +294,17 @@
if (editPart instanceof RootContentEditPart)
{
IEditorPart editorPart = getEditorPart();
+// ActionRegistry registry = (ActionRegistry) editorPart.getAdapter(ActionRegistry.class);
+// IAction action = registry.getAction(SetInputToGraphView.ID);
+// action.run();
ActionRegistry registry = (ActionRegistry) editorPart.getAdapter(ActionRegistry.class);
- IAction action = registry.getAction(SetInputToGraphView.ID);
- action.run();
+ if (registry != null)
+ {
+ IAction action = registry.getAction(OpenInNewEditor.ID);
+ if (action != null)
+ action.run();
+ return;
+ }
}
}
};
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDBaseFieldEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDBaseFieldEditPart.java
index 6a41f7c..8c461b5 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDBaseFieldEditPart.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDBaseFieldEditPart.java
@@ -101,7 +101,8 @@
{
super.createEditPolicies();
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionHandlesEditPolicy);
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DragAndDropEditPolicy(getViewer(), selectionHandlesEditPolicy));
+ if (!isFileReadOnly())
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DragAndDropEditPolicy(getViewer(), selectionHandlesEditPolicy));
}
protected void directEditNameField()
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/XSDGraphViewerDialog.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/XSDGraphViewerDialog.java
index dc18306..de93dfa 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/XSDGraphViewerDialog.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/XSDGraphViewerDialog.java
@@ -10,11 +10,7 @@
*******************************************************************************/
package org.eclipse.wst.xsd.ui.internal.dialogs;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.gef.EditPartFactory;
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
@@ -38,25 +34,20 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.forms.events.IHyperlinkListener;
import org.eclipse.ui.forms.widgets.Hyperlink;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory;
import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart;
import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootEditPart;
import org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.figures.TypeVizFigureFactory;
+import org.eclipse.wst.xsd.ui.internal.common.actions.OpenInNewEditor;
import org.eclipse.wst.xsd.ui.internal.common.util.Messages;
import org.eclipse.wst.xsd.ui.internal.design.editparts.XSDEditPartFactory;
-import org.eclipse.wst.xsd.ui.internal.editor.InternalXSDMultiPageEditor;
import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.editor.XSDFileEditorInput;
import org.eclipse.xsd.XSDConcreteComponent;
import org.eclipse.xsd.XSDSchema;
@@ -245,8 +236,10 @@
public boolean close()
{
getShell().removeControlListener(moveListener);
- link.removeHyperlinkListener(linkListener);
- infoFont.dispose();
+ if (link != null)
+ link.removeHyperlinkListener(linkListener);
+ if (infoFont != null)
+ infoFont.dispose();
infoFont = null;
return super.close();
}
@@ -284,97 +277,59 @@
{
}
}
-
+
+ /**
+ * @deprecated since 1.2.101
+ * @param xsdComponent
+ * @param schema
+ * @param editorName
+ */
public static void openNonXSDResourceSchema(XSDConcreteComponent xsdComponent, XSDSchema schema, String editorName)
{
- if (schema != null)
- {
- String schemaLocation = URIHelper.removePlatformResourceProtocol(schema.getSchemaLocation());
- IPath schemaPath = new Path(schemaLocation);
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(schemaPath);
- if (file != null && file.exists())
- {
- IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (workbenchWindow != null)
- {
- IWorkbenchPage page = workbenchWindow.getActivePage();
- try
- {
- IEditorPart editorPart = null;
-
- XSDFileEditorInput editorInput = new XSDFileEditorInput(file, schema);
-
- editorInput.setEditorName(editorName);
- IEditorReference[] refs = page.getEditorReferences();
- int length = refs.length;
- for (int i = 0; i < length; i++)
- {
- IEditorInput input = refs[i].getEditorInput();
- if (input instanceof XSDFileEditorInput)
- {
- IFile aFile = ((XSDFileEditorInput) input).getFile();
- if (aFile.getFullPath().equals(file.getFullPath()))
- {
- if (((XSDFileEditorInput) input).getSchema() == schema)
- {
- editorPart = refs[i].getEditor(true);
- page.activate(refs[i].getPart(true));
- break;
- }
- }
- }
- }
-
- if (editorPart == null)
- {
- editorPart = page.openEditor(editorInput, "org.eclipse.wst.xsd.ui.internal.editor.InternalXSDMultiPageEditor", true, 0); //$NON-NLS-1$
- }
-
- if (editorPart instanceof InternalXSDMultiPageEditor)
- {
- InternalXSDMultiPageEditor xsdEditor = (InternalXSDMultiPageEditor) editorPart;
- xsdEditor.openOnGlobalReference(xsdComponent);
- }
- }
- catch (PartInitException pie)
- {
-
- }
- }
- }
- }
+ openInlineSchema(getCurrentEditorInput(), xsdComponent, schema, editorName);
}
+ public static void openInlineSchema(IEditorInput editorInput, XSDConcreteComponent xsdComponent, XSDSchema schema, String editorName)
+ {
+ OpenInNewEditor.openInlineSchema(editorInput, xsdComponent, schema, editorName);
+ }
+
+ /**
+ * @deprecated
+ */
public static void openXSDEditor(XSDConcreteComponent xsdComponent)
{
- XSDSchema schema = xsdComponent.getSchema();
- if (schema != null)
- {
- String schemaLocation = URIHelper.removePlatformResourceProtocol(schema.getSchemaLocation());
- IPath schemaPath = new Path(schemaLocation);
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(schemaPath);
- if (file != null && file.exists())
- {
- IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (workbenchWindow != null)
- {
- IWorkbenchPage page = workbenchWindow.getActivePage();
- try
- {
- IEditorPart editorPart = IDE.openEditor(page, file, true);
- if (editorPart instanceof InternalXSDMultiPageEditor)
- {
- InternalXSDMultiPageEditor xsdEditor = (InternalXSDMultiPageEditor) editorPart;
- xsdEditor.openOnGlobalReference(xsdComponent);
- }
- }
- catch (PartInitException pie)
- {
+ openXSDEditor(getCurrentEditorInput(), xsdComponent.getSchema(), xsdComponent);
+ }
+ public static void openXSDEditor(IEditorInput editorInput, XSDSchema schema, XSDConcreteComponent xsdComponent)
+ {
+ OpenInNewEditor.openXSDEditor(editorInput, schema, xsdComponent);
+ }
+
+ private static IEditorInput getCurrentEditorInput()
+ {
+ try
+ {
+ IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page = null;
+ if (workbenchWindow != null)
+ {
+ page = workbenchWindow.getActivePage();
+ if (page != null)
+ {
+ IEditorPart editorPart = page.getActiveEditor();
+ if (editorPart != null)
+ {
+ return editorPart.getEditorInput();
}
}
}
- }
+ }
+ catch (Exception e)
+ {
+
+ }
+ return null;
}
-
}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/InternalXSDMultiPageEditor.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/InternalXSDMultiPageEditor.java
index 481e423..e2c1143 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/InternalXSDMultiPageEditor.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/InternalXSDMultiPageEditor.java
@@ -52,6 +52,7 @@
import org.eclipse.ui.INavigationLocationProvider;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
@@ -78,6 +79,7 @@
import org.eclipse.wst.xsd.ui.internal.adt.editor.ADTMultiPageEditor;
import org.eclipse.wst.xsd.ui.internal.adt.editor.EditorMode;
import org.eclipse.wst.xsd.ui.internal.adt.editor.EditorModeManager;
+import org.eclipse.wst.xsd.ui.internal.adt.editor.IADTEditorInput;
import org.eclipse.wst.xsd.ui.internal.adt.editor.ProductCustomizationProvider;
import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject;
import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel;
@@ -156,17 +158,20 @@
IEditorInput editorInput = getEditorInput();
// If the input schema is from the WSDL Editor, then use that inline schema
- if (editorInput instanceof XSDFileEditorInput)
+ if (editorInput instanceof IADTEditorInput)
{
- xsdSchema = ((XSDFileEditorInput) editorInput).getSchema();
- model = (IModel) XSDAdapterFactory.getInstance().adapt(xsdSchema);
+ xsdSchema = ((IADTEditorInput) editorInput).getSchema();
+ if (xsdSchema != null)
+ model = (IModel) XSDAdapterFactory.getInstance().adapt(xsdSchema);
}
Document document = null;
IDocument doc = structuredTextEditor.getDocumentProvider().getDocument(getEditorInput());
if (doc instanceof IStructuredDocument)
{
- IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForEdit(doc);
+ IStructuredModel model = null;
+ // TODO: for StorageEditorInputs, should be forRead
+ model = StructuredModelManager.getModelManager().getExistingModelForEdit(doc);
if (model == null) {
model = StructuredModelManager.getModelManager().getModelForEdit((IStructuredDocument) doc);
}
@@ -181,10 +186,10 @@
xsdSchema = XSDModelAdapter.lookupOrCreateSchema(document);
model = (IModel) XSDAdapterFactory.getInstance().adapt(xsdSchema);
}
- catch (Exception e) {
- e.printStackTrace();
- }
+ catch (Exception e)
+ {
+ }
// try
// {
@@ -282,7 +287,7 @@
protected void initializeGraphicalViewer()
{
RootContentEditPart root = new RootContentEditPart();
- if (!(getEditorInput() instanceof XSDFileEditorInput))
+ if (!(getEditorInput() instanceof IADTEditorInput))
{
root.setModel(model);
}
@@ -515,10 +520,21 @@
}
}
+ public boolean isReadOnly()
+ {
+ IEditorInput editorInput = getEditorInput();
+ return !(editorInput instanceof IFileEditorInput || editorInput instanceof FileStoreEditorInput);
+ }
+
protected void createActions()
{
super.createActions();
+
ActionRegistry registry = getActionRegistry();
+
+ // add an isReadOnly method to the editorPart instead
+ if (!isReadOnly())
+ {
BaseSelectionAction action = new AddFieldAction(this);
action.setSelectionProvider(getSelectionManager());
registry.registerAction(action);
@@ -646,6 +662,20 @@
BaseDirectEditAction directEditAction = new BaseDirectEditAction(this);
directEditAction.setSelectionProvider(getSelectionManager());
registry.registerAction(directEditAction);
+
+ }
+ else
+ {
+ BaseSelectionAction action = new OpenInNewEditor(this);
+ action.setSelectionProvider(getSelectionManager());
+ registry.registerAction(action);
+
+ action = new ShowPropertiesViewAction(this);
+ registry.registerAction(action);
+
+ PrintAction printAction = new PrintAction(this);
+ registry.registerAction(printAction);
+ }
}
protected void addMultiplicityMenu(ActionRegistry registry)
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/XSDEditorPlugin.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/XSDEditorPlugin.java
index 9dd40a5..a866a64 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/XSDEditorPlugin.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/XSDEditorPlugin.java
@@ -39,7 +39,7 @@
public static final String EXTENSIONS_SCHEMAS_EXTENSIONID = "org.eclipse.wst.xsd.ui.extensionCategories"; //$NON-NLS-1$
private static final String DEPRECATED_EXTENSIONS_SCHEMAS_EXTENSIONID = "org.eclipse.wst.xsd.ui.ExtensionsSchemasDescription"; //$NON-NLS-1$
public final static String DEFAULT_TARGET_NAMESPACE = "http://www.example.org"; //$NON-NLS-1$
-
+ public final static String XSD_CONTENT_TYPE_ID = "org.eclipse.wst.xsd.core.xsdsource"; //$NON-NLS-1$
//The shared instance.
private static XSDEditorPlugin plugin;
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/XSDFileEditorInput.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/XSDFileEditorInput.java
index 78f1d89..62f283f 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/XSDFileEditorInput.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/XSDFileEditorInput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* 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
@@ -12,9 +12,10 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.wst.xsd.ui.internal.adt.editor.IADTEditorInput;
import org.eclipse.xsd.XSDSchema;
-public class XSDFileEditorInput extends FileEditorInput
+public class XSDFileEditorInput extends FileEditorInput implements IADTEditorInput
{
private IFile file;
private XSDSchema schema;
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/messages.properties b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/messages.properties
index 7f12f54..e8ea16f 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/messages.properties
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/messages.properties
@@ -29,7 +29,7 @@
UI_LABEL_MAXOCCURS = Maximum Occurrence:
UI_PAGE_HEADING_REFERENCE = Reference
-UI_LABEL_READ_ONLY = Read-Only
+UI_LABEL_READ_ONLY = read-only
UI_NO_TYPE = No Type
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/text/XSDModelAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/text/XSDModelAdapter.java
index 94239e4..5979978 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/text/XSDModelAdapter.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/text/XSDModelAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
* 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
@@ -88,6 +88,10 @@
{
uri = URI.createPlatformResourceURI(baseLocation);
}
+ else if (baseLocation.startsWith("http"))
+ {
+ uri = URI.createURI(baseLocation);
+ }
else
{
uri = URI.createFileURI(baseLocation);
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/utils/OpenOnSelectionHelper.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/utils/OpenOnSelectionHelper.java
index 9d5ca46..b898d5a 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/utils/OpenOnSelectionHelper.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/utils/OpenOnSelectionHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* 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
@@ -20,13 +20,16 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.wst.xsd.ui.internal.common.actions.OpenInNewEditor;
import org.eclipse.wst.xsd.ui.internal.editor.InternalXSDMultiPageEditor;
import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin;
import org.eclipse.xsd.XSDAttributeDeclaration;
@@ -63,10 +66,17 @@
boolean lastResult;
+ public static void openXSDEditor(XSDSchema schema)
+ {
+ IEditorInput editorInput = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput();
+
+ OpenInNewEditor.openXSDEditor(editorInput, schema, schema);
+
+ }
+
public static void openXSDEditor(String schemaLocation)
{
- IPath schemaPath = new Path(schemaLocation);
-
+ IPath schemaPath = new Path(schemaLocation);
final IFile schemaFile = ResourcesPlugin.getWorkspace().getRoot().getFile(schemaPath);
Display.getDefault().asyncExec(new Runnable()
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseEditPart.java
index 188f0ed..0a1ca1d 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseEditPart.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseEditPart.java
@@ -12,6 +12,7 @@
import java.util.Iterator;
import java.util.List;
+
import org.eclipse.core.runtime.Assert;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.EditPart;
@@ -21,10 +22,14 @@
import org.eclipse.gef.editparts.ZoomListener;
import org.eclipse.gef.editparts.ZoomManager;
import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider;
import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IFeedbackHandler;
import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.KeyBoardAccessibilityEditPolicy;
@@ -195,5 +200,31 @@
public EditPart doGetRelativeEditPart(EditPart editPart, int direction)
{
return null;
- }
+ }
+
+ protected boolean isFileReadOnly()
+ {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ if (workbench != null)
+ {
+ IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+ if (workbenchWindow != null)
+ {
+ IWorkbenchPage page = workbenchWindow.getActivePage();
+ if (page != null)
+ {
+ IEditorPart editor = page.getActiveEditor();
+ if (editor != null)
+ {
+ IEditorInput editorInput = editor.getEditorInput();
+ if (!(editorInput instanceof IFileEditorInput || editorInput instanceof FileStoreEditorInput))
+ {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseFieldEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseFieldEditPart.java
index 524ce99..944b6b7 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseFieldEditPart.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/design/editparts/BaseFieldEditPart.java
@@ -301,7 +301,7 @@
public void performRequest(Request request)
{
- if (((IADTObject)getModel()).isReadOnly())
+ if (((IADTObject)getModel()).isReadOnly() || isFileReadOnly())
{
return;
}
@@ -336,6 +336,7 @@
protected void directEditNameField()
{
+ if (isFileReadOnly()) return;
Object model = getModel();
IFieldFigure fieldFigure = getFieldFigure();
if ( model instanceof IField)
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ADTExternalResourceVariant.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ADTExternalResourceVariant.java
new file mode 100644
index 0000000..19f5aaf
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ADTExternalResourceVariant.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.adt.editor;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.SocketTimeoutException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.eclipse.core.resources.IEncodedStorage;
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin;
+
+public class ADTExternalResourceVariant extends PlatformObject
+{
+ private IStorage storage;
+ private String urlString;
+
+ public static String getCharset(String name, InputStream stream) throws IOException
+ {
+ IContentDescription description = getContentDescription(name, stream);
+ return description == null ? null : description.getCharset();
+ }
+
+ public static IContentDescription getContentDescription(String name, InputStream stream) throws IOException
+ {
+ IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+ try
+ {
+ return contentTypeManager.getDescriptionFor(stream, name, IContentDescription.ALL);
+ }
+ finally
+ {
+ if (stream != null)
+ {
+ try
+ {
+ stream.close();
+ }
+ catch (IOException e)
+ {
+
+ }
+ }
+ }
+ }
+
+ public ADTExternalResourceVariant(String urlString)
+ {
+ this.urlString = urlString;
+ }
+
+ class XSDResourceVariantStorage implements IEncodedStorage
+ {
+
+ protected File getFile()
+ {
+ return new File(urlString);
+ }
+
+ public InputStream getContents() throws CoreException
+ {
+ try
+ {
+ URL url = new URL(urlString);
+ URLConnection urlConnection = url.openConnection();
+ return urlConnection.getInputStream();
+ }
+ catch (SocketTimeoutException toException)
+ {
+ // handle
+ }
+ catch (IOException e)
+ {
+
+ }
+ return new ByteArrayInputStream(new byte[0]);
+ }
+
+ public IPath getFullPath()
+ {
+ return new Path(urlString);
+ }
+
+ public String getName()
+ {
+ return getFullPath().toFile().getName();
+ }
+
+ public boolean isReadOnly()
+ {
+ return true;
+ }
+
+ public Object getAdapter(Class adapter)
+ {
+ return ADTExternalResourceVariant.this.getAdapter(adapter);
+ }
+
+ public String getCharset() throws CoreException
+ {
+ InputStream contents = getContents();
+ try
+ {
+ String charSet = ADTExternalResourceVariant.getCharset(getName(), contents);
+ return charSet;
+ }
+ catch (IOException e)
+ {
+ throw new CoreException(new Status(IStatus.ERROR, XSDEditorPlugin.PLUGIN_ID, IResourceStatus.FAILED_DESCRIBING_CONTENTS, NLS.bind("", new String[] { getFullPath().toString() }), e));
+ }
+ finally
+ {
+ try
+ {
+ contents.close();
+ }
+ catch (IOException ioException)
+ {
+
+ }
+ }
+ }
+ }
+
+ public IStorage getStorage()
+ {
+ if (storage == null)
+ {
+ storage = new XSDResourceVariantStorage();
+ }
+ return storage;
+ }
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ADTFileStoreEditorInput.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ADTFileStoreEditorInput.java
new file mode 100644
index 0000000..d9fc877
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ADTFileStoreEditorInput.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.adt.editor;
+
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.ui.ide.FileStoreEditorInput;
+import org.eclipse.wst.xsd.ui.internal.editor.Messages;
+import org.eclipse.xsd.XSDSchema;
+
+public class ADTFileStoreEditorInput extends FileStoreEditorInput implements IADTEditorInput
+{
+ private XSDSchema schema;
+ private String editorName;
+
+ public ADTFileStoreEditorInput(IFileStore fileStore, XSDSchema xsdSchema)
+ {
+ super(fileStore);
+ this.schema = xsdSchema;
+ }
+
+ public XSDSchema getSchema()
+ {
+ return schema;
+ }
+
+ public void setEditorName(String name)
+ {
+ editorName = name;
+ }
+
+ public String getName()
+ {
+ if (editorName != null)
+ {
+ return editorName;
+ }
+ return super.getName();
+ }
+
+ public String getToolTipText()
+ {
+ if (schema != null)
+ {
+ String ns = schema.getTargetNamespace();
+ if (ns != null && ns.length() > 0)
+ return Messages._UI_LABEL_TARGET_NAMESPACE + ns;
+ else
+ return Messages._UI_LABEL_NO_NAMESPACE;
+ }
+ return super.getToolTipText();
+ }
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ADTReadOnlyFileEditorInput.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ADTReadOnlyFileEditorInput.java
new file mode 100644
index 0000000..b5fd8d2
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ADTReadOnlyFileEditorInput.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.adt.editor;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.IStorageEditorInput;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.wst.common.uriresolver.internal.URI;
+import org.eclipse.xsd.XSDSchema;
+
+/**
+ *
+ * Used for any read-only files, ie. HTTP files.
+ *
+ */
+public class ADTReadOnlyFileEditorInput implements IStorageEditorInput, IADTEditorInput
+{
+ protected String urlString;
+ protected IStorage storage;
+ protected ADTExternalResourceVariant variant;
+ protected XSDSchema xsdSchema;
+ protected String editorName;
+ protected String editorID = "";
+
+ public ADTReadOnlyFileEditorInput(String urlString)
+ {
+ this.urlString = urlString;
+ variant = new ADTExternalResourceVariant(urlString);
+ }
+
+ /*
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ return true;
+
+ if (o instanceof ADTReadOnlyFileEditorInput)
+ {
+ ADTReadOnlyFileEditorInput input = (ADTReadOnlyFileEditorInput) o;
+
+ return urlString.equals(input.getUrlString()) && input.getEditorID().equals(editorID);
+ }
+
+ return false;
+ }
+
+ public String getUrlString()
+ {
+ return urlString;
+ }
+
+ public IStorage getStorage() throws CoreException
+ {
+ storage = variant.getStorage();
+ return storage;
+ }
+
+ public boolean exists()
+ {
+ return false;
+ }
+
+ public ImageDescriptor getImageDescriptor()
+ {
+ return null;
+ }
+
+ public String getName()
+ {
+ if (editorName == null)
+ {
+ URI uri = URI.createURI(urlString);
+ return uri.lastSegment();
+ }
+ return editorName;
+ }
+
+ public IPersistableElement getPersistable()
+ {
+ // http files cannot persist
+ return null;
+ }
+
+ public String getToolTipText()
+ {
+ return urlString;
+ }
+
+ public Object getAdapter(Class adapter)
+ {
+ if (adapter == IWorkbenchAdapter.class)
+ return this;
+ if (adapter == IStorage.class)
+ return storage;
+ return null;
+ }
+
+ public void setSchema(XSDSchema xsdSchema)
+ {
+ this.xsdSchema = xsdSchema;
+ }
+
+ public XSDSchema getSchema()
+ {
+ return xsdSchema;
+ }
+
+ public void setEditorName(String name)
+ {
+ editorName = name;
+ }
+
+ public void setEditorID(String editorID)
+ {
+ this.editorID = editorID;
+ }
+
+ public String getEditorID()
+ {
+ return editorID;
+ }
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/IADTEditorInput.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/IADTEditorInput.java
new file mode 100644
index 0000000..a364d66
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/IADTEditorInput.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.adt.editor;
+
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.xsd.XSDSchema;
+
+public interface IADTEditorInput extends IEditorInput
+{
+ public XSDSchema getSchema();
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/OpenInNewEditor.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/OpenInNewEditor.java
index 31a5291..e27c20b 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/OpenInNewEditor.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/OpenInNewEditor.java
@@ -10,6 +10,10 @@
*******************************************************************************/
package org.eclipse.wst.xsd.ui.internal.common.actions;
+import java.net.URI;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
@@ -21,12 +25,17 @@
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.FileStoreEditorInput;
+import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter;
import org.eclipse.wst.xsd.ui.internal.adapters.XSDSchemaDirectiveAdapter;
import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction;
+import org.eclipse.wst.xsd.ui.internal.adt.editor.ADTFileStoreEditorInput;
+import org.eclipse.wst.xsd.ui.internal.adt.editor.ADTReadOnlyFileEditorInput;
import org.eclipse.wst.xsd.ui.internal.common.util.Messages;
import org.eclipse.wst.xsd.ui.internal.editor.InternalXSDMultiPageEditor;
import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin;
@@ -56,7 +65,20 @@
public void run()
{
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
-
+ IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page = null;
+ IEditorInput editorInput = null;
+ if (workbenchWindow != null)
+ {
+ page = workbenchWindow.getActivePage();
+ IEditorPart activeEditor = page.getActiveEditor();
+ if (activeEditor != null)
+ {
+ editorInput = activeEditor.getEditorInput();
+ }
+
+ }
+
if (selection instanceof XSDBaseAdapter)
{
XSDBaseAdapter xsdAdapter = (XSDBaseAdapter) selection;
@@ -70,104 +92,438 @@
fComponent = ((XSDFeature)fComponent).getResolvedFeature();
}
- if (fComponent.getSchema() != null && fComponent.eContainer() instanceof XSDSchema || isReference)
+ String schemaLocation = null;
+ IPath schemaPath = null;
+ IFile schemaFile = null;
+
+ // Special case any imports/includes
+ if (selection instanceof XSDSchemaDirectiveAdapter)
{
- String schemaLocation = URIHelper.removePlatformResourceProtocol(fComponent.getSchema().getSchemaLocation());
- IPath schemaPath = new Path(schemaLocation);
- IFile schemaFile = ResourcesPlugin.getWorkspace().getRoot().getFile(schemaPath);
-
- // Special case any imports/includes
- if (selection instanceof XSDSchemaDirectiveAdapter)
+ XSDSchemaDirective dir = (XSDSchemaDirective)((XSDSchemaDirectiveAdapter)selection).getTarget();
+ // force load of imported schema
+ if (dir instanceof XSDImportImpl)
{
- XSDSchemaDirective dir = (XSDSchemaDirective)((XSDSchemaDirectiveAdapter)selection).getTarget();
- // force load of imported schema
- if (dir instanceof XSDImportImpl)
+ ((XSDImportImpl)dir).importSchema();
+ }
+ if (dir.getResolvedSchema() != null)
+ {
+ schemaLocation = URIHelper.removePlatformResourceProtocol(dir.getResolvedSchema().getSchemaLocation());
+ schemaPath = new Path(schemaLocation);
+ schemaFile = ResourcesPlugin.getWorkspace().getRoot().getFile(schemaPath);
+ schema = dir.getResolvedSchema();
+ fComponent = dir.getResolvedSchema();
+ }
+ } // Handle any other external components
+ else if (fComponent.getSchema() != null && fComponent.eContainer() instanceof XSDSchema || isReference)
+ {
+ schemaLocation = URIHelper.removePlatformResourceProtocol(fComponent.getSchema().getSchemaLocation());
+ schemaPath = new Path(schemaLocation);
+ schemaFile = ResourcesPlugin.getWorkspace().getRoot().getFile(schemaPath);
+
+ try
+ {
+ XSDSchema xsdSchema = (XSDSchema)getWorkbenchPart().getAdapter(XSDSchema.class);
+ if (fComponent.getSchema() == xsdSchema)
{
- ((XSDImportImpl)dir).importSchema();
- }
- if (dir.getResolvedSchema() != null)
- {
- schemaLocation = URIHelper.removePlatformResourceProtocol(dir.getResolvedSchema().getSchemaLocation());
- schemaPath = new Path(schemaLocation);
- schemaFile = ResourcesPlugin.getWorkspace().getRoot().getFile(schemaPath);
- schema = dir.getResolvedSchema();
- fComponent = dir.getResolvedSchema();
+ IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if (editorPart instanceof InternalXSDMultiPageEditor)
+ {
+ ((InternalXSDMultiPageEditor) editorPart).openOnGlobalReference(fComponent);
+ }
+ return;
}
}
-
- if (schemaFile != null && schemaFile.exists())
+ catch (Exception e)
{
- IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (workbenchWindow != null)
+
+ }
+ }
+
+ // If the schemaFile exists in the workspace
+ if (page != null && schemaFile != null && schemaFile.exists())
+ {
+ try
+ {
+ // Get the current editor's schema
+ XSDSchema xsdSchema = (XSDSchema)getWorkbenchPart().getAdapter(XSDSchema.class);
+ IEditorPart editorPart = null;
+ // This first check is to ensure that the schema is actually
+ // different than the current one we are editing against in the editor, and that we
+ // are in the same resource file....hence multiple schemas in the same file.
+ if (xsdSchema != null && fComponent.getRootContainer().eResource() == xsdSchema.eResource() && xsdSchema != schema)
{
- IWorkbenchPage page = workbenchWindow.getActivePage();
- try
+ String editorName = null;
+ XSDFileEditorInput xsdFileEditorInput = new XSDFileEditorInput(schemaFile, fComponent.getSchema());
+ // will use FileEditorInput's name if still null
+ // Try to use the same editor name as the current one
+ if (editorInput != null)
{
- // Get the current editor's schema
- XSDSchema xsdSchema = (XSDSchema)getWorkbenchPart().getAdapter(XSDSchema.class);
-
- IEditorPart editorPart = null;
- // This first check is to ensure that the schema is actually
- // different than the current one we are editing against in the editor, and that we
- // are in the same resource file....hence multiple schemas in the same file.
- if (xsdSchema != null && fComponent.getRootContainer().eResource() == xsdSchema.eResource() && xsdSchema != schema)
- {
- XSDFileEditorInput xsdFileEditorInput = new XSDFileEditorInput(schemaFile, fComponent.getSchema());
- IEditorPart activeEditor = page.getActiveEditor();
- String editorName = null;
-
- // will use FileEditorInput's name if still null
- // Try to use the same editor name as the current one
- if (activeEditor != null)
- {
- IEditorInput input = activeEditor.getEditorInput();
- if (input != null)
- {
- editorName = input.getName();
- xsdFileEditorInput.setEditorName(editorName);
- }
- }
-
- IEditorReference [] refs = page.getEditorReferences();
- int length = refs.length;
- for (int i = 0; i < length; i++)
- {
- IEditorInput input = refs[i].getEditorInput();
- if (input instanceof XSDFileEditorInput)
- {
- IFile aFile = ((XSDFileEditorInput)input).getFile();
- if (aFile.getFullPath().equals(schemaFile.getFullPath()))
- {
- if (((XSDFileEditorInput)input).getSchema() == schema)
- {
- editorPart = refs[i].getEditor(true);
- page.activate(refs[i].getPart(true));
- break;
- }
- }
- }
- }
-
- if (editorPart == null)
- {
- editorPart = page.openEditor(xsdFileEditorInput, XSDEditorPlugin.EDITOR_ID, true, 0);
- }
- }
- else
- {
- editorPart = page.openEditor(new FileEditorInput(schemaFile), XSDEditorPlugin.EDITOR_ID);
- }
-
- if (editorPart instanceof InternalXSDMultiPageEditor)
- {
- ((InternalXSDMultiPageEditor) editorPart).openOnGlobalReference(fComponent);
- }
+ editorName = editorInput.getName();
+ xsdFileEditorInput.setEditorName(editorName);
}
- catch (Exception e)
+ editorPart = getExistingEditorForInlineSchema(page, schemaFile, schema);
+ if (editorPart == null)
{
+ editorPart = page.openEditor(xsdFileEditorInput, XSDEditorPlugin.EDITOR_ID, true, 0);
+ }
+ }
+ else
+ {
+ editorPart = page.openEditor(new FileEditorInput(schemaFile), XSDEditorPlugin.EDITOR_ID);
+ }
+ if (editorPart instanceof InternalXSDMultiPageEditor)
+ {
+ ((InternalXSDMultiPageEditor) editorPart).openOnGlobalReference(fComponent);
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ else
+ {
+ // open the xsd externally
+ if (schemaLocation != null)
+ openExternalFiles(page, schemaLocation, fComponent);
+ }
+ }
+ }
+
+ public static void openXSDEditor(IEditorInput editorInput, XSDConcreteComponent xsdComponent)
+ {
+ openXSDEditor(editorInput, xsdComponent.getSchema(), xsdComponent);
+ }
+
+ public static void openXSDEditor(IEditorInput editorInput, XSDSchema schema, XSDConcreteComponent xsdComponent)
+ {
+ IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page = null;
+ if (workbenchWindow != null)
+ {
+ page = workbenchWindow.getActivePage();
+ }
+
+ String resource = schema.getSchemaLocation();
+
+ if (editorInput instanceof FileEditorInput && resource != null && !resource.startsWith("http"))
+ {
+ String schemaLocation = URIHelper.removePlatformResourceProtocol(resource);
+ openWorkspaceFile(page, schemaLocation, xsdComponent);
+ }
+ else
+ {
+ openExternalFiles(page, resource, xsdComponent);
+ }
+ }
+
+ public static void openInlineSchema(IEditorInput editorInput, XSDConcreteComponent xsdComponent, XSDSchema schema, String editorName)
+ {
+ IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page = null;
+ if (workbenchWindow != null)
+ {
+ page = workbenchWindow.getActivePage();
+ }
+
+ boolean isWorkspaceFile = false;
+
+ String schemaLocation = schema.getSchemaLocation();
+ String workspaceFileLocation = URIHelper.removePlatformResourceProtocol(schemaLocation);
+ IPath workspaceFilePath = new Path(workspaceFileLocation);
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(workspaceFilePath);
+
+ if (page != null && file != null && file.exists())
+ {
+ isWorkspaceFile = true;
+ }
+
+ if (isWorkspaceFile)
+ {
+ try
+ {
+ IEditorPart editorPart = null;
+ XSDFileEditorInput xsdFileEditorInput = new XSDFileEditorInput(file, schema);
+ xsdFileEditorInput.setEditorName(editorName);
+ IEditorReference[] refs = page.getEditorReferences();
+ int length = refs.length;
+ for (int i = 0; i < length; i++)
+ {
+ IEditorInput input = refs[i].getEditorInput();
+ if (input instanceof XSDFileEditorInput)
+ {
+ IFile aFile = ((XSDFileEditorInput) input).getFile();
+ if (aFile.getFullPath().equals(file.getFullPath()))
+ {
+ if (((XSDFileEditorInput) input).getSchema() == schema)
+ {
+ editorPart = refs[i].getEditor(true);
+ page.activate(refs[i].getPart(true));
+ break;
+ }
}
}
}
+ if (editorPart == null)
+ {
+ editorPart = page.openEditor(xsdFileEditorInput, XSDEditorPlugin.EDITOR_ID, true, 0); //$NON-NLS-1$
+ }
+ if (editorPart instanceof InternalXSDMultiPageEditor)
+ {
+ InternalXSDMultiPageEditor xsdEditor = (InternalXSDMultiPageEditor) editorPart;
+ xsdEditor.openOnGlobalReference(xsdComponent);
+ }
+ }
+ catch (PartInitException pie)
+ {
+ }
+ }
+ else
+ {
+ if (schemaLocation != null && !schemaLocation.startsWith("http"))
+ {
+ String fileLocation = URIHelper.removeProtocol(schemaLocation);
+ IPath schemaPath = new Path(fileLocation);
+ IFileStore fileStore = EFS.getLocalFileSystem().getStore(schemaPath);
+ if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists())
+ {
+ try
+ {
+ ADTFileStoreEditorInput xsdFileStoreEditorInput = new ADTFileStoreEditorInput(fileStore, schema);
+ xsdFileStoreEditorInput.setEditorName(editorName);
+
+ IEditorPart editorPart = null;
+ IEditorReference[] refs = page.getEditorReferences();
+ int length = refs.length;
+ for (int i = 0; i < length; i++)
+ {
+ IEditorInput input = refs[i].getEditorInput();
+ if (input instanceof ADTFileStoreEditorInput)
+ {
+ URI uri = ((ADTFileStoreEditorInput) input).getURI();
+ if (uri.equals(xsdFileStoreEditorInput.getURI()) && ((ADTFileStoreEditorInput) input).getSchema() == xsdFileStoreEditorInput.getSchema())
+ {
+ editorPart = refs[i].getEditor(true);
+ page.activate(refs[i].getPart(true));
+ break;
+ }
+ }
+ }
+
+ if (page != null && editorPart == null)
+ {
+ editorPart = page.openEditor(xsdFileStoreEditorInput, XSDEditorPlugin.EDITOR_ID, true, 0); //$NON-NLS-1$
+ }
+ if (editorPart instanceof InternalXSDMultiPageEditor)
+ {
+ InternalXSDMultiPageEditor xsdEditor = (InternalXSDMultiPageEditor) editorPart;
+ xsdEditor.openOnGlobalReference(xsdComponent);
+ }
+ }
+ catch (PartInitException pie)
+ {
+
+ }
+ }
+ }
+ else
+ {
+ try
+ {
+ IEditorPart editorPart = null;
+ IEditorReference[] refs = page.getEditorReferences();
+ int length = refs.length;
+ // Need to find if an editor on that schema has already been opened
+ for (int i = 0; i < length; i++)
+ {
+ IEditorInput input = refs[i].getEditorInput();
+ if (input instanceof ADTReadOnlyFileEditorInput)
+ {
+ ADTReadOnlyFileEditorInput xsdFileStorageEditorInput = (ADTReadOnlyFileEditorInput) input;
+ if (xsdFileStorageEditorInput.getUrlString().equals(schemaLocation)
+ && xsdFileStorageEditorInput.getEditorID().equals(XSDEditorPlugin.EDITOR_ID))
+ {
+ editorPart = refs[i].getEditor(true);
+ page.activate(refs[i].getPart(true));
+ break;
+ }
+ }
+ }
+ if (editorPart == null)
+ {
+ ADTReadOnlyFileEditorInput xsdFileStorageEditorInput = new ADTReadOnlyFileEditorInput(schemaLocation);
+ xsdFileStorageEditorInput.setSchema(schema);
+ xsdFileStorageEditorInput.setEditorName(editorName);
+ xsdFileStorageEditorInput.setEditorID(XSDEditorPlugin.EDITOR_ID);
+ editorPart = page.openEditor(xsdFileStorageEditorInput, XSDEditorPlugin.EDITOR_ID, true, 0);
+ }
+ if (editorPart instanceof InternalXSDMultiPageEditor)
+ {
+ InternalXSDMultiPageEditor xsdEditor = (InternalXSDMultiPageEditor) editorPart;
+ xsdEditor.openOnGlobalReference(xsdComponent);
+ }
+ }
+ catch (PartInitException pie)
+ {
+ }
+
+ }
+ return;
+ }
+ }
+
+ private IEditorPart getExistingEditorForInlineSchema(IWorkbenchPage page, IFile schemaFile, XSDSchema schema)
+ {
+ IEditorReference [] refs = page.getEditorReferences();
+ int length = refs.length;
+ IEditorPart editorPart = null;
+ try
+ {
+ for (int i = 0; i < length; i++)
+ {
+ IEditorInput input = refs[i].getEditorInput();
+ if (input instanceof XSDFileEditorInput)
+ {
+ IFile aFile = ((XSDFileEditorInput)input).getFile();
+ if (aFile.getFullPath().equals(schemaFile.getFullPath()))
+ {
+ if (((XSDFileEditorInput)input).getSchema() == schema)
+ {
+ editorPart = refs[i].getEditor(true);
+ page.activate(refs[i].getPart(true));
+ break;
+ }
+ }
+ }
+ }
+ }
+ catch (PartInitException e)
+ {
+ }
+ return editorPart;
+ }
+
+ public static void openWorkspaceFile(IWorkbenchPage page, String schemaLocation, XSDConcreteComponent xsdComponent)
+ {
+ IPath schemaPath = new Path(schemaLocation);
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(schemaPath);
+ if (page != null && file != null && file.exists())
+ {
+ try
+ {
+ IEditorPart editorPart = IDE.openEditor(page, file, true);
+ if (editorPart instanceof InternalXSDMultiPageEditor)
+ {
+ InternalXSDMultiPageEditor xsdEditor = (InternalXSDMultiPageEditor) editorPart;
+ xsdEditor.openOnGlobalReference(xsdComponent);
+ }
+ }
+ catch (PartInitException pie)
+ {
+
+ }
+ }
+ }
+
+ public static void openExternalFiles(IWorkbenchPage page, String schemaLocation, XSDConcreteComponent fComponent)
+ {
+ IPath schemaPath = new Path(schemaLocation); // URIHelper.removeProtocol(schemaLocation));
+ String device = schemaPath.getDevice();
+ if (!device.startsWith("http"))
+ {
+ schemaPath = new Path(URIHelper.removeProtocol(schemaLocation));
+ }
+ IFileStore fileStore = EFS.getLocalFileSystem().getStore(schemaPath);
+ URI schemaURI = URI.create(schemaLocation);
+ if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists())
+ {
+ try
+ {
+ IEditorPart editorPart = null;
+ IEditorReference[] refs = page.getEditorReferences();
+ int length = refs.length;
+ // Need to find if an editor on that schema has already been opened
+ for (int i = 0; i < length; i++)
+ {
+ IEditorInput input = refs[i].getEditorInput();
+ if (input instanceof FileStoreEditorInput)
+ {
+ URI uri = ((FileStoreEditorInput) input).getURI();
+ if (uri.equals(schemaURI))
+ {
+ editorPart = refs[i].getEditor(true);
+ page.activate(refs[i].getPart(true));
+ break;
+ }
+ }
+ }
+ if (editorPart == null)
+ {
+ editorPart = IDE.openEditorOnFileStore(page, fileStore);
+ }
+ if (editorPart instanceof InternalXSDMultiPageEditor)
+ {
+ InternalXSDMultiPageEditor xsdEditor = (InternalXSDMultiPageEditor) editorPart;
+ xsdEditor.openOnGlobalReference(fComponent);
+ }
+ }
+ catch (PartInitException pie)
+ {
+ }
+ }
+ else
+ {
+ try
+ {
+ if (device.startsWith("http"))
+ {
+ try
+ {
+ IEditorPart editorPart = null;
+ IEditorReference[] refs = page.getEditorReferences();
+ int length = refs.length;
+ // Need to find if an editor on that schema has already been opened
+ for (int i = 0; i < length; i++)
+ {
+ IEditorInput input = refs[i].getEditorInput();
+ if (input instanceof ADTReadOnlyFileEditorInput)
+ {
+ ADTReadOnlyFileEditorInput readOnlyEditorInput = (ADTReadOnlyFileEditorInput) input;
+ if (readOnlyEditorInput.getUrlString().equals(schemaLocation) &&
+ XSDEditorPlugin.EDITOR_ID.equals(readOnlyEditorInput.getEditorID()))
+ {
+ editorPart = refs[i].getEditor(true);
+ page.activate(refs[i].getPart(true));
+ break;
+ }
+ }
+ }
+ if (editorPart == null)
+ {
+ ADTReadOnlyFileEditorInput readOnlyStorageEditorInput = new ADTReadOnlyFileEditorInput(schemaLocation);
+ readOnlyStorageEditorInput.setEditorID(XSDEditorPlugin.EDITOR_ID);
+ editorPart = page.openEditor(readOnlyStorageEditorInput, XSDEditorPlugin.EDITOR_ID, true, 0); //$NON-NLS-1$
+ }
+ if (editorPart instanceof InternalXSDMultiPageEditor)
+ {
+ InternalXSDMultiPageEditor xsdEditor = (InternalXSDMultiPageEditor) editorPart;
+ xsdEditor.openOnGlobalReference(fComponent);
+ }
+ }
+ catch (PartInitException pie)
+ {
+ }
+
+ }
+ else
+ {
+ FileStoreEditorInput xsdFileStoreEditorInput = new FileStoreEditorInput(fileStore);
+ page.openEditor(xsdFileStoreEditorInput, XSDEditorPlugin.EDITOR_ID, true, 0); //$NON-NLS-1$
+ }
+
+ }
+ catch (PartInitException e)
+ {
+
}
}
}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNameCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNameCommand.java
index 064207d..730a7c2 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNameCommand.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNameCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* 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
@@ -11,6 +11,11 @@
package org.eclipse.wst.xsd.ui.internal.common.commands;
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xsd.ui.internal.refactor.PerformUnsavedRefactoringOperation;
import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringComponent;
@@ -68,17 +73,34 @@
{
// this is a 'globally' defined component (e.g. global element)
if (component.eContainer() instanceof XSDSchema)
- {
- RefactoringComponent refactoringComponent = new XMLRefactoringComponent(
- component,
- (IDOMElement)component.getElement(),
- component.getName(),
- component.getTargetNamespace());
+ {
+ IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (workbenchWindow != null)
+ {
+ IWorkbenchPage page = workbenchWindow.getActivePage();
+ if (page != null)
+ {
+ IEditorInput editorInput = page.getActiveEditor().getEditorInput();
+ if (editorInput instanceof FileEditorInput)
+ {
+ RefactoringComponent refactoringComponent = new XMLRefactoringComponent(
+ component,
+ (IDOMElement)component.getElement(),
+ component.getName(),
+ component.getTargetNamespace());
- RenameComponentProcessor processor = new RenameComponentProcessor(refactoringComponent, newName, true);
- RenameRefactoring refactoring = new RenameRefactoring(processor);
- PerformUnsavedRefactoringOperation operation = new PerformUnsavedRefactoringOperation(refactoring);
- operation.run(null);
+ RenameComponentProcessor processor = new RenameComponentProcessor(refactoringComponent, newName, true);
+ RenameRefactoring refactoring = new RenameRefactoring(processor);
+ PerformUnsavedRefactoringOperation operation = new PerformUnsavedRefactoringOperation(refactoring);
+ operation.run(null);
+ }
+ else
+ {
+ // We can't refactor rename external files
+ component.setName(newName);
+ }
+ }
+ }
}
else
{
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/providers/XSDSectionLabelProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/providers/XSDSectionLabelProvider.java
index 31f8216..321e5f8 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/providers/XSDSectionLabelProvider.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/providers/XSDSectionLabelProvider.java
@@ -13,11 +13,14 @@
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory;
import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter;
import org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement;
@@ -127,7 +130,13 @@
{
IEditorPart editorPart = page.getActiveEditor();
XSDSchema xsdSchema = ((XSDConcreteComponent) selected).getSchema();
- if (editorPart != null && xsdSchema != editorPart.getAdapter(XSDSchema.class))
+ IEditorInput editorInput = editorPart.getEditorInput();
+ boolean isReadOnly = false;
+ if (!(editorInput instanceof IFileEditorInput || editorInput instanceof FileStoreEditorInput))
+ {
+ isReadOnly = true;
+ }
+ if (editorPart != null && xsdSchema != editorPart.getAdapter(XSDSchema.class) || isReadOnly)
{
sb.append(" (" + Messages.UI_LABEL_READ_ONLY + ")"); //$NON-NLS-1$ //$NON-NLS-2$
}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractSection.java
index c90c0a9..128f9c0 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractSection.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractSection.java
@@ -28,8 +28,10 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbench;
@@ -37,6 +39,7 @@
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.FormColors;
+import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin;
@@ -105,7 +108,8 @@
super.dispose();
}
- public void setInput(IWorkbenchPart part, ISelection selection) {
+ public void setInput(IWorkbenchPart part, ISelection selection)
+ {
super.setInput(part, selection);
isSimple = getIsSimple();
Object input = ((IStructuredSelection)selection).getFirstElement();
@@ -137,20 +141,17 @@
isReadOnly = true;
}
+ IEditorInput editorInput = owningEditor.getEditorInput();
+ if (!(editorInput instanceof IFileEditorInput || editorInput instanceof FileStoreEditorInput))
+ {
+ isReadOnly = true;
+ }
}
public void refresh()
{
super.refresh();
-
- if (isReadOnly)
- {
- composite.setEnabled(false);
- }
- else
- {
- composite.setEnabled(true);
- }
+ composite.setEnabled(!isReadOnly);
}
public void applyAllListeners(Control control)
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/CommonDirectivesSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/CommonDirectivesSection.java
index 652d247..5bed29c 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/CommonDirectivesSection.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/CommonDirectivesSection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* 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
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.wst.xsd.ui.internal.common.properties.sections;
+import java.util.HashMap;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.common.util.URI;
import org.eclipse.swt.custom.StyleRange;
@@ -18,6 +20,7 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
import org.eclipse.wst.xsd.ui.internal.common.util.Messages;
@@ -56,13 +59,18 @@
try
{
- IFile currentIFile = ((IFileEditorInput)getActiveEditor().getEditorInput()).getFile();
-
+ IFile currentIFile = null;
+ IEditorInput editorInput = getActiveEditor().getEditorInput();
+ if (editorInput instanceof IFileEditorInput)
+ {
+ currentIFile = ((IFileEditorInput)editorInput).getFile();
+ }
+
URI newURI = URI.createURI(xsdModelFile);
String xsdFile = URIHelper.getRelativeURI(newURI.toString(), currentIFile.getFullPath().toString());
final String normalizedXSDFile = URIHelper.normalize(xsdFile, currentIFile.getLocation().toString(), ""); //$NON-NLS-1$
- XSDParser parser = new XSDParser();
+ XSDParser parser = new XSDParser(new HashMap());
parser.parse(normalizedXSDFile);
externalSchema = parser.getSchema();
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SchemaLocationSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SchemaLocationSection.java
index 129eafd..52058b5 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SchemaLocationSection.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SchemaLocationSection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* 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
@@ -24,6 +24,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
@@ -113,11 +114,21 @@
if (event.widget == wizardButton)
{
Shell shell = Display.getCurrent().getActiveShell();
-
- IFile currentIFile = ((IFileEditorInput)getActiveEditor().getEditorInput()).getFile();
- ViewerFilter filter = new ResourceFilter(new String[] { ".xsd" }, //$NON-NLS-1$
- new IFile[] { currentIFile },
- null);
+
+ IFile currentIFile = null;
+ IEditorInput editorInput = getActiveEditor().getEditorInput();
+ ViewerFilter filter;
+ if (editorInput instanceof IFileEditorInput)
+ {
+ currentIFile = ((IFileEditorInput)editorInput).getFile();
+ filter = new ResourceFilter(new String[] { ".xsd" }, //$NON-NLS-1$
+ new IFile[] { currentIFile }, null);
+ }
+ else
+ {
+ filter = new ResourceFilter(new String[] { ".xsd" }, //$NON-NLS-1$
+ null, null);
+ }
XSDSelectIncludeFileWizard fileSelectWizard =
new XSDSelectIncludeFileWizard(xsdSchema, true,
@@ -137,10 +148,14 @@
errorText.setText(""); //$NON-NLS-1$
IFile selectedIFile = fileSelectWizard.getResultFile();
String schemaFileString = value;
- if (selectedIFile != null)
+ if (selectedIFile != null && currentIFile != null)
{
schemaFileString = URIHelper.getRelativeURI(selectedIFile.getLocation(), currentIFile.getLocation());
}
+ else if (selectedIFile != null && currentIFile == null)
+ {
+ schemaFileString = selectedIFile.getLocationURI().toString();
+ }
else
{
schemaFileString = fileSelectWizard.getURL();
@@ -149,7 +164,7 @@
handleSchemaLocationChange(schemaFileString, fileSelectWizard.getNamespace(), null);
refresh();
}
- }
+ }
}
/*
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAttributeDeclarationSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAttributeDeclarationSection.java
index b3c0916..c9e132e 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAttributeDeclarationSection.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAttributeDeclarationSection.java
@@ -248,25 +248,29 @@
private void fillTypesCombo()
{
IEditorPart editor = getActiveEditor();
- XSDTypeReferenceEditManager manager = (XSDTypeReferenceEditManager)editor.getAdapter(XSDTypeReferenceEditManager.class);
- ComponentSpecification[] items = manager.getQuickPicks();
-
- typeCombo.removeAll();
- typeCombo.add(Messages._UI_ACTION_BROWSE);
- typeCombo.add(Messages._UI_ACTION_NEW);
- for (int i = 0; i < items.length; i++)
+ XSDTypeReferenceEditManager manager = (XSDTypeReferenceEditManager)editor.getAdapter(XSDTypeReferenceEditManager.class);
+ if (manager != null)
{
- typeCombo.add(items[i].getName());
- }
+ ComponentSpecification[] items = manager.getQuickPicks();
- XSDAttributeDeclaration namedComponent = ((XSDAttributeDeclaration) input).getResolvedAttributeDeclaration();
- XSDTypeDefinition namedComponentType = namedComponent.getType();
- if (namedComponentType != null)
- {
- String currentTypeName = namedComponentType.getQName(xsdSchema); // no prefix
- ComponentSpecification ret = getComponentSpecFromQuickPickForValue(currentTypeName, manager);
- if (ret == null) //not in quickPick
- typeCombo.add(currentTypeName);
+ typeCombo.removeAll();
+ typeCombo.add(Messages._UI_ACTION_BROWSE);
+ typeCombo.add(Messages._UI_ACTION_NEW);
+ for (int i = 0; i < items.length; i++)
+ {
+ typeCombo.add(items[i].getName());
+ }
+
+ XSDAttributeDeclaration namedComponent = ((XSDAttributeDeclaration) input).getResolvedAttributeDeclaration();
+ XSDTypeDefinition namedComponentType = namedComponent.getType();
+ if (namedComponentType != null)
+ {
+ String currentTypeName = namedComponentType.getQName(xsdSchema); // no
+ // prefix
+ ComponentSpecification ret = getComponentSpecFromQuickPickForValue(currentTypeName, manager);
+ if (ret == null) // not in quickPick
+ typeCombo.add(currentTypeName);
+ }
}
}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationAdvancedSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationAdvancedSection.java
index 53ad36f..2838317 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationAdvancedSection.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationAdvancedSection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* 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
@@ -322,26 +322,29 @@
private void fillSubstitutionGroupCombo()
{
IEditorPart editor = getActiveEditor();
- ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDSubstitutionGroupEditManager.class);
- ComponentSpecification[] items = manager.getQuickPicks();
-
- substGroupCombo.removeAll();
- substGroupCombo.add(Messages._UI_ACTION_BROWSE);
- substGroupCombo.add(Messages._UI_ACTION_NEW);
- for (int i = 0; i < items.length; i++)
+ ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDSubstitutionGroupEditManager.class);
+ if (manager != null)
{
- substGroupCombo.add(items[i].getName());
- }
- // Add the current substitution group if needed
- XSDElementDeclaration namedComponent = ((XSDElementDeclaration) input).getSubstitutionGroupAffiliation();
- if (namedComponent != null)
- {
- ComponentSpecification ret = getComponentSpecFromQuickPickForValue(namedComponent.getName(),manager);
- if (ret == null)
+ ComponentSpecification[] items = manager.getQuickPicks();
+
+ substGroupCombo.removeAll();
+ substGroupCombo.add(Messages._UI_ACTION_BROWSE);
+ substGroupCombo.add(Messages._UI_ACTION_NEW);
+ for (int i = 0; i < items.length; i++)
{
- substGroupCombo.add(namedComponent.getQName(xsdSchema));
+ substGroupCombo.add(items[i].getName());
}
- }
+ // Add the current substitution group if needed
+ XSDElementDeclaration namedComponent = ((XSDElementDeclaration) input).getSubstitutionGroupAffiliation();
+ if (namedComponent != null)
+ {
+ ComponentSpecification ret = getComponentSpecFromQuickPickForValue(namedComponent.getName(), manager);
+ if (ret == null)
+ {
+ substGroupCombo.add(namedComponent.getQName(xsdSchema));
+ }
+ }
+ }
}
private ComponentSpecification getComponentSpecFromQuickPickForValue(String value, ComponentReferenceEditManager editManager)
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationSection.java
index fbae5a1..aabfd39 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationSection.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationSection.java
@@ -231,30 +231,33 @@
private void fillTypesCombo()
{
IEditorPart editor = getActiveEditor();
- ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDTypeReferenceEditManager.class);
- ComponentSpecification[] items = manager.getQuickPicks();
-
- typeCombo.removeAll();
- typeCombo.add(Messages._UI_ACTION_BROWSE);
- typeCombo.add(Messages._UI_ACTION_NEW);
- for (int i = 0; i < items.length; i++)
+ ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDTypeReferenceEditManager.class);
+ if (manager != null)
{
- typeCombo.add(items[i].getName());
- }
- // Add the current Type of this element if needed
- XSDElementDeclaration namedComponent = ((XSDElementDeclaration) input).getResolvedElementDeclaration();
- XSDTypeDefinition td = namedComponent.getType();
- if (td != null)
- {
- String currentTypeName = td.getQName(xsdSchema);
- if (currentTypeName == null) // anonymous type
- currentTypeName = "**Anonymous**";
- ComponentSpecification ret = getComponentSpecFromQuickPickForValue(currentTypeName,manager);
- if (ret == null && currentTypeName != null) //not in quickPick
+ ComponentSpecification[] items = manager.getQuickPicks();
+
+ typeCombo.removeAll();
+ typeCombo.add(Messages._UI_ACTION_BROWSE);
+ typeCombo.add(Messages._UI_ACTION_NEW);
+ for (int i = 0; i < items.length; i++)
{
- typeCombo.add(currentTypeName);
+ typeCombo.add(items[i].getName());
}
- }
+ // Add the current Type of this element if needed
+ XSDElementDeclaration namedComponent = ((XSDElementDeclaration) input).getResolvedElementDeclaration();
+ XSDTypeDefinition td = namedComponent.getType();
+ if (td != null)
+ {
+ String currentTypeName = td.getQName(xsdSchema);
+ if (currentTypeName == null) // anonymous type
+ currentTypeName = "**Anonymous**";
+ ComponentSpecification ret = getComponentSpecFromQuickPickForValue(currentTypeName, manager);
+ if (ret == null && currentTypeName != null) // not in quickPick
+ {
+ typeCombo.add(currentTypeName);
+ }
+ }
+ }
}
private ComponentSpecification getComponentSpecFromQuickPickForValue(String value, ComponentReferenceEditManager editManager)
@@ -542,31 +545,33 @@
{
IEditorPart editor = getActiveEditor();
ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDElementReferenceEditManager.class);
-
- componentNameCombo.removeAll();
- componentNameCombo.add(Messages._UI_ACTION_BROWSE);
- componentNameCombo.add(Messages._UI_ACTION_NEW);
- ComponentSpecification[] quickPicks = manager.getQuickPicks();
- if (quickPicks != null)
+ if (manager != null)
{
- for (int i=0; i < quickPicks.length; i++)
+ componentNameCombo.removeAll();
+ componentNameCombo.add(Messages._UI_ACTION_BROWSE);
+ componentNameCombo.add(Messages._UI_ACTION_NEW);
+ ComponentSpecification[] quickPicks = manager.getQuickPicks();
+ if (quickPicks != null)
{
- ComponentSpecification componentSpecification = quickPicks[i];
- componentNameCombo.add(componentSpecification.getName());
- }
- }
- ComponentSpecification[] history = manager.getHistory();
- if (history != null)
- {
- for (int i=0; i < history.length; i++)
+ for (int i = 0; i < quickPicks.length; i++)
+ {
+ ComponentSpecification componentSpecification = quickPicks[i];
+ componentNameCombo.add(componentSpecification.getName());
+ }
+ }
+ ComponentSpecification[] history = manager.getHistory();
+ if (history != null)
{
- ComponentSpecification componentSpecification = history[i];
- componentNameCombo.add(componentSpecification.getName());
- }
+ for (int i = 0; i < history.length; i++)
+ {
+ ComponentSpecification componentSpecification = history[i];
+ componentNameCombo.add(componentSpecification.getName());
+ }
+ }
}
-
XSDElementDeclaration namedComponent = (XSDElementDeclaration) input;
Element element = namedComponent.getElement();
+
if (element != null)
{
String attrValue = element.getAttribute(XSDConstants.REF_ATTRIBUTE);
@@ -580,7 +585,7 @@
componentNameCombo.add(attrValue);
}
componentNameCombo.setText(attrValue);
- }
+ }
}
}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDFacetSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDFacetSection.java
index cd2f1a0..572054b 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDFacetSection.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDFacetSection.java
@@ -453,8 +453,8 @@
}
constraintsWidget.setInput(xsdSimpleTypeDefinition);
- setWidgetsEnabled(isSimpleTypeRestriction);
- composite.setEnabled(isSimpleTypeRestriction);
+ setWidgetsEnabled(isSimpleTypeRestriction && !isReadOnly);
+ composite.setEnabled(isSimpleTypeRestriction && !isReadOnly);
setListenerEnabled(true);
}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDImportSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDImportSection.java
index ee6da6a..58517ec 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDImportSection.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDImportSection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* 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
@@ -29,6 +29,7 @@
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.common.ui.internal.viewers.ResourceFilter;
@@ -208,9 +209,20 @@
setListenerEnabled(false);
Shell shell = Display.getCurrent().getActiveShell();
- IFile currentIFile = ((IFileEditorInput) getActiveEditor().getEditorInput()).getFile();
- ViewerFilter filter = new ResourceFilter(new String[] { ".xsd" }, //$NON-NLS-1$
- new IFile[] { currentIFile }, null);
+ IFile currentIFile = null;
+ IEditorInput editorInput = getActiveEditor().getEditorInput();
+ ViewerFilter filter;
+ if (editorInput instanceof IFileEditorInput)
+ {
+ currentIFile = ((IFileEditorInput)editorInput).getFile();
+ filter = new ResourceFilter(new String[] { ".xsd" }, //$NON-NLS-1$
+ new IFile[] { currentIFile }, null);
+ }
+ else
+ {
+ filter = new ResourceFilter(new String[] { ".xsd" }, //$NON-NLS-1$
+ null, null);
+ }
XSDSelectIncludeFileWizard fileSelectWizard = new XSDSelectIncludeFileWizard(xsdSchema, false, XSDEditorPlugin.getXSDString("_UI_FILEDIALOG_SELECT_XML_SCHEMA"), //$NON-NLS-1$
XSDEditorPlugin.getXSDString("_UI_FILEDIALOG_SELECT_XML_DESC"), //$NON-NLS-1$
@@ -228,10 +240,14 @@
errorText.setText("");
IFile selectedIFile = fileSelectWizard.getResultFile();
String schemaFileString = value;
- if (selectedIFile != null)
+ if (selectedIFile != null && currentIFile != null)
{
schemaFileString = URIHelper.getRelativeURI(selectedIFile.getLocation(), currentIFile.getLocation());
}
+ else if (selectedIFile != null && currentIFile == null)
+ {
+ schemaFileString = selectedIFile.getLocationURI().toString();
+ }
else
{
schemaFileString = fileSelectWizard.getURL();
@@ -246,6 +262,23 @@
}
setListenerEnabled(true);
prefixText.addListener(SWT.Modify, this);
+// }
+// else
+// {
+// BrowseInWorkspaceAction browseInWorkspace = new BrowseInWorkspaceAction(shell);
+// browseInWorkspace.run();
+// IFile selectedIFile = browseInWorkspace.getSelectedFile();
+// String value = schemaLocationText.getText();
+// String schemaFileString = value;
+// if (selectedIFile != null)
+// {
+// //schemaFileString = URIHelper.getRelativeURI(selectedIFile.getLocation(), currentIFile.getLocation());
+// schemaFileString = selectedIFile.getLocationURI().toString();
+// handleSchemaLocationChange(schemaFileString, "", null);
+// refresh();
+// }
+//
+// }
}
}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSchemaSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSchemaSection.java
index 562071e..1bf7b19 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSchemaSection.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSchemaSection.java
@@ -135,6 +135,7 @@
*/
public void refresh()
{
+ super.refresh();
setListenerEnabled(false);
Element element = xsdSchema.getElement();
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSimpleTypeSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSimpleTypeSection.java
index b17c3fd..675b6f3 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSimpleTypeSection.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSimpleTypeSection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* 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
@@ -702,27 +702,30 @@
typesCombo.removeAll();
IEditorPart editor = getActiveEditor();
- ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDTypeReferenceEditManager.class);
- ComponentSpecification[] items = manager.getQuickPicks();
-
- typesCombo.add(org.eclipse.wst.xsd.ui.internal.adt.editor.Messages._UI_ACTION_BROWSE);
- typesCombo.add(org.eclipse.wst.xsd.ui.internal.editor.Messages._UI_ACTION_NEW);
-
- for (int i = 0; i < items.length; i++)
+ ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDTypeReferenceEditManager.class);
+ if (manager != null)
{
- typesCombo.add(items[i].getName());
- }
+ ComponentSpecification[] items = manager.getQuickPicks();
- // Add the current Type of this attribute if needed
- XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition) input;
- XSDTypeDefinition baseType = simpleType.getBaseType();
- if (baseType != null && baseType.getQName() != null)
- {
- String currentTypeName = baseType.getQName(xsdSchema); //no prefix
- ComponentSpecification ret = getComponentSpecFromQuickPickForValue(currentTypeName,manager);
- if (ret == null && currentTypeName != null) //not in quickPick
+ typesCombo.add(org.eclipse.wst.xsd.ui.internal.adt.editor.Messages._UI_ACTION_BROWSE);
+ typesCombo.add(org.eclipse.wst.xsd.ui.internal.editor.Messages._UI_ACTION_NEW);
+
+ for (int i = 0; i < items.length; i++)
{
- typesCombo.add(currentTypeName);
+ typesCombo.add(items[i].getName());
+ }
+
+ // Add the current Type of this attribute if needed
+ XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition) input;
+ XSDTypeDefinition baseType = simpleType.getBaseType();
+ if (baseType != null && baseType.getQName() != null)
+ {
+ String currentTypeName = baseType.getQName(xsdSchema); // no prefix
+ ComponentSpecification ret = getComponentSpecFromQuickPickForValue(currentTypeName, manager);
+ if (ret == null && currentTypeName != null) // not in quickPick
+ {
+ typesCombo.add(currentTypeName);
+ }
}
}
}