Lines 119-125
Link Here
|
119 |
public ElementSection(PDEFormPage page, Composite parent) { |
119 |
public ElementSection(PDEFormPage page, Composite parent) { |
120 |
super(page, parent, Section.DESCRIPTION, new String[] { |
120 |
super(page, parent, Section.DESCRIPTION, new String[] { |
121 |
PDEUIMessages.SchemaEditor_ElementSection_newElement, |
121 |
PDEUIMessages.SchemaEditor_ElementSection_newElement, |
122 |
PDEUIMessages.SchemaEditor_ElementSection_newAttribute }); |
122 |
PDEUIMessages.SchemaEditor_ElementSection_newAttribute, |
|
|
123 |
PDEUIMessages.SchemaEditor_ElementSection_newChoice, |
124 |
PDEUIMessages.SchemaEditor_ElementSection_newSequence, |
125 |
PDEUIMessages.SchemaEditor_ElementSection_remove}); |
123 |
getSection().setText(PDEUIMessages.SchemaEditor_ElementSection_title); |
126 |
getSection().setText(PDEUIMessages.SchemaEditor_ElementSection_title); |
124 |
getSection().setDescription(PDEUIMessages.SchemaEditor_ElementSection_desc); |
127 |
getSection().setDescription(PDEUIMessages.SchemaEditor_ElementSection_desc); |
125 |
} |
128 |
} |
Lines 202-209
Link Here
|
202 |
case 1: |
205 |
case 1: |
203 |
handleNewAttribute(); |
206 |
handleNewAttribute(); |
204 |
break; |
207 |
break; |
|
|
208 |
case 2: |
209 |
addCompositor(ISchemaCompositor.CHOICE); |
210 |
break; |
211 |
case 3: |
212 |
addCompositor(ISchemaCompositor.SEQUENCE); |
213 |
break; |
214 |
case 4: |
215 |
final ISelection selection = fTreeViewer.getSelection(); |
216 |
handleDelete((IStructuredSelection)selection); |
217 |
break; |
205 |
} |
218 |
} |
206 |
} |
219 |
} |
|
|
220 |
|
221 |
private void addCompositor (int kind) { |
222 |
Object selection = ((IStructuredSelection)fTreeViewer.getSelection()).getFirstElement(); |
223 |
ISchemaElement sourceElement = null; |
224 |
Object current = selection; |
225 |
while (current instanceof ISchemaCompositor) |
226 |
current = ((ISchemaCompositor)current).getParent(); |
227 |
if (current instanceof ISchemaElement) |
228 |
sourceElement = (ISchemaElement) current; |
229 |
if (sourceElement != null) |
230 |
new NewCompositorAction(sourceElement, selection, kind).run(); |
231 |
} |
207 |
|
232 |
|
208 |
public void dispose() { |
233 |
public void dispose() { |
209 |
if (fClipboard != null) { |
234 |
if (fClipboard != null) { |
Lines 531-552
Link Here
|
531 |
private void updateButtons() { |
556 |
private void updateButtons() { |
532 |
if (!fSchema.isEditable()) |
557 |
if (!fSchema.isEditable()) |
533 |
return; |
558 |
return; |
534 |
Object object = ((IStructuredSelection) fTreeViewer.getSelection()).getFirstElement(); |
559 |
IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection(); |
535 |
ISchemaObject sobject = (ISchemaObject) object; |
560 |
ISchemaObject sobject = (ISchemaObject) selection.getFirstElement(); |
536 |
|
561 |
|
537 |
boolean canAddAttribute = false; |
562 |
boolean canAddAttribute = false; |
538 |
if (sobject != null) { |
563 |
if (sobject instanceof ISchemaElement) { |
539 |
if (sobject instanceof ISchemaElement) { |
564 |
if (!(sobject instanceof ISchemaRootElement) |
540 |
if (!(sobject instanceof ISchemaRootElement) |
565 |
&& !(sobject instanceof ISchemaObjectReference)) |
541 |
&& !(sobject instanceof ISchemaObjectReference)) |
566 |
canAddAttribute = true; |
542 |
canAddAttribute = true; |
567 |
} else if (sobject instanceof ISchemaAttribute) { |
543 |
} else if (sobject instanceof ISchemaAttribute) { |
568 |
ISchemaElement element = (ISchemaElement) (sobject.getParent()); |
544 |
ISchemaElement element = (ISchemaElement) (sobject.getParent()); |
569 |
if (!(element instanceof ISchemaRootElement)) |
545 |
if (!(element instanceof ISchemaRootElement)) |
570 |
canAddAttribute = true; |
546 |
canAddAttribute = true; |
|
|
547 |
} |
548 |
} |
571 |
} |
549 |
getTreePart().setButtonEnabled(1, canAddAttribute); |
572 |
getTreePart().setButtonEnabled(1, canAddAttribute); |
|
|
573 |
|
574 |
boolean canAddCompositor = false; |
575 |
if (sobject instanceof ISchemaElement || sobject instanceof ISchemaCompositor) |
576 |
canAddCompositor = true; |
577 |
getTreePart().setButtonEnabled(2, canAddCompositor); |
578 |
getTreePart().setButtonEnabled(3, canAddCompositor); |
579 |
|
580 |
boolean canRemove = false; |
581 |
for (Iterator iter = selection.iterator(); iter.hasNext();) { |
582 |
sobject = (ISchemaObject) iter.next(); |
583 |
if (sobject != null && !(sobject instanceof ISchemaRootElement) && |
584 |
!(sobject instanceof ISchemaAttribute && sobject.getParent() instanceof ISchemaRootElement)) { |
585 |
canRemove = true; |
586 |
break; |
587 |
} |
588 |
} |
589 |
getTreePart().setButtonEnabled(4, canRemove); |
550 |
} |
590 |
} |
551 |
|
591 |
|
552 |
private ISchemaObject getSibling(Object target, Object object) { |
592 |
private ISchemaObject getSibling(Object target, Object object) { |