Author: scabanovich
Date: 2009-06-19 11:44:59 -0400 (Fri, 19 Jun 2009)
New Revision: 16067
Added:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelMessages.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/messages.properties
Removed:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XBundle.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/ant/parser/AntParser.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/java/generation/JavaBeanGenerator.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/DefaultWizardDataValidator.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/MultistepWizardSupport.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/SignificanceMessageImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/SpecialWizardSupport.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XActionImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XActionListImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XAttributeDataImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XEntityDataImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/AddAttributeToAnyElementSupport.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/CopyHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultCreateHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultCreateSupport.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultRedirectHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultRemoveHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultRenameSupport.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithChoiceHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithHelper.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/PasteEnterNewNameSupport.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/PasteHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/XAdapter.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintJavaName.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintList.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintListInt.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintListTemplates.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintXMLName.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/help/HelpUtil.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XActionItemImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XAttributeImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataConstants.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelEntityImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelMetaDataImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/adapters/XAdapterModelPath.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/adapters/XAdapterProjectsRoot.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/DocumentGenerator.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/MetaValidator.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModel.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelObject.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelObjectConstants.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/engines/impl/EnginesLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/event/XModelTreeEvent.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/files/handlers/CreateFileSupport.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/files/handlers/CreateFolderSupport.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/files/handlers/TargetHolder.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/FileAuxiliary.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/FileSystemsHelper.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractExtendedXMLFileImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractXMLFileImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/CreateFileHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/DiscardFileHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/DiscardFileSignificanceMessage.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/ExtensionChange.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyAuxiliaryImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyLongImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemFolderLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemPeer.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsRenameListener.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsTreeConstraint.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileXMLImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FolderImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/HiddenSystemsHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarFolderImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarSystemImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFileSystemHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFileSystemUndo.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFolderHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/RecognizedFileImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SelectOverlappedFileSystemHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SimpleFileImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/UnmountFileSystemHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/UnmountFileSystemUndo.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/UnmountFolderHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/example/FileMainImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/handlers/RenameFileSystemHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/handlers/RenameFolderHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/CloseProjectHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/DeleteProjectHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/OpenJavaEditorHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RefreshProjectHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RemoveModelNatureHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/GifIcon.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/ModifiersIcon.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/CustomizedObjectImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/OpenedProjectsImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/PropertyObjectImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/RegularObjectImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/WorkspaceObjectImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/AllResourcesTree.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/DefaultSubTree.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/FileSystemResourceBundleTree.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/FileSystemResourceTree.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/FileSystemsTree.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/OptionsTree.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/java/handlers/OpenJavaSourceHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/BodyLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/FileRootLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/PropertiesLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/SimpleWebFileLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/PreferenceModelUtilities.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/SharableConstants.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/DeleteGroupHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/HiddenPaletteTabsHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableElementImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/XStudioDataLoaderImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/XStudioLoaderPeer.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/XModelSaveParticipant.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ClassPathUpdate.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ClassPathUpdateWizard.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/IPromptingProvider.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ProjectHome.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/Watcher.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/WatcherLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ext/store/XMLStoreConstants.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/search/impl/SearchConstraintImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/search/impl/SearchConstraintValueImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/search/impl/SearchDefaultHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XChangeSetUndo.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XChangeUndo.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XCreateUndo.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XMoveUndo.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XRemoveUndo.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/AccessibleJava.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/BrowserHelper.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/FindObjectHelper.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/ModelImages.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelObjectLoaderUtil.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/jst/web/tld/TLDToPaletteHelper.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2969
Most frequently used coded strings moved to constants.
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/ant/parser/AntParser.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/ant/parser/AntParser.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/ant/parser/AntParser.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -13,6 +13,7 @@
import java.io.*;
import org.w3c.dom.*;
import org.eclipse.ant.core.TargetInfo;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.util.XMLUtil;
@@ -32,10 +33,10 @@
if(element.hasAttribute("xsi:schemaLocation")) return;
NodeList es = element.getElementsByTagName("target");
for (int i = 0; i < es.getLength(); i++)
- if(!((Element)es.item(i)).hasAttribute("name")) return;
+ if(!((Element)es.item(i)).hasAttribute(XModelObjectConstants.ATTR_NAME))
return;
targets = new String[es.getLength()];
for (int i = 0; i < es.getLength(); i++)
- targets[i] = ((Element)es.item(i)).getAttribute("name");
+ targets[i] =
((Element)es.item(i)).getAttribute(XModelObjectConstants.ATTR_NAME);
}
public String[] getTargets() {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/java/generation/JavaBeanGenerator.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/java/generation/JavaBeanGenerator.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/java/generation/JavaBeanGenerator.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -36,6 +36,7 @@
import org.eclipse.jface.text.Document;
import org.eclipse.text.edits.TextEdit;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
@@ -63,7 +64,7 @@
}
public IJavaProject getJavaProject() {
- IProject project =
(IProject)context.getModel().getProperties().get("project");
+ IProject project = EclipseResourceUtil.getProject(context);
return EclipseResourceUtil.getJavaProject(project);
}
@@ -74,7 +75,7 @@
if(srcpath == null) return;
String qclsname = input.getProperty(ATT_CLASS_NAME);
- String filepath = srcpath + "/" + qclsname.replace('.', '/')
+ ".java";
+ String filepath = srcpath + XModelObjectConstants.SEPARATOR +
qclsname.replace('.', '/') + ".java";
if(new File(filepath).exists()) return;
int lastDot = qclsname.lastIndexOf('.');
@@ -201,7 +202,7 @@
// String pkgname = p.getProperty(PARAM_PACKAGENAME);
String access = p.getProperty(PARAM_ACCESS);
if(access == null) access = ""; else if(access.length() > 0) access +=
" ";
- boolean isInterface = "true".equals(p.getProperty(PARAM_INTERFACE));
+ boolean isInterface =
XModelObjectConstants.TRUE.equals(p.getProperty(PARAM_INTERFACE));
String kind = isInterface ? "interface " : "class ";
String shortname = p.getProperty(PARAM_SHORTNAME);
String _extends = p.getProperty(PARAM_EXTENDS);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/DefaultWizardDataValidator.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/DefaultWizardDataValidator.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/DefaultWizardDataValidator.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -15,6 +15,8 @@
import org.jboss.tools.common.meta.XChild;
import org.jboss.tools.common.meta.action.*;
import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateHandler;
+import org.jboss.tools.common.meta.impl.XMetaDataConstants;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.impl.CreateFileHandler;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
@@ -40,8 +42,8 @@
XEntityData[] ds = support.getEntityData();
if(ds.length <= step) return;
if(support.action != null) {
- if("true".equals(support.action.getProperty("validator.add"))
&& step == 0) {
- String entity = support.action.getProperty("entity");
+ if(XModelObjectConstants.TRUE.equals(support.action.getProperty("validator.add"))
&& step == 0) {
+ String entity = support.action.getProperty(XMetaDataConstants.ENTITY);
if(entity == null) entity = ds[step].getModelEntity().getName();
if(!checkChild(support.getTarget(), entity, data)) return;
@@ -54,8 +56,8 @@
((max == 1) ? " child " : " children ") +
"with entity " + entity + ".";
}
- } else
if("true".equals(support.action.getProperty("validator.edit"))) {
- String entity = support.action.getProperty("entity");
+ } else
if(XModelObjectConstants.TRUE.equals(support.action.getProperty("validator.edit")))
{
+ String entity = support.action.getProperty(XMetaDataConstants.ENTITY);
if(entity == null) entity = ds[step].getModelEntity().getName();
if(!checkChild(support.getTarget().getParent(), entity, data)) return;
}
@@ -71,7 +73,7 @@
if(message != null) return;
}
if(message != null || support.action == null) return;
- if("true".equals(support.action.getProperty("validator.addfile"))
&& step == 0) {
+ if(XModelObjectConstants.TRUE.equals(support.action.getProperty("validator.addfile"))
&& step == 0) {
validateAddFile(ds, data);
}
String resourceAttr = support.action.getProperty("validator.resource");
@@ -85,7 +87,7 @@
protected void validateAddFile(XEntityData[] ds, Properties data) {
CreateFileHandler.validateNameAndExtension(support.action, data, null);
- String entity = support.action.getProperty("entity");
+ String entity = support.action.getProperty(XMetaDataConstants.ENTITY);
if(entity == null) {
String ext = null;
entity = (ext != null) ?
support.getTarget().getModel().getEntityRecognizer().getEntityName(ext, null)
@@ -115,7 +117,7 @@
protected boolean checkChild(XModelObject parent, String entity, Properties data) {
XModelObject o = support.getTarget().getModel().createModelObject(entity, data);
if(o.getModelEntity().getAttribute(XModelObjectLoaderUtil.ATTR_ID_NAME) != null
- &&
!"true".equals(o.getModelEntity().getProperty("unique"))) return
true;
+ &&
!XModelObjectConstants.TRUE.equals(o.getModelEntity().getProperty("unique")))
return true;
if(o != null && parent == support.getTarget().getParent() &&
o.getPathPart().equals(support.getTarget().getPathPart())) return true;
if(o != null) message = DefaultCreateHandler.getContainsMessage(parent, o);
return message == null;
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/MultistepWizardSupport.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/MultistepWizardSupport.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/MultistepWizardSupport.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -13,6 +13,7 @@
import java.util.Properties;
import org.jboss.tools.common.meta.action.impl.handlers.PasteHandler;
import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObjectConstants;
public class MultistepWizardSupport extends SpecialWizardSupport {
protected MultistepWizardStep[] steps = createSteps();
@@ -34,7 +35,7 @@
execute();
setFinished(true);
} else if(CANCEL.equals(name)) {
- getProperties().setProperty(PasteHandler.IS_CANCELLED, "true");
+ getProperties().setProperty(PasteHandler.IS_CANCELLED, XModelObjectConstants.TRUE);
setFinished(true);
} else if(NEXT.equals(name)) {
int next = next();
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/SignificanceMessageImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/SignificanceMessageImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/SignificanceMessageImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -19,8 +19,8 @@
public String getMessage(XAction action, XModelObject object, XModelObject[] objects)
{
String d = action.getDisplayName();
if(d.endsWith("...")) d = d.substring(d.length() - 3);
- XAttribute e = object.getModelEntity().getAttribute("element type");
- String type = (e == null || !e.isVisible()) ? "" :
object.getAttributeValue("element type");
+ XAttribute e =
object.getModelEntity().getAttribute(XModelObjectConstants.ATTR_ELEMENT_TYPE);
+ String type = (e == null || !e.isVisible()) ? "" :
object.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE);
if(type.length() > 0) type += " ";
String what = (objects != null && objects.length > 1) ? objects.length
+ " selected objects" :
type + "'" + object.getPresentationString() +
"'";
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/SpecialWizardSupport.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/SpecialWizardSupport.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/SpecialWizardSupport.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -21,13 +21,13 @@
import org.jboss.tools.common.meta.key.*;
public abstract class SpecialWizardSupport {
- public static final String OK = "OK";
- public static final String CANCEL = "Cancel";
- public static final String BACK = "<< Back";
- public static final String NEXT = "Next >>";
- public static final String FINISH = "Finish";
- public static final String HELP = "Help";
- public static final String CLOSE = "Close";
+ public static final String OK = "OK"; //$NON-NLS-1$
+ public static final String CANCEL = "Cancel"; //$NON-NLS-1$
+ public static final String BACK = "<< Back"; //$NON-NLS-1$
+ public static final String NEXT = "Next >>"; //$NON-NLS-1$
+ public static final String FINISH = "Finish"; //$NON-NLS-1$
+ public static final String HELP = "Help"; //$NON-NLS-1$
+ public static final String CLOSE = "Close"; //$NON-NLS-1$
static final Set<String> standardButtons = new HashSet<String>();
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XActionImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XActionImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XActionImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -99,7 +99,7 @@
wizard = el.getAttribute("WizardClassName");
baseaction = (!XMetaDataLoader.hasAttribute(el, "BaseActionName")) ?
null :
el.getAttribute("BaseActionName");
- isSave2ModelRequired =
"yes".equals(el.getAttribute("SAVE_REQUIRED"));
+ isSave2ModelRequired =
XModelObjectConstants.YES.equals(el.getAttribute("SAVE_REQUIRED"));
hide = el.getAttribute("HIDE");
Element[] cs = XMetaDataLoader.getChildrenElements(el, "EntityData");
data = new XEntityDataImpl[cs.length];
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XActionListImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XActionListImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XActionListImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -107,7 +107,7 @@
item.load(ei);
list.add(item);
} else if(XMODEL_ACTION_ITEM_REF.equals(tag)) {
- String entityName = ei.getAttribute("entity");
+ String entityName = ei.getAttribute(XMetaDataConstants.ENTITY);
String attrName = ei.getAttribute(NAME);
String path = ei.hasAttribute("path")
? ei.getAttribute("path")
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XAttributeDataImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XAttributeDataImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XAttributeDataImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -14,6 +14,7 @@
import org.jboss.tools.common.meta.*;
import org.jboss.tools.common.meta.action.XAttributeData;
import org.jboss.tools.common.meta.impl.*;
+import org.jboss.tools.common.model.XModelObjectConstants;
public class XAttributeDataImpl implements XAttributeData, XMetaDataConstants {
private String entityname;
@@ -64,9 +65,9 @@
attributename = el.getAttribute("AttributeName"); //$NON-NLS-1$
entityname = ((Element)el.getParentNode()).getAttribute("EntityName");
//$NON-NLS-1$
String m = el.getAttribute("Mandatory"); //$NON-NLS-1$
- mandatory = "yes".equals(m) || "".equals(m);
//$NON-NLS-1$//$NON-NLS-2$
+ mandatory = XModelObjectConstants.YES.equals(m) || "".equals(m);
//$NON-NLS-1$//$NON-NLS-2$
m = el.getAttribute("Advanced"); //$NON-NLS-1$
- isAdvanced = "yes".equals(m); //$NON-NLS-1$
+ isAdvanced = XModelObjectConstants.YES.equals(m); //$NON-NLS-1$
}
public String getAttributeName() {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XEntityDataImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XEntityDataImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/XEntityDataImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -14,6 +14,7 @@
import org.jboss.tools.common.meta.*;
import org.jboss.tools.common.meta.action.*;
import org.jboss.tools.common.meta.impl.*;
+import org.jboss.tools.common.model.XModelObjectConstants;
public class XEntityDataImpl implements XEntityData, XMetaDataConstants {
private String entityname;
@@ -49,7 +50,7 @@
public void load(Element el) {
entityname = el.getAttribute("EntityName"); //$NON-NLS-1$
- mandatory = "yes".equals(el.getAttribute("Mandatory"));
//$NON-NLS-1$ //$NON-NLS-2$
+ mandatory =
XModelObjectConstants.YES.equals(el.getAttribute("Mandatory")); //$NON-NLS-1$
//$NON-NLS-2$
Element[] cs = XMetaDataLoader.getChildrenElements(el,
"AttributeData"); //$NON-NLS-1$
attributes = new XAttributeDataImpl[cs.length];
for (int i = 0; i < cs.length; i++) {
@@ -65,12 +66,12 @@
public static XEntityDataImpl create(String[][] data) {
XEntityDataImpl impl = new XEntityDataImpl();
impl.entityname = data[0][0];
- impl.mandatory = data[0].length > 1 &&
"yes".equals(data[0][1]); //$NON-NLS-1$
+ impl.mandatory = data[0].length > 1 &&
XModelObjectConstants.YES.equals(data[0][1]); //$NON-NLS-1$
impl.attributes = new XAttributeDataImpl[data.length - 1];
for (int i = 0; i < impl.attributes.length; i++) {
impl.attributes[i] = XAttributeDataImpl.create(impl.entityname,
data[i + 1][0],
- (data[i + 1].length > 1 &&
"yes".equals(data[i + 1][1]))); //$NON-NLS-1$
+ (data[i + 1].length > 1 &&
XModelObjectConstants.YES.equals(data[i + 1][1]))); //$NON-NLS-1$
}
return impl;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/AddAttributeToAnyElementSupport.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/AddAttributeToAnyElementSupport.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/AddAttributeToAnyElementSupport.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -13,6 +13,7 @@
import java.util.*;
import org.jboss.tools.common.meta.action.impl.*;
import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.impl.AnyElementObjectImpl;
@@ -32,11 +33,11 @@
for (int i = 0; i < as.length; i++) {
attributes.add(as[i][0]);
}
- edit = "true".equals(action.getProperty("edit"));
- initialName = getProperties().getProperty("name");
+ edit = XModelObjectConstants.TRUE.equals(action.getProperty("edit"));
+ initialName = getProperties().getProperty(XModelObjectConstants.ATTR_NAME);
initialValue = null;
if(initialName != null) {
- setAttributeValue(0, "name", initialName);
+ setAttributeValue(0, XModelObjectConstants.ATTR_NAME, initialName);
for (int i = 0; i < as.length; i++) {
if(initialName.equals(as[i][0])) initialValue = as[i][1];
}
@@ -57,7 +58,7 @@
protected void finish() throws XModelException {
Properties p = extractStepData(0);
- String name = p.getProperty("name");
+ String name = p.getProperty(XModelObjectConstants.ATTR_NAME);
String value = p.getProperty("value");
String as = "";
if(!edit) {
@@ -88,7 +89,7 @@
public void validate(Properties data) {
super.validate(data);
if(message != null) return;
- String name = data.getProperty("name");
+ String name = data.getProperty(XModelObjectConstants.ATTR_NAME);
if(!edit && attributes.contains(name)) {
message = "Attribute " + name + " already exists.";
}
@@ -102,7 +103,7 @@
}
public boolean isFieldEditorEnabled(int stepId, String name, Properties values) {
- return !edit || !name.equals("name");
+ return !edit || !name.equals(XModelObjectConstants.ATTR_NAME);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/CopyHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/CopyHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/CopyHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -16,7 +16,6 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.part.ResourceTransfer;
import org.jboss.tools.common.model.*;
-import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.ModelFeatureFactory;
import org.jboss.tools.common.meta.action.impl.AbstractHandler;
@@ -26,9 +25,6 @@
static {
modelTransfer =
(Transfer)ModelFeatureFactory.getInstance().createFeatureInstance("org.jboss.tools.common.model.ui.dnd.ModelTransfer");
- if(modelTransfer == null) {
- ModelPlugin.getPluginLog().logError("Model transfer class not found.");
- }
}
public CopyHandler() {}
@@ -36,7 +32,7 @@
public void executeHandler(XModelObject object, Properties p) throws XModelException
{
object.getModel().getModelBuffer().clear();
object.getModel().getModelBuffer().addSource(object);
- if(p == null || !"true".equals(p.getProperty("isDrag"))) {
+ if(p == null ||
!XModelObjectConstants.TRUE.equals(p.getProperty("isDrag"))) {
setClipboard(object.getModel());
}
}
@@ -54,7 +50,7 @@
XModelBuffer buffer = object.getModel().getModelBuffer();
buffer.clear();
for (int i = 0; i < objects.length; i++) buffer.addSource(objects[i]);
- if(p == null || !"true".equals(p.getProperty("isDrag"))) {
+ if(p == null ||
!XModelObjectConstants.TRUE.equals(p.getProperty("isDrag"))) {
setClipboard(object.getModel());
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultCreateHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultCreateHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultCreateHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.meta.XChild;
@@ -19,22 +20,22 @@
import org.jboss.tools.common.meta.action.XEntityData;
import org.jboss.tools.common.meta.action.impl.AbstractHandler;
import org.jboss.tools.common.meta.constraint.XAttributeConstraint;
+import org.jboss.tools.common.meta.impl.XMetaDataConstants;
import org.jboss.tools.common.meta.key.WizardKeys;
import org.jboss.tools.common.model.ServiceDialog;
import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.event.ActionDeclinedException;
import org.jboss.tools.common.model.impl.RegularObjectImpl;
+import org.jboss.tools.common.model.plugin.ModelMessages;
import org.jboss.tools.common.model.undo.XCreateUndo;
import org.jboss.tools.common.model.undo.XUndoManager;
import org.jboss.tools.common.model.util.FindObjectHelper;
-import org.jboss.tools.common.model.util.XBundle;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
public class DefaultCreateHandler extends AbstractHandler {
- protected static XBundle bundle = XBundle.getInstance();
-
public DefaultCreateHandler() {}
public void executeHandler(XModelObject object, Properties prop) throws
XModelException {
@@ -59,7 +60,7 @@
}
protected String getEntityName() {
- String n = action.getProperty("entity");
+ String n = action.getProperty(XMetaDataConstants.ENTITY);
return (n == null) ? data[0].getModelEntity().getName() : n;
}
@@ -67,10 +68,6 @@
return o;
}
- protected static String getMessageById(String id) {
- return bundle.getMessage("model", id);
- }
-
public static Properties extractProperties(XEntityData es) {
Properties p = new Properties();
XAttributeData[] ads = es.getAttributeData();
@@ -97,7 +94,7 @@
}
public static String getReguiredMessage(String attributeName) {
- return bundle.getMessage("model", "ATTRIBUTE_REQUIRED", new
Object[]{attributeName});
+ return NLS.bind(ModelMessages.ATTRIBUTE_REQUIRED, new Object[]{attributeName});
}
public static Properties getProperties(XEntityData es) {
@@ -119,7 +116,7 @@
String vis = WizardKeys.getAttributeDisplayName(ad, true);
if(a.isTrimmable()) pv = (pv == null) ? "" : pv.trim();
if((pv == null || pv.length() == 0) && ad.getMandatoryFlag()) {
- return bundle.getMessage("model", "ATTRIBUTE_REQUIRED", new
Object[]{vis});
+ return NLS.bind(ModelMessages.ATTRIBUTE_REQUIRED, new Object[]{vis});
}
XAttributeConstraint c = ad.getAttribute().getConstraint();
return getConstraintMessage(vis, pv, c);
@@ -127,8 +124,7 @@
public static String getConstraintMessage(String name, String value,
XAttributeConstraint c) {
if(c == null || c.getError(value) == null) return null;
- return bundle.getMessage("model", "SET_ATTRIBUTE_FAILURE",
- new Object[]{name, value, c.getError(value)});
+ return NLS.bind(ModelMessages.SET_ATTRIBUTE_FAILURE, new Object[]{name, value,
c.getError(value)});
}
public static void validateValue(String name, String value, XAttributeConstraint c)
{
@@ -155,16 +151,14 @@
XModelObject e = parent.getChildByPath(pathpart);
if(e != null && e != parent && e != parent.getParent()) {
if(child.getModelEntity().getAttribute(XModelObjectLoaderUtil.ATTR_ID_NAME) != null)
{
- if(!forceUnique ||
!"true".equals(child.getModelEntity().getProperty("unique"))) {
+ if(!forceUnique ||
!XModelObjectConstants.TRUE.equals(child.getModelEntity().getProperty("unique")))
{
return null;
}
}
String tp = title(parent, true), tc = title(child, false), te = title(e, false);
String mes = (tc.equals(te))
- ? bundle.getMessage("model", "CONTAINS_OBJECT_1",
- new Object[]{tp, tc})
- : bundle.getMessage("model", "CONTAINS_OBJECT_2",
- new Object[]{tp, te, "\n", tc});
+ ? NLS.bind(ModelMessages.CONTAINS_OBJECT_1, new Object[]{tp, tc})
+ : NLS.bind(ModelMessages.CONTAINS_OBJECT_2, new Object[]{tp, te, "\n",
tc});
return mes;
}
return null;
@@ -179,17 +173,17 @@
}
public static void addCreatedObject(XModelObject parent, final XModelObject child,
boolean registerundo, final int whereSelect) throws XModelException {
- if(child == null) throw new
XModelException(getMessageById("OBJECT_CREATION_FAILURE"));
+ if(child == null) throw new
XModelException(ModelMessages.OBJECT_CREATION_FAILURE);
String mes = getContainsMessage(parent, child, false);
if(mes != null) throw new XModelException(mes);
String ce = child.getModelEntity().getName();
XChild c = parent.getModelEntity().getChild(ce);
- if(c == null) throw new
XModelException(getMessageById("OBJECT_ADDING_FAILURE"));
+ if(c == null) throw new XModelException(ModelMessages.OBJECT_ADDING_FAILURE);
int max = c.getMaxCount();
int cur = parent.getChildren(ce).length;
if(cur >= max) {
ServiceDialog d = parent.getModel().getService();
- d.showDialog("Warning", "The limit of " + max + " children is
achieved.", new String[]{"OK"}, null, ServiceDialog.MESSAGE);
+ d.showDialog(ModelMessages.WARNING, "The limit of " + max + " children
is achieved.", new String[]{"OK"}, null, ServiceDialog.MESSAGE);
mes = title(parent, true) + " can contain only " + max +
((max == 1) ? " child " : " children ") +
"with entity " + ce + ".";
@@ -202,14 +196,14 @@
while(parent.getChildByPath(pp) != null) {
child.setAttributeValue(XModelObjectLoaderUtil.ATTR_ID_NAME, "" + k);
String ppn = child.getPathPart();
- if(ppn.equals(pp)) throw new
RuntimeException(getMessageById("OBJECT_ADDING_FAILURE"));
+ if(ppn.equals(pp)) throw new RuntimeException(ModelMessages.OBJECT_ADDING_FAILURE);
pp = ppn;
++k;
}
b = parent.addChild(child);
}
if(!b) {
- throw new XModelException(getMessageById("OBJECT_ADDING_FAILURE"));
+ throw new XModelException(ModelMessages.OBJECT_ADDING_FAILURE);
}
XUndoManager undo = getUndoManager(parent);
if(registerundo && undo != null) {
@@ -233,7 +227,7 @@
}
public static String title(XModelObject o, boolean capitalize) {
- String elementType = o.getAttributeValue("element type");
+ String elementType = o.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE);
String objectTitle = o.getModelEntity().getRenderer().getTitle(o);
String s = elementType + " " + objectTitle;
if(objectTitle != null && objectTitle.equalsIgnoreCase(elementType)) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultCreateSupport.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultCreateSupport.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultCreateSupport.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -13,7 +13,9 @@
import java.util.Properties;
import org.jboss.tools.common.meta.*;
import org.jboss.tools.common.meta.action.impl.*;
+import org.jboss.tools.common.meta.impl.XMetaDataConstants;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.plugin.ModelMessages;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
public class DefaultCreateSupport extends SpecialWizardSupport {
@@ -23,7 +25,7 @@
}
protected String getEntityName() {
- String n = action.getProperty("entity");
+ String n = action.getProperty(XMetaDataConstants.ENTITY);
return (n == null) ? getEntityData()[0].getModelEntity().getName() : n;
}
@@ -34,7 +36,7 @@
int limit = c.getMaxCount();
if(c != null && limit < Integer.MAX_VALUE && cs.length >= limit)
{
ServiceDialog d = getTarget().getModel().getService();
- d.showDialog("Warning", "The limit of " + limit + " children
is achieved.", new String[]{OK}, null, ServiceDialog.MESSAGE);
+ d.showDialog(ModelMessages.WARNING, "The limit of " + limit + "
children is achieved.", new String[]{OK}, null, ServiceDialog.MESSAGE);
setFinished(true);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultRedirectHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultRedirectHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultRedirectHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -37,7 +37,7 @@
if (ts == null) return null;
String apath = action.getProperty("actionpath");
if(apath == null) return null;
- StringTokenizer st = new StringTokenizer(apath, "/");
+ StringTokenizer st = new StringTokenizer(apath,
XModelObjectConstants.SEPARATOR);
XActionItem l = ts.getModelEntity().getActionList();
while(st.hasMoreElements()) {
l = l.getItem(st.nextToken());
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultRemoveHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultRemoveHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultRemoveHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -34,7 +34,7 @@
public boolean isEnabled(XModelObject object) {
if(object == null || !object.isObjectEditable()) return false;
- if("yes".equals(object.getAttributeValue("issystem"))) return
false;
+
if(XModelObjectConstants.YES.equals(object.getAttributeValue("issystem")))
return false;
if(object.getParent() == null) return false;
if(isUniqueRequiredChild(object)) return isUniqueRequiredChildSet(object);
return true;
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultRenameSupport.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultRenameSupport.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/DefaultRenameSupport.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -57,7 +57,7 @@
public String getSubtitle() {
XModelObject o = getTarget();
if(o == null) return "";
- String element = o.getAttributeValue("element type");
+ String element = o.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE);
if(element == null) return "";
return WizardKeys.toDisplayName(element);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithChoiceHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithChoiceHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithChoiceHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -15,6 +15,7 @@
import org.jboss.tools.common.meta.action.impl.*;
import org.jboss.tools.common.meta.key.WizardKeys;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.plugin.ModelMessages;
import org.jboss.tools.common.model.util.*;
import org.jboss.tools.common.model.filesystems.XFileObject;
@@ -33,35 +34,35 @@
if(!OpenWithExternalHandler.checkSave(displayName, object)) return;
ServiceDialog d = object.getModel().getService();
String ext = OpenWithHelper.getLogicalExtension(object, action);
- XAttributeData a1 = HUtil.find(data, 0, "name");
+ XAttributeData a1 = HUtil.find(data, 0, XModelObjectConstants.ATTR_NAME);
XAttributeData a2 = HUtil.find(data, 0, "default");
XModelObject o = OpenWithHelper.getEditorObject(object.getModel(), ext);
String oldname = null;
if(o != null) {
- oldname = o.get("NAME");
+ oldname = o.get(XModelObjectConstants.XML_ATTR_NAME);
a1.setValue(oldname);
- a2.setValue("yes");
+ a2.setValue(XModelObjectConstants.YES);
} else {
- a2.setValue("no");
+ a2.setValue(XModelObjectConstants.NO);
}
- int i = d.showDialog("Open With", "Select external program",
new String[]{"Ok", "Cancel"}, data[0], ServiceDialog.QUESTION);
+ int i = d.showDialog("Open With", "Select external program",
new String[]{ModelMessages.OK, ModelMessages.Cancel}, data[0], ServiceDialog.QUESTION);
if(i != 0) return;
DefaultCreateHandler.extractProperties(data[0]);
- String en = HUtil.getValue(data, 0, "name");
- boolean def = "yes".equals(HUtil.getValue(data, 0,
"default"));
+ String en = HUtil.getValue(data, 0, XModelObjectConstants.ATTR_NAME);
+ boolean def = XModelObjectConstants.YES.equals(HUtil.getValue(data, 0,
"default"));
if(def && !en.equals(oldname)) {
changeDefaultEditor(object.getModel(), ext, en);
} else if(!def && en.equals(oldname)) {
removeDefaultEditor(object.getModel(), ext);
}
- XModelObject editor = object.getModel().getByPath(OpenWithHelper.EDITORS +
"/" + en);
+ XModelObject editor = object.getModel().getByPath(OpenWithHelper.EDITORS +
XModelObjectConstants.SEPARATOR + en);
String f = OpenWithHelper.getFileName(object);
OpenWithExternalHandler.start(displayName, f, editor);
}
protected boolean check(XModelObject object) {
String[] es = OpenWithHelper.getEditorList(object.getModel());
- HUtil.hackAttributeConstraintList(data, 0, "name", es);
+ HUtil.hackAttributeConstraintList(data, 0, XModelObjectConstants.ATTR_NAME, es);
return es.length > 0;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -16,6 +16,7 @@
import org.jboss.tools.common.meta.action.impl.*;
import org.jboss.tools.common.meta.key.WizardKeys;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.plugin.ModelMessages;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.*;
import org.jboss.tools.common.model.engines.impl.XProcess;
@@ -51,7 +52,7 @@
ServiceDialog d = object.getModel().getService();
String mes = DefaultCreateHandler.title(object, true) + " is
modified.\n" +
"Do you want to save it on disk before launching the external
program?";
- int i = d.showDialog(actionname, mes, new String[]{"Yes",
"No", "Cancel"}, null, ServiceDialog.QUESTION);
+ int i = d.showDialog(actionname, mes, new String[]{ModelMessages.Yes,
ModelMessages.No, ModelMessages.Cancel}, null, ServiceDialog.QUESTION);
if(i == 0) {
((FolderImpl)object.getParent()).saveChild(object);
return !object.isModified();
@@ -114,7 +115,7 @@
protected void buildCommandLine(ArrayList<String> l) {
String program = o.getAttributeValue("path");
l.add(program);
- if("Internet Browser".equals(o.getAttributeValue("name"))
&& !isUrl) {
+ if("Internet
Browser".equals(o.getAttributeValue(XModelObjectConstants.ATTR_NAME)) &&
!isUrl) {
try {
java.net.URL u = new File(file).toURL();
file = u.getProtocol() + "://" + u.getFile();
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithHelper.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithHelper.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithHelper.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -15,6 +15,7 @@
import org.jboss.tools.common.model.*;
import org.jboss.tools.common.meta.action.*;
import org.jboss.tools.common.meta.action.impl.XEntityDataImpl;
+import org.jboss.tools.common.model.plugin.ModelMessages;
import org.jboss.tools.common.model.util.*;
import org.jboss.tools.common.model.filesystems.XFileObject;
import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
@@ -28,9 +29,9 @@
while(o != null) {
int i = o.getFileType();
if(i == XFileObject.FILE) l.add(FileAnyImpl.toFileName(o));
- else if(i == XFileObject.FOLDER) l.add(o.get("NAME"));
+ else if(i == XFileObject.FOLDER)
l.add(o.get(XModelObjectConstants.XML_ATTR_NAME));
else {
- l.add(XModelObjectUtil.expand((String)o.get("location"),
o.getModel(), null));
+
l.add(XModelObjectUtil.expand((String)o.get(XModelObjectConstants.ATTR_NAME_LOCATION),
o.getModel(), null));
break;
}
o = o.getParent();
@@ -61,7 +62,7 @@
XModelObject o = model.getByPath(EDITORS);
XModelObject[] os = o.getChildren();
String[] res = new String[os.length];
- for (int i = 0; i < res.length; i++) res[i] = os[i].get("NAME");
+ for (int i = 0; i < res.length; i++) res[i] =
os[i].get(XModelObjectConstants.XML_ATTR_NAME);
return res;
}
@@ -69,7 +70,7 @@
String[] paths = getEnvironmentPaths();
XModel model = o.getModel();
String en = o.getModelEntity().getName();
- XEntityData[] dt = new XEntityData[]{XEntityDataImpl.create(new String[][]{{en,
"yes"}, {"path", "yes"}})};
+ XEntityData[] dt = new XEntityData[]{XEntityDataImpl.create(new String[][]{{en,
XModelObjectConstants.YES}, {"path", XModelObjectConstants.YES}})};
String path =
o.getAttributeValue("path").replace('\\','/');
XAttributeData ad = HUtil.find(dt, 0, "path");
ad.setValue(path);
@@ -85,7 +86,7 @@
return true;
}
int i = d.showDialog(actionname, "Enter valid path for " +
o.getPresentationString(),
- new String[]{"OK", "Cancel"}, dt[0],
ServiceDialog.QUESTION);
+ new String[]{ModelMessages.OK, ModelMessages.Cancel},
dt[0], ServiceDialog.QUESTION);
if(i != 0) return false;
}
}
@@ -94,7 +95,7 @@
filename = filename.replace('\\', '/');
if(paths == null || filename.indexOf('/') >= 0) return new
File(filename).isFile();
for (int i = 0; i < paths.length; i++) {
- String f = paths[i] + "/" + filename;
+ String f = paths[i] + XModelObjectConstants.SEPARATOR + filename;
if(new File(f).isFile()) return true;
}
return false;
@@ -109,7 +110,7 @@
}
public static String getLogicalExtension(XModelObject object, XAction action) {
- String extension = action.getProperty("extension");
+ String extension =
action.getProperty(XModelObjectConstants.ATTR_NAME_EXTENSION);
return (extension != null) ? extension : getExtension(getFileName(object));
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/PasteEnterNewNameSupport.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/PasteEnterNewNameSupport.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/PasteEnterNewNameSupport.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -47,7 +47,7 @@
}
static String getCapitalizedName(XModelObject o) {
- String n = o.getAttributeValue("element type");
+ String n = o.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE);
if(n == null || n.length() == 0) n = o.getModelEntity().getXMLSubPath();
if(n == null || n.length() == 0) n = o.getPathPart();
return WizardKeys.toDisplayName(n);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/PasteHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/PasteHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/PasteHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -22,13 +22,16 @@
import org.jboss.tools.common.meta.action.impl.AbstractHandler;
import org.jboss.tools.common.meta.action.impl.SpecialWizardSupport;
import org.jboss.tools.common.meta.action.impl.XEntityDataImpl;
+import org.jboss.tools.common.meta.impl.XMetaDataConstants;
import org.jboss.tools.common.meta.impl.XModelMetaDataImpl;
import org.jboss.tools.common.model.ServiceDialog;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelBuffer;
import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.event.ActionDeclinedException;
+import org.jboss.tools.common.model.plugin.ModelMessages;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
public class PasteHandler extends AbstractHandler {
@@ -44,9 +47,9 @@
data = new XEntityDataImpl[1];
}
- private static String[] attrs = {"attribute name", "yes",
- "entity name", "yes",
- "parameters", "no"};
+ private static String[] attrs = {"attribute name",
XModelObjectConstants.YES,
+ "entity name", XModelObjectConstants.YES,
+ "parameters", XModelObjectConstants.NO};
public XEntityData[] getEntityData(XModelObject object) {
return getEntityData(object, 0);
@@ -55,9 +58,9 @@
protected XEntityData[] getEntityData(XModelObject object, int bi) {
if(getBuffer(object).source(bi) == null) return null;
ArrayList<String[]> a = new ArrayList<String[]>();
- a.add(new String[]{getEntityName(object, bi), "yes"});
+ a.add(new String[]{getEntityName(object, bi), XModelObjectConstants.YES});
String an = getAttributeName(getEntityName(object, bi));
- if(an != null) a.add(new String[]{an, "yes"});
+ if(an != null) a.add(new String[]{an, XModelObjectConstants.YES});
for (int i = 0; i < attrs.length; i += 2)
register(object, attrs[i], attrs[i + 1], a, bi);
String[][] ds = new String[a.size()][];
@@ -73,11 +76,11 @@
public void executeHandler(XModelObject object, Properties prop) throws
XModelException {
if(!isEnabled(object)) return;
- boolean isDrop = (prop != null) &&
"true".equals(prop.getProperty("isDrop"));
+ boolean isDrop = (prop != null) &&
XModelObjectConstants.TRUE.equals(prop.getProperty("isDrop"));
int bs = object.getModel().getModelBuffer().getSize();
for (int i = 0; i < bs; i++) {
execute(object, i, isDrop, prop);
- if(prop != null &&
"true".equals(prop.getProperty(IS_CANCELLED))) return;
+ if(prop != null &&
XModelObjectConstants.TRUE.equals(prop.getProperty(IS_CANCELLED))) return;
}
}
@@ -141,7 +144,7 @@
String n = "<" + co.getModelEntity().getXMLSubPath() + ">";
message += n + "?";
ServiceDialog d = parent.getModel().getService();
- int q = d.showDialog("Paste", message, new String[]{"OK",
"Cancel"}, null, ServiceDialog.QUESTION);
+ int q = d.showDialog("Paste", message, new String[]{ModelMessages.OK,
ModelMessages.Cancel}, null, ServiceDialog.QUESTION);
if(q != 0) return false;
DefaultRemoveHandler.removeFromParent(co);
return true;
@@ -149,9 +152,9 @@
private void showUniqueMessae(XModelObject parent, XModelObject source) {
ServiceDialog d = parent.getModel().getService();
String message = DefaultCreateHandler.title(parent, true) +
- " may have only one " +
source.getAttributeValue("element type") + "." +
+ " may have only one " +
source.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE) + "." +
" You cannot add its copy.";
- d.showDialog("Warning", message, new String[]{SpecialWizardSupport.OK}, null,
ServiceDialog.WARNING);
+ d.showDialog(ModelMessages.WARNING, message, new String[]{SpecialWizardSupport.OK},
null, ServiceDialog.WARNING);
}
protected void onChildPasted(XModelObject child) {}
@@ -192,7 +195,7 @@
}
protected String getEntityName(XModelObject object, int i) {
- String entity = action.getProperty("entity");
+ String entity = action.getProperty(XMetaDataConstants.ENTITY);
if(entity != null) return entity;
return getBuffer(object).source(i).getModelEntity().getName();
}
@@ -202,8 +205,8 @@
if(e.getAttribute(XModelObjectLoaderUtil.ATTR_ID_NAME) != null) return
XModelObjectLoaderUtil.ATTR_ID_NAME;
XAttribute[] as = e.getAttributes();
for (int i = 0; i < as.length; i++)
- if("true".equals(as[i].getProperty("id"))) return
as[i].getName();
- if(e.getAttribute("name") != null) return "name";
+ if(XModelObjectConstants.TRUE.equals(as[i].getProperty("id"))) return
as[i].getName();
+ if(e.getAttribute(XModelObjectConstants.ATTR_NAME) != null) return
XModelObjectConstants.ATTR_NAME;
return null;
}
@@ -212,8 +215,8 @@
if(e.getAttribute(XModelObjectLoaderUtil.ATTR_ID_NAME) != null) return true;
XAttribute[] as = e.getAttributes();
for (int i = 0; i < as.length; i++)
- if("true".equals(as[i].getProperty("id")) &&
- "true".equals(as[i].getProperty("generate"))) return true;
+ if(XModelObjectConstants.TRUE.equals(as[i].getProperty("id")) &&
+ XModelObjectConstants.TRUE.equals(as[i].getProperty("generate")))
return true;
return false;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/XAdapter.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/XAdapter.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/XAdapter.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -12,6 +12,7 @@
import org.w3c.dom.*;
import org.jboss.tools.common.meta.impl.*;
+import org.jboss.tools.common.model.XModelObjectConstants;
public class XAdapter extends XMetaElementImpl {
protected XAttributeConstraint constraint = null;
@@ -55,7 +56,7 @@
public void load(Element element) {
setName(element.getAttribute(NAME));
defaultvalue = element.getAttribute(DEFAULT_VALUE);
- visibility = !"false".equals(element.getAttribute(VISIBLE));
+ visibility = !XModelObjectConstants.FALSE.equals(element.getAttribute(VISIBLE));
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -12,7 +12,6 @@
import org.w3c.dom.*;
import org.jboss.tools.common.meta.constraint.*;
-import org.jboss.tools.common.model.util.XBundle;
import org.jboss.tools.common.meta.impl.*;
public class XAttributeConstraintImpl extends XMetaElementImpl implements
XAttributeConstraint {
@@ -36,9 +35,5 @@
return value;
}
- protected String getErrorById(String id) {
- return XBundle.getInstance().getMessage("model", id);
- }
-
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintJavaName.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintJavaName.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintJavaName.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -11,17 +11,20 @@
package org.jboss.tools.common.meta.constraint.impl;
import java.util.*;
+
+import org.jboss.tools.common.model.XModelObjectConstants;
+import org.jboss.tools.common.model.plugin.ModelMessages;
import org.w3c.dom.*;
public class XAttributeConstraintJavaName extends XAttributeConstraintProperties {
private static final String[] keywords = {"break", "case",
"catch", "class", "const", "continue",
"default",
- "else", "extends", "false", "final",
"finally", "for", "if",
+ "else", "extends", XModelObjectConstants.FALSE,
"final", "finally", "for", "if",
"implements", "import", "instanceof",
"interface", "new",
"null", "package", "protected",
"private", "public", "return",
"static", "switch", "synchronized",
"throw", "throws", "transient",
- "true", "try", "void", "volatile",
"while"};
+ XModelObjectConstants.TRUE, "try", "void",
"volatile", "while"};
private static final String[] primitives = {
"boolean", "byte", "char", "double",
"float", "int", "long", "short"
};
@@ -52,7 +55,7 @@
if(value == null) return false;
if(value.length() == 0) return true;
if(!Character.isJavaIdentifierStart(value.charAt(0))) return false;
- if(keytable.contains(value) &&
!"true".equals(p.getProperty("acceptKeyWord"))) return false;
+ if(keytable.contains(value) &&
!XModelObjectConstants.TRUE.equals(p.getProperty("acceptKeyWord"))) return
false;
if(!allowPrimitiveTypes && primitiveSet.contains(value)) return false;
if(custom != null && custom.contains(value)) return false;
for (int i = 1; i < value.length(); i++) {
@@ -62,17 +65,17 @@
}
public String getError(String value) {
- return (value.length() == 0) ? getErrorById("CONSTRAINT_NONEMPTY") :
+ return (value.length() == 0) ? ModelMessages.CONSTRAINT_NONEMPTY :
accepts(value) ? null :
- (keytable.contains(value)) ?
getErrorById("CONSTRAINT_NO_JAVA_KEYWORD") :
- (!allowPrimitiveTypes && primitiveSet.contains(value)) ?
getErrorById("CONSTRAINT_NO_JAVA_KEYWORD") :
- (custom != null && custom.contains(value)) ? "is a reserved
word" :
- getErrorById("CONSTRAINT_JAVA_NAME");
+ (keytable.contains(value)) ? ModelMessages.CONSTRAINT_NO_JAVA_KEYWORD :
+ (!allowPrimitiveTypes && primitiveSet.contains(value)) ?
ModelMessages.CONSTRAINT_NO_JAVA_KEYWORD :
+ (custom != null && custom.contains(value)) ?
ModelMessages.IS_A_RESERVED_WORD :
+ ModelMessages.CONSTRAINT_JAVA_NAME;
}
public String getCorrectedValue(String value) {
if(value == null || value.length() == 0) return null;
-
if("true".equals(getProperties().getProperty("acceptIncorrect")))
return value;
+
if(XModelObjectConstants.TRUE.equals(getProperties().getProperty("acceptIncorrect")))
return value;
StringBuffer sb = new StringBuffer();
boolean first = true;
for (int i = 0; i < value.length(); i++) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintList.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintList.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintList.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.common.meta.constraint.impl;
+import org.jboss.tools.common.model.plugin.ModelMessages;
+
public class XAttributeConstraintList extends XAttributeConstraintAList {
public XAttributeConstraintList() {}
@@ -19,7 +21,7 @@
}
public String getError(String value) {
- return accepts(value) ? null :
getErrorById("CONSTRAINT_IS_NOT_IN_LIST");
+ return accepts(value) ? null : ModelMessages.CONSTRAINT_IS_NOT_IN_LIST;
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintListInt.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintListInt.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintListInt.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.common.meta.constraint.impl;
+import org.jboss.tools.common.model.plugin.ModelMessages;
+
public class XAttributeConstraintListInt extends XAttributeConstraintAList {
public XAttributeConstraintListInt() {}
@@ -25,7 +27,7 @@
}
public String getError(String value) {
- return accepts(value) ? null :
getErrorById("CONSTRAINT_INTEGER_OR_LIST");
+ return accepts(value) ? null : ModelMessages.CONSTRAINT_INTEGER_OR_LIST;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintListTemplates.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintListTemplates.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintListTemplates.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -12,6 +12,9 @@
import java.io.*;
+import org.jboss.tools.common.model.XModelObjectConstants;
+import org.jboss.tools.common.model.plugin.ModelMessages;
+
public class XAttributeConstraintListTemplates extends XAttributeConstraintList {
public XAttributeConstraintListTemplates() {}
@@ -23,7 +26,7 @@
protected void refresh() {
values.clear();
- String tr = System.getProperty("global.ECOM_HOME") + "/" +
"Templates";
+ String tr = System.getProperty("global.ECOM_HOME") +
XModelObjectConstants.SEPARATOR + "Templates";
File f = new File(tr);
File[] fs = f.listFiles();
if(fs == null) return;
@@ -37,7 +40,7 @@
}
public String getError(String value) {
- return (accepts(value)) ? null :
getErrorById("CONSTRAINT_RED_HAT_TEMPLATE_NAME");
+ return (accepts(value)) ? null : ModelMessages.CONSTRAINT_RED_HAT_TEMPLATE_NAME;
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintXMLName.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintXMLName.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintXMLName.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.common.meta.constraint.impl;
+import org.jboss.tools.common.model.plugin.ModelMessages;
+
public class XAttributeConstraintXMLName extends XAttributeConstraintImpl {
public XAttributeConstraintXMLName() {}
@@ -25,7 +27,7 @@
}
public String getError(String value) {
- return accepts(value) ? null : getErrorById("CONSTRAINT_XML_NAME");
+ return accepts(value) ? null : ModelMessages.CONSTRAINT_XML_NAME;
}
public static final boolean isXMLStartChar(char c) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/help/HelpUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/help/HelpUtil.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/help/HelpUtil.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -23,6 +23,7 @@
import org.jboss.tools.common.meta.action.impl.handlers.OpenWithExternalHandler;
import org.jboss.tools.common.meta.key.KeyLoader;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.plugin.ModelMessages;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
public class HelpUtil {
@@ -77,12 +78,12 @@
public static void help(XModel model, String key) {
ServiceDialog d = model.getService();
if(!hasHelp(key)) {
- d.showDialog("Warning", "Help for key " + key + " is
not available.", new String[]{"Close"}, null, ServiceDialog.WARNING);
+ d.showDialog(ModelMessages.WARNING, "Help for key " + key + "
is not available.", new String[]{"Close"}, null, ServiceDialog.WARNING);
} else {
try {
HelpUtil.callHelp(model, key);
} catch (XModelException e) {
- d.showDialog("Warning", e.getMessage(), new
String[]{"Close"}, null, ServiceDialog.WARNING);
+ d.showDialog(ModelMessages.WARNING, e.getMessage(), new
String[]{"Close"}, null, ServiceDialog.WARNING);
}
}
}
@@ -110,14 +111,14 @@
URL url = EclipseResourceUtil.getInstallURL(p);
if(url == null) continue;
String f = url.getFile().replace('\\', '/');
- if(f.endsWith("/")) f = f.substring(0, f.length() - 1);
- if(!path.startsWith("/")) path = "/" + path;
+ if(f.endsWith(XModelObjectConstants.SEPARATOR)) f = f.substring(0, f.length() - 1);
+ if(!path.startsWith(XModelObjectConstants.SEPARATOR)) path =
XModelObjectConstants.SEPARATOR + path;
String zipPath = f + "/doc.zip";
if(new File(zipPath).exists()) {
Set set = getZipEntries(zipPath);
- if(set.contains(path)) return "/" + PLUGINS[i] + "/" + path;
+ if(set.contains(path)) return XModelObjectConstants.SEPARATOR + PLUGINS[i] +
XModelObjectConstants.SEPARATOR + path;
}
- if(new java.io.File(f + path).isFile()) return "/" + PLUGINS[i] +
"/" + path;
+ if(new java.io.File(f + path).isFile()) return XModelObjectConstants.SEPARATOR +
PLUGINS[i] + XModelObjectConstants.SEPARATOR + path;
}
return null;
}
@@ -134,7 +135,7 @@
Enumeration en = zip.entries();
while(en.hasMoreElements()) {
ZipEntry entry = (ZipEntry)en.nextElement();
- set.add("/" + entry.getName());
+ set.add(XModelObjectConstants.SEPARATOR + entry.getName());
}
} catch (IOException e) {
//ignore
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XActionItemImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XActionItemImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XActionItemImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -13,6 +13,7 @@
import org.w3c.dom.*;
import org.eclipse.swt.graphics.Image;
import org.jboss.tools.common.meta.action.XActionItem;
+import org.jboss.tools.common.model.XModelObjectConstants;
public class XActionItemImpl extends XMetaElementImpl implements XActionItem {
private XActionItemImpl parent = null;
@@ -27,7 +28,7 @@
public String getPath() {
if(parent == null) return null;
String pp = parent.getPath();
- return (pp == null) ? getName() : pp + "/" + getName();
+ return (pp == null) ? getName() : pp + XModelObjectConstants.SEPARATOR +
getName();
}
public String getIconKey() {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XAttributeImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XAttributeImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XAttributeImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -144,8 +144,8 @@
setDefaultValue(el.getAttribute(DEFAULT_VALUE));
setXMLName(el.getAttribute(XML_NAME));
loadAdapter(el);
- trimmable = !"no".equals(el.getAttribute("TRIM"));
//$NON-NLS-1$//$NON-NLS-2$
- copyable = !"no".equals(el.getAttribute("COPYABLE"));
//$NON-NLS-1$//$NON-NLS-2$
+ trimmable = !XModelObjectConstants.NO.equals(el.getAttribute("TRIM"));
//$NON-NLS-1$//$NON-NLS-2$
+ copyable =
!XModelObjectConstants.NO.equals(el.getAttribute("COPYABLE"));
//$NON-NLS-1$//$NON-NLS-2$
loadProperties(el);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataConstants.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataConstants.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataConstants.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.common.meta.impl;
+import org.jboss.tools.common.model.XModelObjectConstants;
+
public interface XMetaDataConstants {
String XMODEL_STRUCTURE = "XModelStructure";
@@ -24,7 +26,7 @@
String XMODEL_ACTION_ITEM_REF = "XActionItemReference";
String XMODEL_CHILDREN = "XChildrenEntities";
String XMODEL_CHILD = "XChildEntity";
- String NAME = "name";
+ String NAME = XModelObjectConstants.ATTR_NAME;
String XML_NAME = "xmlname";
String DISPLAYNAME="displayName";
String LOADER = "loader";
@@ -52,6 +54,8 @@
String MAX_COUNT= "maxCount";
String ENTITY_NAME= "entityName";
+ String ENTITY = "entity";
+
String ICONS = "ICONS";
String ICON = "ICON";
String ICON_PATH = "path";
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -16,6 +16,7 @@
import org.w3c.dom.*;
import org.jboss.tools.common.meta.XMetaElement;
import org.jboss.tools.common.meta.XModelEntity;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.*;
import org.jboss.tools.common.xml.XMLUtilities;
@@ -92,7 +93,7 @@
public static boolean getBoolean(Element el, String attName, boolean def){
String a = el.getAttribute(attName);
return (a == null || a.length() == 0) ? def :
- ("true".equalsIgnoreCase(a) ||
"yes".equalsIgnoreCase(a));
+ (XModelObjectConstants.TRUE.equalsIgnoreCase(a) ||
XModelObjectConstants.YES.equalsIgnoreCase(a));
}
public static int getInt(Element el, String attName, int def){
@@ -116,7 +117,7 @@
}
static void loadEntityGroup(XModelMetaDataImpl factory, Element g) {
-// String n = g.getAttribute("NAME");
+// String n = g.getAttribute(XModelObjectConstants.XML_ATTR_NAME);
String module = "";
Element v = XMLUtilities.getUniqueChild(g, "VERSION");
if(v != null && v.hasAttribute("MODULE")) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelEntityImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelEntityImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelEntityImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -245,7 +245,7 @@
XAttributeImpl attr = (XAttributeImpl)XMetaDataLoader.loadMetaElement(e,
XAttributeImpl.class, false);
if(attr != null) list.add(attr);
} else if(XMODEL_ATTRIBUTE_REF.equals(name)) {
- String entityName = e.getAttribute("entity");
+ String entityName = e.getAttribute(XMetaDataConstants.ENTITY);
String attrName = e.getAttribute(NAME);
String attributes = e.getAttribute("attributes");
String[] atributeNames = new String[]{attrName};
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelMetaDataImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelMetaDataImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelMetaDataImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -13,6 +13,7 @@
import java.util.*;
import org.w3c.dom.*;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.icons.*;
import org.jboss.tools.common.meta.*;
@@ -54,7 +55,7 @@
//uses cached elements
parents.init(this);
- XModelEntityImpl r = (XModelEntityImpl)getEntity("Root");
+ XModelEntityImpl r =
(XModelEntityImpl)getEntity(XModelObjectConstants.ROOT_OBJECT);
r.validateChildren();
//Resolve XML now, or late resolving may not be thread safe.
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/adapters/XAdapterModelPath.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/adapters/XAdapterModelPath.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/adapters/XAdapterModelPath.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -11,6 +11,7 @@
package org.jboss.tools.common.meta.impl.adapters;
import org.jboss.tools.common.meta.constraint.*;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
@@ -20,7 +21,7 @@
public String getProperty(XProperty object) {
String p = XModelObjectLoaderUtil.getResourcePath((XModelObject)object);
- return (p == null) ? "" + object.get("NAME") : p;
+ return (p == null) ? "" +
object.get(XModelObjectConstants.XML_ATTR_NAME) : p;
}
public void setProperty(XProperty object, String value) {}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/adapters/XAdapterProjectsRoot.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/adapters/XAdapterProjectsRoot.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/adapters/XAdapterProjectsRoot.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -19,7 +19,7 @@
public String getProperty(XProperty object) {
XModelObject o = (XModelObject)object;
- if("yes".equals(o.getAttributeValue(USE_DEFAULT))) {
+ if(XModelObjectConstants.YES.equals(o.getAttributeValue(USE_DEFAULT))) {
return ModelPlugin.getWorkspace().getRoot().getLocation().toOSString();
}
return super.getProperty(object);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/DocumentGenerator.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/DocumentGenerator.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/DocumentGenerator.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -23,7 +23,9 @@
import java.util.Iterator;
import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.XMLUtil;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
@@ -67,7 +69,7 @@
}
protected void generateBody(Element e) {
- Element b = XMLUtil.createElement(e, "body");
+ Element b = XMLUtil.createElement(e, XModelObjectConstants.ATTR_NAME_BODY);
XModelObject entities = meta.getChildren("MetaEntities")[0];
parents = new Parents();
parents.set(entities);
@@ -86,7 +88,7 @@
protected void processEntity(Element e, XModelObject o) {
XMLUtil2.hr(e);
Element t = XMLUtil.createElement(e, "table");
- XMLUtil2.entityRow(t, "Name:", o.getAttributeValue("name"));
+ XMLUtil2.entityRow(t, "Name:",
o.getAttributeValue(XModelObjectConstants.ATTR_NAME));
XMLUtil2.simpleRow(t, "Editor:",
o.getAttributeValue("editor"));
processHierarchy(e, o);
processAttributeList(e, o.getChildren("MetaAttributes")[0]);
@@ -140,7 +142,7 @@
tr = XMLUtil.createElement(tr, "tr");
Element td = XMLUtil.createElement(tr, "td");
td.setAttribute("class", "value");
- XMLUtil2.createEntityReference(td,
as[i].getAttributeValue("name"));
+ XMLUtil2.createEntityReference(td,
as[i].getAttributeValue(XModelObjectConstants.ATTR_NAME));
createValueCell(tr, as[i].getAttributeValue("required"));
}
}
@@ -157,10 +159,10 @@
XModelObject[] as = o.getChildren("MetaAttribute");
for (int i = 0; i < as.length; i++) {
tr = XMLUtil.createElement(tr, "tr");
- createValueCell(tr, as[i].getAttributeValue("name"));
+ createValueCell(tr,
as[i].getAttributeValue(XModelObjectConstants.ATTR_NAME));
createValueCell(tr, as[i].getAttributeValue("visibility"));
XModelObject oe = as[i].getChildren("MetaAttributeEditor")[0];
- String ed = oe.getAttributeValue("name");
+ String ed = oe.getAttributeValue(XModelObjectConstants.ATTR_NAME);
createValueCell(tr, ed);
String dv = as[i].getAttributeValue("default value");
createValueCell(tr, dv);
@@ -187,7 +189,7 @@
}
void createHeaderCell(Element e, String name, int width) {
Element td = XMLUtil.createElement(e, "td");
- td.setAttribute("class", "name");
+ td.setAttribute("class", XModelObjectConstants.ATTR_NAME);
if(width > 0) td.setAttribute("width", "" + width);
XMLUtil2.createText(td, name);
}
@@ -203,7 +205,7 @@
for (int i = 0; i < vs.length; i++) {
Element s = XMLUtil.createElement(td, "span");
s.setAttribute("class", "value");
- XMLUtil2.createText(s, vs[i].getAttributeValue("name"));
+ XMLUtil2.createText(s,
vs[i].getAttributeValue(XModelObjectConstants.ATTR_NAME));
XMLUtil.createElement(td, "br");
}
}
@@ -248,7 +250,7 @@
for (int i = 0; i < cs.length; i++) set(cs[i]);
cs = o.getChildren("MetaEntity");
for (int i = 0; i < cs.length; i++) {
- String n = cs[i].getAttributeValue("name");
+ String n = cs[i].getAttributeValue(XModelObjectConstants.ATTR_NAME);
ent.put(n, cs[i]);
par.put(n, new ArrayList<String>());
}
@@ -257,17 +259,17 @@
Iterator it = ent.values().iterator();
while(it.hasNext()) {
XModelObject o = (XModelObject)it.next();
- String p = o.getAttributeValue("name");
+ String p = o.getAttributeValue(XModelObjectConstants.ATTR_NAME);
XModelObject[] os =
o.getChildren("MetaChildren")[0].getChildren();
for (int i = 0; i < os.length; i++) {
- String n = os[i].getAttributeValue("name");
+ String n = os[i].getAttributeValue(XModelObjectConstants.ATTR_NAME);
ArrayList<String> v = par.get(n);
if(v != null) v.add(p);
}
}
}
public ArrayList<String> get(XModelObject o) {
- return par.get(o.getAttributeValue("name"));
+ return par.get(o.getAttributeValue(XModelObjectConstants.ATTR_NAME));
}
}
@@ -337,7 +339,7 @@
public static void simpleRow(Element e, String name, String value) {
Element tr = XMLUtil.createElement(e, "tr");
Element td1 = XMLUtil.createElement(tr, "td");
- td1.setAttribute("class", "name");
+ td1.setAttribute("class", XModelObjectConstants.ATTR_NAME);
createText(td1, name);
Element td2 = XMLUtil.createElement(tr, "td");
td1.setAttribute("class", "value");
@@ -356,12 +358,12 @@
public static void entityRow(Element e, String name, String value) {
Element tr = XMLUtil.createElement(e, "tr");
Element td1 = XMLUtil.createElement(tr, "td");
- td1.setAttribute("class", "name");
+ td1.setAttribute("class", XModelObjectConstants.ATTR_NAME);
createText(td1, name);
Element td2 = XMLUtil.createElement(tr, "td");
td1.setAttribute("class", "value");
Element a = XMLUtil.createElement(td2, "a");
- a.setAttribute("name", value);
+ a.setAttribute(XModelObjectConstants.ATTR_NAME, value);
createText(a, value);
}
@@ -393,7 +395,7 @@
private void processGroup(XModelObject o) {
XModelObject[] es = o.getChildren("MetaEntity");
- for (int i = 0; i < es.length; i++)
list.put(es[i].getAttributeValue("name"), es[i]);
+ for (int i = 0; i < es.length; i++)
list.put(es[i].getAttributeValue(XModelObjectConstants.ATTR_NAME), es[i]);
XModelObject[] gs = o.getChildren("MetaEntityGroup");
for (int i = 0; i < gs.length; i++) processGroup(gs[i]);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/MetaValidator.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/MetaValidator.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/MetaValidator.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -15,6 +15,7 @@
import java.util.Set;
import java.util.Vector;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
public class MetaValidator {
@@ -37,7 +38,7 @@
}
public static final String id(XModelObject object) {
- return object.getAttributeValue("element type") + " " +
+ return object.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE) + "
" +
object.getModelEntity().getRenderer().getTitle(object);
}
@@ -150,8 +151,8 @@
for (int i = 0; i < es.length; i++) {
XModelObject[] as =
es[i].getChildByPath("Attributes").getChildren();
Vector<String> v = new Vector<String>();
- for (int j = 0; j < as.length; j++)
v.addElement(as[j].getAttributeValue("name"));
- entities.put(es[i].getAttributeValue("name"), v);
+ for (int j = 0; j < as.length; j++)
v.addElement(as[j].getAttributeValue(XModelObjectConstants.ATTR_NAME));
+ entities.put(es[i].getAttributeValue(XModelObjectConstants.ATTR_NAME), v);
}
}
}
@@ -160,7 +161,7 @@
public void validate(XModelObject object) {
XModelObject[] cs = object.getChildByPath("Children").getChildren();
for (int i = 0; i < cs.length; i++) {
- String c = cs[i].getAttributeValue("name");
+ String c = cs[i].getAttributeValue(XModelObjectConstants.ATTR_NAME);
if(EntitiesValidator.entities.get(c) == null) {
MetaValidator.message("Error in " + MetaValidator.id(object) +
": child " + c + " not found in the entity
list.");
@@ -174,10 +175,10 @@
public void validate(XModelObject object) {
XModelObject[] as = object.getChildByPath("Attributes").getChildren();
for (int i = 0; i < as.length; i++) {
- String an = as[i].getAttributeValue("name");
+ String an = as[i].getAttributeValue(XModelObjectConstants.ATTR_NAME);
MetaValidator.checkClass(as[i], "loader",
"org.jboss.tools.common.meta.impl.adapters.XAdapter", false, null);
XModelObject ed = as[i].getChildren("MetaAttributeEditor")[0];
- String en = ed.getAttributeValue("name");
+ String en = ed.getAttributeValue(XModelObjectConstants.ATTR_NAME);
if("GUI".equals(en)) continue;
XModelObject mi =
ed.getModel().getByPath("MetaModel/Mappings/AttributeEditor/" + en);
if(mi == null) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModel.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModel.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModel.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -100,10 +100,10 @@
/**
* Returns model object by String path. The path contains parts
- * separated by "/". The root has empty string path.
+ * separated by XModelObjectConstants.SEPARATOR. The root has empty string path.
* For convenience, to find object in any file system (which is
* an immediate child of "FileSystems" sub-root), path may be
- * started with "/".
+ * started with XModelObjectConstants.SEPARATOR.
* To get so-called "extra-root" which defines an auxiliary
* structure not connected to the structure of the main root object,
* path may be started with "root:".
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelObject.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelObject.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelObject.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -124,7 +124,7 @@
/**
* Returns child object by path that contains path parts
- * separated by "/".
+ * separated by XModelObjectConstants.SEPARATOR.
*
* @param path
* @return child model object or null
@@ -154,7 +154,7 @@
* - empty string for the model root;
* - path part for an immediate child of the model root;
* - "root:" plus path part for an extra model root;
- * - parent path plus separator "/" plus path part for any
+ * - parent path plus separator XModelObjectConstants.SEPARATOR plus path part for
any
* other model object.
* @return
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelObjectConstants.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelObjectConstants.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelObjectConstants.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -15,31 +15,51 @@
*/
public interface XModelObjectConstants {
- public static final String ATTR_NAME_BODY = "body";
- public static final String ATTR_NAME__BODY_ = "_body_";
- public static final String ATTR_NAME_HAS_ERRORS = "_hasErrors_";
- public static final String ATTR_NAME_IS_INCORRECT = "isIncorrect";
- public static final String ATTR_NAME_ACTUAL_BODY_TIME_STAMP =
"actualBodyTimeStamp";
- public static final String ATTR_NAME_INCORRECT_BODY =
"incorrectBody";
- public static final String ATTR_NAME_CORRECT_BODY = "correctBody";
- public static final String ATTR_NAME_ENCODING = "encoding";
- public static final String ATTR_NAME_SYSTEM_ID = "systemId";
- public static final String ATTR_NAME_PUBLIC_ID = "publicId";
+ public static final String ATTR_NAME_BODY = "body";
//$NON-NLS-1$
+ public static final String ATTR_NAME__BODY_ =
"_body_"; //$NON-NLS-1$
+ public static final String ATTR_NAME_HAS_ERRORS = "_hasErrors_";
//$NON-NLS-1$
+ public static final String ATTR_NAME_IS_INCORRECT = "isIncorrect";
//$NON-NLS-1$
+ public static final String ATTR_NAME_ACTUAL_BODY_TIME_STAMP =
"actualBodyTimeStamp"; //$NON-NLS-1$
+ public static final String ATTR_NAME_INCORRECT_BODY = "incorrectBody";
//$NON-NLS-1$
+ public static final String ATTR_NAME_CORRECT_BODY = "correctBody";
//$NON-NLS-1$
+ public static final String ATTR_NAME_ENCODING = "encoding";
//$NON-NLS-1$
+ public static final String ATTR_NAME_SYSTEM_ID = "systemId";
//$NON-NLS-1$
+ public static final String ATTR_NAME_PUBLIC_ID = "publicId";
//$NON-NLS-1$
- public static final String ATTR_NAME_ERRORS = "errors";
- public static final String ATTR_NAME_OVERLAPPED = "overlapped";
- public static final String ATTR_NAME_OVERLAPPED_SYSTEM =
"overlappedSystem";
+ public static final String ATTR_NAME_ERRORS = "errors";
//$NON-NLS-1$
+ public static final String ATTR_NAME_OVERLAPPED = "overlapped";
//$NON-NLS-1$
+ public static final String ATTR_NAME_OVERLAPPED_SYSTEM =
"overlappedSystem"; //$NON-NLS-1$
- public static final String ATTR_NAME_NAMESPACE = "namespace";
- public static final String ATTR_NAME_VERSION = "version";
- public static final String ATTR_NAME_STANDALONE = "standalone";
+ public static final String ATTR_NAME_NAMESPACE = "namespace";
//$NON-NLS-1$
+ public static final String ATTR_NAME_VERSION = "version";
//$NON-NLS-1$
+ public static final String ATTR_NAME_STANDALONE = "standalone";
//$NON-NLS-1$
- public static final String ATTR_NAME_FORCE_LOAD = "forceLoad";
+ public static final String ATTR_NAME_FORCE_LOAD = "forceLoad";
//$NON-NLS-1$
+
+ public static final String ATTR_NAME__FILE = "_file";
//$NON-NLS-1$
+
+ public static final String ATTR_NAME_EXTENSION = "extension";
//$NON-NLS-1$
+ public static final String ATTR_NAME_LOCATION = "location";
//$NON-NLS-1$
- public static final String ATTRIBUTE_VALUE_STR_YES = "yes";
- // public static final String ATTRIBUTE_VALUE_STR_NO = "no"
- // "true"
- // "false"
+ public static final String ATTRIBUTE_VALUE_STR_YES = "yes";
//$NON-NLS-1$
+
+ public static final String ENT_FILE_ANY_LONG = "FileAnyLong";
//$NON-NLS-1$
+ public static final String ENT_FILE_SYSTEM_FOLDER =
"FileSystemFolder"; //$NON-NLS-1$
+
+ public static String SEPARATOR = "/"; //$NON-NLS-1$
+ public static String YES = "yes"; //$NON-NLS-1$
+ public static String NO = "no"; //$NON-NLS-1$
+ public static String TRUE = "true"; //$NON-NLS-1$
+ public static String FALSE = "false"; //$NON-NLS-1$
+
+ public static String ATTR_NAME = "name"; //$NON-NLS-1$
+ public static String XML_ATTR_NAME = "NAME"; //$NON-NLS-1$
+ public static String ATTR_ELEMENT_TYPE = "element type"; //$NON-NLS-1$
+
+ public static String PROJECT = "project"; //$NON-NLS-1$
+
+ public static String PROP_ROOT_ENTITY = "rootEntity"; //$NON-NLS-1$
+ public static String ROOT_OBJECT = "Root"; //$NON-NLS-1$
// ""
// "setModified" use ENUM for compare
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/engines/impl/EnginesLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/engines/impl/EnginesLoader.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/engines/impl/EnginesLoader.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -61,7 +61,7 @@
}
public String fileroot(XModelObject object) {
- return XModelConstants.getWorkspace(object.getModel()) + "/";
+ return XModelConstants.getWorkspace(object.getModel()) +
XModelObjectConstants.SEPARATOR;
}
protected String fileName(XModelObject object) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/event/XModelTreeEvent.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/event/XModelTreeEvent.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/event/XModelTreeEvent.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -20,6 +20,9 @@
public static final int CHILD_REMOVED = 2;
public static final int STRUCTURE_CHANGED = 3;
+ public static final String BEFORE_MERGE = "beforeMerge";
+ public static final String AFTER_MERGE = "afterMerge";
+
private XModelObject object;
private Object info;
private Object details;
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/files/handlers/CreateFileSupport.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/files/handlers/CreateFileSupport.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/files/handlers/CreateFileSupport.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -21,12 +21,17 @@
import org.jboss.tools.common.meta.action.*;
import org.jboss.tools.common.meta.action.impl.*;
import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateHandler;
+import org.jboss.tools.common.meta.impl.XMetaDataConstants;
import org.jboss.tools.common.model.*;
import org.jboss.tools.common.model.filesystems.impl.*;
+import org.jboss.tools.common.model.plugin.ModelMessages;
import org.jboss.tools.common.model.util.*;
import org.jboss.tools.common.util.FileUtil;
public class CreateFileSupport extends SpecialWizardSupport {
+ static final String ATTR_TEMPLATE = "template";
+ static final String ATTR_FOLDER = "folder";
+
protected TargetHolder targetHolder = new TargetHolder();
TreeMap<String,String> versionEntities = new TreeMap<String,String>();
boolean useVersions = false;
@@ -35,7 +40,7 @@
targetHolder.setAction(action);
if(hasTemplate()) {
String[] s = getPageTemplateList();
- setValueList(0, "template", s);
+ setValueList(0, ATTR_TEMPLATE, s);
if(s.length > 0) {
//take from preferences
String defaultPageTemplate = getDefaultPageTemplate();
@@ -48,17 +53,17 @@
}
if (!bFound) defaultPageTemplate = s[0];
}
- setAttributeValue(0, "template", defaultPageTemplate);
+ setAttributeValue(0, ATTR_TEMPLATE, defaultPageTemplate);
}
}
targetHolder.target = getTarget();
IResource r = (IResource)getTarget().getAdapter(IResource.class);
if(r == null) {
- setAttributeValue(0, "folder", "");
+ setAttributeValue(0, ATTR_FOLDER, "");
targetHolder.revalidate(null);
} else {
targetHolder.revalidate(r.getFullPath().toString());
- setAttributeValue(0, "folder", "" + targetHolder.path);
+ setAttributeValue(0, ATTR_FOLDER, "" + targetHolder.path);
}
initVersions();
}
@@ -84,8 +89,8 @@
String version = keys[i].substring(entityVersion.length());
versionEntities.put(version, entity);
}
- if(versionEntities.size() == 0 && action.getProperty("entity") !=
null) {
- versionEntities.put("default", action.getProperty("entity"));
+ if(versionEntities.size() == 0 && action.getProperty(XMetaDataConstants.ENTITY)
!= null) {
+ versionEntities.put("default",
action.getProperty(XMetaDataConstants.ENTITY));
}
String[] versionList = (String[])versionEntities.keySet().toArray(new String[0]);
setValueList(0, "version", versionList);
@@ -95,7 +100,7 @@
}
private boolean hasTemplate() {
- return findAttribute(0, "template") != null;
+ return findAttribute(0, ATTR_TEMPLATE) != null;
}
public void action(String name) throws XModelException {
@@ -116,7 +121,7 @@
protected void execute() throws XModelException {
Properties p = extractStepData(0);
- String path = p.getProperty("name");
+ String path = p.getProperty(XModelObjectConstants.ATTR_NAME);
path = revalidatePath(path);
XModelObject f = createFile(path);
if(f != null) targetHolder.saveLastPath();
@@ -127,14 +132,14 @@
if(targetHolder.addPath.length() == 0) return true;
ServiceDialog d = getTarget().getModel().getService();
String message = "Folder " + targetHolder.path + " does not exist. Do
you want to create it?";
- int q = d.showDialog("Warning", message, new
String[]{SpecialWizardSupport.OK, SpecialWizardSupport.CANCEL}, null,
ServiceDialog.QUESTION);
+ int q = d.showDialog(ModelMessages.WARNING, message, new
String[]{SpecialWizardSupport.OK, SpecialWizardSupport.CANCEL}, null,
ServiceDialog.QUESTION);
return q == 0;
}
public boolean isFieldEditorEnabled(int stepId, String name, Properties values) {
- String path = values.getProperty("name");
+ String path = values.getProperty(XModelObjectConstants.ATTR_NAME);
boolean c = canCreateFile(path);
- if(name.equals("template")) {
+ if(name.equals(ATTR_TEMPLATE)) {
return c;
}
return true;
@@ -148,21 +153,21 @@
boolean isCorrectPath(String path) {
path = revalidatePath(path);
- if(path == null || path.equals("/") || path.indexOf("//") >= 0)
return false;
+ if(path == null || path.equals(XModelObjectConstants.SEPARATOR) ||
path.indexOf("//") >= 0) return false;
return true;
}
boolean fileExists(String path) {
if(path == null || targetHolder.target == null) return false;
path = revalidatePath(path);
- if(path.startsWith("/")) path = path.substring(1);
+ if(path.startsWith(XModelObjectConstants.SEPARATOR)) path = path.substring(1);
return targetHolder.target.getChildByPath(path) != null;
}
protected String revalidatePath(String path) {
if(path == null || path.length() == 0) return path;
- if(!path.startsWith("/")) path = "/" + path;
- String extension = "." + action.getProperty("extension");
+ if(!path.startsWith(XModelObjectConstants.SEPARATOR)) path =
XModelObjectConstants.SEPARATOR + path;
+ String extension = "." +
action.getProperty(XModelObjectConstants.ATTR_NAME_EXTENSION);
if(path.lastIndexOf('.') < 0) {
path += extension;
} else {
@@ -188,7 +193,7 @@
protected String getTemplateBody() throws IOException {
File templateFile = null;
- String template = getAttributeValue(0, "template");
+ String template = getAttributeValue(0, ATTR_TEMPLATE);
if(template != null && template.trim().length() > 0) {
templateFile = findTemplate(template.trim());
if(templateFile == null || !templateFile.isFile()) throw new
IOException("Template " + template + " is not found.");
@@ -209,14 +214,14 @@
}
XModelObject createFile(XModelObject fs, String path, String body, Properties p) throws
XModelException {
- StringTokenizer st = new StringTokenizer(path, "/");
+ StringTokenizer st = new StringTokenizer(path, XModelObjectConstants.SEPARATOR);
int c = st.countTokens(), i = 0;
while(i < c - 1) {
String s = st.nextToken();
XModelObject o = fs.getChildByPath(s);
if(o == null) {
o = fs.getModel().createModelObject("FileFolder", null);
- o.setAttributeValue("name", s);
+ o.setAttributeValue(XModelObjectConstants.ATTR_NAME, s);
DefaultCreateHandler.addCreatedObject(fs, o, FindObjectHelper.IN_NAVIGATOR_ONLY);
((FolderImpl)o).save();
}
@@ -229,9 +234,9 @@
String e = s.substring(dot + 1);
String entity = getFileEntity(e);
XModelObject f = XModelObjectLoaderUtil.createValidObject(fs.getModel(), entity, p);
- f.setAttributeValue("name", n);
- f.setAttributeValue("extension", e);
- if(body != null) f.setAttributeValue("body", body);
+ f.setAttributeValue(XModelObjectConstants.ATTR_NAME, n);
+ f.setAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION, e);
+ if(body != null) f.setAttributeValue(XModelObjectConstants.ATTR_NAME_BODY, body);
f = modifyCreatedObject(f);
XModelObject fq = fs.getChildByPath(f.getPathPart());
if(fq != null) return fq;
@@ -262,7 +267,7 @@
("htm".equals(extension)) ? "FileHTML" :
("html".equals(extension)) ? "FileHTML" :
("properties".equals(extension)) ? "FilePROPERTIES" :
- (extension.equals(action.getProperty("extension"))) ?
action.getProperty("entity") :
+ (extension.equals(action.getProperty(XModelObjectConstants.ATTR_NAME_EXTENSION))) ?
action.getProperty(XMetaDataConstants.ENTITY) :
"FileAny";
}
@@ -295,14 +300,14 @@
protected class Validator extends DefaultWizardDataValidator {
public void validate(Properties data) {
- String folder = data.getProperty("folder");
+ String folder = data.getProperty(ATTR_FOLDER);
targetHolder.revalidate(folder);
message = null;
validateFolderName();
if(message != null) return;
validateFileName(data);
if(message != null) return;
- String template = data.getProperty("template");
+ String template = data.getProperty(ATTR_TEMPLATE);
if(template != null && template.trim().length() > 0) {
File templateFile = findTemplate(template.trim());
if(templateFile == null || !templateFile.isFile()) {
@@ -316,7 +321,7 @@
String FORBIDDEN_INDICES = "\"\n\t*\\/:<>?|";
protected void validateFileName(Properties data) {
if(message != null) return;
- String fileName = data.getProperty("name");
+ String fileName = data.getProperty(XModelObjectConstants.ATTR_NAME);
if(fileName == null || fileName.length() == 0) return;
if(fileName.equals(".")) {
message = "Incorrect file name.";
@@ -347,7 +352,7 @@
protected void validateAddFile(XEntityData[] ds, Properties data) {
CreateFileHandler.validateNameAndExtension(action, data, null);
if(targetHolder.target != null) {
- String entity = action.getProperty("entity");
+ String entity = action.getProperty(XMetaDataConstants.ENTITY);
if(entity == null) entity = getEntityData()[step].getModelEntity().getName();
if(targetHolder.addPath == null || targetHolder.addPath.length() == 0) {
if(!checkChild(targetHolder.target, entity, data)) return;
@@ -361,7 +366,7 @@
public String getFocusAttribute(int stepId) {
if(stepId == 0) {
- return "name";
+ return XModelObjectConstants.ATTR_NAME;
}
return super.getFocusAttribute(stepId);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/files/handlers/CreateFolderSupport.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/files/handlers/CreateFolderSupport.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/files/handlers/CreateFolderSupport.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -9,11 +9,14 @@
import org.jboss.tools.common.meta.action.impl.SpecialWizardSupport;
import org.jboss.tools.common.meta.action.impl.WizardDataValidator;
import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateHandler;
+import org.jboss.tools.common.meta.impl.XMetaDataConstants;
import org.jboss.tools.common.model.ServiceDialog;
import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.impl.CreateFileHandler;
import org.jboss.tools.common.model.filesystems.impl.FolderImpl;
+import org.jboss.tools.common.model.plugin.ModelMessages;
public class CreateFolderSupport extends SpecialWizardSupport {
protected TargetHolder targetHolder = new TargetHolder();
@@ -54,7 +57,7 @@
if(targetHolder.addPath.length() == 0) return true;
ServiceDialog d = getTarget().getModel().getService();
String message = "Folder " + targetHolder.path + " does not exist. Do
you want to create it?";
- int q = d.showDialog("Warning", message, new
String[]{SpecialWizardSupport.OK, SpecialWizardSupport.CANCEL}, null,
ServiceDialog.QUESTION);
+ int q = d.showDialog(ModelMessages.WARNING, message, new
String[]{SpecialWizardSupport.OK, SpecialWizardSupport.CANCEL}, null,
ServiceDialog.QUESTION);
return q == 0;
}
@@ -66,20 +69,20 @@
boolean isCorrectPath(String path) {
path = revalidatePath(path);
- if(path == null || path.equals("/") || path.indexOf("//") >= 0)
return false;
+ if(path == null || path.equals(XModelObjectConstants.SEPARATOR) ||
path.indexOf("//") >= 0) return false;
return true;
}
boolean resourceExists(String path) {
if(path == null || targetHolder.target == null) return false;
path = revalidatePath(path);
- if(path.startsWith("/")) path = path.substring(1);
+ if(path.startsWith(XModelObjectConstants.SEPARATOR)) path = path.substring(1);
return targetHolder.target.getChildByPath(path) != null;
}
protected String revalidatePath(String path) {
if(path == null || path.length() == 0) return path;
- if(!path.startsWith("/")) path = "/" + path;
+ if(!path.startsWith(XModelObjectConstants.SEPARATOR)) path =
XModelObjectConstants.SEPARATOR + path;
if(targetHolder.addPath.length() > 0) {
path = targetHolder.addPath + path;
}
@@ -88,7 +91,7 @@
protected void execute() throws XModelException {
Properties p = extractStepData(0);
- String path = p.getProperty("name");
+ String path = p.getProperty(XModelObjectConstants.ATTR_NAME);
path = revalidatePath(path);
XModelObject f = createFolder(path);
if(f != null) targetHolder.saveLastPath();
@@ -98,14 +101,14 @@
if(!canCreateResource(path)) return null;
XModelObject fs = targetHolder.target;
- StringTokenizer st = new StringTokenizer(path, "/");
+ StringTokenizer st = new StringTokenizer(path, XModelObjectConstants.SEPARATOR);
int c = st.countTokens(), i = 0;
while(i < c) {
String s = st.nextToken();
XModelObject o = fs.getChildByPath(s);
if(o == null) {
o = fs.getModel().createModelObject("FileFolder", null);
- o.setAttributeValue("name", s);
+ o.setAttributeValue(XModelObjectConstants.ATTR_NAME, s);
DefaultCreateHandler.addCreatedObject(fs, o, getProperties());
((FolderImpl)o).save();
}
@@ -150,7 +153,7 @@
String FORBIDDEN_INDICES = "\"\n\t*\\/:<>?|";
protected void validateChildName(Properties data) {
if(message != null) return;
- String name = data.getProperty("name");
+ String name = data.getProperty(XModelObjectConstants.ATTR_NAME);
if(name == null || name.length() == 0) return;
if(name.equals(".")) {
message = "Incorrect name.";
@@ -180,7 +183,7 @@
protected void validateAddFile(XEntityData[] ds, Properties data) {
CreateFileHandler.validateNameAndExtension(action, data, null);
if(targetHolder.target != null) {
- String entity = action.getProperty("entity");
+ String entity = action.getProperty(XMetaDataConstants.ENTITY);
if(entity == null) entity = getEntityData()[step].getModelEntity().getName();
if(targetHolder.addPath == null || targetHolder.addPath.length() == 0) {
if(!checkChild(targetHolder.target, entity, data)) return;
@@ -194,7 +197,7 @@
public String getFocusAttribute(int stepId) {
if(stepId == 0) {
- return "name";
+ return XModelObjectConstants.ATTR_NAME;
}
return super.getFocusAttribute(stepId);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/files/handlers/TargetHolder.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/files/handlers/TargetHolder.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/files/handlers/TargetHolder.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -5,6 +5,8 @@
import org.eclipse.core.runtime.QualifiedName;
import org.jboss.tools.common.meta.action.XAction;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelObjectConstants;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
@@ -36,14 +38,14 @@
folder = ModelPlugin.getWorkspace().getRoot().findMember(p);
if(folder != null && folder.exists()) {
addPath = ap;
- if(addPath.endsWith("/")) addPath = addPath.substring(0, addPath.length()
- 1);
+ if(addPath.endsWith(XModelObjectConstants.SEPARATOR)) addPath = addPath.substring(0,
addPath.length() - 1);
target = EclipseResourceUtil.createObjectForResource(folder);
break;
}
}
} else if(target == null && folder != null && folder.exists()) {
target = EclipseResourceUtil.createObjectForResource(folder);
- } else if(target != null &&
"FileSystems".equals(target.getModelEntity().getName())) {
+ } else if(target != null &&
FileSystemsHelper.FILE_SYSTEMS.equals(target.getModelEntity().getName())) {
target = EclipseResourceUtil.findFileSystem(folder, target.getModel());
if(target == null) target = EclipseResourceUtil.createObjectForResource(folder);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/FileAuxiliary.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/FileAuxiliary.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/FileAuxiliary.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -46,8 +46,8 @@
if(!(f instanceof FileAnyAuxiliaryImpl)) {
if(!create) return null;
f = folder.getModel().createModelObject(AUX_FILE_ENTITY, null);
- f.setAttributeValue("name", name);
- f.setAttributeValue("extension", extension);
+ f.setAttributeValue(XModelObjectConstants.ATTR_NAME, name);
+ f.setAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION, extension);
folder.addChild(f);
}
FileAnyAuxiliaryImpl aux = (FileAnyAuxiliaryImpl)f;
@@ -57,7 +57,7 @@
}
public String getMainName(XModelObject aux) {
- String auxname = aux.getAttributeValue("name");
+ String auxname = aux.getAttributeValue(XModelObjectConstants.ATTR_NAME);
if(replaceExtension) return auxname;
int i = auxname.lastIndexOf('.');
String s = (i < 0) ? auxname : auxname.substring(0, i);
@@ -66,8 +66,8 @@
}
public String getAuxiliaryName(XModelObject main) {
- String name = main.getAttributeValue("name");
- if(!replaceExtension) name += "." +
main.getAttributeValue("extension");
+ String name = main.getAttributeValue(XModelObjectConstants.ATTR_NAME);
+ if(!replaceExtension) name += "." +
main.getAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION);
if(addLeadingDot) name = "." + name;
return name;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/FileSystemsHelper.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/FileSystemsHelper.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/FileSystemsHelper.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -20,7 +20,7 @@
}
public static XModelObject getFileSystem(XModel model, String name) {
- return model.getByPath(FILE_SYSTEMS + "/" + name);
+ return model.getByPath(FILE_SYSTEMS + XModelObjectConstants.SEPARATOR + name);
}
public static XModelObject getWebRoot(XModel model) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractExtendedXMLFileImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractExtendedXMLFileImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractExtendedXMLFileImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -19,6 +19,7 @@
import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.model.*;
import org.jboss.tools.common.model.engines.impl.EnginesLoader;
+import org.jboss.tools.common.model.event.XModelTreeEvent;
import org.jboss.tools.common.model.filesystems.BodySource;
import org.jboss.tools.common.model.filesystems.impl.AbstractXMLFileImpl;
import org.jboss.tools.common.model.loaders.*;
@@ -45,7 +46,7 @@
public String get(String name) {
if(name.equals("_hasErrors_")) {
- return super.get("isIncorrect");
+ return super.get(XModelObjectConstants.ATTR_NAME_IS_INCORRECT);
}
if (getParent() != null && ns.indexOf("." + name +
".") < 0) {
if(loadAttributeSeparately(name)) return super.get(name);
@@ -92,7 +93,7 @@
}
public boolean isObjectEditable() {
- return super.isObjectEditable() &&
(!"yes".equals(get("_hasErrors_")));
+ return super.isObjectEditable() &&
(!XModelObjectConstants.YES.equals(get("_hasErrors_")));
}
protected void loadChildren() {
@@ -122,7 +123,7 @@
if(!isActive()) return;
XModelObject s = getParent();
while(s != null && s.getFileType() != XModelObject.SYSTEM) s =
s.getParent();
- if(s == null || !s.getModelEntity().getName().equals("FileSystemFolder"))
{
+ if(s == null ||
!s.getModelEntity().getName().equals(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER)) {
return;
}
/*Runnable r = new Runnable() {
@@ -138,7 +139,7 @@
public void set(String name, String value) {
super.set(name, value);
if("incorrectBody".equals(name) && value.length() > 0) {
- set("isIncorrect", "yes");
+ set(XModelObjectConstants.ATTR_NAME_IS_INCORRECT,
XModelObjectConstants.YES);
// setErrors(value, hasDTD(), !hasDTD()); //never validate dtd
int resolution =
EntityXMLRegistration.getInstance().resolve(getModelEntity());
if(EntityXMLRegistration.isSystemId(value)) resolution =
EntityXMLRegistration.UNRESOLVED;
@@ -147,7 +148,7 @@
}
public String getAsText() {
- return get("body");
+ return get(XModelObjectConstants.ATTR_NAME_BODY);
}
public void edit(String body) throws XModelException {
@@ -155,14 +156,14 @@
}
protected boolean isForceLoadOn() {
- return "true".equals(get("forceLoad"));
+ return XModelObjectConstants.TRUE.equals(get("forceLoad"));
}
public void edit(String body, boolean update) throws XModelException {
if(body == null) return;
if(!isForceLoadOn() && body.equals(getAsText())) return;
- String entity =
getModel().getEntityRecognizer().getEntityName(getAttributeValue("extension"),
body);
+ String entity =
getModel().getEntityRecognizer().getEntityName(getAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION),
body);
if(!entity.equals(getModelEntity().getName())) {
String[] errors = (body.length() == 0) ? null : XMLUtil.getXMLErrors(new
java.io.StringReader(body), false);
if(errors == null || errors.length == 0) errors = new String[]{"Doctype has been
changed. Please save file for the change to take effect in object model. :0:0"};
@@ -173,7 +174,7 @@
return;
}
- boolean errors1 = ("yes".equals(get("_hasErrors_")));
+ boolean errors1 = (XModelObjectConstants.YES.equals(get("_hasErrors_")));
AbstractExtendedXMLFileImpl f = getUpdatedFile(body, true);
if(f == null) return;
f.getChildren();
@@ -187,7 +188,7 @@
boolean fire = this.loaderError == null && f.loaderError != null;
this.loaderError = f.loaderError;
super.set("incorrectBody", f.get("incorrectBody"));
- super.set("isIncorrect", "yes");
+ super.set(XModelObjectConstants.ATTR_NAME_IS_INCORRECT, XModelObjectConstants.YES);
if(f.get("errors") != null) super.set("errors",
f.get("errors"));
if(fire) changeTimeStamp();
@@ -241,7 +242,7 @@
}
private AbstractExtendedXMLFileImpl getUpdatedFile(String body, boolean fire) {
- boolean errors1 = ("yes".equals(get("_hasErrors_")));
+ boolean errors1 =
(XModelObjectConstants.YES.equals(get("_hasErrors_")));
loaderError = null;
// setErrors(body, hasDTD(), !hasDTD()); //never validate dtd
int resolution = EntityXMLRegistration.getInstance().resolve(getModelEntity());
@@ -257,8 +258,8 @@
}
}
AbstractExtendedXMLFileImpl f =
(AbstractExtendedXMLFileImpl)getModel().createModelObject(getModelEntity().getName(),
null);
- f.setAttributeValue("name", getAttributeValue("name"));
- f.setAttributeValue("extension",
getAttributeValue("extension"));
+ f.setAttributeValue(XModelObjectConstants.ATTR_NAME,
getAttributeValue(XModelObjectConstants.ATTR_NAME));
+ f.setAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION,
getAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION));
if(errors2) {
f.set("incorrectBody", body);
f.set("errors", super.get("errors"));
@@ -268,9 +269,12 @@
}
protected final void merge(XModelObject update, boolean fire) throws XModelException
{
- if(!"yes".equals(update.get("isIncorrect"))) {
+ if(fire) {
+ fireObjectChanged(XModelTreeEvent.BEFORE_MERGE);
+ }
+
if(!XModelObjectConstants.YES.equals(update.get(XModelObjectConstants.ATTR_NAME_IS_INCORRECT)))
{
super.set("incorrectBody", "");
- super.set("isIncorrect","no");
+ super.set(XModelObjectConstants.ATTR_NAME_IS_INCORRECT,XModelObjectConstants.NO);
super.set("errors", "");
loaderError = null;
}
@@ -323,6 +327,9 @@
}
if(fire && doFire) ((XModelImpl)getModel()).fireStructureChanged(this);
mergeAttributes(update, fire);
+ if(fire) {
+ fireObjectChanged(XModelTreeEvent.AFTER_MERGE);
+ }
}
static String NO_MERGE_ATTRIBUTES =
".name.extension._lateload.isIncorrect.incorrectBody.expand.";
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractXMLFileImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractXMLFileImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractXMLFileImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -13,7 +13,9 @@
import java.util.*;
import org.jboss.tools.common.model.markers.ResourceMarkers;
import org.jboss.tools.common.model.plugin.ModelPlugin;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.filesystems.impl.RecognizedFileImpl;
import org.jboss.tools.common.model.util.FindObjectHelper;
import org.jboss.tools.common.model.util.XMLUtil;
@@ -32,7 +34,7 @@
public final static boolean turnOffDTDCheck = true;
public boolean isIncorrect() {
- return ("yes".equals(get("isIncorrect")));
//$NON-NLS-1$//$NON-NLS-2$
+ return
(XModelObjectConstants.YES.equals(get(XModelObjectConstants.ATTR_NAME_IS_INCORRECT)));
}
public AbstractXMLFileImpl() {
@@ -91,14 +93,14 @@
if(s.equals(get("errors"))) return; //$NON-NLS-1$
super.set("incorrectBody", body); //$NON-NLS-1$
set("errors", s); //$NON-NLS-1$
- setAttributeValue("isIncorrect", (errors.length == 0 && loaderError
== null) ? "no" : "yes"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ setAttributeValue(XModelObjectConstants.ATTR_NAME_IS_INCORRECT, (errors.length == 0
&& loaderError == null) ? XModelObjectConstants.NO : XModelObjectConstants.YES);
if(!isOverlapped()) markers.update();
}
protected boolean isOverlapped() {
XModelObject p = getParent();
- while(p != null && !"true".equals(p.get("overlapped"))) p =
p.getParent(); //$NON-NLS-1$ //$NON-NLS-2$
+ while(p != null &&
!XModelObjectConstants.TRUE.equals(p.get("overlapped"))) p = p.getParent();
//$NON-NLS-1$ //$NON-NLS-2$
return (p != null);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/CreateFileHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/CreateFileHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/CreateFileHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -18,6 +18,7 @@
import org.jboss.tools.common.meta.action.XAction;
import org.jboss.tools.common.meta.action.XActionInvoker;
import org.jboss.tools.common.meta.action.impl.handlers.*;
+import org.jboss.tools.common.meta.impl.XMetaDataConstants;
import org.jboss.tools.common.model.util.*;
public class CreateFileHandler extends DefaultCreateHandler {
@@ -28,8 +29,8 @@
String defaultExtention = getDefaultExtension(prop);
validateNameAndExtension(action, p, defaultExtention);
XModelObject parent = getParentFolder(object, p);
- String ext = p.getProperty("extension");
- String entity = action.getProperty("entity");
+ String ext = p.getProperty(XModelObjectConstants.ATTR_NAME_EXTENSION);
+ String entity = action.getProperty(XMetaDataConstants.ENTITY);
if(entity == null) {
entity = (ext != null) ?
object.getModel().getEntityRecognizer().getEntityName(ext, null)
: data[0].getModelEntity().getName();
@@ -65,7 +66,7 @@
}
public static void validateNameAndExtension(XAction action, Properties p, String
defaultExtention) {
- String name = p.getProperty("name");
+ String name = p.getProperty(XModelObjectConstants.ATTR_NAME);
String ext = defaultExtention;
String path = null;
int i = name.lastIndexOf('.');
@@ -83,21 +84,21 @@
path = name.substring(0, i);
name = name.substring(i + 1);
}
- p.setProperty("name", name);
- if(ext != null) p.setProperty("extension", ext);
+ p.setProperty(XModelObjectConstants.ATTR_NAME, name);
+ if(ext != null) p.setProperty(XModelObjectConstants.ATTR_NAME_EXTENSION, ext);
if(path != null) p.setProperty("path", path);
}
private XModelObject getParentFolder(XModelObject object, Properties p) throws
XModelException {
String path = p.getProperty("path");
if(path == null || path.length() == 0) return object;
- StringTokenizer st = new StringTokenizer(path, "/");
+ StringTokenizer st = new StringTokenizer(path, XModelObjectConstants.SEPARATOR);
while(st.hasMoreTokens()) {
String pp = st.nextToken();
XModelObject c = object.getChildByPath(pp);
if(c == null) {
c = object.getModel().createModelObject("FileFolder", null);
- c.setAttributeValue("name", pp);
+ c.setAttributeValue(XModelObjectConstants.ATTR_NAME, pp);
p.put("parentObject", object);
p.put("childObject", c);
return createFolder(c, st);
@@ -114,7 +115,7 @@
while(path.hasMoreTokens()) {
String pp = path.nextToken();
XModelObject c = object.getModel().createModelObject("FileFolder",
null);
- c.setAttributeValue("name", pp);
+ c.setAttributeValue(XModelObjectConstants.ATTR_NAME, pp);
object.addChild(c);
object = c;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/DiscardFileHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/DiscardFileHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/DiscardFileHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -34,7 +34,7 @@
object.setModified(false);
XModelObjectLoaderUtil.updateModifiedOnSave(object);
}
- if(p != null) p.setProperty("done", "true");
+ if(p != null) p.setProperty("done", XModelObjectConstants.TRUE);
}
public boolean getSignificantFlag(XModelObject object) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/DiscardFileSignificanceMessage.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/DiscardFileSignificanceMessage.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/DiscardFileSignificanceMessage.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -18,8 +18,8 @@
public String getMessage(XAction action, XModelObject object, XModelObject[] objects) {
String d = "Discard changes in";
- XAttribute e = object.getModelEntity().getAttribute("element type");
- String type = (e == null || !e.isVisible()) ? "" :
object.getAttributeValue("element type");
+ XAttribute e =
object.getModelEntity().getAttribute(XModelObjectConstants.ATTR_ELEMENT_TYPE);
+ String type = (e == null || !e.isVisible()) ? "" :
object.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE);
if(type.length() > 0) type += " ";
String what = (objects != null && objects.length > 1) ? objects.length +
" selected objects" :
type + "'" + object.getPresentationString() + "'";
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/ExtensionChange.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/ExtensionChange.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/ExtensionChange.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -17,7 +17,9 @@
import org.jboss.tools.common.meta.action.impl.handlers.DefaultRemoveHandler;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.loaders.XObjectLoader;
import org.jboss.tools.common.model.undo.XTransactionUndo;
import org.jboss.tools.common.model.undo.XUndoManager;
@@ -44,7 +46,7 @@
String body = __body();
if(body == null) return false;
if("FileAny".equals(entity)) {
- if("FileAnyLong".equals(oldEntity)) return false;
+ if(XModelObjectConstants.ENT_FILE_ANY_LONG.equals(oldEntity)) return false;
if(FileUtil.isText(body)) entity = "FileTXT";
else return false;
} else if(entity == null) {
@@ -54,12 +56,12 @@
if(file.getModelEntity().getName().equals(entity)) return false;
XModelObject o = createFileObject(entity, body);
if(o == null) return false;
- if(o.getModelEntity().getAttribute("_file") != null &&
- file.getModelEntity().getAttribute("_file") != null) {
- o.set("_file", file.get("_file"));
+ if(o.getModelEntity().getAttribute(XModelObjectConstants.ATTR_NAME__FILE) != null
&&
+ file.getModelEntity().getAttribute(XModelObjectConstants.ATTR_NAME__FILE) !=
null) {
+ o.set(XModelObjectConstants.ATTR_NAME__FILE,
file.get(XModelObjectConstants.ATTR_NAME__FILE));
}
XUndoManager undo = model.getUndoManager();
- String d = "Change extension " +
file.getParent().getAttributeValue("name");
+ String d = "Change extension " +
file.getParent().getAttributeValue(XModelObjectConstants.ATTR_NAME);
XTransactionUndo u = new XTransactionUndo(d, XTransactionUndo.EDIT);
undo.addUndoable(u);
try {
@@ -81,27 +83,27 @@
file.setModified(true);
loader.save(file);
return XModelObjectLoaderUtil.getTempBody(file);
- } else if(file.getModelEntity().getAttribute("_file") != null) {
- String sfn = file.get("_file");
+ } else
if(file.getModelEntity().getAttribute(XModelObjectConstants.ATTR_NAME__FILE) != null) {
+ String sfn = file.get(XModelObjectConstants.ATTR_NAME__FILE);
if(sfn.length() == 0) return null;
File sf = new File(sfn);
return (sf.isFile()) ? FileUtil.readFile(sf) : null;
} else {
- return file.getAttributeValue("body");
+ return file.getAttributeValue(XModelObjectConstants.ATTR_NAME_BODY);
}
}
private XModelObject createFileObject(String entity, String body) {
Properties p = new Properties();
- p.setProperty("name", file.getAttributeValue("name"));
- p.setProperty("extension", extension);
+ p.setProperty(XModelObjectConstants.ATTR_NAME,
file.getAttributeValue(XModelObjectConstants.ATTR_NAME));
+ p.setProperty(XModelObjectConstants.ATTR_NAME_EXTENSION, extension);
XModelObject c = file.getModel().createModelObject(entity, p);
XObjectLoader loader = XModelObjectLoaderUtil.getObjectLoader(c);
if(loader != null) {
XModelObjectLoaderUtil.setTempBody(c, body);
loader.load(c);
} else {
- c.setAttributeValue("body", body);
+ c.setAttributeValue(XModelObjectConstants.ATTR_NAME_BODY, body);
}
return c;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyAuxiliaryImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyAuxiliaryImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyAuxiliaryImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -50,7 +50,7 @@
XModelObject o = main.getObject();
if(o == null || !o.isActive()) return true;
String n = helper.getMainName(this);
- return !n.equals(o.getAttributeValue("name"));
+ return !n.equals(o.getAttributeValue(XModelObjectConstants.ATTR_NAME));
}
public void setModified(boolean value) {}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -79,7 +79,7 @@
}
private boolean isObjectEditable0() {
- if("true".equals(get("overlapped")) && isActive()) return
false;
+ if(XModelObjectConstants.TRUE.equals(get("overlapped")) &&
isActive()) return false;
XModelObject p = getParent();
if(p == null) return true;
if(p instanceof JarFolderImpl) return false;
@@ -88,15 +88,15 @@
}
public boolean isAttributeEditable(String name) {
- if("name".equals(name) || "extension".equals(name)) return false;
- if("body".equals(name)) {
+ if(XModelObjectConstants.ATTR_NAME.equals(name) ||
XModelObjectConstants.ATTR_NAME_EXTENSION.equals(name)) return false;
+ if(XModelObjectConstants.ATTR_NAME_BODY.equals(name)) {
return isObjectEditable0();
}
return super.isAttributeEditable(name);
}
public String getMainIconName() {
- if("true".equals(get("overlapped")) && isActive()) {
+ if(XModelObjectConstants.TRUE.equals(get("overlapped")) &&
isActive()) {
String oin = get("overlappedSystem");
XModelObject o = (oin == null || oin.length() == 0) ? null :
getModel().getByPath(oin);
if(o == null) {
@@ -123,7 +123,7 @@
}
public static String toFileName(XProperty p) {
- String n = p.get("NAME");
+ String n = p.get(XModelObjectConstants.XML_ATTR_NAME);
if(n == null) return null;
String s = p.get("EXTENSION");
return n + ((s == null || s.length() == 0) ? "" : "." + s);
@@ -131,7 +131,7 @@
public void setBodySource(BodySource bodysource) {
this.bodysource = bodysource;
- super.set("body", "");
+ super.set(XModelObjectConstants.ATTR_NAME_BODY, "");
changeTimeStamp();
}
@@ -147,19 +147,19 @@
}
public String get(String name) {
- if(bodysource != null && "body".equals(name))
readBodySource();
+ if(bodysource != null &&
XModelObjectConstants.ATTR_NAME_BODY.equals(name)) readBodySource();
return super.get(name);
}
private void readBodySource() {
String s = bodysource.get();
bodysource = null;
- if(s != null) super.set("body", s);
+ if(s != null) super.set(XModelObjectConstants.ATTR_NAME_BODY, s);
}
public String setAttributeValue(String name, String value) {
-// if("extension".equals(name) && isActive()) {
-// if(!value.equals(getAttributeValue("extension"))) {
+// if(XModelObjectConstants.ATTR_NAME_EXTENSION.equals(name) &&
isActive()) {
+//
if(!value.equals(getAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION))) {
// if(new ExtensionChange().execute(this, value) && getParent() ==
null) {
// return getAttributeValue(name);
// }
@@ -169,15 +169,15 @@
}
public String getAsText() {
- return getAttributeValue("body");
+ return getAttributeValue(XModelObjectConstants.ATTR_NAME_BODY);
}
public void edit(String body) throws XModelException {
- getModel().changeObjectAttribute(this, "body", body);
+ getModel().changeObjectAttribute(this, XModelObjectConstants.ATTR_NAME_BODY, body);
}
public void set(String name, String value) {
- if((!"NAME".equals(name) && !"EXTENSION".equals(name)) ||
!isActive() || !(getParent() instanceof FolderImpl)) {
+ if((!XModelObjectConstants.XML_ATTR_NAME.equals(name) &&
!"EXTENSION".equals(name)) || !isActive() || !(getParent() instanceof
FolderImpl)) {
super.set(name, value);
} else {
rename0(value, name);
@@ -185,11 +185,11 @@
}
public void fileRenamed(String name, String extension) {
- if(name != null && name.equals(super.get("NAME"))
+ if(name != null && name.equals(super.get(XModelObjectConstants.XML_ATTR_NAME))
&& extension != null &&
extension.equals(super.get("EXTENSION"))) {
return;
}
- super.set("NAME", name);
+ super.set(XModelObjectConstants.XML_ATTR_NAME, name);
super.set("EXTENSION", extension);
fireObjectChanged(null);
}
@@ -204,7 +204,7 @@
if(f2.exists() && !f.exists()) return;
if(!n2.equals(n1)) {
try {
- f.move(new Path(f.getParent().getFullPath() + "/" + toFileName(this)),
true, null);
+ f.move(new Path(f.getParent().getFullPath() + XModelObjectConstants.SEPARATOR +
toFileName(this)), true, null);
} catch (OperationCanceledException e) {
super.set(attr, n1);
} catch (CoreException e) {
@@ -266,7 +266,7 @@
}
protected void onAttributeValueEdit(String name, String oldValue, String newValue)
throws XModelException {
- if("body".equals(name) && listener != null) {
+ if(XModelObjectConstants.ATTR_NAME_BODY.equals(name) && listener != null) {
listener.bodyChanged(newValue);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyLongImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyLongImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyLongImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -16,6 +16,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.util.FileUtil;
@@ -46,7 +47,7 @@
}
private File _getFile() {
- String f = get("_file");
+ String f = get(XModelObjectConstants.ATTR_NAME__FILE);
return (f == null) ? null : new File(f);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemFolderLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemFolderLoader.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemFolderLoader.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -29,7 +29,7 @@
}
private boolean isProtectedFileSystem(XModelObject object) {
- String name = object.getAttributeValue("name");
+ String name = object.getAttributeValue(XModelObjectConstants.ATTR_NAME);
if("WEB-ROOT".equals(name) || "WEB-INF".equals(name)) return
true;
return false;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -15,6 +15,7 @@
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.*;
import org.jboss.tools.common.model.filesystems.*;
@@ -37,7 +38,7 @@
public IProject getProject() {
if(project == null) {
- project = (IProject)getModel().getProperties().get("project");
+ project = EclipseResourceUtil.getProject(this);
}
return project;
}
@@ -46,7 +47,7 @@
if(getProject() == null || resource != null) return resource;
if(!project.isOpen() || project.getLocation() == null) return resource;
String prloc = project.getLocation().toString().replace('\\', '/');
- String thloc = XModelObjectUtil.getExpandedValue(this, "location", null);
+ String thloc = XModelObjectUtil.getExpandedValue(this,
XModelObjectConstants.ATTR_NAME_LOCATION, null);
try {
prloc = new File(prloc).getCanonicalPath().replace('\\','/');
} catch (IOException e) {
@@ -86,7 +87,7 @@
return resource = f;
}
- IFolder f = project.getFolder(new Path("/" +
getAttributeValue("name")));
+ IFolder f = project.getFolder(new Path(XModelObjectConstants.SEPARATOR +
getAttributeValue(XModelObjectConstants.ATTR_NAME)));
if(!f.exists()) {
try {
f.createLink(new Path(thloc), IFolder.FORCE, null);
@@ -105,7 +106,7 @@
}
public String getAbsoluteLocation() {
- String s = XModelObjectUtil.getExpandedValue(this, "location", null);
+ String s = XModelObjectUtil.getExpandedValue(this,
XModelObjectConstants.ATTR_NAME_LOCATION, null);
if(s == null || s.length() == 0) return s;
try {
return new java.io.File(s).getCanonicalPath();
@@ -120,7 +121,7 @@
}
protected String getAbsolutePath() {
- return "" + get("location");
+ return "" + get(XModelObjectConstants.ATTR_NAME_LOCATION);
}
public FileSystemPeer getPeer() {
@@ -161,7 +162,7 @@
if(resourceName != null && resource.isLinked()) return
resourceName.replace('#', '/');
return resourceName;
}
-
if("true".equals(getModel().getProperties().getProperty("isProjectFragment")))
{
+
if(XModelObjectConstants.TRUE.equals(getModel().getProperties().getProperty("isProjectFragment")))
{
return resourceName;
}
return p.replace('#', '/') + " (" + resourceName +
")";
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemPeer.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemPeer.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemPeer.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -13,6 +13,7 @@
import java.io.*;
import java.util.*;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.filesystems.FilePathHelper;
public class FileSystemPeer {
@@ -57,7 +58,7 @@
private String toKey(File f, boolean asDir) {
String s = f.getAbsolutePath().replace('\\', '/');
s = FilePathHelper.toPathPath(s);
- return (asDir) ? s + "/" : s;
+ return (asDir) ? s + XModelObjectConstants.SEPARATOR : s;
}
private Long toLastModified(File f) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -38,7 +38,7 @@
}
public String getPresentationString() {
- IProject p = (IProject)getModel().getProperties().get("project");
+ IProject p = EclipseResourceUtil.getProject(this);
String app = getAttributeValue("application name");
if(p != null && !app.equals(p.getName())) {
app = app.length() > 0 ? p.getName() + " (" + app + ")" :
p.getName();
@@ -118,7 +118,7 @@
XModelObject[] cs = getChildren();
String[] paths = new String[cs.length];
for (int i = 0; i < cs.length; i++) {
- String path = XModelObjectUtil.getExpandedValue(cs[i], "location",
null);
+ String path = XModelObjectUtil.getExpandedValue(cs[i],
XModelObjectConstants.ATTR_NAME_LOCATION, null);
try {
File f = new File(path);
path = f.getCanonicalPath().replace('\\', '/');
@@ -146,7 +146,7 @@
String path = (String)it.next();
if(_overlapped.contains(path)) {
XModelObject c = getChildByPath(path);
- if(c == null || "true".equals(c.get("overlapped"))) {
+ if(c == null || XModelObjectConstants.TRUE.equals(c.get("overlapped"))) {
_overlapped.remove(path);
}
} else {
@@ -165,7 +165,7 @@
overlapped.add(path);
XModelObject c = getChildByPath(path);
if(c == null) continue;
- c.set("overlapped", "true");
+ c.set("overlapped", XModelObjectConstants.TRUE);
c.set("overlappedSystem", "" +
overlappedSystems.get(path));
c = c.getParent();
if(c != null) fire.add(c);
@@ -224,7 +224,7 @@
return (d.length > 0 && checkDelta(d[0]));
} else {
IProject p = resource.getProject();
- IProject cp = (IProject)getModel().getProperties().get("project");
+ IProject cp = EclipseResourceUtil.getProject(this);
if(cp != null && cp != p && p != null) {
return false;
}
@@ -293,14 +293,14 @@
}
private boolean isOpenProject() {
- IProject p = (IProject)getModel().getProperties().get("project");
+ IProject p = EclipseResourceUtil.getProject(this);
return p != null && p.isAccessible() && p.isOpen();
}
private IContributorResourceAdapter contributorResourceAdapter = null;
public Object getAdapter(Class adapter) {
- if(IResource.class == adapter || IProject.class == adapter) return
(IProject)getModel().getProperties().get("project");
+ if(IResource.class == adapter || IProject.class == adapter) return
EclipseResourceUtil.getProject(this);
if(IContributorResourceAdapter.class == adapter) {
if(contributorResourceAdapter == null) {
contributorResourceAdapter = new ExtendedJavaElementAdapterFactory();
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -91,10 +91,10 @@
XModelObject[] os = object.getChildren();
for (int i = 0; i < os.length; i++) {
- String s = os[i].getAttributeValue("location");
+ String s = os[i].getAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION);
if(s == null || !s.startsWith(XModelConstants.WORKSPACE_OLD_REF)) continue;
s = XModelConstants.WORKSPACE_REF +
s.substring(XModelConstants.WORKSPACE_OLD_REF.length());
- os[i].setAttributeValue("location", s);
+ os[i].setAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION, s);
// System.out.println("Migrated " + s);
}
@@ -114,7 +114,7 @@
}
public String fileroot(XModelObject object) {
- return XModelConstants.getWorkspace(object.getModel()) + "/";
+ return XModelConstants.getWorkspace(object.getModel()) +
XModelObjectConstants.SEPARATOR;
}
protected String fileName(XModelObject object) {
@@ -140,7 +140,7 @@
private String getEclipseFileName(XModelObject object, boolean load) {
String project =
object.getModel().getProperties().getProperty(IModelNature.ECLIPSE_PROJECT);
if(project == null) return null;
- String fn = project + "/" + IModelNature.PROJECT_FILE;
+ String fn = project + XModelObjectConstants.SEPARATOR + IModelNature.PROJECT_FILE;
if(!load || new File(fn).exists()) return fn;
return null;
}
@@ -158,7 +158,7 @@
if(WatcherLoader.isLocked(object.getModel())) {
return;
}
- IProject project =
(IProject)object.getModel().getProperties().get("project");
+ IProject project = EclipseResourceUtil.getProject(object);
if(project == null) return;
XModelObject lib = validateLib(object);
if(lib == null) {
@@ -201,17 +201,17 @@
fss.remove(o);
} else {
o = object.getModel().createModelObject("FileSystemJar", null);
//$NON-NLS-1$
- o.setAttributeValue("name", jsname); //$NON-NLS-1$
- o.setAttributeValue("location", path); //$NON-NLS-1$
- o.set(IS_ADDED_TO_CLASSPATH, "true"); //$NON-NLS-1$
+ o.setAttributeValue(XModelObjectConstants.ATTR_NAME, jsname); //$NON-NLS-1$
+ o.setAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION, path); //$NON-NLS-1$
+ o.set(IS_ADDED_TO_CLASSPATH, XModelObjectConstants.TRUE); //$NON-NLS-1$
object.addChild(o);
// object.setModified(true);
}
}
for (XModelObject o: fss) {
- String path = XModelObjectUtil.expand(o.getAttributeValue("location"),
o.getModel(), null); //$NON-NLS-1$
- if("true".equals(o.get(FileSystemsLoader.IS_ADDED_TO_CLASSPATH))) {
//$NON-NLS-1$
+ String path =
XModelObjectUtil.expand(o.getAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION),
o.getModel(), null); //$NON-NLS-1$
+ if(XModelObjectConstants.TRUE.equals(o.get(FileSystemsLoader.IS_ADDED_TO_CLASSPATH)))
{ //$NON-NLS-1$
o.removeFromParent();
} else if(!new File(path).exists()) {
o.removeFromParent();
@@ -227,9 +227,9 @@
if(wi == null) return null;
XModelObject lb = wi.getChildByPath("lib");
if(lb == null) return null;
- lib = wi.getModel().createModelObject("FileSystemFolder", null);
- lib.setAttributeValue("name", "lib");
- lib.setAttributeValue("location",
wi.getAttributeValue("location") + "/lib");
+ lib = wi.getModel().createModelObject(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER,
null);
+ lib.setAttributeValue(XModelObjectConstants.ATTR_NAME, "lib");
+ lib.setAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION,
wi.getAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION) + "/lib");
object.addChild(lib);
object.setModified(true);
}
@@ -254,10 +254,10 @@
if(path == null) continue;
paths.add(path);
}
- XModelObject[] cs = object.getChildren("FileSystemFolder");
+ XModelObject[] cs =
object.getChildren(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER);
for (int i = 0; i < cs.length; i++) {
- if(cs[i].getAttributeValue("name").startsWith("src")) {
- String loc = cs[i].getAttributeValue("location");
+
if(cs[i].getAttributeValue(XModelObjectConstants.ATTR_NAME).startsWith("src"))
{
+ String loc = cs[i].getAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION);
if(!paths.contains(loc)) {
object.removeChild(cs[i]);
} else {
@@ -268,9 +268,9 @@
for (String path : paths) {
String n = getNextSrcName(object);
Properties properties = new Properties();
- properties.setProperty("location", path);
- properties.setProperty("name", n);
- FileSystemImpl s =
(FileSystemImpl)object.getModel().createModelObject("FileSystemFolder",
properties);
+ properties.setProperty(XModelObjectConstants.ATTR_NAME_LOCATION, path);
+ properties.setProperty(XModelObjectConstants.ATTR_NAME, n);
+ FileSystemImpl s =
(FileSystemImpl)object.getModel().createModelObject(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER,
properties);
object.addChild(s);
}
}
@@ -346,7 +346,7 @@
String project = p.getProperty(IModelNature.ECLIPSE_PROJECT);
String workspace = p.getProperty(XModelConstants.WORKSPACE);
if(project == null) return;
- String relative = workspace.startsWith(project + "/") ?
+ String relative = workspace.startsWith(project + XModelObjectConstants.SEPARATOR) ?
"." + workspace.substring(project.length()) : workspace;
element.setAttribute("workspace-home", relative);
}
@@ -357,7 +357,7 @@
oldAttributes.put("application-name", "APPLICATION_NAME");
oldAttributes.put("workspace-home", "WORKSPACE_HOME");
oldAttributes.put("info", "INFO");
- oldAttributes.put("location", "LOCATION");
+ oldAttributes.put(XModelObjectConstants.ATTR_NAME_LOCATION, "LOCATION");
oldAttributes.put("model-path", "MODEL_PATH");
oldAttributes.put("root", "ROOT");
oldAttributes.put("web-root", "root");
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsRenameListener.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsRenameListener.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsRenameListener.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -114,13 +114,13 @@
fileSystems.getModel().getProperties().setProperty(XModelConstants.WORKSPACE, ws);
//now just recreate folder file systems
- XModelObject[] fs = fileSystems.getChildren("FileSystemFolder");
+ XModelObject[] fs =
fileSystems.getChildren(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER);
for (int i = 0; i < fs.length; i++) {
- String s = XModelObjectUtil.getExpandedValue(fs[i], "location", null);
+ String s = XModelObjectUtil.getExpandedValue(fs[i],
XModelObjectConstants.ATTR_NAME_LOCATION, null);
s = s.replace('\\', '/');
-// String name = fs[i].getAttributeValue("name");
+// String name = fs[i].getAttributeValue(XModelObjectConstants.ATTR_NAME);
XModelObject ns = fs[i].copy(0);
-/// ns.setAttributeValue("location", newPath);
+/// ns.setAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION, newPath);
fs[i].removeFromParent();
fileSystems.addChild(ns);
((XModelImpl)fileSystems.getModel()).fireStructureChanged(ns);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsTreeConstraint.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsTreeConstraint.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsTreeConstraint.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -29,12 +29,12 @@
return (s == null || s.indexOf("hidden=yes") < 0);
}
if(object.getFileType() == XFileObject.FILE) {
- String ext = "." + object.getAttributeValue("extension") +
".";
+ String ext = "." +
object.getAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION) + ".";
if(excludeExtensions.indexOf(ext) >= 0) return false;
- if(".rule-sets".equals(object.getAttributeValue("name")))
return false;
+
if(".rule-sets".equals(object.getAttributeValue(XModelObjectConstants.ATTR_NAME)))
return false;
} else if(object.getFileType() == XFileObject.FOLDER) {
String[] ns = getHiddenFolderNames();
- String n = object.get("NAME");
+ String n = object.get(XModelObjectConstants.XML_ATTR_NAME);
for (int i = 0; i < ns.length; i++) if(ns[i].equalsIgnoreCase(n)) return false;
}
return true;
@@ -42,13 +42,13 @@
public boolean isHidingAllChildren(XModelObject object) {
if(object.getFileType() > XFileObject.NONE
- && "true".equals(object.get("overlapped"))) return
true;
+ &&
XModelObjectConstants.TRUE.equals(object.get("overlapped"))) return true;
// String entity = object.getModelEntity().getName();
return false; ///entity.equals("FilePROPERTIES");
}
public boolean isHidingSomeChildren(XModelObject object) {
- if(object.getModelEntity().getName().equals("FileSystems")) return
true;
+ if(object.getModelEntity().getName().equals(FileSystemsHelper.FILE_SYSTEMS))
return true;
if(object.getFileType() < XFileObject.FOLDER) return false;
return true;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileXMLImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileXMLImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileXMLImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.model.filesystems.impl;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.filesystems.impl.AbstractXMLFileImpl;
public class FileXMLImpl extends AbstractXMLFileImpl {
@@ -28,16 +29,16 @@
public String get(String name) {
if(name.equals("_hasErrors_")) {
- return super.get("isIncorrect");
+ return super.get(XModelObjectConstants.ATTR_NAME_IS_INCORRECT);
}
if(!markersReset && isActive()) {
- updateMarkers(super.get("body"));
+ updateMarkers(super.get(XModelObjectConstants.ATTR_NAME_BODY));
}
return super.get(name);
}
public void set(String name, String value) {
- boolean isBody = "body".equals(name) || "_body_".equals(name);
+ boolean isBody = XModelObjectConstants.ATTR_NAME_BODY.equals(name) ||
XModelObjectConstants.ATTR_NAME__BODY_.equals(name);
if(isActive() && isBody && !value.equals(get(name))) {
super.set(name, value);
updateMarkers(value);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FolderImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FolderImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FolderImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -34,9 +34,12 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.widgets.Display;
import org.jboss.tools.common.meta.action.XActionInvoker;
+import org.jboss.tools.common.meta.impl.XMetaDataConstants;
import org.jboss.tools.common.model.ServiceDialog;
import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.filesystems.BodySource;
import org.jboss.tools.common.model.filesystems.FileAuxiliary;
import org.jboss.tools.common.model.filesystems.FilePathHelper;
@@ -110,7 +113,7 @@
if(parent.linked.containsKey(getPathPart())) {
return parent.linked.get(getPathPart()).getAbsolutePath();
}
- return (p == null) ? null : p + "/" + name();
+ return (p == null) ? null : p + XModelObjectConstants.SEPARATOR + name();
}
public IProject getProject() {
@@ -126,7 +129,7 @@
}
public void set(String name, String value) {
- if("NAME".equals(name) && isActive()) {
+ if(XModelObjectConstants.XML_ATTR_NAME.equals(name) && isActive()) {
if(value != null && !value.equals(get(name))) copy();
}
super.set(name, value);
@@ -180,7 +183,7 @@
private void _loadChild(FileSystemPeer peer, File f) {
if(f.isDirectory()) {
Properties p = new Properties();
- p.setProperty("name", f.getName());
+ p.setProperty(XModelObjectConstants.ATTR_NAME, f.getName());
XModelObject c = getModel().createModelObject("FileFolder", p);
String pp = FilePathHelper.toPathPath(f.getName());
if(linked.containsKey(pp)) {
@@ -196,20 +199,20 @@
private Properties getEntityProperties(File f) {
Properties p = new Properties();
parseFileName(p, f.getName());
- String ext = p.getProperty("extension");
+ String ext = p.getProperty(XModelObjectConstants.ATTR_NAME_EXTENSION);
String body = null;
String entity = getModel().getEntityRecognizer().getEntityName(ext, body);
if("FileAny".equals(entity)) {
boolean isText = XModelObjectLoaderUtil.isTextFile(f, 100);
- if(f.length() > 100000 || !isText) entity = "FileAnyLong";
+ if(f.length() > 100000 || !isText) entity =
XModelObjectConstants.ENT_FILE_ANY_LONG;
else if(isText) entity = "FileTXT";
} else if(entity == null) {
body = getBodySource(f).get();
entity = getModel().getEntityRecognizer().getEntityName(ext, body);
}
if(entity == null || getModel().getMetaData().getEntity(entity) == null) entity =
"FileAny";
- p.setProperty("entity", entity);
- if(body != null) p.setProperty("body", body);
+ p.setProperty(XMetaDataConstants.ENTITY, entity);
+ if(body != null) p.setProperty(XModelObjectConstants.ATTR_NAME_BODY, body);
return p;
}
@@ -219,8 +222,8 @@
private void createFileObject(File f, Properties p) {
BodySource bs = getBodySource(f);
- String body = p.getProperty("body");
- String entity = p.getProperty("entity");
+ String body = p.getProperty(XModelObjectConstants.ATTR_NAME_BODY);
+ String entity = p.getProperty(XMetaDataConstants.ENTITY);
XModelObject c = getModel().createModelObject(entity, p);
if(c == null) {
ModelPlugin.getPluginLog().logInfo("Cannot create file for entity " +
entity);
@@ -238,8 +241,8 @@
if(encoding != null) c.set("_encoding_", encoding);
}
loader.load(c);
- } else if(c.getModelEntity().getAttribute("_file") != null) {
- c.set("_file", f.getAbsolutePath());
+ } else
if(c.getModelEntity().getAttribute(XModelObjectConstants.ATTR_NAME__FILE) != null) {
+ c.set(XModelObjectConstants.ATTR_NAME__FILE, f.getAbsolutePath());
}
}
if(linked.containsValue(f)) {
@@ -403,10 +406,10 @@
XModelObject main = aux.getMainObject();
if(main != null && main.isActive() && h != null) {
String n = h.getAuxiliaryName(main);
- String p = n + "." +
aux.getAttributeValue("extension");
+ String p = n + "." +
aux.getAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION);
XModelObject other = getChildByPath(p);
if(other != null && other != aux) other.removeFromParent();
- aux.fileRenamed(n, aux.getAttributeValue("extension"));
+ aux.fileRenamed(n,
aux.getAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION));
aux.updateBodySource();
if(!isOverlapped()) {
File r = new File(f.getParentFile(), FileAnyImpl.toFileName(aux));
@@ -480,14 +483,14 @@
}
private void setForceLoadProperty(XModelObject f, boolean b) {
- f.set("forceLoad", b ? "true" : "");
+ f.set("forceLoad", b ? XModelObjectConstants.TRUE : "");
}
protected void updateLoaded(XModelObject o, File f) throws XModelException {
FileSystemPeer peer = getFileSystem().getPeer();
if(o instanceof FolderImpl) {
- if(!o.getAttributeValue("name").equals(f.getName())) {
- o.setAttributeValue("name", f.getName());
+ if(!o.getAttributeValue(XModelObjectConstants.ATTR_NAME).equals(f.getName())) {
+ o.setAttributeValue(XModelObjectConstants.ATTR_NAME, f.getName());
((FolderImpl)o).getResource();
}
((FolderImpl)o).update();
@@ -562,12 +565,12 @@
public boolean isChangedEntity(XModelObject o, File f) {
Properties p = getEntityProperties(f);
- return (!o.getModelEntity().getName().equals(p.getProperty("entity")));
+ return
(!o.getModelEntity().getName().equals(p.getProperty(XMetaDataConstants.ENTITY)));
}
private void reload(XModelObject o, File f) throws XModelException {
Properties p = getEntityProperties(f);
- if(!o.getModelEntity().getName().equals(p.getProperty("entity"))) {
+
if(!o.getModelEntity().getName().equals(p.getProperty(XMetaDataConstants.ENTITY))) {
o.removeFromParent();
createFileObject(f, p);
return;
@@ -594,7 +597,7 @@
loader.update(o);
} else if(o instanceof Reloadable) {
((Reloadable)o).reload();
- } else if("FileAnyLong".equals(o.getModelEntity().getName())) {
+ } else
if(XModelObjectConstants.ENT_FILE_ANY_LONG.equals(o.getModelEntity().getName())) {
o.setModified(false);
}
}
@@ -606,7 +609,7 @@
XModelObject c = null;
if(f.isDirectory()) {
Properties p = new Properties();
- p.setProperty("name", f.getName());
+ p.setProperty(XModelObjectConstants.ATTR_NAME, f.getName());
c = getModel().createModelObject("FileFolder", p);
String pp = FilePathHelper.toPathPath(f.getName());
if(linked.containsKey(pp)) {
@@ -614,14 +617,14 @@
}
} else {
Properties ep = getEntityProperties(f);
- XModelObject old = findOldObject(ep.getProperty("entity"), toRemove);
+ XModelObject old = findOldObject(ep.getProperty(XMetaDataConstants.ENTITY),
toRemove);
if(old != null) {
String ofn = FileAnyImpl.toFileName(old);
if(!f.getName().equals(ofn)) {
File of = new File(f.getParent(), ofn);
peer.unregister(of);
- String nm = ep.getProperty("name");
- String ext = ep.getProperty("extension");
+ String nm = ep.getProperty(XModelObjectConstants.ATTR_NAME);
+ String ext = ep.getProperty(XModelObjectConstants.ATTR_NAME_EXTENSION);
((FileAnyImpl)old).fileRenamed(nm, ext);
}
updateLoaded(old, f);
@@ -669,7 +672,7 @@
File rf = getChildIOFile(o);
boolean c = (d && peer.containsDir(rf)) || ((!d) &&
peer.contains(rf));
if(!c) return;
- if(o.getModel().getModelBuffer().source() == o && rf.exists() &&
o.getModelEntity().getAttribute("_file") != null) {
+ if(o.getModel().getModelBuffer().source() == o && rf.exists() &&
o.getModelEntity().getAttribute(XModelObjectConstants.ATTR_NAME__FILE) != null) {
File temp = null;
try {
temp = File.createTempFile("efs_", rf.getName());
@@ -679,10 +682,10 @@
if(temp != null) {
FileUtil.copyFile(rf, temp);
temp.deleteOnExit();
- o.set("_file", temp.getAbsolutePath());
+ o.set(XModelObjectConstants.ATTR_NAME__FILE, temp.getAbsolutePath());
}
}
- IResource r = (d) ? (IResource)
getChildContainer(o.getAttributeValue("name"))
+ IResource r = (d) ? (IResource)
getChildContainer(o.getAttributeValue(XModelObjectConstants.ATTR_NAME))
: (IResource) getChildFile(FileAnyImpl.toFileName(o));
o.removeFromParent();
if(r.exists()) {
@@ -855,8 +858,8 @@
private boolean saveFileWithoutLoader(File f, XModelObject o) {
if(!o.isModified()) return true;
- if(o.getModelEntity().getAttribute("_file") == null) return true;
- String sfn = o.get("_file");
+ if(o.getModelEntity().getAttribute(XModelObjectConstants.ATTR_NAME__FILE) ==
null) return true;
+ String sfn = o.get(XModelObjectConstants.ATTR_NAME__FILE);
if(sfn.length() == 0) return true;
if(f.getAbsolutePath().equalsIgnoreCase(sfn)) {
o.setModified(false);
@@ -867,7 +870,7 @@
f.getParentFile().mkdirs();
FileUtil.copyFile(sf, f);
}
- o.set("_file", f.getAbsolutePath());
+ o.set(XModelObjectConstants.ATTR_NAME__FILE, f.getAbsolutePath());
o.setModified(false);
return true;
}
@@ -906,12 +909,12 @@
int i = fn.lastIndexOf('.');
String n = (i < 0) ? fn : fn.substring(0, i);
String e = (i < 0) ? "" : fn.substring(i + 1);
- p.setProperty("name", n);
- p.setProperty("extension", e);
+ p.setProperty(XModelObjectConstants.ATTR_NAME, n);
+ p.setProperty(XModelObjectConstants.ATTR_NAME_EXTENSION, e);
}
public String getPathPart() {
- String s = get("NAME");
+ String s = get(XModelObjectConstants.XML_ATTR_NAME);
return FilePathHelper.toPathPath(s);
}
@@ -922,7 +925,7 @@
static boolean isLateloadFile(XModelObject o) {
return (o.getModelEntity().getAttribute("_lateload") != null
&&
- o.getModelEntity().getAttribute("body") != null);
+ o.getModelEntity().getAttribute(XModelObjectConstants.ATTR_NAME_BODY) !=
null);
}
static boolean isLateloadFile2(XModelObject o) {
@@ -948,11 +951,11 @@
public boolean isObjectEditable() {
initEditability();
- return (editability == 1 &&
!"true".equals(get("overlapped")) && isActive());
+ return (editability == 1 &&
!XModelObjectConstants.TRUE.equals(get("overlapped")) && isActive());
}
public String getMainIconName() {
- if("true".equals(get("overlapped")) && isActive()) {
+ if(XModelObjectConstants.TRUE.equals(get("overlapped")) &&
isActive()) {
String oin = get("overlappedSystem");
XModelObject o = (oin == null || oin.length() == 0) ? null :
getModel().getByPath(oin);
if(o == null) {
@@ -970,7 +973,7 @@
return r instanceof IContainer ? (IContainer)r : null;
}
IContainer c = getResource();
- return (c == null) ? null : c.getFolder(new Path("/" + name));
+ return (c == null) ? null : c.getFolder(new Path(XModelObjectConstants.SEPARATOR +
name));
}
public IFile getChildFile(String name) {
@@ -979,18 +982,18 @@
return r instanceof IFile ? (IFile)r : null;
}
IContainer c = getResource();
- return (c == null) ? null : c.getFile(new Path("/" + name));
+ return (c == null) ? null : c.getFile(new Path(XModelObjectConstants.SEPARATOR +
name));
}
public IContainer getResource() {
if(!needUpdateResource()) return resource;
- resource =
((FolderImpl)getParent()).getChildContainer(getAttributeValue("name"));
+ resource =
((FolderImpl)getParent()).getChildContainer(getAttributeValue(XModelObjectConstants.ATTR_NAME));
pathForResource = getPath();
return resource;
}
protected boolean needUpdateResource() {
- if(resource != null &&
!resource.getName().equals(getAttributeValue("name"))) return true;
+ if(resource != null &&
!resource.getName().equals(getAttributeValue(XModelObjectConstants.ATTR_NAME))) return
true;
if(!isActive()) return false;
if(pathForResource == null || resource == null) return true;
String path = getPath();
@@ -1010,7 +1013,7 @@
public boolean isOverlapped() {
XModelObject p = this;
- while(p != null && !"true".equals(get("overlapped"))) p =
p.getParent();
+ while(p != null &&
!XModelObjectConstants.TRUE.equals(get("overlapped"))) p = p.getParent();
return p != null;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/HiddenSystemsHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/HiddenSystemsHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/HiddenSystemsHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -32,9 +32,9 @@
XModelObject[] fs = object.getChildren();
String[][] vs = new String[fs.length][];
for (int i = 0; i < vs.length; i++) {
- String name = fs[i].getAttributeValue("name");
+ String name = fs[i].getAttributeValue(XModelObjectConstants.ATTR_NAME);
Properties fsp = XModelObjectUtil.toProperties(fs[i]);
- String hidden = "" + fsp.getProperty("hidden",
"no");
+ String hidden = "" + fsp.getProperty("hidden",
XModelObjectConstants.NO);
String jar = "" +
"FileSystemJar".equals(fs[i].getModelEntity().getName());
vs[i] = new String[]{name, hidden, jar};
}
@@ -46,7 +46,7 @@
boolean ch = false;
for (int i = 0; i < vs.length; i++) {
Properties fsp = XModelObjectUtil.toProperties(fs[i]);
- String hidden = "" + fsp.getProperty("hidden",
"no");
+ String hidden = "" + fsp.getProperty("hidden",
XModelObjectConstants.NO);
if(hidden.equals(vs[i][1])) continue;
fsp.setProperty("hidden", vs[i][1]);
fs[i].setAttributeValue("info", XModelObjectUtil.toString(fsp));
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -23,6 +23,7 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.util.FileUtil;
@@ -106,7 +107,7 @@
while(en.hasMoreElements()) {
ZipEntry entry = (ZipEntry)en.nextElement();
String name = entry.getName();
- if(name != null && !name.endsWith("/") && entry.getSize()
> 0) {
+ if(name != null && !name.endsWith(XModelObjectConstants.SEPARATOR)
&& entry.getSize() > 0) {
fileEntries.put(name, Long.valueOf(entry.getSize()));
}
register(name);
@@ -144,13 +145,13 @@
String[] parsed = parse(path);
check(parsed[0]);
HashSet<String> set = map.get(parsed[0]);
- if (!"/".equals(parsed[1]))
+ if (!XModelObjectConstants.SEPARATOR.equals(parsed[1]))
set.add(parsed[1]);
}
private String[] parse(String path) {
String q = path;
- if (path.endsWith("/"))
+ if (path.endsWith(XModelObjectConstants.SEPARATOR))
q = q.substring(0, path.length() - 1);
int i = q.lastIndexOf('/');
String root = (i < 0) ? "" : path.substring(0, i);
@@ -167,7 +168,7 @@
if ("".equals(parsed[1]))
return;
HashSet<String> set = map.get(parsed[0]);
- set.add(parsed[1] + "/");
+ set.add(parsed[1] + XModelObjectConstants.SEPARATOR);
}
public String[] getChildren(String path) {
@@ -325,9 +326,9 @@
String[] r = access.getChildren(relpath);
String rp = getPath();
for (int i = 0; i < r.length; i++) {
- if (r[i].endsWith("/"))
+ if (r[i].endsWith(XModelObjectConstants.SEPARATOR))
r[i] = r[i].substring(0, r[i].length() - 1);
- r[i] = rp + "/" + r[i];
+ r[i] = rp + XModelObjectConstants.SEPARATOR + r[i];
}
return r;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarFolderImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarFolderImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarFolderImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -42,14 +42,14 @@
protected String getAbsolutePath() {
String p = (getParent() == null) ? null :
((JarFolderImpl)getParent()).getAbsolutePath();
- if(p != null && p.length() > 0) p += "/";
+ if(p != null && p.length() > 0) p += XModelObjectConstants.SEPARATOR;
return (p == null) ? null : p + name();
}
public BodySource getBodySource(String filename) {
String path = getAbsolutePath();
if(path == null) return null;
- String cpath = (path.length() == 0) ? filename : path + "/" +
filename;
+ String cpath = (path.length() == 0) ? filename : path +
XModelObjectConstants.SEPARATOR + filename;
return new JarBodySource(getJarSystem().getJarAccess(), cpath);
}
@@ -63,11 +63,11 @@
String[] cs = jar.getChildren(path);
Properties p = new Properties();
for (int i = 0; i < cs.length; i++) {
- boolean d = cs[i].endsWith("/");
+ boolean d = cs[i].endsWith(XModelObjectConstants.SEPARATOR);
if(d) cs[i] = cs[i].substring(0, cs[i].length() - 1);
if(d) {
p.clear();
- p.setProperty("name", cs[i]);
+ p.setProperty(XModelObjectConstants.ATTR_NAME, cs[i]);
XModelObject c = getModel().createModelObject("JarFolder", p);
addChild(c);
} else {
@@ -79,14 +79,14 @@
}
private void createFileObject(JarAccess jar, String path, String name) {
- String cpath = (path.length() == 0) ? name : path + "/" + name;
+ String cpath = (path.length() == 0) ? name : path +
XModelObjectConstants.SEPARATOR + name;
Properties p = new Properties();
FolderImpl.parseFileName(p, name);
- String ext = p.getProperty("extension");
+ String ext = p.getProperty(XModelObjectConstants.ATTR_NAME_EXTENSION);
String body = null;
String entity = getModel().getEntityRecognizer().getEntityName(ext, body);
if("FileAny".equals(entity)) {
- if(jar.getSize(cpath) > 100000) entity = "FileAnyLong";
+ if(jar.getSize(cpath) > 100000) entity =
XModelObjectConstants.ENT_FILE_ANY_LONG;
else if(jar.isTextEntry(cpath, 100)) entity = "FileTXT";
} else if(entity == null) {
body = jar.getContent(cpath);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarSystemImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarSystemImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarSystemImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -32,7 +32,7 @@
}
public boolean isAttributeEditable(String name) {
- return super.isAttributeEditable(name) && "name".equals(name);
+ return super.isAttributeEditable(name) &&
XModelObjectConstants.ATTR_NAME.equals(name);
}
protected String getAbsolutePath() {
@@ -52,13 +52,13 @@
}
public String getLocation() {
- return Paths.expand(get("location"), getModel().getProperties());
+ return Paths.expand(get(XModelObjectConstants.ATTR_NAME_LOCATION),
getModel().getProperties());
}
public String getTempLocation() {
if(!jar.isLoaded()) loadChildren();
String s = jar.getTempLocation();
- return (s == null) ? get("location") : s;
+ return (s == null) ? get(XModelObjectConstants.ATTR_NAME_LOCATION) : s;
}
public LFileObject getFileObject(String relpath) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFileSystemHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFileSystemHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFileSystemHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -16,6 +16,7 @@
import org.jboss.tools.common.meta.action.*;
import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateHandler;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.plugin.ModelMessages;
import org.jboss.tools.common.model.util.*;
public class MountFileSystemHandler extends DefaultCreateHandler {
@@ -42,20 +43,20 @@
}
private boolean checkOverlap(XModelObject object, String entity, Properties p) {
- String location = p.getProperty("location");
+ String location = p.getProperty(XModelObjectConstants.ATTR_NAME_LOCATION);
if(location == null) return true;
boolean b = location.indexOf('%') >= 0;
location = canonize(location, object.getModel());
- if(location != null && !b) p.setProperty("location",
location);
- if(!"FileSystemFolder".equals(entity)) return true;
- location += "/";
+ if(location != null && !b)
p.setProperty(XModelObjectConstants.ATTR_NAME_LOCATION, location);
+ if(!XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER.equals(entity)) return true;
+ location += XModelObjectConstants.SEPARATOR;
XModelObject[] cs = object.getChildren(entity);
for (int i = 0; i < cs.length; i++) {
- String loc = canonize(cs[i].get("location"), cs[i].getModel()) +
"/";
+ String loc = canonize(cs[i].get(XModelObjectConstants.ATTR_NAME_LOCATION),
cs[i].getModel()) + XModelObjectConstants.SEPARATOR;
if(!loc.startsWith(location) && !location.startsWith(loc)) continue;
- String mes = "File system " + p.get("name") + " will
share files with file system " + cs[i].getAttributeValue("name");
+ String mes = "File system " +
p.get(XModelObjectConstants.ATTR_NAME) + " will share files with file system " +
cs[i].getAttributeValue(XModelObjectConstants.ATTR_NAME);
ServiceDialog d = object.getModel().getService();
- int q = d.showDialog("Warning", mes, new String[]{"OK",
"Cancel"}, null, ServiceDialog.WARNING);
+ int q = d.showDialog(ModelMessages.WARNING, mes, new
String[]{ModelMessages.OK, ModelMessages.Cancel}, null, ServiceDialog.WARNING);
return (q == 0);
}
return true;
@@ -71,22 +72,22 @@
}
private void validateName(XModelObject object, Properties p) {
- String name = p.getProperty("name");
+ String name = p.getProperty(XModelObjectConstants.ATTR_NAME);
if(name != null && name.length() > 0) return;
- String location = p.getProperty("location");
+ String location = p.getProperty(XModelObjectConstants.ATTR_NAME_LOCATION);
name = location.substring(location.lastIndexOf('/') + 1);
if(name.length() == 0) name = "filesystem";
name = XModelObjectUtil.createNewChildName(name, object);
- p.setProperty("name", name);
+ p.setProperty(XModelObjectConstants.ATTR_NAME, name);
}
private void setRelativeToProject(XModelObject object, Properties p) {
- boolean isRelative = "true".equals(p.getProperty("set location
relative to project"));
+ boolean isRelative = XModelObjectConstants.TRUE.equals(p.getProperty("set
location relative to project"));
if(!isRelative) return;
- String location = canonize(p.getProperty("location"),
object.getModel());
+ String location =
canonize(p.getProperty(XModelObjectConstants.ATTR_NAME_LOCATION), object.getModel());
String project = canonize(XModelConstants.WORKSPACE_REF, object.getModel());
if(location.equals(project)) {
- p.setProperty("location", XModelConstants.WORKSPACE_REF);
+ p.setProperty(XModelObjectConstants.ATTR_NAME_LOCATION,
XModelConstants.WORKSPACE_REF);
return;
}
boolean common = false;
@@ -101,18 +102,18 @@
if(!p1.equals(p2)) break;
location = location.substring(i1);
project = project.substring(i2);
- if(location.startsWith("/")) location = location.substring(1);
- if(project.startsWith("/")) project = project.substring(1);
+ if(location.startsWith(XModelObjectConstants.SEPARATOR)) location =
location.substring(1);
+ if(project.startsWith(XModelObjectConstants.SEPARATOR)) project =
project.substring(1);
common = true;
}
if(!common) return;
String s = XModelConstants.WORKSPACE_REF;
if(project.length() > 0) {
- int q = new StringTokenizer(project, "/").countTokens();
+ int q = new StringTokenizer(project,
XModelObjectConstants.SEPARATOR).countTokens();
for (int i = 0; i < q; i++) s += "/..";
}
- if(location.length() > 0) s += "/" + location;
- p.setProperty("location", s);
+ if(location.length() > 0) s += XModelObjectConstants.SEPARATOR + location;
+ p.setProperty(XModelObjectConstants.ATTR_NAME_LOCATION, s);
}
static SpecialWizard w =
SpecialWizardFactory.createSpecialWizard("org.jboss.tools.common.model.project.ClassPathUpdateWizard");
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFileSystemUndo.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFileSystemUndo.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFileSystemUndo.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -15,7 +15,7 @@
public MountFileSystemUndo(XModelObject fs) {
super(fs);
- description = "Mount file system " +
p.getProperty("location");
+ description = "Mount file system " +
p.getProperty(XModelObjectConstants.ATTR_NAME_LOCATION);
}
protected void doUndo() {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFolderHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFolderHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFolderHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -22,11 +22,11 @@
public MountFolderHandler() {}
public boolean isEnabled(XModelObject object) {
- if(object == null || "true".equals(object.get("overlapped")))
return false;
+ if(object == null ||
XModelObjectConstants.TRUE.equals(object.get("overlapped"))) return false;
String entity = object.getModelEntity().getName();
if("FileFolder".equals(entity)) return true;
if(object.getFileType() == XFileObject.FILE &&
- "jar".equals(object.getAttributeValue("extension"))
&&
+
"jar".equals(object.getAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION))
&&
isInFileFolderSystem(object)) return true;
return false;
}
@@ -39,8 +39,8 @@
String rpath = XModelObjectLoaderUtil.getResourcePath(object);
String fspath = path.substring(0, path.length() - rpath.length());
XModelObject fso = object.getModel().getByPath(fspath);
- String location = fso.getAttributeValue("location") + rpath;
- p.setProperty("location", location);
+ String location = fso.getAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION)
+ rpath;
+ p.setProperty(XModelObjectConstants.ATTR_NAME_LOCATION, location);
XModelObject c = h.mount(fso.getParent(), p, entity);
c.setModified(false);
FindObjectHelper.findModelObject(c, 0);
@@ -48,7 +48,7 @@
private boolean isInFileFolderSystem(XModelObject o) {
while(o != null && o.getFileType() != XFileObject.SYSTEM) o =
o.getParent();
- return o != null &&
o.getModelEntity().getName().equals("FileSystemFolder");
+ return o != null &&
o.getModelEntity().getName().equals(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/RecognizedFileImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/RecognizedFileImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/RecognizedFileImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -16,7 +16,7 @@
public RecognizedFileImpl() {}
/// public String getPresentationString() {
-/// return (String)properties.get("NAME");
+/// return (String)properties.get(XModelObjectConstants.XML_ATTR_NAME);
/// }
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SelectOverlappedFileSystemHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SelectOverlappedFileSystemHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SelectOverlappedFileSystemHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -17,6 +17,7 @@
import org.jboss.tools.common.meta.action.impl.*;
import org.jboss.tools.common.model.*;
import org.jboss.tools.common.model.filesystems.FilePathHelper;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.impl.*;
import org.jboss.tools.common.model.util.*;
@@ -25,7 +26,7 @@
public SelectOverlappedFileSystemHandler() {}
public boolean isEnabled(XModelObject o) {
- return o != null &&
("true".equals(o.get("overlapped")));
+ return o != null &&
(XModelObjectConstants.TRUE.equals(o.get("overlapped")));
}
public void executeHandler(XModelObject object, java.util.Properties p) throws
XModelException {
@@ -39,8 +40,8 @@
return;
}
Properties fsp = XModelObjectUtil.toProperties(fs);
- if("yes".equals(fsp.getProperty("hidden", "no")))
{
- fsp.setProperty("hidden", "no");
+ if(XModelObjectConstants.YES.equals(fsp.getProperty("hidden",
XModelObjectConstants.NO))) {
+ fsp.setProperty("hidden", XModelObjectConstants.NO);
fs.setAttributeValue("info", XModelObjectUtil.toString(fsp));
fs.setModified(true);
XModelImpl m = (XModelImpl)object.getModel();
@@ -52,7 +53,7 @@
static XModelObject getOverlappedFileSystem(XModelObject source) {
String fp = getAbsoluteFileFolderPath(source);
if(fp == null) return null;
- XModelObject fs = source.getModel().getByPath("FileSystems");
+ XModelObject fs = FileSystemsHelper.getFileSystems(source.getModel());
if(fs == null) return null;
XModelObject[] cs = fs.getChildren();
for (int i = 0; i < cs.length; i++)
@@ -61,7 +62,7 @@
}
private static String getAbsoluteFileSystemPath(XModelObject fso) {
- String path = XModelObjectUtil.getExpandedValue(fso, "location",
null);
+ String path = XModelObjectUtil.getExpandedValue(fso,
XModelObjectConstants.ATTR_NAME_LOCATION, null);
try {
path = new File(path).getCanonicalPath().replace('\\', '/');
return FilePathHelper.toPathPath(path);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SimpleFileImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SimpleFileImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SimpleFileImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.model.filesystems.impl;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.filesystems.impl.AbstractExtendedXMLFileImpl;
import org.jboss.tools.common.model.impl.*;
import org.jboss.tools.common.model.loaders.impl.SerializingLoader;
@@ -28,7 +29,7 @@
public String get(String name) {
String v = super.get(name);
- return (!"body".equals(name)) ? v : getBody();
+ return (!XModelObjectConstants.ATTR_NAME_BODY.equals(name)) ? v : getBody();
}
public String getBody() {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/UnmountFileSystemHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/UnmountFileSystemHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/UnmountFileSystemHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -14,6 +14,7 @@
import org.jboss.tools.common.model.*;
import org.jboss.tools.common.model.util.*;
import org.jboss.tools.common.model.loaders.*;
+import org.jboss.tools.common.model.plugin.ModelMessages;
public class UnmountFileSystemHandler extends DefaultRemoveHandler {
@@ -45,9 +46,9 @@
private boolean handleModified(XModelObject object) {
if(!object.isModified()) return true;
ServiceDialog d = object.getModel().getService();
- String mes = "File system " + object.get("NAME") + " was
modified.\n" +
+ String mes = "File system " +
object.get(XModelObjectConstants.XML_ATTR_NAME) + " was modified.\n" +
"Do you want to save changes?";
- int i = d.showDialog(action.getDisplayName(), mes, new String[]{"Yes",
"No", "Cancel"}, null, ServiceDialog.QUESTION);
+ int i = d.showDialog(action.getDisplayName(), mes, new
String[]{ModelMessages.Yes, ModelMessages.No, ModelMessages.Cancel}, null,
ServiceDialog.QUESTION);
if(i == 1) return true;
if(i != 0) return false;
XObjectLoader loader = XModelObjectLoaderUtil.getObjectLoader(object);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/UnmountFileSystemUndo.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/UnmountFileSystemUndo.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/UnmountFileSystemUndo.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -12,6 +12,7 @@
import java.util.*;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.undo.*;
public class UnmountFileSystemUndo extends XUndoableImpl {
@@ -19,7 +20,7 @@
protected String entity;
protected String pathpart;
protected Properties p = new Properties();
- protected String[] pns = {"name", "location", "slave
model", "file system"};
+ protected String[] pns = {XModelObjectConstants.ATTR_NAME,
XModelObjectConstants.ATTR_NAME_LOCATION, "slave model", "file
system"};
public UnmountFileSystemUndo(XModelObject fs) {
model = fs.getModel();
@@ -37,7 +38,7 @@
protected void doUndo() {
XModelObject o = model.createModelObject(entity, p);
- model.getByPath("FileSystems").addChild(o);
+ FileSystemsHelper.getFileSystems(model).addChild(o);
MountFileSystemHandler.updateClassPath(o);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/UnmountFolderHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/UnmountFolderHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/UnmountFolderHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -18,7 +18,7 @@
public UnmountFolderHandler() {}
public boolean isEnabled(XModelObject object) {
- return (object != null &&
"true".equals(object.get("overlapped")));
+ return (object != null &&
XModelObjectConstants.TRUE.equals(object.get("overlapped")));
}
protected XModelObject getTrueSource(XModelObject source) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/example/FileMainImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/example/FileMainImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/example/FileMainImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.model.filesystems.impl.example;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.filesystems.*;
import org.jboss.tools.common.model.filesystems.impl.*;
import org.jboss.tools.common.model.util.*;
@@ -22,7 +23,7 @@
}
public String get(String name) {
- if(!("NAME".equals(name) || "EXTENSION".equals(name))
+ if(!(XModelObjectConstants.XML_ATTR_NAME.equals(name) ||
"EXTENSION".equals(name))
&& getParent() != null) loadChildren();
return super.get(name);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/handlers/RenameFileSystemHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/handlers/RenameFileSystemHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/handlers/RenameFileSystemHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -20,16 +20,16 @@
public boolean isEnabled(XModelObject object) {
if(!super.isEnabled(object)) return false;
- String nm = object.getAttributeValue("name");
+ String nm = object.getAttributeValue(XModelObjectConstants.ATTR_NAME);
return !"WEB-INF".equals(nm);
}
public void executeHandler(XModelObject object, Properties prop) throws XModelException
{
if(!isEnabled(object) || data == null) return;
Properties p = extractProperties(data[0]);
setOtherProperties(object, p);
- String oldName = object.getAttributeValue("name");
+ String oldName = object.getAttributeValue(XModelObjectConstants.ATTR_NAME);
edit(object, p);
- String newName = p.getProperty("name");
+ String newName = p.getProperty(XModelObjectConstants.ATTR_NAME);
XModelObject web = object.getModel().getByPath("Web");
if(web == null) return;
XModelObject[] ms = web.getChildren();
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/handlers/RenameFolderHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/handlers/RenameFolderHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/handlers/RenameFolderHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -16,6 +16,7 @@
import org.eclipse.core.runtime.Path;
import org.jboss.tools.common.meta.action.impl.handlers.DefaultEditHandler;
import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.impl.FolderImpl;
@@ -25,22 +26,22 @@
FolderImpl f = (FolderImpl)object;
f.save();
Properties p = extractProperties(data[0]);
- String name = p.getProperty("name");
+ String name = p.getProperty(XModelObjectConstants.ATTR_NAME);
rename0(f, name);
f.save();
}
void rename0(FolderImpl f, String name) throws XModelException {
IFolder folder = (IFolder)f.getResource();
- String n1 = f.get("NAME");
- f.set("NAME", name);
- String n2 = f.get("NAME");
+ String n1 = f.get(XModelObjectConstants.XML_ATTR_NAME);
+ f.set(XModelObjectConstants.XML_ATTR_NAME, name);
+ String n2 = f.get(XModelObjectConstants.XML_ATTR_NAME);
if(!n2.equals(n1)) {
try {
- folder.move(new Path(folder.getParent().getFullPath() + "/" + name), true,
null);
+ folder.move(new Path(folder.getParent().getFullPath() +
XModelObjectConstants.SEPARATOR + name), true, null);
f.setModified(true);
} catch (CoreException e) {
- f.set("NAME", n1);
+ f.set(XModelObjectConstants.XML_ATTR_NAME, n1);
throw new XModelException(e);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/CloseProjectHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/CloseProjectHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/CloseProjectHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -14,6 +14,7 @@
import org.eclipse.core.resources.IProject;
import org.jboss.tools.common.model.plugin.ModelPlugin;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.actions.CloseResourceAction;
@@ -30,7 +31,7 @@
public void executeHandler(XModelObject object, Properties p) throws XModelException
{
- IProject project =
(IProject)object.getModel().getProperties().get("project");
+ IProject project = EclipseResourceUtil.getProject(object);
if (project != null)
{
CloseResourceAction closeAction = new
CloseResourceAction(ModelPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell());
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/DeleteProjectHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/DeleteProjectHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/DeleteProjectHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -18,7 +18,9 @@
import org.jboss.tools.common.meta.action.impl.AbstractHandler;
import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.plugin.ModelPlugin;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
public class DeleteProjectHandler extends AbstractHandler
{
@@ -29,14 +31,14 @@
public void executeHandler(XModelObject object, Properties p) throws XModelException
{
- IProject project =
(IProject)object.getModel().getProperties().get("project");
+ IProject project = EclipseResourceUtil.getProject(object);
if (project != null)
{
DeleteResourceAction deleteAction = new
DeleteResourceAction(ModelPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell());
deleteAction.selectionChanged(new StructuredSelection(project));
deleteAction.run();
if(!project.exists()) {
- XActionInvoker.invoke("Registration.UnregisterInServerXML",
object.getModel().getByPath("FileSystems"), null);
+ XActionInvoker.invoke("Registration.UnregisterInServerXML",
FileSystemsHelper.getFileSystems(object.getModel()), null);
}
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/OpenJavaEditorHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/OpenJavaEditorHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/OpenJavaEditorHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -26,6 +26,7 @@
import org.jboss.tools.common.meta.action.impl.AbstractHandler;
import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
@@ -35,13 +36,13 @@
}
public void executeHandler(XModelObject object, Properties p) throws XModelException {
- IProject project =
(IProject)object.getModel().getProperties().get("project");
+ IProject project = EclipseResourceUtil.getProject(object);
try {
IJavaProject javaProject = (IJavaProject)project.getNature(JavaCore.NATURE_ID);
String className =
EclipseResourceUtil.getJavaClassQualifiedName(object).replace('.',
'/') +
- "." + object.getAttributeValue("extension");
+ "." + object.getAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION);
IJavaElement javaElement = javaProject.findElement(new Path(className));
if(javaElement != null) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RefreshProjectHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RefreshProjectHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RefreshProjectHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -20,6 +20,7 @@
import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.plugin.ModelPlugin;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
public class RefreshProjectHandler extends AbstractHandler
@@ -31,7 +32,7 @@
public void executeHandler(XModelObject object, Properties p) throws XModelException
{
- IProject project =
(IProject)object.getModel().getProperties().get("project");
+ IProject project = EclipseResourceUtil.getProject(object);
if (project != null)
{
RefreshAction refreshAction = new
RefreshAction(ModelPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell());
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RemoveModelNatureHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RemoveModelNatureHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RemoveModelNatureHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -42,18 +42,14 @@
return true;
}
- private IProject getProject(XModelObject object) {
- return (object == null) ? null :
(IProject)object.getModel().getProperties().get("project");
- }
-
private String getNature(XModelObject object) {
- IProject p = getProject(object);
+ IProject p = EclipseResourceUtil.getProject(object);
IModelNature n = EclipseResourceUtil.getModelNature(p);
return n == null ? null : n.getID();
}
public void executeHandler(XModelObject object, Properties p) throws XModelException {
- IProject project = getProject(object);
+ IProject project = EclipseResourceUtil.getProject(object);
String nature = (p == null) ? null : p.getProperty("nature");
if(nature == null) nature = getNature(object);
if (project == null || nature == null) return;
@@ -104,7 +100,7 @@
}
private void removeFiles(String location, String workspace) {
- File f = new File(location + "/" + IModelNature.PROJECT_FILE);
+ File f = new File(location + XModelObjectConstants.SEPARATOR +
IModelNature.PROJECT_FILE);
if(f.exists()) f.delete();
}
@@ -171,8 +167,8 @@
XAction action =
XActionInvoker.getAction("Registration.UnregisterInServerXML", fs);
if(action != null) {
Properties runningProperties = new Properties();
- runningProperties.setProperty("unregisterFromAllServers",
"true");
- runningProperties.setProperty("showResult", "false");
+ runningProperties.setProperty("unregisterFromAllServers",
XModelObjectConstants.TRUE);
+ runningProperties.setProperty("showResult", XModelObjectConstants.FALSE);
XActionInvoker.invoke("Registration.UnregisterInServerXML", fs,
runningProperties);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/GifIcon.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/GifIcon.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/GifIcon.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -22,7 +22,7 @@
public int getHash(XModelObject obj) {
String p = obj.getPath();
- if(p == null) p = obj.getAttributeValue("name");
+ if(p == null) p = obj.getAttributeValue(XModelObjectConstants.ATTR_NAME);
return (p == null) ? 0 : p.hashCode();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/ModifiersIcon.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/ModifiersIcon.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/ModifiersIcon.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -88,7 +88,7 @@
private boolean isShowingModifiers(XModelObject obj) {
XModelObject o = obj.getModel().getRoot("Preferences");
- return (o == null) ? true : "yes".equals(o.getAttributeValue("show
modifiers"));
+ return (o == null) ? true :
XModelObjectConstants.YES.equals(o.getAttributeValue("show modifiers"));
}
private Image getModifiersIcon(int access, boolean isStatic, int override) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/CustomizedObjectImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/CustomizedObjectImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/CustomizedObjectImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -11,6 +11,7 @@
package org.jboss.tools.common.model.impl;
import org.jboss.tools.common.meta.XAttribute;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.plugin.ModelPlugin;
public class CustomizedObjectImpl extends RegularObjectImpl {
@@ -21,7 +22,7 @@
if(attribute != null) return attribute;
XAttribute[] as = getModelEntity().getAttributes();
for (int i = 0; i < as.length; i++) {
- if("true".equals(as[i].getProperty("id"))) {
+ if(XModelObjectConstants.TRUE.equals(as[i].getProperty("id"))) {
attribute = as[i].getName();
return attribute;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/OpenedProjectsImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/OpenedProjectsImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/OpenedProjectsImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -27,7 +27,7 @@
boolean reopen = (c != null);
if(!reopen) {
Properties p = new Properties();
- p.setProperty("name", name);
+ p.setProperty(XModelObjectConstants.ATTR_NAME, name);
c = getModel().createModelObject("Workspace", p);
addChild_0(c);
}
@@ -43,7 +43,7 @@
XModelObject[] os = children.getObjects();
if(os.length > MAX_PROJECT_COUNT)
for (int q = MAX_PROJECT_COUNT; q < os.length; q++)
os[q].removeFromParent();
- set("OPEN", "yes");
+ set("OPEN", XModelObjectConstants.YES);
}
public XModelObject getChildByFile(String name) {
@@ -52,7 +52,7 @@
name = name.replace('\\', '/');
XModelObject[] os = children.getObjects();
for (int i = 0; i < os.length; i++) {
- String p = XModelObjectUtil.getExpandedValue(os[i], "name", null);
+ String p = XModelObjectUtil.getExpandedValue(os[i],
XModelObjectConstants.ATTR_NAME, null);
p = FilePathHelper.toPathPath(p);
if(name.equals(p.replace('\\', '/'))) return os[i];
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/PropertyObjectImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/PropertyObjectImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/PropertyObjectImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.common.model.impl;
+import org.jboss.tools.common.model.XModelObjectConstants;
+
public class PropertyObjectImpl extends RegularObjectImpl {
private static final long serialVersionUID = 1L;
static int MAX_VISIBLE_VALUE_LENGTH = 25;
@@ -18,14 +20,14 @@
public String getPathPart() {
String name = name();
- if(name == null || !"no".equals(get("ENABLED"))) return
super.getPathPart();
+ if(name == null || !XModelObjectConstants.NO.equals(get("ENABLED")))
return super.getPathPart();
return "#" + name + '=' + get("VALUE");
}
public String getPresentationString() {
String name = name();
if(name == null) return "";
- if("no".equals(get("ENABLED"))) name = "#" + name;
+ if(XModelObjectConstants.NO.equals(get("ENABLED"))) name =
"#" + name;
String value = get("VALUE");
if(value == null) value = "";
if(value.indexOf("\n") >= 0) value = value.substring(0,
value.indexOf("\n")) + "...";
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/RegularObjectImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/RegularObjectImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/RegularObjectImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -31,7 +31,7 @@
}
public String name() {
- return get("NAME");
+ return get(XModelObjectConstants.XML_ATTR_NAME);
}
protected void onSetEntity(String name) {
@@ -139,7 +139,7 @@
}
private static String title(XModelObject o) {
- return o.getAttributeValue("element type") + " " +
+ return o.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE) + "
" +
o.getModelEntity().getRenderer().getTitle(o);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/WorkspaceObjectImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/WorkspaceObjectImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/WorkspaceObjectImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.model.impl;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.util.XModelObjectUtil;
public class WorkspaceObjectImpl extends RegularObjectImpl {
@@ -18,7 +19,7 @@
public WorkspaceObjectImpl() {}
public String getPresentationString() {
- return XModelObjectUtil.getExpandedValue(this, "name", null);
+ return XModelObjectUtil.getExpandedValue(this, XModelObjectConstants.ATTR_NAME,
null);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -23,6 +23,7 @@
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.osgi.util.NLS;
import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.meta.XMapping;
import org.jboss.tools.common.meta.XModelEntity;
@@ -36,6 +37,7 @@
import org.jboss.tools.common.model.XModelBuffer;
import org.jboss.tools.common.model.XModelConstants;
import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.XModelTransferBuffer;
import org.jboss.tools.common.model.event.XModelChangeManager;
@@ -47,11 +49,11 @@
import org.jboss.tools.common.model.loaders.EntityRecognizer;
import org.jboss.tools.common.model.loaders.XObjectLoader;
import org.jboss.tools.common.model.loaders.impl.ModelEntityRecognizer;
+import org.jboss.tools.common.model.plugin.ModelMessages;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.undo.XChangeUndo;
import org.jboss.tools.common.model.undo.XUndoManager;
import org.jboss.tools.common.model.util.ModelFeatureFactory;
-import org.jboss.tools.common.model.util.XBundle;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
import org.jboss.tools.common.util.FileUtil;
@@ -69,14 +71,14 @@
private FileSystemPeer fileregistry = new FileSystemPeer();
private PrintWriter out = new PrintWriter(System.out, true);
private HashMap<String,XModelObject> extraroots = new
HashMap<String,XModelObject>(2);
- private String rootEntity = "Root";
+ private String rootEntity = XModelObjectConstants.ROOT_OBJECT;
public XModelImpl(Properties properties, XModelMetaData metadata) {
this.metadata = metadata;
this.properties = properties;
recognizer.setMetaData(metadata);
- if(properties.getProperty("rootEntity") != null) {
- rootEntity = properties.getProperty("rootEntity");
+ if(properties.getProperty(XModelObjectConstants.PROP_ROOT_ENTITY) != null) {
+ rootEntity = properties.getProperty(XModelObjectConstants.PROP_ROOT_ENTITY);
}
XModelConstants.validate(this);
}
@@ -154,7 +156,7 @@
XModelObject r = extraroots.get(path.substring(0, i));
return (r == null) ? null : r.getChildByPath(path.substring(i + 1));
}
- if(path.startsWith("/")) {
+ if(path.startsWith(XModelObjectConstants.SEPARATOR)) {
return getByPathInFileSystem(path.substring(1));
} else if(path.startsWith("%")) {
int i = path.indexOf("%"), j = path.lastIndexOf("%");
@@ -175,14 +177,14 @@
public static XModelObject getByRelativePath(XModel model, String path) {
XModelObject o = null;
- if(path != null && path.startsWith("/")) {
+ if(path != null && path.startsWith(XModelObjectConstants.SEPARATOR)) {
XModelObject wr = FileSystemsHelper.getWebRoot(model);
if(wr != null) o = wr.getChildByPath(path.substring(1));
}
if(o == null) o = model.getByPath(path);
- if(o == null || !path.startsWith("/")) return o;
+ if(o == null || !path.startsWith(XModelObjectConstants.SEPARATOR)) return o;
XModelObject p = o;
- while(p != null &&
!"true".equals(p.get("overlapped"))) p = p.getParent();
+ while(p != null &&
!XModelObjectConstants.TRUE.equals(p.get("overlapped"))) p = p.getParent();
if(p == null) return o;
path = o.getPath().substring(p.getPath().length());
if(p.getModelEntity().getName().equals("FileFolder")) {
@@ -203,7 +205,7 @@
if(!(p instanceof FileSystemImpl)) return null;
String loc = ((FileSystemImpl)p).getAbsoluteLocation().replace('\\',
'/');
XModelObject fs = FileSystemsHelper.getFileSystems(folder.getModel());
- XModelObject[] cs = fs.getChildren("FileSystemFolder");
+ XModelObject[] cs =
fs.getChildren(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER);
for (int i = 0; i < cs.length; i++) {
if(!(cs[i] instanceof FileSystemImpl)) continue;
String loci =
((FileSystemImpl)cs[i]).getAbsoluteLocation().replace('\\', '/');
@@ -213,7 +215,7 @@
}
public XModelObject getByPathInFileSystem(String path) {
- XModelObject fs = getByPath("FileSystems");
+ XModelObject fs = getByPath(FileSystemsHelper.FILE_SYSTEMS);
if(fs == null) return null;
XModelObject[] cs = fs.getChildren();
for (int i = 0; i < cs.length; i++) {
@@ -228,7 +230,7 @@
static void creationFailed(String entity, String cause) {
if(!unknownEntities.contains(entity)) {
unknownEntities.add(entity);
- String message = XBundle.getInstance().getMessage("model", cause, new
Object[]{entity});
+ String message = NLS.bind(cause, new Object[]{entity});
ModelPlugin.getPluginLog().logInfo(message);
}
}
@@ -239,12 +241,12 @@
}
XModelEntity ent = getMetaData().getEntity(entity);
if(ent == null) {
- creationFailed(entity, "UNKNOUN_ENTITY");
+ creationFailed(entity, ModelMessages.UNKNOUN_ENTITY);
return null;
}
XModelObjectImpl me = (XModelObjectImpl)ent.getObjectImplementation();
if(me == null) {
- creationFailed(entity, "CREATION_ENTITY_FAILURE");
+ creationFailed(entity, ModelMessages.CREATION_ENTITY_FAILURE);
return null;
}
@@ -286,7 +288,7 @@
if(a.isTrimmable() && value != null) value = value.trim();
String ov = object.getAttributeValue(attributeName);
ov = (ov == null) ? "" : ov;
- if(value.length() == 0 &&
"true".equals(a.getProperty("required"))) {
+ if(value.length() == 0 &&
XModelObjectConstants.TRUE.equals(a.getProperty("required"))) {
String mes = "Attribute " + a.getName() + " is required.";
return mes;
}
@@ -296,9 +298,7 @@
? ((XAttributeConstraintV)c).getError(value, object)
: c.getError(value);
if(error != null) {
- String mes = XBundle.getInstance().getMessage("model",
- "SET_ATTRIBUTE_FAILURE",
- new Object[]{attributeName, value, error});
+ String mes = NLS.bind(ModelMessages.SET_ATTRIBUTE_FAILURE, new
Object[]{attributeName, value, error});
return mes;
}
}
@@ -314,7 +314,7 @@
String ov = object.getAttributeValue(attributeName);
ov = (ov == null) ? "" : ov;
if(!isDifferent(ov, value)) return;
- if(value.length() == 0 &&
"true".equals(a.getProperty("required"))) {
+ if(value.length() == 0 &&
XModelObjectConstants.TRUE.equals(a.getProperty("required"))) {
String mes = "Attribute " + a.getName() + " is required.";
service.showDialog("Error",
mes, new String[]{"OK"}, null, ServiceDialog.ERROR);
@@ -327,16 +327,14 @@
: c.getError(value);
if(error != null) {
if(edit) {
- String mes = XBundle.getInstance().getMessage("model",
- "SET_ATTRIBUTE_FAILURE",
- new Object[]{attributeName, value, error});
+ String mes = NLS.bind(ModelMessages.SET_ATTRIBUTE_FAILURE, new
Object[]{attributeName, value, error});
if(service != null) {
XEntityData data = XEntityDataImpl.create(new String[][]{
- {object.getModelEntity().getName(), "yes"},
- {attributeName, "no"}
+ {object.getModelEntity().getName(), XModelObjectConstants.YES},
+ {attributeName, XModelObjectConstants.NO}
});
data.setValue(attributeName, value);
- int q = service.showDialog("Error", mes, new
String[]{"Finish", "Cancel"}, data, ServiceDialog.ERROR);
+ int q = service.showDialog(ModelMessages.Error, mes, new
String[]{ModelMessages.Finish, ModelMessages.Cancel}, data, ServiceDialog.ERROR);
if(q != 0) return;
changeObjectAttribute(object, attributeName,
data.getValue(attributeName), true);
}
@@ -414,9 +412,9 @@
////ProjectWatcher
private void loadWatcher() {
- if(getProperties().get("project") == null) return;
+ if(getProperties().get(XModelObjectConstants.PROJECT) == null) return;
XObjectLoader l =
(XObjectLoader)ModelFeatureFactory.getInstance().createFeatureInstance("org.jboss.tools.common.model.project.WatcherLoader");
- XModelObject fs = getByPath("FileSystems");
+ XModelObject fs = getByPath(FileSystemsHelper.FILE_SYSTEMS);
if(l != null && fs != null) l.load(fs);
}
@@ -460,7 +458,7 @@
public void save() {
XModelObject r = getRoot();
- r.set("isSaveOn", "true");
+ r.set("isSaveOn", XModelObjectConstants.TRUE);
XModelObjectLoaderUtil.getObjectLoader(r).save(r);
r.set("isSaveOn", "");
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -29,6 +29,7 @@
import org.jboss.tools.common.meta.XModelEntity;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.adapter.IModelObjectAdapter;
import org.jboss.tools.common.model.adapter.ModelObjectAdapterExtensionPoint;
@@ -279,7 +280,7 @@
if(getParent() == null) return null;
String p = parent.getLongPath();
return (p == null) ? null : (p.length() == 0)
- ? getPathPart() : p + "/" + getPathPart();
+ ? getPathPart() : p + XModelObjectConstants.SEPARATOR +
getPathPart();
}
public String getPath() {
@@ -302,7 +303,7 @@
}
public XModelObject getChildByPath(String path) {
- int i = path.indexOf("/");
+ int i = path.indexOf(XModelObjectConstants.SEPARATOR);
String n = (i < 0) ? path : path.substring(0, i);
String f = (i < 0) ? "" : path.substring(i + 1);
XModelObject me = getChildByPathPart(n);
@@ -392,8 +393,8 @@
}
protected String name() {
- XAttribute a = getModelEntity().getAttribute("name");
- return (a != null) ? getAttributeValue("name") :
getModelEntity().getName();
+ XAttribute a = getModelEntity().getAttribute(XModelObjectConstants.ATTR_NAME);
+ return (a != null) ? getAttributeValue(XModelObjectConstants.ATTR_NAME) :
getModelEntity().getName();
}
public String getMainIconName() {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/AllResourcesTree.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/AllResourcesTree.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/AllResourcesTree.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -98,7 +98,7 @@
IResource resource = (IResource)object.getAdapter(IResource.class);
if(resource == null) {
XFilteredTree tree = getSubTree(object.getModel());
- return "/" +
((IProject)object.getModel().getProperties().get("project")).getName() +
"/" + tree.getValue(object);
+ return XModelObjectConstants.SEPARATOR +
EclipseResourceUtil.getProject(object).getName() + XModelObjectConstants.SEPARATOR +
tree.getValue(object);
}
return (resource == null) ? "" : resource.getFullPath().toString();
}
@@ -135,7 +135,7 @@
protected abstract XFilteredTree createProjectTree();
private XFilteredTree getSubTree(XModel model) {
- return
trees.get(((IProject)model.getProperties().get("project")).getName());
+ return
trees.get(((IProject)model.getProperties().get(XModelObjectConstants.PROJECT)).getName());
}
public XModelObject find(String value) {
@@ -145,7 +145,7 @@
XFilteredTree tree = trees.get(pn);
return (tree == null) ? null :
tree.getRoot().getModel().getByPath(value.substring(value.indexOf("//") + 1));
}
- if(value.indexOf("/", 1) < 0) return null;
+ if(value.indexOf(XModelObjectConstants.SEPARATOR, 1) < 0) return null;
IResource r = ModelPlugin.getWorkspace().getRoot().getFolder(new Path(value));
if(r == null || !r.exists()) {
//we can have both folders and files in tree
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/DefaultSubTree.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/DefaultSubTree.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/DefaultSubTree.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -39,7 +39,7 @@
public String getValue(XModelObject object) {
if(object == root) return "";
- String sr = root.getPath() + "/";
+ String sr = root.getPath() + XModelObjectConstants.SEPARATOR;
String so = object.getPath();
return (so.startsWith(sr)) ? so.substring(sr.length()) : so;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/FileSystemResourceBundleTree.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/FileSystemResourceBundleTree.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/FileSystemResourceBundleTree.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -12,6 +12,7 @@
import java.util.*;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelObjectConstants;
public class FileSystemResourceBundleTree extends FileSystemResourceTree {
@@ -31,7 +32,7 @@
public XModelObject find(String value) {
return (value == null || value.length() == 0) ? null :
- model.getByPath("/" + value.replace('.', '/') +
".properties");
+ model.getByPath(XModelObjectConstants.SEPARATOR + value.replace('.',
'/') + ".properties");
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/FileSystemResourceTree.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/FileSystemResourceTree.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/FileSystemResourceTree.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -62,7 +62,7 @@
while(st.hasMoreTokens()) entities.add(st.nextToken());
}
String jro = tc.getProperties().getProperty("java_roots_only");
- if("true".equals(jro)) {
+ if(XModelObjectConstants.TRUE.equals(jro)) {
javaRootsOnly = true;
}
}
@@ -115,7 +115,7 @@
protected boolean accepts0(XModelObject o) {
int type = o.getFileType();
- if(type == XModelObject.FOLDER) return
!"true".equals(o.get("overlapped"));
+ if(type == XModelObject.FOLDER) return
!XModelObjectConstants.TRUE.equals(o.get("overlapped"));
if(type != XModelObject.FILE) return false;
String pathpart = o.getPathPart();
String pp = pathpart.substring(pathpart.lastIndexOf('.') + 1);
@@ -131,8 +131,8 @@
SortedMap<String,XModelObject> t = new
TreeMap<String,XModelObject>();
for (int i = 0; i < fs.length; i++) {
if(javaRootsOnly) {
- if("FileSystemFolder".equals(fs[i].getModelEntity().getName())
- &&
!fs[i].getAttributeValue("name").startsWith("src")) {
+
if(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER.equals(fs[i].getModelEntity().getName())
+ &&
!fs[i].getAttributeValue(XModelObjectConstants.ATTR_NAME).startsWith("src")) {
continue;
}
}
@@ -151,7 +151,7 @@
private XModelObject[] getChildrenInFileSystems(XModelObject object) {
String path = getPath(object);
- if(path.startsWith("/")) path = path.substring(1);
+ if(path.startsWith(XModelObjectConstants.SEPARATOR)) path = path.substring(1);
XModelObject[] fs = getRoot().getChildren();
SortedMap<String,XModelObject> t = new
TreeMap<String,XModelObject>();
for (int i = 0; i < fs.length; i++) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/FileSystemsTree.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/FileSystemsTree.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/FileSystemsTree.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -15,6 +15,7 @@
import org.jboss.tools.common.model.*;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.*;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.filesystems.impl.*;
public class FileSystemsTree extends DefaultSiftedTree {
@@ -40,7 +41,7 @@
}
public XModelObject getRoot() {
- return model.getByPath("FileSystems");
+ return FileSystemsHelper.getFileSystems(model);
}
private void load() {
@@ -69,7 +70,7 @@
}
public boolean hasChildren(XModelObject object) {
-/// if(object.getFileType() == XModelObject.FILE &&
"yes".equals(object.get("_hasErrors_"))) return false;
+/// if(object.getFileType() == XModelObject.FILE &&
XModelObjectConstants.YES.equals(object.get("_hasErrors_"))) return false;
for (int i = 0; i < constraints.length; i++)
if(constraints[i].isHidingAllChildren(object)) return false;
return super.hasChildren(object);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/OptionsTree.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/OptionsTree.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/OptionsTree.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -11,6 +11,7 @@
package org.jboss.tools.common.model.impl.trees;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.options.SharableConstants;
public class OptionsTree extends DefaultSiftedTree {
@@ -19,7 +20,7 @@
public void dispose() {}
public XModelObject getRoot() {
- return model.getRoot("Options");
+ return model.getRoot(SharableConstants.OPTIONS);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/java/handlers/OpenJavaSourceHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/java/handlers/OpenJavaSourceHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/java/handlers/OpenJavaSourceHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -20,6 +20,7 @@
import org.eclipse.ui.*;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.plugin.ModelMessages;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.meta.action.impl.*;
@@ -68,19 +69,19 @@
}
public static void open(XModel model, String type, Properties p) throws
XModelException, CoreException {
- IProject project = (IProject)model.getProperties().get("project");
+ IProject project = (IProject)model.getProperties().get(XModelObjectConstants.PROJECT);
IJavaProject javaProject = (IJavaProject)project.getNature(JavaCore.NATURE_ID);
IJavaElement javaElement = javaProject.findElement(new Path(type));
if (javaElement == null) {
String message = "Cannot find java source.";
- if(p != null &&
"true".equals(p.getProperty("ignoreWarning"))) {
+ if(p != null &&
XModelObjectConstants.TRUE.equals(p.getProperty("ignoreWarning"))) {
p.setProperty("error", message);
} else {
ServiceDialog d = model.getService();
- d.showDialog("Warning", message, new String[]{"Close"}, null,
ServiceDialog.WARNING);
+ d.showDialog(ModelMessages.WARNING, message, new String[]{"Close"}, null,
ServiceDialog.WARNING);
}
} else {
- if(p != null &&
"true".equals(p.getProperty("onlySelectIfOpen"))) {
+ if(p != null &&
XModelObjectConstants.TRUE.equals(p.getProperty("onlySelectIfOpen"))) {
IEditorInput ii = EditorUtility.getEditorInput(javaElement);
IWorkbenchPage page = getWorkbenchPage();
if(page == null) return;
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/BodyLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/BodyLoader.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/BodyLoader.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -20,7 +20,7 @@
public void load(XModelObject object) {
String body = XModelObjectLoaderUtil.getTempBody(object);
- object.setAttributeValue("body", body);
+ object.setAttributeValue(XModelObjectConstants.ATTR_NAME_BODY, body);
}
public boolean update(XModelObject object) throws XModelException {
@@ -30,7 +30,7 @@
public boolean save(XModelObject object) {
if(!object.isModified()) return true;
- XModelObjectLoaderUtil.setTempBody(object,
object.getAttributeValue("body"));
+ XModelObjectLoaderUtil.setTempBody(object,
object.getAttributeValue(XModelObjectConstants.ATTR_NAME_BODY));
return true;
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/FileRootLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/FileRootLoader.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/FileRootLoader.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -45,7 +45,7 @@
}
public String fileroot(XModelObject object) {
- return XModelConstants.getHome(object.getModel()) + "/";
+ return XModelConstants.getHome(object.getModel()) +
XModelObjectConstants.SEPARATOR;
}
protected String fileName(XModelObject object) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/PropertiesLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/PropertiesLoader.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/PropertiesLoader.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -23,6 +23,7 @@
import org.jboss.tools.common.model.loaders.*;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
+import org.jboss.tools.common.model.event.XModelTreeEvent;
import org.jboss.tools.common.model.impl.*;
import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.util.FileUtil;
@@ -117,7 +118,7 @@
sb.setLength(0);
String value = properties.getProperty(visualName);
Properties p = new Properties();
- p.setProperty("name", visualName);
+ p.setProperty(XModelObjectConstants.ATTR_NAME, visualName);
p.setProperty("dirtyname", dirtyName);
p.setProperty("value", value);
@@ -184,9 +185,9 @@
name_value_separator = "=";
}
appendComments(sb, cs[i].get("COMMENTS"), cs[i].get("SEPARATOR"),
lineSeparator);
- if("no".equals(cs[i].get("ENABLED"))) sb.append('#');
+ if(XModelObjectConstants.NO.equals(cs[i].get("ENABLED")))
sb.append('#');
String dirtyname = cs[i].getAttributeValue("dirtyname");
- String name = EncodedProperties.saveConvert(cs[i].get("NAME"), true); //
convertName(cs[i].get("NAME"));
+ String name =
EncodedProperties.saveConvert(cs[i].get(XModelObjectConstants.XML_ATTR_NAME), true); //
convertName(cs[i].get(XModelObjectConstants.XML_ATTR_NAME));
String value = cs[i].get("VALUE");
String dirtyvalue = cs[i].getAttributeValue("dirtyvalue");
if(value == null || dirtyvalue == null || !value.equals(dirtyvalue.trim())) {
@@ -257,7 +258,12 @@
XModelObject c = object.copy(0);
XModelObjectLoaderUtil.setTempBody(c, body);
load(c);
- merge(object, c);
+ object.fireObjectChanged(XModelTreeEvent.BEFORE_MERGE);
+ try {
+ merge(object, c);
+ } finally {
+ object.fireObjectChanged(XModelTreeEvent.AFTER_MERGE);
+ }
}
private void merge(XModelObject o1, XModelObject o2) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/SimpleWebFileLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/SimpleWebFileLoader.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/SimpleWebFileLoader.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -58,8 +58,8 @@
loadNamespace(element, object);
//// String postfix = (namespace == null) ? "" : ":" +
namespace;
String postfix = "";
- element.setAttribute("NAME" + postfix,
object.getAttributeValue("name"));
- element.setAttribute("EXTENSION" + postfix,
object.getAttributeValue("extension"));
+ element.setAttribute(XModelObjectConstants.XML_ATTR_NAME + postfix,
object.getAttributeValue(XModelObjectConstants.ATTR_NAME));
+ element.setAttribute("EXTENSION" + postfix,
object.getAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION));
util.load(element, object);
String loadingError = util.getError();
@@ -71,7 +71,7 @@
((AbstractXMLFileImpl)object).setLoaderError(loadingError);
if(!((AbstractXMLFileImpl)object).isIncorrect() && loadingError != null) {
- object.setAttributeValue("isIncorrect", "yes");
+ object.setAttributeValue(XModelObjectConstants.ATTR_NAME_IS_INCORRECT,
XModelObjectConstants.YES);
object.setAttributeValue("incorrectBody", body);
object.set("actualBodyTimeStamp", "" + object.getTimeStamp());
}
@@ -83,13 +83,13 @@
String[] errors =
XMLUtil.getXMLErrors(new StringReader(body), resolution == EntityXMLRegistration.DTD,
resolution == EntityXMLRegistration.SCHEMA);
if(errors != null && errors.length > 0) {
- object.setAttributeValue("isIncorrect", "yes");
+ object.setAttributeValue(XModelObjectConstants.ATTR_NAME_IS_INCORRECT,
XModelObjectConstants.YES);
object.set("correctBody", "");
object.setAttributeValue("incorrectBody", body);
object.set("actualBodyTimeStamp", "-1");
// return;
} else {
- object.setAttributeValue("isIncorrect", "no");
+ object.setAttributeValue(XModelObjectConstants.ATTR_NAME_IS_INCORRECT,
XModelObjectConstants.NO);
object.set("correctBody", body);
object.set("actualBodyTimeStamp", "0");
object.setAttributeValue("incorrectBody", "");
@@ -156,11 +156,11 @@
public boolean save(XModelObject object) {
if (!object.isModified()) return true;
- if("yes".equals(object.get("isIncorrect"))) {
+
if(XModelObjectConstants.YES.equals(object.get(XModelObjectConstants.ATTR_NAME_IS_INCORRECT)))
{
XModelObjectLoaderUtil.setTempBody(object,
object.get("incorrectBody"));
return true;
}
- String main = object.get("body");
+ String main = object.get(XModelObjectConstants.ATTR_NAME_BODY);
if(main == null) return false;
XModelObjectLoaderUtil.setTempBody(object, main);
return true;
@@ -199,7 +199,7 @@
util.saveChildren(element, object);
util.saveFinalComment(element, object);
//// String postfix = (namespace == null) ? "" : ":" +
namespace;
- element.removeAttribute("NAME");
+ element.removeAttribute(XModelObjectConstants.XML_ATTR_NAME);
element.removeAttribute("EXTENSION");
return serialize(element, object);
} catch (IOException e) {
@@ -230,8 +230,8 @@
if("UTF-8".equals(encoding)) return null;
ServiceDialog d = object.getModel().getService();
XEntityData data = XEntityDataImpl.create(new String[][]{
- {object.getModelEntity().getName(), "yes"},
- {XModelObjectConstants.ATTR_NAME_ENCODING, "no"}
+ {object.getModelEntity().getName(), XModelObjectConstants.YES},
+ {XModelObjectConstants.ATTR_NAME_ENCODING, XModelObjectConstants.NO}
});
data.setValue(XModelObjectConstants.ATTR_NAME_ENCODING, "UTF-8");
String message = "Encoding " + encoding + " is not supported. Please
enter correct value.";
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/PreferenceModelUtilities.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/PreferenceModelUtilities.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/PreferenceModelUtilities.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -16,6 +16,7 @@
import org.jboss.tools.common.model.util.ModelFeatureFactory;
public class PreferenceModelUtilities {
+ static final String ENT_OPTION_ROOT = "OptionRoot";
private static class PreferenceModelHolder {
public static XModel preferenceModel;
@@ -44,7 +45,7 @@
public static XModel createPreferenceModel(Properties p) {
p.putAll(System.getProperties());
- p.setProperty("rootEntity", "OptionRoot");
+ p.setProperty(XModelObjectConstants.PROP_ROOT_ENTITY, ENT_OPTION_ROOT);
return XModelFactory.getModel(p);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/SharableConstants.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/SharableConstants.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/SharableConstants.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -11,15 +11,17 @@
package org.jboss.tools.common.model.options;
public interface SharableConstants {
- public String GENERAL = "general";
- public String PROJECT = "project";
+ public String GENERAL = "general"; //$NON-NLS-1$
+ public String PROJECT = "project"; //$NON-NLS-1$
public String[] LIST = {GENERAL, PROJECT};
- public String SCOPE = "SCOPE";
- public String XSTUDIO = "XStudio";
- public String GENERAL_FILE = "meta/ProgramSettingsDefault.xml";
+ public String SCOPE = "SCOPE"; //$NON-NLS-1$
+ public String XSTUDIO = "XStudio"; //$NON-NLS-1$
+ public String GENERAL_FILE = "meta/ProgramSettingsDefault.xml";
//$NON-NLS-1$
// public String PROJECT_PALETTE_FILE = "../../../config/Palette.xml";
// public String PROJECT_PREFERENCES_FILE = "../../../config/Preferences.xml";
- public String PROJECT_PALETTE_FILE = "Palette.xml";
- public String PROJECT_PREFERENCES_FILE = "Preferences.xml";
- public String[][] FILE_LIST = {{GENERAL_FILE}, {PROJECT_PALETTE_FILE,
PROJECT_PREFERENCES_FILE}};
+ public String PROJECT_PALETTE_FILE = "Palette.xml"; //$NON-NLS-1$
+ public String PROJECT_PREFERENCES_FILE = "Preferences.xml"; //$NON-NLS-1$
+ public String[][] FILE_LIST = {{GENERAL_FILE}, {PROJECT_PALETTE_FILE,
PROJECT_PREFERENCES_FILE}};
+
+ public String OPTIONS = "Options"; //$NON-NLS-1$
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/DeleteGroupHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/DeleteGroupHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/DeleteGroupHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -1,6 +1,7 @@
package org.jboss.tools.common.model.options.impl;
import org.jboss.tools.common.meta.action.impl.handlers.DefaultRemoveHandler;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
public class DeleteGroupHandler extends DefaultRemoveHandler {
@@ -11,7 +12,7 @@
if(!super.isEnabled(object)) return false;
if(!(object instanceof SharableElementImpl)) return false;
SharableElementImpl e = (SharableElementImpl)object;
- String name = e.getAttributeValue("name");
+ String name = e.getAttributeValue(XModelObjectConstants.ATTR_NAME);
if(!(e.getParent() instanceof SharableElementImpl)) return false;
SharableElementImpl p = (SharableElementImpl)e.getParent();
return p.canRemoveChild(name);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/HiddenPaletteTabsHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/HiddenPaletteTabsHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/HiddenPaletteTabsHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -47,12 +47,12 @@
private void collect(XModelObject object, String prefix,
Map<String,XModelObject> objects, List<String[]> dataList) {
XModelObject[] cs = object.getChildren();
for (int i = 0; i < cs.length; i++) {
- String path = prefix + "/" + cs[i].getAttributeValue("name");
+ String path = prefix + XModelObjectConstants.SEPARATOR +
cs[i].getAttributeValue(XModelObjectConstants.ATTR_NAME);
String hidden = cs[i].getAttributeValue("hidden");
- if(hidden == null) hidden = "no";
+ if(hidden == null) hidden = XModelObjectConstants.NO;
dataList.add(new String[]{path, hidden});
objects.put(path, cs[i]);
- String kind = cs[i].getAttributeValue("element type");
+ String kind = cs[i].getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE);
if("group".equals(kind)) collect(cs[i], path, objects, dataList);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableElementImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableElementImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableElementImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -165,7 +165,7 @@
int c = x.length() - 1;
return (c < 0) ? "" : x.substring(0, c);
}
- return ("NAME".equals(name)) ? name()
+ return (XModelObjectConstants.XML_ATTR_NAME.equals(name)) ? name()
: scope.getProperty(name);
}
@@ -181,7 +181,7 @@
} else if("sharing".equals(name)) {
setScopeExists(GENERAL, value.indexOf(GENERAL) >= 0);
setScopeExists(PROJECT, value.indexOf(PROJECT) >= 0);
- } else if("NAME".equals(name)) {
+ } else if(XModelObjectConstants.XML_ATTR_NAME.equals(name)) {
setName(value);
} else {
scope.setProperty(name, value);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -16,6 +16,7 @@
import org.jboss.tools.common.meta.XChild;
import org.jboss.tools.common.meta.XModelEntity;
import org.jboss.tools.common.model.XModelConstants;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.options.SharableConstants;
import org.jboss.tools.common.model.options.SharableElement;
import org.jboss.tools.common.model.plugin.ModelPlugin;
@@ -65,13 +66,13 @@
if(en == null) return;
XModelEntity ent = sharable.getModel().getMetaData().getEntity(en);
if(ent == null) return;
- boolean hasName = (ent.getAttribute("name") != null);
+ boolean hasName = (ent.getAttribute(XModelObjectConstants.ATTR_NAME) != null);
String name = (!hasName) ? element.getNodeName()
- : element.getAttribute("NAME");
+ : element.getAttribute(XModelObjectConstants.XML_ATTR_NAME);
SharableElement sc = sharable.findSharableChild(name);
if(sc == null) {
Properties p = new Properties();
- if(hasName) p.setProperty("name", name);
+ if(hasName) p.setProperty(XModelObjectConstants.ATTR_NAME, name);
sc = (SharableElement)sharable.getModel().createModelObject(en, p);
sc.setScopeExists(PROJECT, false);
sharable.addChild(sc);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/XStudioDataLoaderImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/XStudioDataLoaderImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/XStudioDataLoaderImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -83,7 +83,7 @@
private void saveProject() {
File[] fs = peer.getFilesForScope(PROJECT);
boolean isPaletteModified = studio.getChildByPath("Palette").isModified() ||
studio.getChildByPath("Icons").isModified();
- boolean isPreferencesModified =
studio.getChildByPath("Options").isModified();
+ boolean isPreferencesModified = studio.getChildByPath(OPTIONS).isModified();
if(!fs[0].exists() || isPaletteModified) savePalette(fs[0]);
if(!fs[1].exists() || isPreferencesModified) savePreferences(fs[1]);
}
@@ -97,8 +97,8 @@
private void savePreferences(File f) {
if(handleReadOnly(studio, LIST[1], f) != 0) return;
- save(studio, PROJECT, f, new String[]{"Options"});
- studio.getChildByPath("Options").setModified(false);
+ save(studio, PROJECT, f, new String[]{OPTIONS});
+ studio.getChildByPath(OPTIONS).setModified(false);
}
private void save(SharableElement q, String scopename, File f, String[] names) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/XStudioLoaderPeer.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/XStudioLoaderPeer.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/XStudioLoaderPeer.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -30,7 +30,7 @@
public void init(XModelObject studio) {
XModel model = studio.getModel();
- String r = XModelConstants.getWorkspace(model) + "/";
+ String r = XModelConstants.getWorkspace(model) + XModelObjectConstants.SEPARATOR;
for (int i = 0; i < LIST.length; i++) {
String[] fns = FILE_LIST[i];
File[] fs = new File[fns.length];
Added:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelMessages.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelMessages.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelMessages.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -0,0 +1,44 @@
+package org.jboss.tools.common.model.plugin;
+
+import org.eclipse.osgi.util.NLS;
+
+public class ModelMessages extends NLS {
+ private static final String BUNDLE_NAME =
"org.jboss.tools.common.model.plugin.messages";//$NON-NLS-1$
+
+ private ModelMessages() {}
+
+ public static String WARNING;
+
+ public static String UNKNOUN_ENTITY;
+ public static String CREATION_ENTITY_FAILURE;
+
+ public static String SET_ATTRIBUTE_FAILURE;
+ public static String CONSTRAINT_NOLOOP;
+ public static String CONSTRAINT_INTEGER;
+ public static String CONSTRAINT_NONEMPTY;
+ public static String CONSTRAINT_NO_JAVA_KEYWORD;
+ public static String CONSTRAINT_JAVA_NAME;
+ public static String CONSTRAINT_INTEGER_OR_LIST;
+ public static String CONSTRAINT_RED_HAT_TEMPLATE_NAME;
+ public static String CONSTRAINT_XML_NAME;
+ public static String CONSTRAINT_IS_NOT_IN_LIST;
+ public static String IS_A_RESERVED_WORD;
+
+ public static String ATTRIBUTE_REQUIRED;
+ public static String OBJECT_CREATION_FAILURE;
+ public static String OBJECT_ADDING_FAILURE;
+ public static String CONTAINS_OBJECT_1;
+ public static String CONTAINS_OBJECT_2;
+
+ public static String OK;
+ public static String Cancel;
+ public static String Finish;
+ public static String Error;
+ public static String Yes;
+ public static String No;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, ModelMessages.class);
+ }
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/XModelSaveParticipant.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/XModelSaveParticipant.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/XModelSaveParticipant.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -55,7 +55,7 @@
XModel[] ms = models.toArray(new XModel[0]);
ArrayList<XModelObject> l = new ArrayList<XModelObject>();
for (int i = 0; i < ms.length; i++) {
- IProject p = (IProject)ms[i].getProperties().get("project");
+ IProject p = (IProject)ms[i].getProperties().get(XModelObjectConstants.PROJECT);
if(p == null || !p.isOpen()) continue;
if(ms[i].getRoot().isModified()) {
XModelObject fs = FileSystemsHelper.getFileSystems(ms[i]);
Added:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/messages.properties
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/messages.properties
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/messages.properties 2009-06-19
15:44:59 UTC (rev 16067)
@@ -0,0 +1,34 @@
+WARNING=Warning
+
+#.model.impl.meta.constraints.*
+# used as parameter {2} of SET_ATTRIBUTE_FAILURE
+CONSTRAINT_NOLOOP = causes a loop of classes extending one another
+CONSTRAINT_INTEGER = must be an integer
+CONSTRAINT_NONEMPTY = cannot be empty
+CONSTRAINT_NO_JAVA_KEYWORD = is a Java keyword
+CONSTRAINT_JAVA_NAME = is not a Java name
+CONSTRAINT_INTEGER_OR_LIST = must be an integer or be selected from the list
+CONSTRAINT_RED_HAT_TEMPLATE_NAME = is not an Red Hat project template name
+CONSTRAINT_XML_NAME = is not xml name
+CONSTRAINT_IS_NOT_IN_LIST = is not the value of the list
+IS_A_RESERVED_WORD=is a reserved word
+
+#XModelImpl
+UNKNOUN_ENTITY = Unknown entity: {0}
+CREATION_ENTITY_FAILURE = Cannot create entity: {0}
+SET_ATTRIBUTE_FAILURE = Cannot set "{0}" = "{1}" because the value
{2}.
+
+#DefaultCreateHandler
+ATTRIBUTE_REQUIRED = Attribute {0} must be set.
+OBJECT_CREATION_FAILURE = Cannot create model object.
+OBJECT_ADDING_FAILURE = Cannot add new object to model.
+CONTAINS_OBJECT_1 = {0} already contains {1}.
+CONTAINS_OBJECT_2 = {0} contains {1},{2}{3} cannot be added.
+
+OK=OK
+Cancel=Cancel
+Finish=Finish
+Error=Error
+Yes=Yes
+No=No
+
Property changes on:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ClassPathUpdate.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ClassPathUpdate.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ClassPathUpdate.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -17,6 +17,7 @@
import org.eclipse.jdt.core.*;
import org.jboss.tools.common.meta.action.*;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.filesystems.impl.FileSystemsLoader;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.project.IModelNature;
@@ -129,7 +130,7 @@
if(objectPath.length() == 0) continue;
XModelObject srcObject = model.getByPath("FileSystems/" + objectPath);
if (srcObject == null) continue;
- String osPath = XModelObjectUtil.getExpandedValue(srcObject, "location",
null);
+ String osPath = XModelObjectUtil.getExpandedValue(srcObject,
XModelObjectConstants.ATTR_NAME_LOCATION, null);
if (osPath != null && !"".equals(osPath) &&
!set.contains(osPath)) {
srcPaths.add(osPath);
set.add(osPath);
@@ -152,7 +153,7 @@
XModelObject classesObject = model.getByPath("FileSystems/classes");
String classesPath = "";
if (classesObject != null)
- classesPath = XModelObjectUtil.getExpandedValue(classesObject, "location",
null);
+ classesPath = XModelObjectUtil.getExpandedValue(classesObject,
XModelObjectConstants.ATTR_NAME_LOCATION, null);
else if(classes != null)
classesPath = classes.toString();
@@ -188,14 +189,14 @@
}
private void addLibJars() {
- XModelObject fss = model.getByPath("FileSystems");
+ XModelObject fss = FileSystemsHelper.getFileSystems(model);
XModelObject[] children = fss == null ? new XModelObject[0] :
fss.getChildren("FileSystemJar");
List<String> srcPaths = new ArrayList<String>();
for (int i = 0; i < children.length; i++) {
- if("true".equals(children[i].get(FileSystemsLoader.IS_ADDED_TO_CLASSPATH)))
continue;
- String osPath = XModelObjectUtil.getExpandedValue(children[i], "location",
null);
+ if(XModelObjectConstants.TRUE.equals(children[i].get(FileSystemsLoader.IS_ADDED_TO_CLASSPATH)))
continue;
+ String osPath = XModelObjectUtil.getExpandedValue(children[i],
XModelObjectConstants.ATTR_NAME_LOCATION, null);
if (osPath != null && !"".equals(osPath) && new
File(osPath).isFile()) srcPaths.add(osPath);
- children[i].set(FileSystemsLoader.IS_ADDED_TO_CLASSPATH, "true");
+ children[i].set(FileSystemsLoader.IS_ADDED_TO_CLASSPATH, XModelObjectConstants.TRUE);
}
// Leave it to WTP
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ClassPathUpdateWizard.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ClassPathUpdateWizard.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ClassPathUpdateWizard.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -16,6 +16,7 @@
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.common.meta.action.SpecialWizard;
import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.plugin.ModelPlugin;
public class ClassPathUpdateWizard implements SpecialWizard {
@@ -25,7 +26,7 @@
u = new ClassPathUpdate();
Properties p = (Properties)object;
XModel model = (XModel)p.get("model");
- u.setProject((IProject)model.getProperties().get("project"));
+ u.setProject((IProject)model.getProperties().get(XModelObjectConstants.PROJECT));
u.setModel(model);
u.setReplacedSrc((Map)p.get("replacedSrc"));
IPath classes = (IPath)p.get("classes");
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/IPromptingProvider.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/IPromptingProvider.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/IPromptingProvider.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -12,6 +12,7 @@
import java.util.*;
import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObjectConstants;
public interface IPromptingProvider {
static String ERROR = "error";
@@ -25,7 +26,7 @@
static String TYPE = "type";
static String PROPERTY = "property";
static String MODEL_OBJECT_PATH = "model-path";
- static String NAME = "name";
+ static String NAME = XModelObjectConstants.ATTR_NAME;
static String ATTRIBUTE = "attribute";
static String LOCALE = "locale";
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -101,7 +101,7 @@
}
p.setProperty(ECLIPSE_PROJECT, project.getLocation().toString());
p.setProperty(ECLIPSE_PROJECT_OLD, project.getLocation().toString());
- p.put("project", project);
+ p.put(XModelObjectConstants.PROJECT, project);
p.setProperty("nature", getID());
model = (XModel)models.get(project);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ProjectHome.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ProjectHome.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ProjectHome.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -24,6 +24,7 @@
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.jboss.tools.common.model.XModelConstants;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.*;
import org.w3c.dom.Element;
@@ -44,8 +45,8 @@
public String getLocation(String projectLocation) {
String location = projectLocation;
- File f = new File(location + "/" + IModelNature.PROJECT_TEMP);
- File ep = new File(location + "/" + IModelNature.PROJECT_FILE);
+ File f = new File(location + XModelObjectConstants.SEPARATOR +
IModelNature.PROJECT_TEMP);
+ File ep = new File(location + XModelObjectConstants.SEPARATOR +
IModelNature.PROJECT_FILE);
if(ep.isFile()) {
// to remove .struts file
if(f.isFile()) f.delete();
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/Watcher.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/Watcher.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/Watcher.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -166,9 +166,9 @@
private void setCorrect(boolean correct) {
XModelObject fs = FileSystemsHelper.getFileSystems(model);
if(fs == null) return;
- boolean b = !"yes".equals(fs.get("_hasErrors_"));
+ boolean b = !XModelObjectConstants.YES.equals(fs.get("_hasErrors_"));
if(b == correct) return;
- fs.set("_hasErrors_", (correct) ? "" : "yes");
+ fs.set("_hasErrors_", (correct) ? "" : XModelObjectConstants.YES);
fs.fireObjectChanged("_hasErrors_");
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/WatcherLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/WatcherLoader.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/WatcherLoader.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -38,7 +38,7 @@
IProject p = EclipseResourceUtil.getProject(model.getRoot());
if(p == null) return false;
try {
- return "true".equals(p.getSessionProperty(LOCK));
+ return XModelObjectConstants.TRUE.equals(p.getSessionProperty(LOCK));
} catch(CoreException e) {
//ignore
return false;
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ext/store/XMLStoreConstants.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ext/store/XMLStoreConstants.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ext/store/XMLStoreConstants.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.common.model.project.ext.store;
+import org.jboss.tools.common.model.XModelObjectConstants;
+
/**
* @author Viacheslav Kabanovich
*/
@@ -29,7 +31,7 @@
public String ATTR_VALUE = "value";
public String ATTR_PATH = "path";
public String ATTR_CLASS = "class";
- public String ATTR_NAME = "name";
+ public String ATTR_NAME = XModelObjectConstants.ATTR_NAME;
public String ATTR_PROJECT = "project";
public String ATTR_TYPE = "type";
public String ATTR_PARAMS = "params";
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/search/impl/SearchConstraintImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/search/impl/SearchConstraintImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/search/impl/SearchConstraintImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -31,7 +31,7 @@
}
public void prepare() {
- not = "true".equals(getAttributeValue("not"));
+ not = XModelObjectConstants.TRUE.equals(getAttributeValue("not"));
SharableElement[] cs = getSharableChildren();
constraints = new SearchConstraint[cs.length];
for (int i = 0; i < cs.length; i++) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/search/impl/SearchConstraintValueImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/search/impl/SearchConstraintValueImpl.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/search/impl/SearchConstraintValueImpl.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -49,8 +49,8 @@
public void prepare() {
propertyname = getAttributeValue("property name");
propertyvalue = getAttributeValue("text to find");
- not = "true".equals(getAttributeValue("not"));
- ignorecase = "true".equals(getAttributeValue("ignore
case"));
+ not = XModelObjectConstants.TRUE.equals(getAttributeValue("not"));
+ ignorecase = XModelObjectConstants.TRUE.equals(getAttributeValue("ignore
case"));
if(ignorecase) propertyvalue = propertyvalue.toLowerCase();
String eq = getAttributeValue("equality");
equality = ("coincides".equals(eq)) ? 0 :
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/search/impl/SearchDefaultHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/search/impl/SearchDefaultHandler.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/search/impl/SearchDefaultHandler.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -12,6 +12,7 @@
import java.util.*;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.plugin.ModelMessages;
import org.jboss.tools.common.model.util.*;
import org.jboss.tools.common.meta.action.*;
import org.jboss.tools.common.meta.action.impl.*;
@@ -48,7 +49,7 @@
XModelObject sc = findOrCreateDefaultSearch(object, objects);
ServiceDialog d = model.getService();
XEntityData ed = getSearchEntityData(sc);
- int i = d.showDialog("Search", getDialogTitle(objects), new
String[]{"Ok", "Cancel"}, ed, ServiceDialog.QUESTION);
+ int i = d.showDialog("Search", getDialogTitle(objects), new
String[]{ModelMessages.OK, ModelMessages.Cancel}, ed, ServiceDialog.QUESTION);
if(i != 0) return null;
Properties p = DefaultCreateHandler.extractProperties(ed);
Enumeration en = p.keys();
@@ -73,7 +74,7 @@
sb.append(objects[i].getPath());
}
if(ds == null) {
- p.setProperty("name", "Default");
+ p.setProperty(XModelObjectConstants.ATTR_NAME, "Default");
p.setProperty("root", sb.toString());
ds = XModelObjectLoaderUtil.createValidObject(model,
"SearchCommand", p);
sr.addChild(ds);
@@ -87,7 +88,7 @@
v = match.getChildren(CONSTRAINT_ENTITY)[0];
} else {
p.clear();
- p.setProperty("name", "value constraint");
+ p.setProperty(XModelObjectConstants.ATTR_NAME, "value
constraint");
v = XModelObjectLoaderUtil.createValidObject(model, CONSTRAINT_ENTITY, p);
match.addChild(v);
match.setModified(true);
@@ -104,10 +105,10 @@
private XEntityData getSearchEntityData(XModelObject sc) {
XModelObject c = sc.getChildByPath("Match/value constraint");
- String[][] ds = new String[][]{{"SearchValue", "yes"},
- {"text to find", "yes"},
- {"property name", "no"},
- {"ignore case", "no"}};
+ String[][] ds = new String[][]{{"SearchValue",
XModelObjectConstants.YES},
+ {"text to find",
XModelObjectConstants.YES},
+ {"property name",
XModelObjectConstants.NO},
+ {"ignore case",
XModelObjectConstants.NO}};
XEntityData d = XEntityDataImpl.create(ds);
XAttributeData[] as = d.getAttributeData();
for (int i = 0; i < as.length; i++) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XChangeSetUndo.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XChangeSetUndo.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XChangeSetUndo.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -60,7 +60,7 @@
}
protected String createDescription(XModelObject o) {
- return o.getAttributeValue("element type") + " " +
+ return o.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE) + "
" +
o.getModelEntity().getRenderer().getTitle(o);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XChangeUndo.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XChangeUndo.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XChangeUndo.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -20,7 +20,7 @@
protected String createDescription(XModelObject o) {
return "'" + attr[0][0] + "' of " +
- o.getAttributeValue("element type") + " " +
+ o.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE) + "
" +
o.getModelEntity().getRenderer().getTitle(o);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XCreateUndo.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XCreateUndo.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XCreateUndo.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -23,9 +23,9 @@
this.model = parent.getModel();
parentpath = parent.getPath();
childpath = child.getPathPart();
- description = child.getAttributeValue("element type") + " "
+
+ description = child.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE) +
" " +
child.getModelEntity().getRenderer().getTitle(child) + " in
" +
- parent.getAttributeValue("element type") + " "
+
+ parent.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE) +
" " +
parent.getModelEntity().getRenderer().getTitle(parent);
String[] types = child.getModelEntity().getRenderer().getIconNames();
String iconType = types.length == 0 ? "main" :
child.getModelEntity().getRenderer().getIconNames()[0];
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XMoveUndo.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XMoveUndo.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XMoveUndo.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -24,7 +24,7 @@
path = object.getPath();
this.from = from;
this.to = to;
- op = object.getAttributeValue("element type") + " " +
+ op = object.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE) + "
" +
object.getModelEntity().getRenderer().getTitle(object);
resetDescription();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XRemoveUndo.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XRemoveUndo.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/undo/XRemoveUndo.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -24,9 +24,9 @@
parentpath = parent.getPath();
childpath = child.getPathPart();
this.child = child.copy(false);
- description = child.getAttributeValue("element type") + " "
+
+ description = child.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE) +
" " +
child.getModelEntity().getRenderer().getTitle(child) + " in
" +
- parent.getAttributeValue("element type") + " "
+
+ parent.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE) +
" " +
parent.getModelEntity().getRenderer().getTitle(parent);
String[] types = child.getModelEntity().getRenderer().getIconNames();
String iconType = types.length == 0 ? "main" :
child.getModelEntity().getRenderer().getIconNames()[0];
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/AccessibleJava.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/AccessibleJava.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/AccessibleJava.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -15,6 +15,7 @@
import java.util.jar.*;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.plugin.ModelPlugin;
public class AccessibleJava implements ISimpleTree {
@@ -104,12 +105,12 @@
private static String[] serviceroots = {"CVS/", "META-INF/",
".svn"};
private void register(String path, Map<String,SortedSet<String>> map) {
- if(path == null || path.indexOf("$") >= 0 ||
path.equals("/")) return;
+ if(path == null || path.indexOf("$") >= 0 ||
path.equals(XModelObjectConstants.SEPARATOR)) return;
for (int j = 0; j < serviceroots.length; j++)
if(path.indexOf(serviceroots[j]) >= 0) return;
- boolean isPackage = path.endsWith("/");
+ boolean isPackage = path.endsWith(XModelObjectConstants.SEPARATOR);
if(!(isPackage || path.endsWith(extension()))) return;
- if(path.startsWith("/")) path = path.substring(1);
+ if(path.startsWith(XModelObjectConstants.SEPARATOR)) path = path.substring(1);
path = path.substring(0, path.length() - ((isPackage) ? 1 :
6)).replace('/', '.');
register0(path, isPackage, map);
}
@@ -164,7 +165,7 @@
for (int i = 0; i < folders.length; i++) {
File[] fs = folders[i].listFiles();
if(fs != null) for (int j = 0; j < fs.length; j++) {
- if(fs[j].isDirectory()) register(fs[j].getName() + "/", map);
+ if(fs[j].isDirectory()) register(fs[j].getName() +
XModelObjectConstants.SEPARATOR, map);
}
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/BrowserHelper.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/BrowserHelper.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/BrowserHelper.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -15,6 +15,7 @@
import org.jboss.tools.common.model.*;
import org.jboss.tools.common.model.engines.impl.XProcess;
import org.jboss.tools.common.model.options.PreferenceModelUtilities;
+import org.jboss.tools.common.model.plugin.ModelMessages;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.meta.action.*;
import org.jboss.tools.common.meta.action.impl.*;
@@ -35,7 +36,7 @@
static boolean validatePath(ServiceDialog d, XModelObject o) {
String[] paths = getEnvironmentPaths();
String en = o.getModelEntity().getName();
- XEntityData[] dt = new XEntityData[]{XEntityDataImpl.create(new String[][]{{en,
"yes"}, {ATTRIBUTE, "yes"}})};
+ XEntityData[] dt = new XEntityData[]{XEntityDataImpl.create(new String[][]{{en,
XModelObjectConstants.YES}, {ATTRIBUTE, XModelObjectConstants.YES}})};
String path = o.getAttributeValue(ATTRIBUTE).replace('\\','/');
XAttributeData ad = HUtil.find(dt, 0, ATTRIBUTE);
ad.setValue(path);
@@ -54,7 +55,7 @@
ModelPlugin.getPluginLog().logError("BrowserHelper:" + e.getMessage());
}
int i = d.showDialog("Run", "Enter valid path for " +
o.getPresentationString(),
- new String[]{"OK", "Cancel"}, dt[0],
ServiceDialog.QUESTION);
+ new String[]{ModelMessages.OK, ModelMessages.Cancel}, dt[0],
ServiceDialog.QUESTION);
if(i != 0) return false;
}
}
@@ -71,7 +72,7 @@
filename = filename.replace('\\', '/');
if(paths == null || filename.indexOf('/') >= 0) return new
File(filename).isFile();
for (int i = 0; i < paths.length; i++) {
- String f = paths[i] + "/" + filename;
+ String f = paths[i] + XModelObjectConstants.SEPARATOR + filename;
if(new File(f).isFile()) return true;
}
return false;
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -45,11 +45,11 @@
public class EclipseResourceUtil {
public static IProject getProject(XModelObject o) {
- return (o == null) ? null :
(IProject)o.getModel().getProperties().get("project");
+ return (o == null) ? null :
(IProject)o.getModel().getProperties().get(XModelObjectConstants.PROJECT);
}
public static boolean isProjectFragment(XModel model) {
- return
("true".equals(model.getProperties().getProperty("isProjectFragment")));
+ return
(XModelObjectConstants.TRUE.equals(model.getProperties().getProperty("isProjectFragment")));
}
public static IResource getResource(XModelObject object) {
@@ -59,19 +59,19 @@
public static String getJavaClassQualifiedName(XModelObject object) {
if(object.getFileType() != XFileObject.FILE) return null;
- String ext = object.getAttributeValue("extension");
+ String ext = object.getAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION);
if(!"java".equals(ext) && !"class".equals(ext)) return
null;
- String q = object.getAttributeValue("name");
+ String q = object.getAttributeValue(XModelObjectConstants.ATTR_NAME);
String p = getJavaPackageName(object.getParent());
return (p == null) ? q : p + "." + q;
}
public static String getJavaPackageName(XModelObject object) {
if(object == null || object.getFileType() != XFileObject.FOLDER) return null;
- String q = object.getAttributeValue("name");
+ String q = object.getAttributeValue(XModelObjectConstants.ATTR_NAME);
XModelObject o = object.getParent();
while(o != null && o.getFileType() == XFileObject.FOLDER) {
- q = o.getAttributeValue("name") + "." + q;
+ q = o.getAttributeValue(XModelObjectConstants.ATTR_NAME) + "." + q;
o = o.getParent();
}
return q;
@@ -105,7 +105,7 @@
FileSystemsImpl fso = (FileSystemsImpl)FileSystemsHelper.getFileSystems(model);
if(fso == null) return null;
fso.updateOverlapped();
- XModelObject[] fs = fso.getChildren("FileSystemFolder");
+ XModelObject[] fs = fso.getChildren(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER);
for (int i = 0; i < fs.length; i++) {
FileSystemImpl s = (FileSystemImpl)fs[i];
XModelObject o = findResourceInFileSystem(s, resource);
@@ -163,16 +163,16 @@
} else {
fsLoc = getRelativeLocation(model, fsLoc);
}
- XModelObject[] cs = fss.getChildren("FileSystemFolder");
+ XModelObject[] cs = fss.getChildren(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER);
for (int i = 0; i < cs.length; i++) {
- String loc = cs[i].getAttributeValue("location");
+ String loc = cs[i].getAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION);
if(fsLoc.equals(loc)) return null;
}
- properties.setProperty("location", fsLoc);
+ properties.setProperty(XModelObjectConstants.ATTR_NAME_LOCATION, fsLoc);
String name = resource.getName();
name = XModelObjectUtil.createNewChildName(name, fss);
- properties.setProperty("name", name);
- FileSystemImpl s =
(FileSystemImpl)model.createModelObject("FileSystemFolder", properties);
+ properties.setProperty(XModelObjectConstants.ATTR_NAME, name);
+ FileSystemImpl s =
(FileSystemImpl)model.createModelObject(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER,
properties);
boolean b = fss.addChild(s);
if(b) {
fss.setModified(true);
@@ -201,7 +201,7 @@
public static boolean hasNature(XModel model, String nature) {
if(model == null) return false;
- IProject p = (IProject)model.getProperties().get("project");
+ IProject p = (IProject)model.getProperties().get(XModelObjectConstants.PROJECT);
if(p == null || !p.isOpen()) return false;
try {
if(p.hasNature(nature)) return true;
@@ -246,7 +246,7 @@
XModel model = n.getModel();
XModelObject object = model.getRoot();
if(object == null) return null;
- if(!"Root".equals(object.getModelEntity().getName())) return null;
+ if(!XModelObjectConstants.ROOT_OBJECT.equals(object.getModelEntity().getName())) return
null;
return n;
}
@@ -330,8 +330,8 @@
if(r == null) return null;
properties.setProperty(XModelConstants.WORKSPACE,
r.getParent().getLocation().toString());
properties.setProperty(IModelNature.ECLIPSE_PROJECT,
project.getLocation().toString());
- properties.put("project", project);
- properties.put("isProjectFragment", "true");
+ properties.put(XModelObjectConstants.PROJECT, project);
+ properties.put("isProjectFragment", XModelObjectConstants.TRUE);
model = XModelFactory.getModel(properties);
models.put(project, model);
@@ -345,17 +345,17 @@
properties = new Properties();
fsLoc = project.getLocation().toString();
- properties.setProperty("location", fsLoc);
- properties.setProperty("name", project.getName());
- s = (FileSystemImpl)model.createModelObject("FileSystemFolder", properties);
+ properties.setProperty(XModelObjectConstants.ATTR_NAME_LOCATION, fsLoc);
+ properties.setProperty(XModelObjectConstants.ATTR_NAME, project.getName());
+ s =
(FileSystemImpl)model.createModelObject(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER,
properties);
fs.addChild(s);
if(!isJar(resource)) {
IResource webRoot = getFirstWebContentResource(project);
if(webRoot != null && webRoot.exists() && webRoot != project) {
fsLoc = webRoot.getLocation().toString();
- properties.setProperty("location", fsLoc);
- properties.setProperty("name", "WEB-ROOT");
- s = (FileSystemImpl)model.createModelObject("FileSystemFolder",
properties);
+ properties.setProperty(XModelObjectConstants.ATTR_NAME_LOCATION, fsLoc);
+ properties.setProperty(XModelObjectConstants.ATTR_NAME, "WEB-ROOT");
+ s =
(FileSystemImpl)model.createModelObject(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER,
properties);
fs.addChild(s);
}
}
@@ -363,9 +363,9 @@
if(!isJar(resource) || getObjectByResource(model, resource) == null) {
properties = new Properties();
fsLoc = (r instanceof IFile) ? r.getParent().getLocation().toString() :
r.getLocation().toString();
- properties.setProperty("location", fsLoc);
- properties.setProperty("name", r.getName());
- s = (FileSystemImpl)model.createModelObject("FileSystemFolder",
properties);
+ properties.setProperty(XModelObjectConstants.ATTR_NAME_LOCATION, fsLoc);
+ properties.setProperty(XModelObjectConstants.ATTR_NAME, r.getName());
+ s =
(FileSystemImpl)model.createModelObject(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER,
properties);
fs.addChild(s);
}
@@ -379,9 +379,9 @@
if(!cs[i].isLinked()) continue;
properties = new Properties();
fsLoc = cs[i].getLocation().toString();
- properties.setProperty("location", fsLoc);
- properties.setProperty("name", cs[i].getName());
- s = (FileSystemImpl)model.createModelObject("FileSystemFolder",
properties);
+ properties.setProperty(XModelObjectConstants.ATTR_NAME_LOCATION, fsLoc);
+ properties.setProperty(XModelObjectConstants.ATTR_NAME, cs[i].getName());
+ s =
(FileSystemImpl)model.createModelObject(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER,
properties);
fs.addChild(s);
}
validateJarSystem(fs, resource);
@@ -409,8 +409,8 @@
String location = resource.getLocation().toString().replace('\\',
'/');
if(fs.getChildByPath(jsname) == null) {
XModelObject q = fs.getModel().createModelObject("FileSystemJar", null);
- q.setAttributeValue("name", jsname);
- q.setAttributeValue("location", location);
+ q.setAttributeValue(XModelObjectConstants.ATTR_NAME, jsname);
+ q.setAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION, location);
fs.addChild(q);
}
}
@@ -434,7 +434,7 @@
}
if(o == null) return null;
XModelObject p = o;
- while(p != null && !"true".equals(p.get("overlapped"))) p =
p.getParent();
+ while(p != null &&
!XModelObjectConstants.TRUE.equals(p.get("overlapped"))) p = p.getParent();
if(p == null) {
IResource r = (IResource)o.getAdapter(IResource.class);
if(r == null || !resource.getLocation().equals(r.getLocation())) {
@@ -447,7 +447,7 @@
public static boolean isOverlapped(XModelObject object) {
XModelObject p = object;
- while(p != null && !"true".equals(p.get("overlapped"))) p =
p.getParent();
+ while(p != null &&
!XModelObjectConstants.TRUE.equals(p.get("overlapped"))) p = p.getParent();
return (p != null);
}
@@ -463,7 +463,7 @@
properties.putAll(System.getProperties());
properties.setProperty(XModelConstants.WORKSPACE, f.getParent());
- properties.put("isProjectFragment", "true");
+ properties.put("isProjectFragment", XModelObjectConstants.TRUE);
XModel model = XModelFactory.getModel(properties);
XModelObject fs = FileSystemsHelper.getFileSystems(model);
if(fs == null) {
@@ -472,12 +472,12 @@
}
properties = new Properties();
String fsLoc = f.getParent();
- properties.setProperty("location", fsLoc);
- properties.setProperty("name", f.getParentFile().getName());
- FileSystemImpl s =
(FileSystemImpl)model.createModelObject("FileSystemFolder", properties);
+ properties.setProperty(XModelObjectConstants.ATTR_NAME_LOCATION, fsLoc);
+ properties.setProperty(XModelObjectConstants.ATTR_NAME, f.getParentFile().getName());
+ FileSystemImpl s =
(FileSystemImpl)model.createModelObject(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER,
properties);
fs.addChild(s);
String pp = FilePathHelper.toPathPath(f.getName());
- return model.getByPath("/" + pp);
+ return model.getByPath(XModelObjectConstants.SEPARATOR + pp);
}
public static String[] getJavaProjectSrcLocations(IProject project) {
@@ -551,7 +551,7 @@
String path = es[i].getPath().toString();
//First let's check if path is defined within Eclipse work space.
- if(path.startsWith("/") && path.indexOf("/", 1) > 1)
{
+ if(path.startsWith(XModelObjectConstants.SEPARATOR) &&
path.indexOf(XModelObjectConstants.SEPARATOR, 1) > 1) {
IResource findMember =
ResourcesPlugin.getWorkspace().getRoot().findMember(es[i].getPath());
if(findMember != null) {
s = findMember.getLocation().toString();
@@ -562,7 +562,7 @@
//If search in Eclipse work space has failed, this is a useless attempt, but
//let keep it just in case (this is good old code that worked for a long while).
- if(s == null && path.startsWith("/" + project.getName() +
"/")) {
+ if(s == null && path.startsWith(XModelObjectConstants.SEPARATOR +
project.getName() + XModelObjectConstants.SEPARATOR)) {
IResource findMember = project.findMember(es[i].getPath().removeFirstSegments(1));
if(findMember != null) {
s = findMember.getLocation().toString();
@@ -605,7 +605,7 @@
try {
String s = null;
String path = es[i].getPath().toString();
- if(path.startsWith("/" + project.getName() + "/")) {
//$NON-NLS-1$ //$NON-NLS-2$
+ if(path.startsWith(XModelObjectConstants.SEPARATOR + project.getName() +
XModelObjectConstants.SEPARATOR)) { //$NON-NLS-1$ //$NON-NLS-2$
s =
project.findMember(es[i].getPath().removeFirstSegments(1)).getLocation().toString();
} else if(new java.io.File(path).isFile()) {
s = path;
@@ -686,7 +686,7 @@
if(!relative.endsWith(".java")) return null;
relative = relative.substring(0, relative.length() - 5);
relative = relative.replace('\\', '/');
- if(relative.startsWith("/")) relative = relative.substring(1);
+ if(relative.startsWith(XModelObjectConstants.SEPARATOR)) relative =
relative.substring(1);
return relative.replace('/', '.');
}
@@ -702,7 +702,7 @@
IResource r = project.getWorkspace().getRoot().findMember(p);
if(r == null || r.getLocation() == null) return false;
String output = r.getLocation().toString();
- String f = output + "/" + className.replace('.', '/') +
".class";
+ String f = output + XModelObjectConstants.SEPARATOR + className.replace('.',
'/') + ".class";
return new java.io.File(f).isFile();
} catch (JavaModelException t) {
ModelPlugin.getPluginLog().logError("Error checking class " + className,
t);
@@ -816,10 +816,10 @@
public static URL getInstallURL(Bundle bundle) {
try {
- return bundle == null ? null : FileLocator.resolve(bundle.getEntry("/"));
+ return bundle == null ? null :
FileLocator.resolve(bundle.getEntry(XModelObjectConstants.SEPARATOR));
} catch (IOException e) {
//ignore and try to execute it in the other way
- return bundle.getEntry("/");
+ return bundle.getEntry(XModelObjectConstants.SEPARATOR);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/FindObjectHelper.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/FindObjectHelper.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/FindObjectHelper.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -50,11 +50,11 @@
}
public static String makeRef(XModelObject o) {
- return "" + o.getAttributeValue("element type") + "
" + makeRef(o.getPath(), o.getPresentationString());
+ return "" +
o.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE) + " " +
makeRef(o.getPath(), o.getPresentationString());
}
public static String makeRef(XModelObject o, int line) {
- return "" + o.getAttributeValue("element type") + "
" + makeRef(o.getPath() + ":" + line, o.getPresentationString());
+ return "" +
o.getAttributeValue(XModelObjectConstants.ATTR_ELEMENT_TYPE) + " " +
makeRef(o.getPath() + ":" + line, o.getPresentationString());
}
public static String makeRef(String hidden, String visible) {
@@ -155,7 +155,7 @@
private String jpath = "";
public void setData(String cls, int ln, XModel model) {
- jpath = "/" + cls.replace('.', '/') +
".java";
+ jpath = XModelObjectConstants.SEPARATOR + cls.replace('.', '/') +
".java";
line = ln;
String fn = "" +
XModelObjectUtil.getExpandedValue(model.getByPath("Engines/generator"),
"directory", null) + "/src" + jpath;
text = XModelObjectLoaderUtil.readFile(fn);
@@ -164,7 +164,7 @@
public void setData(XModelObject cls, int ln, XModel model) {
jpath = cls.getPath();
line = ln;
- text = cls.getAttributeValue("body");
+ text = cls.getAttributeValue(XModelObjectConstants.ATTR_NAME_BODY);
}
public String getJPath() {
@@ -326,7 +326,7 @@
String p = "" + XModelObjectUtil.getExpandedValue(g,
"directory", null) + "/src/";
cls = fn.substring(p.length()).replace('/',
'.').replace('\\', '.');
}
- findJFile(model, "/" + fn.replace('\\', '/') +
".java");
+ findJFile(model, XModelObjectConstants.SEPARATOR + fn.replace('\\',
'/') + ".java");
}
private void findJFile(XModel model, String fn) {
@@ -339,7 +339,7 @@
private boolean isOverlapped(XModelObject o) {
while(o != null) {
- if("true".equals(o.get("overlapped"))) return true;
+ if(XModelObjectConstants.TRUE.equals(o.get("overlapped"))) return
true;
o = o.getParent();
}
return false;
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/ModelImages.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/ModelImages.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/ModelImages.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -18,6 +18,7 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.commands.ICommandImageService;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.osgi.framework.Bundle;
@@ -25,7 +26,7 @@
private static ModelImages instance;
static {
- instance = new
ModelImages(ModelPlugin.getDefault().getBundle().getEntry("/"));
+ instance = new
ModelImages(ModelPlugin.getDefault().getBundle().getEntry(XModelObjectConstants.SEPARATOR));
}
public static Image getImage(String key) {
@@ -56,7 +57,7 @@
key = key.substring(i + 1);
Bundle bundle = Platform.getBundle(plugin);
if(bundle != null) {
- url = bundle.getEntry("/");
+ url = bundle.getEntry(XModelObjectConstants.SEPARATOR);
}
}
try {
Deleted:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XBundle.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XBundle.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XBundle.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.model.util;
-
-import java.text.MessageFormat;
-
-import org.jboss.tools.common.meta.key.WizardKeys;
-import org.jboss.tools.common.model.plugin.ModelPlugin;
-
-public class XBundle {
- private static XBundle bundle = new XBundle();
-
- private XBundle() {}
-
- public static XBundle getInstance() {
- return bundle;
- }
-
- private String findTemplate(String resourceid, String templateid) {
- return WizardKeys.getString(templateid);
- }
-
- public String getMessage(String resourceid, String templateid) {
- return getMessage(resourceid, templateid, null);
- }
-
- public String getMessage(String resourceid, String templateid, Object[] args) {
- String t = findTemplate(resourceid, templateid);
- if(args == null) return t;
- try {
- return MessageFormat.format(t, args);
- } catch (IllegalArgumentException e) {
- ModelPlugin.getPluginLog().logError(e);
- return
MessageFormat.format(Messages.getString("ERR_GET_MESSAGE"),new
Object[]{resourceid,templateid,t}); //$NON-NLS-1$
- }
- }
-
-}
-
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelObjectLoaderUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelObjectLoaderUtil.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelObjectLoaderUtil.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -42,13 +42,16 @@
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelConstants;
import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.engines.impl.EnginesLoader;
import org.jboss.tools.common.model.filesystems.XFileObject;
import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
import org.jboss.tools.common.model.impl.XModelImpl;
import org.jboss.tools.common.model.impl.XModelObjectImpl;
import org.jboss.tools.common.model.loaders.XObjectLoader;
+import org.jboss.tools.common.model.plugin.ModelMessages;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.common.xml.XMLUtilities;
@@ -700,7 +703,7 @@
int i = 0;
while(i == 0 && f.exists() && !f.canWrite())
i = o.getModel().getService().showDialog("Question",
- getReadOnlyMessage(f), new String[]{"Retry",
"Discard", "Cancel"}, null,
+ getReadOnlyMessage(f), new String[]{"Retry",
"Discard", ModelMessages.Cancel}, null,
ServiceDialog.QUESTION);
return i;
}
@@ -710,13 +713,13 @@
}
public static String getTempBody(XModelObject o) {
- String b = o.get("_body_");
- o.set("_body_", "");
+ String b = o.get(XModelObjectConstants.ATTR_NAME__BODY_);
+ o.set(XModelObjectConstants.ATTR_NAME__BODY_, "");
return b;
}
public static void setTempBody(XModelObject o, String body) {
- o.set("_body_", body);
+ o.set(XModelObjectConstants.ATTR_NAME__BODY_, body);
}
//////pass correct properties!
@@ -765,11 +768,11 @@
if(t == XFileObject.SYSTEM) return "";
XModelObject p = object.getParent();
if(p == null) return null;
- String n = (t == XFileObject.FOLDER) ? object.get("NAME") :
+ String n = (t == XFileObject.FOLDER) ?
object.get(XModelObjectConstants.XML_ATTR_NAME) :
(t == XFileObject.FILE) ? FileAnyImpl.toFileName(object) :
object.getPathPart();
String pp = getResourcePath(p);
- return (pp == null) ? n : pp + "/" + n;
+ return (pp == null) ? n : pp + XModelObjectConstants.SEPARATOR + n;
}
/*
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/jst/web/tld/TLDToPaletteHelper.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/jst/web/tld/TLDToPaletteHelper.java 2009-06-19
14:21:30 UTC (rev 16066)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/jst/web/tld/TLDToPaletteHelper.java 2009-06-19
15:44:59 UTC (rev 16067)
@@ -28,15 +28,15 @@
Properties p = new Properties();
String parentname = getTldName(tag.getParent());
String prefix = (parentname.length() == 0) ? "" : parentname +
":";
- String shortname = tag.getAttributeValue("name");
+ String shortname = tag.getAttributeValue(XModelObjectConstants.ATTR_NAME);
String name = prefix + shortname;
String tagname = shortname; ///name;
- p.setProperty("name", shortname);
+ p.setProperty(XModelObjectConstants.ATTR_NAME, shortname);
boolean empty =
"empty".equals(tag.getAttributeValue("bodycontent"));
if(!empty) p.setProperty(END_TEXT, "</" + tagname +
">");
p.setProperty(START_TEXT, getStartText(tag, empty, tagname));
p.setProperty(DESCRIPTION, getTagDescription(tag, empty, name));
- if(!empty) p.setProperty(REFORMAT, "yes");
+ if(!empty) p.setProperty(REFORMAT, XModelObjectConstants.YES);
return model.createModelObject("SharableMacroHTML", p);
}
@@ -45,7 +45,7 @@
String n = tld.getAttributeValue("shortname");
if(n == null) return "";
if(n.length() == 0) {
- n = tld.getAttributeValue("name");
+ n = tld.getAttributeValue(XModelObjectConstants.ATTR_NAME);
int q = n.lastIndexOf('-');
if(q >= 0) n = n.substring(q + 1);
}
@@ -62,15 +62,15 @@
for (int i = 0; i < as.length; i++) {
if(!TLDUtil.isAttribute(as[i])) continue;
String required = as[i].getAttributeValue("required");
- if(!"true".equals(required) &&
!"yes".equals(required)) continue;
- sb.append('
').append(as[i].getAttributeValue("name")).append("=\"");
+ if(!XModelObjectConstants.TRUE.equals(required) &&
!XModelObjectConstants.YES.equals(required)) continue;
+ sb.append('
').append(as[i].getAttributeValue(XModelObjectConstants.ATTR_NAME)).append("=\"");
if(!found) {
sb.append('|');
found = true;
}
sb.append('"');
}
- if(empty) sb.append("/");
+ if(empty) sb.append(XModelObjectConstants.SEPARATOR);
sb.append(">");
return sb.toString();
}
@@ -86,13 +86,13 @@
for (int i = 0; i < as.length; i++) {
if(!TLDUtil.isAttribute(as[i])) continue;
if(!isRequired(as[i])) continue;
-
sb.append("<b>").append(as[i].getAttributeValue("name")).append("</b>");
+
sb.append("<b>").append(as[i].getAttributeValue(XModelObjectConstants.ATTR_NAME)).append("</b>");
++k;
if(k < as.length) sb.append(", ");
}
for (int i = 0; i < as.length; i++) {
if(isRequired(as[i])) continue;
- sb.append(as[i].getAttributeValue("name"));
+ sb.append(as[i].getAttributeValue(XModelObjectConstants.ATTR_NAME));
++k;
if(k < as.length) sb.append(", ");
}
@@ -120,14 +120,14 @@
for (int i = 0; i < as.length; i++) {
if(!TLDUtil.isAttribute(as[i])) continue;
if(!isRequired(as[i])) continue;
-
sb.append("<b>").append(as[i].getAttributeValue("name")).append("</b>");
+
sb.append("<b>").append(as[i].getAttributeValue(XModelObjectConstants.ATTR_NAME)).append("</b>");
++k;
if(k < as.length) sb.append(',');
sb.append("\n ");
}
for (int i = 0; i < as.length; i++) {
if(isRequired(as[i])) continue;
- sb.append(as[i].getAttributeValue("name"));
+ sb.append(as[i].getAttributeValue(XModelObjectConstants.ATTR_NAME));
++k;
if(k < as.length) sb.append(',');
sb.append("\n ");
@@ -144,7 +144,7 @@
private boolean isRequired(XModelObject attr) {
String required = attr.getAttributeValue("required");
- return ("true".equals(required) || "yes".equals(required));
+ return (XModelObjectConstants.TRUE.equals(required) ||
XModelObjectConstants.YES.equals(required));
}
public XModelObject createTabByTLD(XModelObject tld, XModel model) {
@@ -157,7 +157,7 @@
private XModelObject createGroupByTLD(XModelObject tld, XModel model, String entity)
{
Properties p = new Properties();
- p.setProperty("name", capitalize(getTldName(tld)));
+ p.setProperty(XModelObjectConstants.ATTR_NAME, capitalize(getTldName(tld)));
p.setProperty(DESCRIPTION, TLDUtil.getTagDescription(tld));
p.setProperty(DEFAULT_PREFIX, getTldName(tld));
p.setProperty(URIConstants.LIBRARY_URI, "" +
tld.getAttributeValue("uri"));