use of org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject in project webtools.sourceediting by eclipse.
the class XSDAttributeGroupDefinitionAdapter method clearFields.
protected void clearFields() {
if (otherThingsToListenTo != null) {
for (Iterator i = otherThingsToListenTo.iterator(); i.hasNext(); ) {
Adapter adapter = (Adapter) i.next();
if (adapter instanceof IADTObject) {
IADTObject adtObject = (IADTObject) adapter;
adtObject.unregisterListener(this);
}
}
}
fields = null;
otherThingsToListenTo = null;
}
use of org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject in project webtools.sourceediting by eclipse.
the class XSDComplexTypeDefinitionAdapter method getFields.
public List getFields() {
if (fields == null) {
fields = new ArrayList();
otherThingsToListenTo = new ArrayList();
XSDVisitorForFields visitor = new XSDVisitorForFieldsWithSpaceFillers();
visitor.visitComplexTypeDefinition(getXSDComplexTypeDefinition());
populateAdapterList(visitor.concreteComponentList, fields);
populateAdapterList(visitor.thingsWeNeedToListenTo, otherThingsToListenTo);
for (Iterator i = otherThingsToListenTo.iterator(); i.hasNext(); ) {
Adapter adapter = (Adapter) i.next();
if (adapter instanceof IADTObject) {
IADTObject adtObject = (IADTObject) adapter;
adtObject.registerListener(this);
}
}
}
return fields;
}
use of org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject in project webtools.sourceediting by eclipse.
the class DesignViewGraphicalViewer method selectionChanged.
// this method is called when something changes in the selection manager
// (e.g. a selection occured from another view)
public void selectionChanged(SelectionChangedEvent event) {
Object selectedObject = null;
ISelection eventSelection = event.getSelection();
if (eventSelection instanceof StructuredSelection) {
selectedObject = ((StructuredSelection) eventSelection).getFirstElement();
}
// if (event.getSource() instanceof ADTContentOutlinePage)
if (selectedObject != null) {
if (event.getSource() != internalSelectionProvider) {
if (selectedObject instanceof IStructure) {
if (((getInput() instanceof IModel) && (event.getSource() instanceof ADTContentOutlinePage)) || (!(getInput() instanceof IModel))) {
if ((selectedObject instanceof IGraphElement) && ((IGraphElement) selectedObject).isFocusAllowed()) {
if (!(event.getSource() instanceof org.eclipse.jface.viewers.IPostSelectionProvider)) {
setInputAndMarkLocation((IStructure) selectedObject);
}
}
}
} else if (selectedObject instanceof IGraphElement) {
if (((IGraphElement) selectedObject).isFocusAllowed() && ((event.getSource() instanceof ADTContentOutlinePage))) {
setInputAndMarkLocation((IADTObject) selectedObject);
} else if (!((IGraphElement) selectedObject).isFocusAllowed()) {
// We encountered an object that is not a valid input to the graph viewer
// Now find the top container that can be a valid input
IADTObject obj = ((IGraphElement) selectedObject).getTopContainer();
if (event.getSource() instanceof ADTContentOutlinePage) {
// change the inputs
if (// Don't change inputs if the obj is already the input
obj != null && getInput() != obj)
setInputAndMarkLocation(obj);
} else if (event.getSource() instanceof CommonSelectionManager) {
// otherwise, inputs will change unexpectedly!!
if (getInput() instanceof IModel) {
if (obj != null)
setInput(obj);
}
} else if (event.getSource() instanceof org.eclipse.jface.viewers.IPostSelectionProvider) {
// of anonymous types
if (obj != null)
setInput(obj);
} else {
if (obj != null && getInput() instanceof IModel)
setInputAndMarkLocation(obj);
}
}
if (selectedObject instanceof IField) {
IField field = (IField) selectedObject;
if ((!field.isGlobal() && getInput() instanceof IModel) || (!field.isGlobal() && !(event.getSource() instanceof CommonSelectionManager))) {
IADTObject obj = ((IGraphElement) selectedObject).getTopContainer();
if (obj != null)
setInputAndMarkLocation(obj);
} else if (field.isGlobal() && !(getInput() instanceof IModel)) {
if (event.getSource() instanceof org.eclipse.jface.viewers.IPostSelectionProvider)
setInput(field);
else
setInputAndMarkLocation(field);
}
}
} else if (selectedObject instanceof IField) {
IField field = (IField) selectedObject;
if ((field.isGlobal() && (getInput() instanceof IModel) && (event.getSource() instanceof ADTContentOutlinePage)) || ((field.isGlobal() && !(getInput() instanceof IModel)))) {
setInputAndMarkLocation(field);
}
} else if (selectedObject instanceof IModelProxy) {
IModelProxy adapter = (IModelProxy) selectedObject;
if (selectedObject instanceof RedefineCategoryAdapter) {
RedefineCategoryAdapter selectionAdapter = (RedefineCategoryAdapter) selectedObject;
XSDRedefineAdapter selectionParentAdapter = selectionAdapter.getXsdRedefineAdapter();
setInputAndMarkLocation(selectionParentAdapter);
} else if (getInput() != adapter.getModel())
setInput(adapter.getModel());
} else if (selectedObject instanceof IModel) {
if (getInput() != selectedObject)
setInput((IModel) selectedObject);
}
EditPart editPart = getEditPart(getRootEditPart(), selectedObject);
if (editPart != null) {
setSelection(new StructuredSelection(editPart));
setFocus(editPart);
}
}
}
}
use of org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject in project webtools.sourceediting by eclipse.
the class DesignViewGraphicalViewer method setInputAndMarkLocation.
public void setInputAndMarkLocation(IADTObject object) {
IADTObject oldInput = getInput();
INavigationHistory navigationHistory = null;
IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench != null) {
IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
if (activeWorkbenchWindow != null) {
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
if (activePage != null) {
navigationHistory = activePage.getNavigationHistory();
}
}
}
setInput(object);
if (editorPart != null && oldInput != object) {
navigationHistory.markLocation(editorPart);
}
}
use of org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject 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);
}
}
}
}
Aggregations