use of org.eclipse.xsd.XSDConcreteComponent 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.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class XSDEditPartFactory method createStructureFigure.
public IStructureFigure createStructureFigure(Object model) {
IStructureFigure figure = delegate.createStructureFigure(model);
if (model instanceof XSDBaseAdapter) {
XSDConcreteComponent comp = (XSDConcreteComponent) ((XSDBaseAdapter) model).getTarget();
boolean isReadOnly = ((XSDBaseAdapter) model).isReadOnly();
figure.getNameLabel().setIcon(XSDCommonUIUtils.getUpdatedImage(comp, ((XSDBaseAdapter) model).getImage(), isReadOnly));
}
return figure;
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class MoveXSDElementAction method run.
/*
* @see IAction#run()
*/
public void run() {
int originalIndex = 0;
for (Iterator particles = parentModelGroup.getContents().iterator(); particles.hasNext(); ) {
XSDParticle particle = (XSDParticle) particles.next();
XSDParticleContent particleContent = particle.getContent();
if (particleContent == selected) {
parentModelGroup.getContents().remove(particle);
break;
}
originalIndex++;
}
int index = 0;
boolean addedBack = false;
if (insertType == INSERT_DIRECT) {
XSDConcreteComponent container = selected.getContainer();
if (container != null) {
XSDConcreteComponent container2 = container.getContainer();
if (container2 instanceof XSDModelGroup) {
((XSDModelGroup) container2).getContents().remove(container);
}
if (insertAtEnd)
parentModelGroup.getContents().add(container);
else
parentModelGroup.getContents().add(0, container);
addedBack = true;
}
return;
}
List particles = parentModelGroup.getContents();
for (Iterator iterator = particles.iterator(); iterator.hasNext(); ) {
XSDParticle particle = (XSDParticle) iterator.next();
XSDParticleContent particleContent = particle.getContent();
if (insertType == INSERT_BEFORE) {
if (particleContent == nextRefComponent) {
parentModelGroup.getContents().add(index, selected.getContainer());
addedBack = true;
break;
}
if (selected == nextRefComponent && originalIndex == index) {
parentModelGroup.getContents().add(index, selected.getContainer());
addedBack = true;
break;
}
} else if (insertType == INSERT_AFTER) {
if (particleContent == previousRefComponent) {
parentModelGroup.getContents().add(index + 1, selected.getContainer());
addedBack = true;
break;
}
if (selected == previousRefComponent && originalIndex == index) {
parentModelGroup.getContents().add(index, selected.getContainer());
addedBack = true;
break;
}
}
index++;
}
if (particles.size() == 0) {
parentModelGroup.getContents().add(selected.getContainer());
addedBack = true;
}
if (!addedBack) {
parentModelGroup.getContents().add(originalIndex, selected.getContainer());
}
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class XSDSchemaAdapter method getTypes.
public List getTypes() {
if (types == null) {
types = new ArrayList();
XSDSchema schema = (XSDSchema) target;
List concreteComponentList = new ArrayList();
for (Iterator i = schema.getContents().iterator(); i.hasNext(); ) {
XSDConcreteComponent component = (XSDConcreteComponent) i.next();
if (component instanceof XSDTypeDefinition) {
concreteComponentList.add(component);
}
}
populateAdapterList(concreteComponentList, types);
}
return types;
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class XSDSimpleContentAdapter method getTopContainer.
public IADTObject getTopContainer() {
XSDConcreteComponent c = getXSDSimpleTypeContent().getContainer();
if (c instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition) c;
Adapter adapter = XSDAdapterFactory.getInstance().adapt(ct);
if (adapter instanceof IADTObject)
return (IADTObject) adapter;
}
return null;
}
Aggregations