use of org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer in project webtools.sourceediting by eclipse.
the class InternalXSDMultiPageEditor method editorModeChanged.
public void editorModeChanged(EditorMode newEditorMode) {
// if (isInitializing)
// return;
EditPartFactory editPartFactory = newEditorMode.getEditPartFactory();
if (editPartFactory != null) {
graphicalViewer.setEditPartFactory(editPartFactory);
if (graphicalViewer instanceof DesignViewGraphicalViewer) {
DesignViewGraphicalViewer viewer = (DesignViewGraphicalViewer) graphicalViewer;
IADTObject input = viewer.getInput();
viewer.setInput(null);
// viewer.getRootEditPart().refresh();
// viewer.getRootEditPart().getContents().refresh();
viewer.setInput(input);
floatingToolbar.setEditPartFactory(editPartFactory);
floatingToolbar.setModel(getModel());
floatingToolbar.refresh(!(input instanceof IModel));
Control control = graphicalViewer.getControl();
if (control instanceof Composite) {
Composite parent = ((Composite) control).getParent();
parent.layout();
}
}
}
IContentProvider provider = newEditorMode.getOutlineProvider();
if (provider != null) {
ADTContentOutlinePage outline = (ADTContentOutlinePage) getContentOutlinePage();
if (outline != null) {
TreeViewer treeViewer = outline.getTreeViewer();
if (treeViewer != null) {
outline.getTreeViewer().setContentProvider(provider);
outline.getTreeViewer().refresh();
}
}
}
}
use of org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer in project webtools.sourceediting by eclipse.
the class DesignViewNavigationLocation method restoreLocation.
public void restoreLocation() {
XSDSchema schema = (XSDSchema) getEditorPart().getAdapter(XSDSchema.class);
Object viewer = getEditorPart().getAdapter(GraphicalViewer.class);
if (viewer instanceof DesignViewGraphicalViewer) {
DesignViewGraphicalViewer graphicalViewer = (DesignViewGraphicalViewer) viewer;
XSDConcreteComponent component = Path.computeComponent(schema, path);
if (component != null) {
Adapter adapter = XSDAdapterFactory.getInstance().adapt(component);
if (adapter instanceof IADTObject) {
graphicalViewer.setInput((IADTObject) adapter);
}
} else if (path.segments.isEmpty()) {
Adapter adapter = XSDAdapterFactory.getInstance().adapt(schema);
if (adapter instanceof IADTObject) {
graphicalViewer.setInput((IADTObject) adapter);
}
}
}
}
use of org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer in project webtools.sourceediting by eclipse.
the class DeleteAction method run.
public void run() {
for (Iterator i = ((IStructuredSelection) getSelection()).iterator(); i.hasNext(); ) {
Object selection = i.next();
Command command = null;
boolean doSetInput = false;
boolean doSetModelAsInput = false;
IADTObject topLevelContainer = null;
IModel model = null;
if (selection instanceof IGraphElement) {
IGraphElement xsdObj = (IGraphElement) selection;
if (xsdObj instanceof XSDBaseAdapter) {
XSDBaseAdapter baseAdapter = (XSDBaseAdapter) xsdObj;
// is null and the read only check cannot be completed
if (baseAdapter == null || baseAdapter.isReadOnly()) {
continue;
}
topLevelContainer = xsdObj.getTopContainer();
if (topLevelContainer == selection) {
doSetInput = true;
doSetModelAsInput = true;
}
command = xsdObj.getDeleteCommand();
model = xsdObj.getModel();
}
}
if (command != null) {
IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench != null) {
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
if (workbenchWindow != null && workbenchWindow.getActivePage() != null) {
IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor();
if (editorPart != null) {
Object viewer = editorPart.getAdapter(GraphicalViewer.class);
if (viewer instanceof DesignViewGraphicalViewer) {
Object input = ((DesignViewGraphicalViewer) viewer).getInput();
if (input != selection) {
// Bug 86218 : Don't switch to top level view if the object we're deleting
// is not the input to the viewer
doSetInput = false;
}
}
}
}
}
command.execute();
if (doSetInput) {
if (model != null && doSetModelAsInput)
provider.setSelection(new StructuredSelection(model));
else if (topLevelContainer != null && !doSetModelAsInput)
provider.setSelection(new StructuredSelection(topLevelContainer));
}
}
}
}
use of org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer in project webtools.sourceediting by eclipse.
the class SetInputToGraphView method run.
public void run() {
Object selection = input;
if (selection == null) {
selection = ((IStructuredSelection) getSelection()).getFirstElement();
}
Object adapter = getWorkbenchPart().getAdapter(GraphicalViewer.class);
if (selection instanceof IADTObject) {
IADTObject obj = (IADTObject) selection;
if (adapter instanceof DesignViewGraphicalViewer) {
DesignViewGraphicalViewer graphicalViewer = (DesignViewGraphicalViewer) adapter;
EditPart editPart = graphicalViewer.getInputEditPart();
if (editPart instanceof RootContentEditPart) {
graphicalViewer.setInputAndMarkLocation(obj);
}
}
}
}
use of org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer in project webtools.sourceediting by eclipse.
the class ADTMultiPageEditor method getGraphicalViewer.
protected ScrollingGraphicalViewer getGraphicalViewer() {
DesignViewGraphicalViewer viewer = new DesignViewGraphicalViewer(this, getSelectionManager());
viewer.addInputChangdListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection input = (IStructuredSelection) event.getSelection();
floatingToolbar.refresh(isTableOfContentsApplicable(input.getFirstElement()));
}
});
// Workaround bug 227687 An edit part's focus state is not updated properly
// Once this is bug is fixed, we can remove custom selection manager
viewer.setSelectionManager(new CustomSelectionManager());
return viewer;
}
Aggregations