use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.
the class BaseFieldEditPart method doEditName.
public void doEditName(boolean addFromDesign) {
if (!addFromDesign)
return;
// removeFeedback();
Runnable runnable = new Runnable() {
public void run() {
Object object = ((XSDBaseAdapter) getModel()).getTarget();
if (object instanceof XSDNamedComponent) {
Point p = getNameLabelFigure().getLocation();
LabelEditManager manager = new LabelEditManager(BaseFieldEditPart.this, new LabelCellEditorLocator(BaseFieldEditPart.this, p));
NameUpdateCommandWrapper wrapper = new NameUpdateCommandWrapper();
adtDirectEditPolicy.setUpdateCommand(wrapper);
manager.show();
}
}
};
Display.getCurrent().asyncExec(runnable);
}
use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.
the class AddXSDSchemaDirectiveAction method run.
public void run() {
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
if (selection instanceof XSDBaseAdapter) {
selection = ((XSDBaseAdapter) selection).getTarget();
}
BaseCommand command = null;
if (selection instanceof XSDSchema) {
if (INCLUDE_ID.equals(getId())) {
command = new AddXSDIncludeCommand(label, (XSDSchema) selection);
} else if (IMPORT_ID.equals(getId())) {
command = new AddXSDImportCommand(label, (XSDSchema) selection);
} else if (REDEFINE_ID.equals(getId())) {
command = new AddXSDRedefineCommand(label, (XSDSchema) selection);
}
getCommandStack().execute(command);
}
if (command != null) {
Adapter adapter = XSDAdapterFactory.getInstance().adapt(command.getAddedComponent());
if (adapter != null) {
provider.setSelection(new StructuredSelection(adapter));
// Automatically open the schema location dialog if the preference is enabled
if (XSDEditorPlugin.getDefault().getAutomaticallyOpenSchemaLocationDialogSetting()) {
XSDSchemaDirectiveAdapter xsdSchemaDirectiveAdapter = null;
if (adapter instanceof XSDSchemaDirectiveAdapter) {
xsdSchemaDirectiveAdapter = (XSDSchemaDirectiveAdapter) adapter;
}
XSDDirectivesSchemaLocationUpdater.updateSchemaLocation((XSDSchema) selection, xsdSchemaDirectiveAdapter.getTarget(), (command instanceof AddXSDIncludeCommand || command instanceof AddXSDRedefineCommand));
}
// The graphical view may deselect, so select again
provider.setSelection(new StructuredSelection(adapter));
}
}
}
use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.
the class AddXSDAnyAttributeAction method run.
public void run() {
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
if (selection instanceof XSDBaseAdapter) {
selection = ((XSDBaseAdapter) selection).getTarget();
}
AddXSDAnyAttributeCommand command = null;
if (selection instanceof XSDComplexTypeDefinition) {
command = new AddXSDAnyAttributeCommand(Messages._UI_ACTION_ADD_ANY_ATTRIBUTE, (XSDComplexTypeDefinition) selection);
getCommandStack().execute(command);
} else if (selection instanceof XSDAttributeGroupDefinition) {
command = new AddXSDAnyAttributeCommand(Messages._UI_ACTION_ADD_ANY_ATTRIBUTE, (XSDAttributeGroupDefinition) selection);
getCommandStack().execute(command);
}
if (command != null) {
addedComponent = command.getAddedComponent();
Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent);
selectAddedComponent(adapter);
}
}
use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.
the class AddXSDAttributeDeclarationAction method run.
public void run() {
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
if (selection instanceof XSDBaseAdapter) {
selection = ((XSDBaseAdapter) selection).getTarget();
if (selection instanceof XSDAttributeDeclaration) {
selection = ((XSDAttributeDeclaration) selection).getContainer();
}
}
AddXSDAttributeDeclarationCommand command = null;
if (selection instanceof XSDComplexTypeDefinition) {
command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, (XSDComplexTypeDefinition) selection);
command.setReference(isReference);
getCommandStack().execute(command);
} else if (selection instanceof XSDAttributeUse) {
XSDAttributeUse xsdAttributeUse = (XSDAttributeUse) selection;
XSDConcreteComponent parent = null;
XSDComplexTypeDefinition ct = null;
XSDAttributeGroupDefinition group = null;
for (parent = xsdAttributeUse.getContainer(); parent != null; ) {
if (parent instanceof XSDComplexTypeDefinition) {
ct = (XSDComplexTypeDefinition) parent;
break;
} else if (parent instanceof XSDAttributeGroupDefinition) {
group = (XSDAttributeGroupDefinition) parent;
break;
}
parent = parent.getContainer();
}
if (ct != null) {
XSDAttributeUse sel = (XSDAttributeUse) selection;
int index = ct.getAttributeContents().indexOf(sel);
command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, ct, getId(), index);
command.setReference(isReference);
getCommandStack().execute(command);
} else if (group != null) {
XSDAttributeUse sel = (XSDAttributeUse) selection;
int index = group.eContents().indexOf(sel);
command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, group, getId(), index);
command.setReference(isReference);
getCommandStack().execute(command);
}
} else if (selection instanceof XSDAttributeGroupDefinition) {
command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, (XSDAttributeGroupDefinition) selection);
command.setReference(isReference);
getCommandStack().execute(command);
} else if (selection instanceof XSDSchema) {
command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, (XSDSchema) selection);
getCommandStack().execute(command);
}
if (command != null) {
addedComponent = command.getAddedComponent();
Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent);
selectAddedComponent(adapter);
}
}
use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.
the class AddXSDComplexTypeDefinitionAction method run.
public void run() {
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
if (selection instanceof XSDBaseAdapter) {
selection = ((XSDBaseAdapter) selection).getTarget();
}
if (selection instanceof XSDSchema) {
AddXSDComplexTypeDefinitionCommand command = new AddXSDComplexTypeDefinitionCommand(Messages._UI_ACTION_ADD_COMPLEX_TYPE, (XSDSchema) selection);
getCommandStack().execute(command);
addedComponent = command.getAddedComponent();
Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent);
selectAddedComponent(adapter);
}
}
Aggregations