use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class ADTContentOutlinePage method createControl.
public void createControl(Composite parent) {
super.createControl(parent);
getTreeViewer().setContentProvider(contentProvider);
getTreeViewer().setLabelProvider(labelProvider);
getTreeViewer().setInput(model);
getTreeViewer().addSelectionChangedListener(this);
// $NON-NLS-1$
MenuManager menuManager = new MenuManager("#popup");
menuManager.setRemoveAllWhenShown(true);
Menu menu = menuManager.createContextMenu(getTreeViewer().getControl());
getTreeViewer().getControl().setMenu(menu);
setSelectionManager(editor.getSelectionManager());
// Create menu...for now reuse graph's. Note edit part viewer = null
DesignViewContextMenuProvider menuProvider = new DesignViewContextMenuProvider(editor, null, editor.getSelectionManager());
menuManager.addMenuListener(menuProvider);
// $NON-NLS-1$
getSite().registerContextMenu("org.eclipse.wst.xsd.ui.popup.outline", menuManager, editor.getSelectionManager());
// enable popupMenus extension
// getSite().registerContextMenu("org.eclipse.wst.xsdeditor.ui.popup.outline",
// menuManager, xsdEditor.getSelectionManager());
// drill down from outline view
getTreeViewer().getControl().addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent e) {
ISelection iSelection = getTreeViewer().getSelection();
if (iSelection instanceof StructuredSelection) {
StructuredSelection selection = (StructuredSelection) iSelection;
Object obj = selection.getFirstElement();
if (obj instanceof XSDConcreteComponent) {
XSDConcreteComponent comp = (XSDConcreteComponent) obj;
if (comp.getContainer() instanceof XSDSchema) {
// getXSDEditor().getGraphViewer().setInput(obj);
}
}
}
}
});
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class AddXSDAttributeGroupDefinitionCommand method getNewName.
protected String getNewName(String description) {
// $NON-NLS-1$
String candidateName = "New" + description;
XSDConcreteComponent parent = xsdComplexTypeDefinition;
names = new ArrayList();
int i = 1;
if (parent instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition) parent;
walkUpInheritance(ct);
boolean ready = false;
while (!ready) {
ready = true;
for (Iterator iter = names.iterator(); iter.hasNext(); ) {
String attrName = (String) iter.next();
if (candidateName.equals(attrName)) {
ready = false;
// $NON-NLS-1$
candidateName = "New" + description + String.valueOf(i);
i++;
}
}
}
}
return candidateName;
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class AddXSDElementCommand method createXSDElementDeclaration.
protected XSDParticle createXSDElementDeclaration() {
// $NON-NLS-1$
XSDSimpleTypeDefinition type = xsdModelGroup.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string");
XSDElementDeclaration element = XSDFactory.eINSTANCE.createXSDElementDeclaration();
XSDConcreteComponent comp = xsdModelGroup.getContainer();
ArrayList usedAttributeNames = new ArrayList();
XSDCommonUIUtils.resetVisitedGroupsStack();
usedAttributeNames.addAll(XSDCommonUIUtils.getChildElements(xsdModelGroup));
while (comp != null) {
if (comp instanceof XSDModelGroupDefinition) {
usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes((XSDModelGroupDefinition) comp));
break;
} else if (comp instanceof XSDComplexTypeDefinition) {
usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes((XSDComplexTypeDefinition) comp));
usedAttributeNames.addAll(XSDCommonUIUtils.getInheritedAttributes((XSDComplexTypeDefinition) comp));
break;
}
comp = comp.getContainer();
}
element.setName(XSDCommonUIUtils.createUniqueElementName(nameToAdd == null ? "NewElement" : nameToAdd, // $NON-NLS-1$
usedAttributeNames));
element.setTypeDefinition(type);
XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
particle.setContent(element);
addedXSDConcreteComponent = element;
return particle;
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class DeleteXSDConcreteComponentAction method run.
public void run() {
for (Iterator i = ((IStructuredSelection) getSelection()).iterator(); i.hasNext(); ) {
Object selection = i.next();
boolean doReselect = false;
if (selection instanceof XSDBaseAdapter) {
selection = ((XSDBaseAdapter) selection).getTarget();
}
if (selection instanceof XSDConcreteComponent) {
XSDConcreteComponent xsdComponent = (XSDConcreteComponent) selection;
XSDSchema model = xsdComponent.getSchema();
doReselect = xsdComponent.eContainer() instanceof XSDSchema;
DeleteCommand command = new DeleteCommand(getText(), xsdComponent);
getCommandStack().execute(command);
if (model != null && doReselect) {
Adapter adapter = XSDAdapterFactory.getInstance().adapt(model);
if (adapter != null)
provider.setSelection(new StructuredSelection(adapter));
}
}
}
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class SetTypeAction method run.
public void run() {
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
if (selection instanceof XSDBaseAdapter) {
Object target = ((XSDBaseAdapter) selection).getTarget();
if (target instanceof XSDConcreteComponent) {
command = new SetTypeCommand(Messages._UI_ACTION_SET_TYPE, getId(), (XSDConcreteComponent) target);
command.setAdapter((XSDBaseAdapter) selection);
getCommandStack().execute(command);
}
}
}
Aggregations