use of org.eclipse.wst.dtd.core.internal.CMBasicNode in project webtools.sourceediting by eclipse.
the class ContentModelTypeSection method refresh.
/*
* @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
*/
public void refresh() {
Object input = getInput();
if (input != null) {
if (input instanceof CMNode) {
typeCombo.removeAll();
typeCombo.add(CMNode.ANY);
typeCombo.add(CMNode.EMPTY);
typeCombo.add(CMNode.PCDATA);
typeCombo.add(CMNode.CHILDREN);
typeCombo.add(CMNode.MIXED);
Iterator iterator = ((CMNode) input).getDTDFile().getNodes().iterator();
String nodeName = null;
while (iterator.hasNext()) {
DTDNode node = (DTDNode) iterator.next();
nodeName = node.getName();
if (node instanceof Element && typeCombo.indexOf(nodeName) == -1)
typeCombo.add(nodeName);
else if (node instanceof Entity && ((Entity) node).isParameterEntity() && typeCombo.indexOf(nodeName) == -1)
// $NON-NLS-1$ //$NON-NLS-2$
typeCombo.add("%" + nodeName + ";");
}
if (input instanceof CMGroupNode)
typeCombo.setText(((CMGroupNode) input).getType());
else if (input instanceof CMBasicNode)
typeCombo.setText(((CMBasicNode) input).getType());
}
}
// end if (fInput != null)
}
use of org.eclipse.wst.dtd.core.internal.CMBasicNode in project webtools.sourceediting by eclipse.
the class ContentModelNameSection method widgetSelected.
public void widgetSelected(SelectionEvent e) {
if (e.widget == typeCombo) {
Object input = getInput();
if (input instanceof CMBasicNode) {
CMBasicNode node = (CMBasicNode) input;
String selected = typeCombo.getText();
// if (CMNode.PCDATA.equals(selected))
node.setName(selected);
}
}
}
use of org.eclipse.wst.dtd.core.internal.CMBasicNode in project webtools.sourceediting by eclipse.
the class ContentModelNameSection method refresh.
/*
* @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
*/
public void refresh() {
Object input = getInput();
if (input != null) {
if (input instanceof CMBasicNode) {
typeCombo.removeAll();
typeCombo.add(CMNode.PCDATA);
// NodeList list =
// ((CMBasicNode)fInput).getDTDFile().getElementsAndParameterEntityReferences();
Iterator iterator = ((CMBasicNode) input).getDTDFile().getNodes().iterator();
boolean isForRootContent = ((CMBasicNode) input).isRootElementContent();
while (iterator.hasNext()) {
DTDNode node = (DTDNode) iterator.next();
if (!isForRootContent && node instanceof Element)
typeCombo.add(node.getName());
if (node instanceof Entity && ((Entity) node).isParameterEntity())
// $NON-NLS-1$ //$NON-NLS-2$
typeCombo.add("%" + node.getName() + ";");
}
typeCombo.setText(((CMBasicNode) input).getName());
}
}
}
use of org.eclipse.wst.dtd.core.internal.CMBasicNode in project webtools.sourceediting by eclipse.
the class ContentModelTypeSection method widgetSelected.
public void widgetSelected(SelectionEvent e) {
if (e.widget == typeCombo) {
Object input = getInput();
if (input instanceof CMGroupNode || input instanceof CMBasicNode) {
CMNode node = (CMNode) input;
String selected = typeCombo.getText();
if (CMNode.MIXED.equals(selected))
node.setMixedContent();
else if (CMNode.CHILDREN.equals(selected))
// $NON-NLS-1$
node.setChildrenContent("");
else if (CMNode.EMPTY.equals(selected) || CMNode.ANY.equals(selected) || CMNode.PCDATA.equals(selected))
node.setContent(selected);
else
node.setChildrenContent(selected);
}
}
}
use of org.eclipse.wst.dtd.core.internal.CMBasicNode in project webtools.sourceediting by eclipse.
the class DTDSectionLabelProvider method getText.
/**
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
public String getText(Object object) {
if (object == null || object.equals(StructuredSelection.EMPTY)) {
return null;
}
Object selected = object;
if (object instanceof IStructuredSelection) {
selected = ((IStructuredSelection) object).getFirstElement();
}
if (selected instanceof DTDFile) {
return ((DTDFile) selected).getName();
} else if (selected instanceof CMBasicNode) {
if (((CMBasicNode) selected).isReference())
return DTDPropertiesMessages._UI_PROPERTIES_VIEW_TITLE_ELEMENT_REF;
else
return ((CMBasicNode) selected).getName();
} else if (selected instanceof CMRepeatableNode) {
CMRepeatableNode node = (CMRepeatableNode) selected;
String name = node.getName();
if (node instanceof CMGroupNode) {
if (((CMGroupNode) node).getConnector() == CMGroupNode.CHOICE)
name = DTDPropertiesMessages.DTDSectionLabelProvider_0;
else
name = DTDPropertiesMessages.DTDSectionLabelProvider_1;
}
char occurrence = node.getOccurrence();
switch(occurrence) {
case CMRepeatableNode.ONCE:
// $NON-NLS-1$
name += " [1..1]";
break;
case CMRepeatableNode.OPTIONAL:
// $NON-NLS-1$
name += " [0..1]";
break;
case CMRepeatableNode.ONE_OR_MORE:
// $NON-NLS-1$
name += " [1..*]";
break;
case CMRepeatableNode.ZERO_OR_MORE:
// $NON-NLS-1$
name += " [0..*]";
break;
}
return name;
} else if (selected instanceof DTDNode) {
if (selected instanceof Element)
return DTDPropertiesMessages.DTDSectionLabelProvider_6;
else if (selected instanceof Attribute)
return DTDPropertiesMessages.DTDSectionLabelProvider_7;
else if (selected instanceof AttributeList)
return DTDPropertiesMessages.DTDSectionLabelProvider_8;
else if (selected instanceof Comment)
return DTDPropertiesMessages.DTDSectionLabelProvider_9;
else if (selected instanceof Entity)
return DTDPropertiesMessages.DTDSectionLabelProvider_10;
else if (selected instanceof Notation)
return DTDPropertiesMessages.DTDSectionLabelProvider_11;
else if (selected instanceof ParameterEntityReference)
// return "parameter entity reference";
return null;
else
return ((DTDNode) selected).getName();
} else if (selected instanceof org.w3c.dom.Element) {
return ((org.w3c.dom.Element) selected).getLocalName();
} else if (object instanceof ITextSelection) {
// $NON-NLS-1$
return "";
} else
return object.toString();
}
Aggregations