Author: scabanovich
Date: 2009-07-09 06:19:50 -0400 (Thu, 09 Jul 2009)
New Revision: 16512
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/handlers/ImportTLDToPaletteSupport.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4556
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/handlers/ImportTLDToPaletteSupport.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/handlers/ImportTLDToPaletteSupport.java 2009-07-09
09:41:36 UTC (rev 16511)
+++
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/handlers/ImportTLDToPaletteSupport.java 2009-07-09
10:19:50 UTC (rev 16512)
@@ -33,6 +33,10 @@
import org.jboss.tools.jst.web.tld.model.helpers.TLDToPaletteHelper;
public class ImportTLDToPaletteSupport extends SpecialWizardSupport {
+ static String NAME = "name"; //$NON-NLS-1$
+ static String TLD = "tld"; //$NON-NLS-1$
+ static String PARENT_GROUP = "parent group"; //$NON-NLS-1$
+
Map<String,XModelObject> groups;
XModelObject palette;
AllTldsTree tree = new AllTldsTree();
@@ -43,7 +47,7 @@
tree.getChildren(tree.getRoot());
selectedFile = (XModelObject)getProperties().get("initialSelection");
//$NON-NLS-1$
if(selectedFile != null) {
- setAttributeValue(0, "tld", "" + tree.getValue(selectedFile));
//$NON-NLS-1$ //$NON-NLS-2$
+ setAttributeValue(0, TLD, "" + tree.getValue(selectedFile)); //$NON-NLS-1$
onPathModified();
}
}
@@ -55,9 +59,9 @@
collectParents(palette);
XModelObject t = (XModelObject)getProperties().get("target"); //$NON-NLS-1$
if(t != null && t != target) {
- String g = t.getAttributeValue("name"); //$NON-NLS-1$
+ String g = t.getAttributeValue(NAME);
if(g != null && groups.containsKey(g)) {
- getProperties().setProperty("parent group", g); //$NON-NLS-1$
+ getProperties().setProperty(PARENT_GROUP, g);
}
}
@@ -68,7 +72,7 @@
for (int i = 0; i < cs.length; i++) {
String kind = cs[i].getAttributeValue("element type"); //$NON-NLS-1$
if(!"group".equals(kind) && !"sub-group".equals(kind))
continue; //$NON-NLS-1$ //$NON-NLS-2$
- String name = cs[i].getAttributeValue("name"); //$NON-NLS-1$
+ String name = cs[i].getAttributeValue(NAME);
groups.put(name, cs[i]);
}
getProperties().put("groups", groups.keySet().toArray(new String[0]));
//$NON-NLS-1$
@@ -85,20 +89,20 @@
protected void execute() throws XModelException {
Properties p0 = extractStepData(0);
- String name = p0.getProperty("name"); //$NON-NLS-1$
- String path = p0.getProperty("tld"); //$NON-NLS-1$
+ String name = p0.getProperty(NAME);
+ String path = p0.getProperty(TLD);
XModelObject tld = getSelectedResource(path);
- String parentName = getProperties().getProperty("parent group");
//$NON-NLS-1$
+ String parentName = getProperties().getProperty(PARENT_GROUP);
XModelObject parent = groups.get(parentName);
if(parent == null) {
Properties p = new Properties();
- p.setProperty("name", parentName); //$NON-NLS-1$
+ p.setProperty(NAME, parentName);
parent =
getTarget().getModel().createModelObject("SharablePageTabHTML", p);
//$NON-NLS-1$
DefaultCreateHandler.addCreatedObject(palette, parent, getProperties());
}
TLDToPaletteHelper h = new TLDToPaletteHelper();
XModelObject added = h.createGroupByTLD(tld, getTarget().getModel());
- added.setAttributeValue("name", name); //$NON-NLS-1$
+ added.setAttributeValue(NAME, name);
added.setAttributeValue(URIConstants.LIBRARY_URI, getAttributeValue(0,
URIConstants.LIBRARY_URI));
added.setAttributeValue(URIConstants.DEFAULT_PREFIX, getAttributeValue(0,
URIConstants.DEFAULT_PREFIX));
PaletteAdopt.add(parent, getTarget(), added);
@@ -125,7 +129,7 @@
if(selectedFile == null) return;
String name = selectedFile.getAttributeValue("display-name");
//$NON-NLS-1$
if(name == null || name.length() == 0) name =
selectedFile.getAttributeValue("shortname"); //$NON-NLS-1$
- setAttributeValue(0, "name", name); //$NON-NLS-1$
+ setAttributeValue(0, NAME, name);
String pref = TLDToPaletteHelper.getTldName(selectedFile);
setAttributeValue(0, URIConstants.DEFAULT_PREFIX, pref);
String uri = selectedFile.getAttributeValue("uri"); //$NON-NLS-1$
@@ -142,17 +146,17 @@
class ImportTLDValidator extends DefaultWizardDataValidator {
public void validate(Properties data) {
message = null;
- String tld = data.getProperty("tld");
+ String tld = data.getProperty(TLD);
IStatus status = ResourcesPlugin.getWorkspace().validatePath(tld, IResource.FILE);
if(status != null && !status.isOK()) {
message = status.getMessage();
return;
}
- XModelObject s = getSelectedResource(tld); //$NON-NLS-1$
+ XModelObject s = getSelectedResource(tld);
super.validate(data);
if(message != null) return;
- String name = data.getProperty("name"); //$NON-NLS-1$
- String parentName = getProperties().getProperty("parent group");
//$NON-NLS-1$
+ String name = data.getProperty(NAME);
+ String parentName = getProperties().getProperty(PARENT_GROUP);
if(parentName == null || parentName.length() == 0) {
message = WebUIMessages.PARENT_GROUP_MUST_BE_SPECIFIED;
return;