use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class AbstractSection method setInput.
public void setInput(IWorkbenchPart part, ISelection selection) {
super.setInput(part, selection);
isSimple = getIsSimple();
Object input = ((IStructuredSelection) selection).getFirstElement();
this.input = input;
if (input instanceof XSDConcreteComponent) {
xsdSchema = ((XSDConcreteComponent) input).getSchema();
}
// set owning editor of this section
if (part != null) {
if (part instanceof IEditorPart) {
owningEditor = (IEditorPart) part;
} else {
owningEditor = part.getSite().getWorkbenchWindow().getActivePage().getActiveEditor();
}
}
if (xsdSchema == owningEditor.getAdapter(XSDSchema.class)) {
isReadOnly = false;
} else {
isReadOnly = true;
}
IEditorInput editorInput = owningEditor.getEditorInput();
if (!(editorInput instanceof IFileEditorInput || editorInput instanceof FileStoreEditorInput)) {
isReadOnly = true;
}
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class AnnotationSection method refresh.
/*
* @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
*/
public void refresh() {
super.refresh();
if (simpleText.isFocusControl())
return;
setListenerEnabled(false);
if (input instanceof XSDConcreteComponent) {
XSDAnnotation xsdAnnotation = XSDCommonUIUtils.getInputXSDAnnotation((XSDConcreteComponent) input, false);
setInitialText(xsdAnnotation);
}
setListenerEnabled(true);
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class AddXSDModelGroupAction method run.
public void run() {
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
if (selection instanceof XSDBaseAdapter) {
XSDConcreteComponent xsdComponent = (XSDConcreteComponent) ((XSDBaseAdapter) selection).getTarget();
AddXSDModelGroupCommand command = null;
if (xsdComponent instanceof XSDElementDeclaration) {
XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration) xsdComponent;
command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdElementDeclaration, xsdCompositor);
getCommandStack().execute(command);
} else if (xsdComponent instanceof XSDModelGroup) {
XSDModelGroup xsdModelGroup = (XSDModelGroup) xsdComponent;
command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdModelGroup, xsdCompositor);
getCommandStack().execute(command);
} else if (xsdComponent instanceof XSDComplexTypeDefinition || xsdComponent instanceof XSDModelGroupDefinition) {
command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdComponent, xsdCompositor);
getCommandStack().execute(command);
}
if (command != null) {
Adapter adapter = XSDAdapterFactory.getInstance().adapt(command.getAddedComponent());
if (adapter != null)
provider.setSelection(new StructuredSelection(adapter));
}
}
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class SetMultiplicityAction method getXSDInput.
private XSDConcreteComponent getXSDInput() {
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
XSDConcreteComponent xsdConcreteComponent = null;
if (selection instanceof XSDBaseAdapter) {
xsdConcreteComponent = (XSDConcreteComponent) ((XSDBaseAdapter) selection).getTarget();
}
return xsdConcreteComponent;
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class XSDBaseAction method calculateEnabled.
protected boolean calculateEnabled() {
if (getWorkbenchPart() instanceof IEditorPart) {
IEditorPart owningEditor = (IEditorPart) getWorkbenchPart();
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
if (selection instanceof XSDBaseAdapter) {
selection = ((XSDBaseAdapter) selection).getTarget();
}
XSDSchema xsdSchema = null;
if (selection instanceof XSDConcreteComponent) {
xsdSchema = ((XSDConcreteComponent) selection).getSchema();
}
if (xsdSchema != null && xsdSchema == owningEditor.getAdapter(XSDSchema.class)) {
return true;
}
}
return false;
}
Aggregations