generic.setText(ClickPlugin.getString("editor.clickXML.general"));
generic.setLayoutData(ClickUtils.createGridData(2, GridData.FILL_HORIZONTAL));
IDOMDocument doc = ((IDOMModel)model).getDocument();
NodeList nodes = doc.getElementsByTagName(ClickPlugin.TAG_CLICK_APP);
final IDOMElement clickApp = (IDOMElement)nodes.item(0);
IDOMElement format = ClickUtils.getElement(clickApp, ClickPlugin.TAG_FORMAT);
IDOMElement mode = ClickUtils.getElement(clickApp, ClickPlugin.TAG_MODE);
Composite compsote = toolkit.createComposite(generic);
compsote.setLayout(ClickUtils.createGridLayout(2));
compsote.setLayoutData(new GridData(GridData.FILL_BOTH));
generic.setClient(compsote);
textCharset = AttributeEditorUtils.createText(
toolkit, compsote, clickApp,
ClickPlugin.getString("editor.clickXML.general.charset"),
ClickPlugin.ATTR_CHARSET);
textCharset.addModifyListener(new ModifyListener(){
public void modifyText(ModifyEvent e){
if(textCharset.getText().equals("")){
clickApp.removeAttribute(ClickPlugin.ATTR_CHARSET);
} else {
clickApp.setAttribute(ClickPlugin.ATTR_CHARSET, textCharset.getText());
}
}
});
textLocale = AttributeEditorUtils.createText(
toolkit, compsote, clickApp,
ClickPlugin.getString("editor.clickXML.general.locale"),
ClickPlugin.ATTR_LOCALE);
textLocale.addModifyListener(new ModifyListener(){
public void modifyText(ModifyEvent e){
if(textLocale.getText().equals("")){
clickApp.removeAttribute(ClickPlugin.ATTR_LOCALE);
} else {
clickApp.setAttribute(ClickPlugin.ATTR_LOCALE, textLocale.getText());
}
}
});
IFile file = (IFile)ClickUtils.getResource(clickApp.getStructuredDocument());
IJavaProject project = JavaCore.create(file.getProject());
textFormat = AttributeEditorUtils.createClassText(
project, toolkit, compsote, format,
ClickPlugin.getString("editor.clickXML.general.format"),
ClickPlugin.ATTR_CLASSNAME, null, null);
textFormat.addModifyListener(new ModifyListener(){
public void modifyText(ModifyEvent e){
IDOMElement format = ClickUtils.getElement(clickApp, ClickPlugin.TAG_FORMAT);
if(textFormat.getText().equals("")){
if(format!=null){
clickApp.removeChild(format);
}
} else {
if(format==null){
format = (IDOMElement)clickApp.getOwnerDocument().createElement(ClickPlugin.TAG_FORMAT);
IDOMElement[] elements = {
ClickUtils.getElement(clickApp, ClickPlugin.TAG_MODE),
ClickUtils.getElement(clickApp, ClickPlugin.TAG_CONTROLS)};
for(int i=0;i<elements.length;i++){
if(elements[i]!=null){
clickApp.insertBefore(format, elements[i]);
break;
}
}
if(ClickUtils.getElement(clickApp, ClickPlugin.TAG_FORMAT)==null){
clickApp.appendChild(format);
}
}
format.setAttribute(ClickPlugin.ATTR_CLASSNAME, textFormat.getText());
}
}
});
comboMode = AttributeEditorUtils.createCombo(
toolkit, compsote, mode,
ClickPlugin.getString("editor.clickXML.general.mode"),
ClickPlugin.ATTR_VALUE,
ClickUtils.createComboValues(ClickPlugin.MODE_VALUES));
comboMode.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent evt){
IDOMElement mode = ClickUtils.getElement(clickApp, ClickPlugin.TAG_MODE);
if(comboMode.getText().equals("")){
if(mode!=null){
mode.removeAttribute(ClickPlugin.ATTR_VALUE);
if(mode.getAttributes().getLength()==0){
clickApp.removeChild(mode);
}
}
} else {
if(mode==null){
mode = (IDOMElement)clickApp.getOwnerDocument().createElement(ClickPlugin.TAG_MODE);
IDOMElement control = ClickUtils.getElement(clickApp, ClickPlugin.TAG_CONTROLS);
if(control!=null){
clickApp.insertBefore(mode, control);
} else {
clickApp.appendChild(mode);
}