JBoss Tools SVN: r38305 - trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-01-30 19:06:27 -0500 (Mon, 30 Jan 2012)
New Revision: 38305
Modified:
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/MetaModelTest.java
Log:
JBIDE-10448
https://issues.jboss.org/browse/JBIDE-10448
Tests are added.
Modified: trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/MetaModelTest.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/MetaModelTest.java 2012-01-30 23:15:51 UTC (rev 38304)
+++ trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/MetaModelTest.java 2012-01-31 00:06:27 UTC (rev 38305)
@@ -29,6 +29,7 @@
import org.jboss.tools.common.meta.impl.XModelMetaDataImpl;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelFactory;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.engines.impl.EnginesLoader;
import org.jboss.tools.common.model.event.XModelTreeEvent;
@@ -162,7 +163,7 @@
assertTrue(sb.toString(), errors.size() == 0);
}
- void collectActionsWithWrongHandlers(XModelEntity entity, XActionItem item, Set<String> errors) {
+ protected void collectActionsWithWrongHandlers(XModelEntity entity, XActionItem item, Set<String> errors) {
if(item instanceof XActionList) {
XActionList list = (XActionList)item;
XActionItem[] is = list.getActionItems();
@@ -245,7 +246,7 @@
assertTrue(message.toString(), actionsWithoutIcons.size() == 0);
}
- void collectActionsWithoutIcon(XModelEntity entity, XActionItem item, Set<String> actionsWithoutIcons) {
+ protected void collectActionsWithoutIcon(XModelEntity entity, XActionItem item, Set<String> actionsWithoutIcons) {
String iconPath = item.getIconKey();
if(iconPath != null && item.getPath() != null
&& iconPath.length() > 0
@@ -277,7 +278,7 @@
*/
public void testCreatingModelObjects() {
XModelMetaData meta = XModelMetaDataImpl.getInstance();
- XModel model = PreferenceModelUtilities.getPreferenceModel();
+ XModel model = XModelFactory.getDefaultInstance();
String[] entities = meta.entities();
StringBuilder sb = new StringBuilder();
int errors = 0;
@@ -306,7 +307,7 @@
* introduce attribute 'example' to entity.
*/
public void testObjectLoaders() {
- XModel model = PreferenceModelUtilities.getPreferenceModel();
+ XModel model = XModelFactory.getDefaultInstance();
XModelMetaData meta = XModelMetaDataImpl.getInstance();
String[] entities = meta.entities();
StringBuilder sb = new StringBuilder();
12 years, 11 months
JBoss Tools SVN: r38304 - trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-01-30 18:15:51 -0500 (Mon, 30 Jan 2012)
New Revision: 38304
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/strutswebapp.meta
trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/webapp24.meta
trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/webapp30.meta
Log:
JBIDE-10448
https://issues.jboss.org/browse/JBIDE-10448
Logical references to image declared in jsf module is replaced by references to a local declaration.
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/strutswebapp.meta
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/strutswebapp.meta 2012-01-30 23:11:09 UTC (rev 38303)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/strutswebapp.meta 2012-01-30 23:15:51 UTC (rev 38304)
@@ -73,6 +73,7 @@
<ICON name="file" path="images/struts/pro/webapp_file.gif"/>
<ICON name="filter" path="images/webxml/filter.gif"/>
<ICON name="filter_mapping" path="images/webxml/filter_map.gif"/>
+ <ICON name="folder" path="images/struts/plug_in_folder.gif"/>
<ICON name="listener" path="images/webxml/listener.gif"/>
<ICON name="login_config" path="images/webxml/login.gif"/>
<ICON name="mapping" path="images/java/attr.gif"/>
@@ -1001,7 +1002,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1055,7 +1056,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1121,7 +1122,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1174,7 +1175,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1228,7 +1229,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1291,7 +1292,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1343,7 +1344,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1404,7 +1405,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1457,7 +1458,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1519,7 +1520,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1570,7 +1571,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1621,7 +1622,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1673,7 +1674,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1735,7 +1736,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/webapp24.meta
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/webapp24.meta 2012-01-30 23:11:09 UTC (rev 38303)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/webapp24.meta 2012-01-30 23:15:51 UTC (rev 38304)
@@ -1099,7 +1099,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1164,7 +1164,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1229,7 +1229,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1281,7 +1281,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/webapp30.meta
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/webapp30.meta 2012-01-30 23:11:09 UTC (rev 38303)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/webapp30.meta 2012-01-30 23:15:51 UTC (rev 38304)
@@ -697,7 +697,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -735,7 +735,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -773,7 +773,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -825,7 +825,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -865,7 +865,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -916,7 +916,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -964,7 +964,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1012,7 +1012,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1049,7 +1049,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
@@ -1087,7 +1087,7 @@
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
- <ICON info="main.jsf.components" type="main"/>
+ <ICON info="main.struts.webapp.folder" type="main"/>
</ICONS>
</XEntityRenderer>
<XModelAttributes>
12 years, 11 months
JBoss Tools SVN: r38303 - trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-01-30 18:11:09 -0500 (Mon, 30 Jan 2012)
New Revision: 38303
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/LabelDecoratorImpl.java
Log:
JBIDE-10448
https://issues.jboss.org/browse/JBIDE-10448
LabelDecoratorImpl should not fail for null image, it should only report the missing image.
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/LabelDecoratorImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/LabelDecoratorImpl.java 2012-01-30 22:50:10 UTC (rev 38302)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/navigator/LabelDecoratorImpl.java 2012-01-30 23:11:09 UTC (rev 38303)
@@ -38,9 +38,17 @@
return new DecoratingLabelProviderExt(provider, decorator);
}
+ static Set<String> missingImages = new HashSet<String>();
+
public Image decorateImage(Image image, Object element) {
int severity = getErrorState(element);
- if(severity == IMarker.SEVERITY_ERROR) {
+ if(image == null && element instanceof XModelObject && severity > 0) {
+ String entity = ((XModelObject)element).getModelEntity().getName();
+ if(!missingImages.contains(entity)) {
+ missingImages.add(entity);
+ ModelUIPlugin.getDefault().logWarning("Problem in " + LabelDecoratorImpl.class.getName() + ": Cannot find icon for entity " + entity); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } else if(severity == IMarker.SEVERITY_ERROR) {
return getErrorImage(image);
} else if(severity == IMarker.SEVERITY_WARNING) {
return getWarningImage(image);
12 years, 11 months
JBoss Tools SVN: r38302 - trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core.
by jbosstools-commits@lists.jboss.org
Author: fbricon
Date: 2012-01-30 17:50:10 -0500 (Mon, 30 Jan 2012)
New Revision: 38302
Modified:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/ProjectUtil.java
Log:
JBDS-1999 : ProjectUtil was not committed
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/ProjectUtil.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/ProjectUtil.java 2012-01-30 22:03:42 UTC (rev 38301)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/ProjectUtil.java 2012-01-30 22:50:10 UTC (rev 38302)
@@ -6,6 +6,8 @@
import java.util.Iterator;
import java.util.List;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -14,6 +16,10 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
/**
* A utility class for Eclipse Projects.
@@ -67,5 +73,66 @@
monitor.done();
}
}
+
+ /**
+ * Returns the underlying file for a given path
+ * @param project
+ * @param path, ex. WEB-INF/web.xml
+ * @return the underlying file corresponding to path, or null if no file exists.
+ */
+ public static IFile getWebResourceFile(IProject project, String path) {
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ if (component == null) {
+ return null;
+ }
+ IPath filePath = new Path(path);
+ IContainer[] underlyingFolders = component.getRootFolder().getUnderlyingFolders();
+ for (IContainer underlyingFolder : underlyingFolders) {
+ IPath p = underlyingFolder.getProjectRelativePath().append(filePath);
+ IFile f = project.getFile(p);
+ if (f.exists()) {
+ return f;
+ }
+ }
+ return null;
+ }
+ /**
+ * Returns the first underlying IFile for a given path, not under the folder tagged as defaultRoot
+ * @param project
+ * @param path, ex. WEB-INF/web.xml
+ * @return the underlying file corresponding to path, or null if no file exists.
+ */
+ public static IFile getGeneratedWebResourceFile(IProject project, String path) {
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ if (component == null) {
+ return null;
+ }
+ IPath filePath = new Path(path);
+ IVirtualFolder root = component.getRootFolder();
+ IContainer[] underlyingFolders = root.getUnderlyingFolders();
+ IPath defaultDDFolderPath = J2EEModuleVirtualComponent.getDefaultDeploymentDescriptorFolder(root);
+ for (IContainer underlyingFolder : underlyingFolders) {
+ if (defaultDDFolderPath ==null || !defaultDDFolderPath.equals(underlyingFolder.getProjectRelativePath())) {
+ IPath p = underlyingFolder.getProjectRelativePath().append(filePath);
+ IFile f = project.getFile(p);
+ return f;
+ }
+ }
+ return null;
+ }
+
+ public static String getRelativePath(IProject project, String absolutePath) {
+ File basedir = project.getLocation().toFile();
+ String relative;
+ if (absolutePath.equals(basedir.getAbsolutePath())) {
+ relative = ".";
+ } else if (absolutePath.startsWith(basedir.getAbsolutePath())) {
+ relative = absolutePath.substring(basedir.getAbsolutePath().length() + 1);
+ } else {
+ relative = absolutePath;
+ }
+ return relative.replace('\\', '/'); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
}
12 years, 11 months
JBoss Tools SVN: r38301 - trunk/runtime/plugins/org.jboss.tools.runtime.seam.detector/src/org/jboss/tools/runtime/handlers.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2012-01-30 17:03:42 -0500 (Mon, 30 Jan 2012)
New Revision: 38301
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.seam.detector/src/org/jboss/tools/runtime/handlers/SeamHandler.java
Log:
JBIDE-10749 Runtime detection should recognize Seam 2.3
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.seam.detector/src/org/jboss/tools/runtime/handlers/SeamHandler.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.seam.detector/src/org/jboss/tools/runtime/handlers/SeamHandler.java 2012-01-30 21:22:01 UTC (rev 38300)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.seam.detector/src/org/jboss/tools/runtime/handlers/SeamHandler.java 2012-01-30 22:03:42 UTC (rev 38301)
@@ -158,6 +158,10 @@
JarFile jar = new JarFile(jarFile);
Attributes attributes = jar.getManifest().getMainAttributes();
String version = attributes.getValue(seamVersionAttributeName);
+ if (version == null) {
+ // Seam 2.3
+ version = attributes.getValue("Implementation-Version");
+ }
return version;
} catch (IOException e) {
return null;
12 years, 11 months
JBoss Tools SVN: r38300 - in trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard: xpl and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-01-30 16:22:01 -0500 (Mon, 30 Jan 2012)
New Revision: 38300
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/AddQualifiersToBeanWizardPage.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectBeanWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java
Log:
Wizard 'Specify CDI Bean for the Injection Point' does not compute correctly condition 'can finish' https://issues.jboss.org/browse/JBIDE-10637
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/AddQualifiersToBeanWizardPage.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/AddQualifiersToBeanWizardPage.java 2012-01-30 20:12:47 UTC (rev 38299)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/AddQualifiersToBeanWizardPage.java 2012-01-30 21:22:01 UTC (rev 38300)
@@ -32,6 +32,7 @@
setTitle(pageName);
}
+ @Override
public void createControl(Composite parent) {
composite = new AddQualifiersToBeanComposite(parent, this);
setControl(composite);
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectBeanWizard.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectBeanWizard.java 2012-01-30 20:12:47 UTC (rev 38299)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectBeanWizard.java 2012-01-30 21:22:01 UTC (rev 38300)
@@ -21,6 +21,7 @@
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
@@ -48,7 +49,8 @@
import org.jboss.tools.common.model.ui.ModelUIImages;
public class SelectBeanWizard extends AbstractModifyInjectionPointWizard{
- private AddQualifiersToBeanWizardPage page;
+ private SelectBeanWizardPage selectBeanPage;
+ private AddQualifiersToBeanWizardPage addQualifiersPage;
private Text pattern;
public SelectBeanWizard(ProcessorBasedRefactoring refactoring){
@@ -58,30 +60,32 @@
setDefaultPageImageDescriptor(ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_DEFAULT));
}
- public void addUserInputPages() {
- addPage(new SelectBeanWizardPage(""));
- page = new AddQualifiersToBeanWizardPage("");
- addPage(page);
+ @Override
+ public void addUserInputPages() {
+ selectBeanPage = new SelectBeanWizardPage("");
+ addPage(selectBeanPage);
+ addQualifiersPage = new AddQualifiersToBeanWizardPage("");
+ addPage(addQualifiersPage);
}
public java.util.List<ValuedQualifier> getDeployedQualifiers(){
- return page.getDeployedQualifiers();
+ return addQualifiersPage.getDeployedQualifiers();
}
public java.util.List<IQualifier> getAvailableQualifiers(){
- return page.getAvailableQualifiers();
+ return addQualifiersPage.getAvailableQualifiers();
}
public void init(IBean bean){
- page.init(bean);
+ addQualifiersPage.init(bean);
}
public void deploy(ValuedQualifier qualifier){
- page.deploy(qualifier);
+ addQualifiersPage.deploy(qualifier);
}
public boolean checkBeans(){
- return page.checkBeans();
+ return addQualifiersPage.checkBeans();
}
class SelectBeanWizardPage extends UserInputWizardPage{
@@ -92,6 +96,7 @@
setPageComplete(false);
}
+ @Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
@@ -108,6 +113,7 @@
GridData data = new GridData(GridData.FILL_HORIZONTAL);
pattern.setLayoutData(data);
pattern.addModifyListener(new ModifyListener(){
+ @Override
public void modifyText(ModifyEvent e){
tableViewer.refresh();
}
@@ -123,16 +129,18 @@
availableList.setLayoutData(data);
tableViewer = new TableViewer(availableList);
- ILabelProvider labelProvider = new BeanListLabelProvider();
+ final ILabelProvider labelProvider = new BeanListLabelProvider();
tableViewer.setLabelProvider(labelProvider);
IContentProvider contentProvider = new BeanListContentProvider();
tableViewer.setContentProvider(contentProvider);
tableViewer.setComparator(new ViewerComparator() {
+ @Override
public int compare(Viewer viewer, Object o1, Object o2) {
if (o1 instanceof IBean && o2 instanceof IBean) {
IBean b1 = (IBean) o1;
IBean b2 = (IBean) o2;
- return (b1.getBeanClass().getElementName().compareToIgnoreCase(b2.getBeanClass().getElementName()));
+
+ return labelProvider.getText(b1).compareToIgnoreCase(labelProvider.getText(b2));
}
return super.compare(viewer, o1, o2);
@@ -141,21 +149,22 @@
tableViewer.setInput(getBeans());
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
IBean bean = getSelection();
if(bean != null){
setPageComplete(true);
- IWizardPage next = getNextPage();
- if(next instanceof AddQualifiersToBeanWizardPage)
- ((AddQualifiersToBeanWizardPage)next).init(bean);
+ addQualifiersPage.init(bean);
setSelectedBean(bean);
- page.setDeployedQualifiers(page.getDeployedQualifiers());
+ addQualifiersPage.setDeployedQualifiers(addQualifiersPage.getDeployedQualifiers());
}else
setPageComplete(false);
}
});
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
+ @Override
public void doubleClick(DoubleClickEvent event) {
+
}
});
tableViewer.addFilter(new BeanFilter());
@@ -163,6 +172,20 @@
setControl(composite);
}
+ public void setDefaultSelection(){
+
+ if(getBeans().size() > 0){
+ IBean defaultBean = getBeans().get(0);
+ tableViewer.setSelection(new StructuredSelection(defaultBean));
+ tableViewer.getTable().select(0);
+ addQualifiersPage.init(defaultBean);
+ setSelectedBean(defaultBean);
+ addQualifiersPage.setDeployedQualifiers(addQualifiersPage.getDeployedQualifiers());
+ setPageComplete(true);
+ }
+
+ }
+
protected IBean getSelection() {
IStructuredSelection sel = (IStructuredSelection) tableViewer.getSelection();
if (sel.isEmpty())
@@ -178,6 +201,7 @@
return true;
}
+ @Override
public boolean select(Viewer viewer, Object parentElement,
Object element) {
@@ -205,19 +229,24 @@
class BeanListLabelProvider implements ILabelProvider{
+ @Override
public void addListener(ILabelProviderListener listener) {
}
+ @Override
public void dispose() {
}
+ @Override
public boolean isLabelProperty(Object element, String property) {
return false;
}
+ @Override
public void removeListener(ILabelProviderListener listener) {
}
+ @Override
public Image getImage(Object element) {
if(element instanceof IBean){
return CDIImages.getImageByElement((IBean)element);
@@ -225,6 +254,7 @@
return null;
}
+ @Override
public String getText(Object element) {
if(element instanceof IBean){
IBean bean = (IBean)element;
@@ -241,12 +271,15 @@
class BeanListContentProvider implements IStructuredContentProvider{
+ @Override
public void dispose() {
}
+ @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
+ @Override
public Object[] getElements(Object inputElement) {
if(inputElement instanceof ArrayList){
return ((ArrayList)inputElement).toArray();
@@ -255,4 +288,10 @@
}
}
+
+ @Override
+ public void createPageControls(Composite pageContainer) {
+ super.createPageControls(pageContainer);
+ selectBeanPage.setDefaultSelection();
+ }
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java 2012-01-30 20:12:47 UTC (rev 38299)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java 2012-01-30 21:22:01 UTC (rev 38300)
@@ -228,6 +228,7 @@
public void refresh() {
Display.getDefault().syncExec(new Runnable() {
+ @Override
public void run() {
if (availableTableViewer == null || availableTableViewer.getControl().isDisposed())
return;
@@ -269,6 +270,7 @@
fd[i].setStyle(SWT.ITALIC);
font = new Font(display, fd);
addDisposeListener(new DisposeListener() {
+ @Override
public void widgetDisposed(DisposeEvent e) {
font.dispose();
}
@@ -290,6 +292,7 @@
data = new GridData(GridData.FILL_HORIZONTAL);
pattern.setLayoutData(data);
pattern.addModifyListener(new ModifyListener(){
+ @Override
public void modifyText(ModifyEvent e){
availableTableViewer.refresh();
}
@@ -323,6 +326,7 @@
IContentProvider contentProvider = new QualifiersListContentProvider();
availableTableViewer.setContentProvider(contentProvider);
availableTableViewer.setComparator(new ViewerComparator() {
+ @Override
public int compare(Viewer viewer, Object o1, Object o2) {
if (o1 instanceof IQualifier && o2 instanceof IQualifier) {
IQualifier q1 = (IQualifier) o1;
@@ -336,11 +340,13 @@
availableTableViewer.setInput(qualifiers);
availableTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
setEnablement();
}
});
availableTableViewer.addDoubleClickListener(new IDoubleClickListener() {
+ @Override
public void doubleClick(DoubleClickEvent event) {
setEnablement();
if (add.isEnabled())
@@ -364,6 +370,7 @@
add.setText(CDIUIMessages.ADD_QUALIFIERS_TO_BEAN_WIZARD_ADD);
add.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
add.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent event) {
add(false);
}
@@ -373,6 +380,7 @@
remove.setText(CDIUIMessages.ADD_QUALIFIERS_TO_BEAN_WIZARD_REMOVE);
remove.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
remove.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent event) {
remove(false);
}
@@ -385,6 +393,7 @@
addAll.setText(CDIUIMessages.ADD_QUALIFIERS_TO_BEAN_WIZARD_ADD_ALL);
addAll.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
addAll.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent event) {
add(true);
}
@@ -394,6 +403,7 @@
removeAll.setText(CDIUIMessages.ADD_QUALIFIERS_TO_BEAN_WIZARD_REMOVE_ALL);
removeAll.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
removeAll.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent event) {
remove(true);
}
@@ -408,6 +418,7 @@
deployedTableViewer.setLabelProvider(labelProvider);
deployedTableViewer.setContentProvider(contentProvider);
deployedTableViewer.setComparator(new ViewerComparator() {
+ @Override
public int compare(Viewer viewer, Object o1, Object o2) {
if (o1 instanceof IQualifier && o2 instanceof IQualifier) {
IQualifier q1 = (IQualifier) o1;
@@ -421,11 +432,13 @@
deployedTableViewer.setInput(originalQualifiers);
deployedTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
setEnablement();
}
});
deployedTableViewer.addDoubleClickListener(new IDoubleClickListener() {
+ @Override
public void doubleClick(DoubleClickEvent event) {
setEnablement();
if (remove.isEnabled())
@@ -437,11 +450,13 @@
createQualifier.setText(CDIUIMessages.ADD_QUALIFIERS_TO_BEAN_WIZARD_CREATE_NEW_QUALIFIER);
createQualifier.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent event) {
final IJobManager manager= Job.getJobManager();
// reload qualifiers
if (Display.getCurrent() != null) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable(){
+ @Override
public void run(){
NewQualifierCreationWizard wizard = new NewQualifierCreationWizard();
StructuredSelection selection = new StructuredSelection(new Object[]{bean.getBeanClass()});
@@ -474,6 +489,7 @@
editQualifierValue.setText(CDIUIMessages.ADD_QUALIFIERS_TO_BEAN_WIZARD_EDIT_QUALIFIER_VALUE);
editQualifierValue.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent event) {
ValuedQualifier[] vq = getDeployedSelection();
ValueDialog d = new ValueDialog(getShell(), vq[0].getValue());
@@ -612,9 +628,9 @@
list.add(mods[i]);
}
- Iterator iterator = list.iterator();
+ Iterator<ValuedQualifier> iterator = list.iterator();
while (iterator.hasNext()) {
- ValuedQualifier qualifier = (ValuedQualifier) iterator.next();
+ ValuedQualifier qualifier = iterator.next();
if (add2) {
qualifiers.remove(qualifier);
deployed.add(qualifier);
@@ -649,9 +665,9 @@
public ArrayList<ValuedQualifier> getQualifiersToRemove() {
ArrayList<ValuedQualifier> list = new ArrayList<ValuedQualifier>();
- Iterator iterator = originalQualifiers.iterator();
+ Iterator<ValuedQualifier> iterator = originalQualifiers.iterator();
while (iterator.hasNext()) {
- ValuedQualifier qualifier = (ValuedQualifier) iterator.next();
+ ValuedQualifier qualifier = iterator.next();
if (!contains(deployed, qualifier))
list.add(qualifier);
}
@@ -660,9 +676,9 @@
public ArrayList<ValuedQualifier> getQualifiersToAdd() {
ArrayList<ValuedQualifier> list = new ArrayList<ValuedQualifier>();
- Iterator iterator = deployed.iterator();
+ Iterator<ValuedQualifier> iterator = deployed.iterator();
while (iterator.hasNext()) {
- ValuedQualifier qualifier = (ValuedQualifier) iterator.next();
+ ValuedQualifier qualifier = iterator.next();
if (!contains(originalQualifiers, qualifier))
list.add(qualifier);
}
@@ -702,19 +718,24 @@
class QualifiersListLabelProvider implements ILabelProvider, IColorProvider{
+ @Override
public void addListener(ILabelProviderListener listener) {
}
+ @Override
public void dispose() {
}
+ @Override
public boolean isLabelProperty(Object element, String property) {
return true;
}
+ @Override
public void removeListener(ILabelProviderListener listener) {
}
+ @Override
public Image getImage(Object element) {
if(element instanceof ValuedQualifier){
return CDIImages.getImageByElement(((ValuedQualifier) element).getQualifier());
@@ -722,6 +743,7 @@
return null;
}
+ @Override
public String getText(Object element) {
if(element instanceof ValuedQualifier){
ValuedQualifier vq = (ValuedQualifier)element;
@@ -734,6 +756,7 @@
return "";
}
+ @Override
public Color getForeground(Object element) {
if(element instanceof ValuedQualifier){
if(contains(originalQualifiers, (ValuedQualifier)element))
@@ -742,6 +765,7 @@
return ColorConstants.black;
}
+ @Override
public Color getBackground(Object element) {
return null;
}
@@ -749,12 +773,15 @@
class QualifiersListContentProvider implements IStructuredContentProvider{
+ @Override
public void dispose() {
}
+ @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
+ @Override
public Object[] getElements(Object inputElement) {
if(inputElement instanceof ArrayList){
return ((ArrayList)inputElement).toArray();
@@ -770,6 +797,7 @@
return true;
}
+ @Override
public boolean select(Viewer viewer, Object parentElement,
Object element) {
@@ -806,6 +834,7 @@
this.value = value;
}
+ @Override
protected Control createCustomArea(Composite parent) {
Composite composite = new Composite(parent, 0);
GridLayout layout = new GridLayout();
@@ -825,6 +854,7 @@
text.setLayoutData(data);
text.setText(value);
text.addModifyListener(new ModifyListener(){
+ @Override
public void modifyText(ModifyEvent e) {
value = text.getText();
}
12 years, 11 months
JBoss Tools SVN: r38299 - in trunk: as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-01-30 15:12:47 -0500 (Mon, 30 Jan 2012)
New Revision: 38299
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/JBossServerType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBean.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBeanLoader.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBoss7RuntimeWizardFragment.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeLocator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/ServerBeanLoaderTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
Log:
JBIDE-10688 - fixing up the server bean loader and cleaning the api slightly
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/JBossServerType.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/JBossServerType.java 2012-01-30 19:30:30 UTC (rev 38298)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/JBossServerType.java 2012-01-30 20:12:47 UTC (rev 38299)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2012 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,
@@ -11,11 +11,14 @@
package org.jboss.ide.eclipse.as.core.server.bean;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.core.util.IWTPConstants;
@@ -156,6 +159,16 @@
return this.condition.isServerRoot(location);
}
+ public String getFullVersion(File root) {
+ if( this.condition == null )
+ return null;
+ return this.condition.getFullVersion(root, new File(root, getSystemJarPath()));
+ }
+
+ public String getServerAdapterTypeId(String version) {
+ return this.condition.getServerTypeId(version);
+ }
+
private static final String IMPLEMENTATION_TITLE = "Implementation-Title"; //$NON-NLS-1$
private static final String JBEAP_RELEASE_VERSION = "JBossEAP-Release-Version"; //$NON-NLS-1$
private static final String JBAS7_RELEASE_VERSION = "JBossAS-Release-Version"; //$NON-NLS-1$
@@ -200,24 +213,102 @@
public static final JBossServerType[] KNOWN_TYPES = {AS, EAP, SOAP, SOAP_STD, EWP, EPP};
static interface Condition {
+ /**
+ * Is this location the root of an installation?
+ * @param location
+ * @return
+ */
public boolean isServerRoot(File location);
+
+ /**
+ * Get the full version of this server. Provide the system jar / reference file
+ * as a hint.
+ *
+ * @param serverRoot
+ * @param systemFile
+ * @return
+ */
+ public String getFullVersion(File serverRoot, File systemFile);
+
+ /**
+ * Get the ServerType id associated with this installation
+ *
+ * @param serverRoot
+ * @param systemFile
+ * @return
+ */
+ public String getServerTypeId(String version);
+
}
+ public static abstract class AbstractCondition implements Condition {
+ public String getFullVersion(File location, File systemFile) {
+ return ServerBeanLoader.getFullServerVersionFromZip(systemFile);
+ }
+ }
+
+ public static abstract class AbstractEAPTypeCondition extends AbstractCondition {
+ public String getServerTypeId(String version) {
+ // V4_2,V4_3,V5_0,V5_1
+ if( V4_2.equals(version)) return IJBossToolingConstants.SERVER_EAP_43;
+ if( V4_3.equals(version)) return IJBossToolingConstants.SERVER_EAP_43;
+ if( V5_0.equals(version)) return IJBossToolingConstants.SERVER_EAP_50;
+ if( V5_1.equals(version)) return IJBossToolingConstants.SERVER_EAP_50;
+ if( V6_0.equals(version)) return IJBossToolingConstants.SERVER_EAP_60;
+ return null;
+ }
+ }
- public static class EAPServerTypeCondition implements Condition {
+ public static class EAPServerTypeCondition extends AbstractEAPTypeCondition {
public boolean isServerRoot(File location) {
File asSystemJar = new File(location, JBossServerType.EAP.getSystemJarPath());
return asSystemJar.exists() && asSystemJar.isFile();
}
}
- public static class EAP6ServerTypeCondition implements Condition {
+ public static class EAP6ServerTypeCondition extends AbstractEAPTypeCondition {
public boolean isServerRoot(File location) {
- return checkAS7EAP6Version(location, JBEAP_RELEASE_VERSION, "6."); //$NON-NLS-1$
+ return getEAP6Version(location, "6.") != null; //$NON-NLS-1$
}
+ public String getFullVersion(File location, File systemJarFile) {
+ return getEAP6Version(location, "6."); //$NON-NLS-1$
+ }
}
+
+ /**
+ * Get the eap6-style version string, or null if not found
+ * @param location
+ * @param versionPrefix
+ * @return
+ */
+ protected static String getEAP6Version(File location, String versionPrefix) {
+ IPath rootPath = new Path(location.getAbsolutePath());
+ IPath productConf = rootPath.append("bin/product.conf"); //$NON-NLS-1$
+ if( productConf.toFile().exists()) {
+ try {
+ Properties p = new Properties();
+ p.load(new FileInputStream(productConf.toFile()));
+ String product = (String) p.get("slot"); //$NON-NLS-1$
+ if("eap".equals(product)) { //$NON-NLS-1$
+ IPath eapDir = rootPath.append("modules/org/jboss/as/product/eap/dir/META-INF"); //$NON-NLS-1$
+ if( eapDir.toFile().exists()) {
+ IPath manifest = eapDir.append("MANIFEST.MF"); //$NON-NLS-1$
+ Properties p2 = new Properties();
+ p2.load(new FileInputStream(manifest.toFile()));
+ String type = p2.getProperty("JBoss-Product-Release-Name"); //$NON-NLS-1$
+ String version = p2.getProperty("JBoss-Product-Release-Version"); //$NON-NLS-1$
+ if( "EAP".equals(type) && version.startsWith(versionPrefix)) //$NON-NLS-1$
+ return version;
+ }
+ }
+ } catch(IOException ioe) {
+
+ }
+ }
+ return null;
+ }
- public static class EAPStandaloneServerTypeCondition implements Condition {
+ public static class EAPStandaloneServerTypeCondition extends AbstractEAPTypeCondition {
public boolean isServerRoot(File location) {
File asSystemJar = new File(location, JBossServerType.EAP_STD.getSystemJarPath());
if (asSystemJar.exists() && asSystemJar.isFile()) {
@@ -227,8 +318,7 @@
}
}
- public static class ASServerTypeCondition implements Condition {
-
+ public static class ASServerTypeCondition extends AbstractCondition {
public boolean isServerRoot(File location) {
File asSystemJar = new File(location, JBossServerType.AS.getSystemJarPath());
if (asSystemJar.exists() && asSystemJar.isFile()) {
@@ -236,25 +326,36 @@
}
return false;
}
+
+ @Override
+ public String getServerTypeId(String version) {
+ // V6_0, V6_1, V5_1, V5_0, V4_2, V4_0, V3_2
+ if( version.equals(V3_2)) return IJBossToolingConstants.SERVER_AS_32;
+ if( version.equals(V4_0)) return IJBossToolingConstants.SERVER_AS_40;
+ if( version.equals(V4_2)) return IJBossToolingConstants.SERVER_AS_42;
+ if( version.equals(V5_0)) return IJBossToolingConstants.SERVER_AS_50;
+ if( version.equals(V5_1)) return IJBossToolingConstants.SERVER_AS_51;
+ if( version.equals(V6_0)) return IJBossToolingConstants.SERVER_AS_60;
+ if( version.equals(V6_1)) return IJBossToolingConstants.SERVER_AS_60;
+ return null;
+ }
}
- public static class AS7ServerTypeCondition implements Condition {
+ public static class AS7ServerTypeCondition extends AbstractCondition {
public boolean isServerRoot(File location) {
- return checkAS7EAP6Version(location, JBAS7_RELEASE_VERSION, "7."); //$NON-NLS-1$
+ return checkAS7Version(location, JBAS7_RELEASE_VERSION, "7."); //$NON-NLS-1$
}
+
+ public String getServerTypeId(String version) {
+ if( version.equals(V7_0)) return IJBossToolingConstants.SERVER_AS_70;
+ if( version.equals(V7_1)) return IJBossToolingConstants.SERVER_AS_71;
+ return null;
+ }
}
- protected static boolean checkAS7EAP6Version(File location, String property, String propPrefix) {
- String mainFolder = new StringBuilder(location.getAbsolutePath())
- .append(File.separator)
- .append("modules").append(File.separator) //$NON-NLS-1$
- .append("org").append(File.separator) //$NON-NLS-1$
- .append("jboss").append(File.separator) //$NON-NLS-1$
- .append("as").append(File.separator) //$NON-NLS-1$
- .append("server").append(File.separator) //$NON-NLS-1$
- .append("main").append(File.separator) //$NON-NLS-1$
- .toString();
- File f = new File(mainFolder);
+ protected static boolean checkAS7Version(File location, String property, String propPrefix) {
+ String mainFolder = JBossServerType.AS7.jbossSystemJarPath;
+ File f = new File(location, mainFolder);
if( f.exists() ) {
File[] children = f.listFiles();
for( int i = 0; i < children.length; i++ ) {
@@ -275,9 +376,21 @@
File jbpmFolder = new File(location, SOAP_JBPM_JPDL_PATH);
return super.isServerRoot(location) && jbpmFolder.exists() && jbpmFolder.isDirectory();
}
+
+ public String getFullVersion(File location, File systemFile) {
+ String fullVersion = ServerBeanLoader.getFullServerVersionFromZip(location);
+ if (fullVersion != null && fullVersion.startsWith("5.1.1")) { //$NON-NLS-1$
+ // SOA-P 5.2
+ String runJar = JBossServerType.JBOSS_AS_PATH + File.separatorChar +
+ JBossServerType.BIN_PATH+ File.separatorChar + JBossServerType.RUN_JAR_NAME;
+ fullVersion = ServerBeanLoader.getFullServerVersionFromZip(new File(location, runJar));
+ }
+ return fullVersion;
+ }
+
}
- public static class SOAPStandaloneServerTypeCondition implements Condition {
+ public static class SOAPStandaloneServerTypeCondition extends EAPServerTypeCondition {
public boolean isServerRoot(File location) {
File jbpmFolder = new File(location, SOAP_JBPM_JPDL_PATH);
@@ -289,15 +402,18 @@
}
}
- public static class EWPTypeCondition implements Condition {
+ public static class EWPTypeCondition extends EAPServerTypeCondition {
public boolean isServerRoot(File location) {
File ewpSystemJar = new File(location,JBossServerType.EWP.getSystemJarPath());
return ewpSystemJar.exists() && ewpSystemJar.isFile();
}
}
- public static class EPPTypeCondition implements Condition {
+ public static class EPPTypeCondition extends EAPServerTypeCondition {
public boolean isServerRoot(File location) {
+ if( !super.isServerRoot(location))
+ return false;
+
File portletBridgeFolder = new File(location, JBOSS_PORTLETBRIDGE_PATH);
IJBossRuntimeResourceConstants CONSTANTS = new IJBossRuntimeResourceConstants(){};
File portlalSarFolder = new File(location, JBOSS_AS_PATH + File.separatorChar + CONSTANTS.SERVER + File.separatorChar + CONSTANTS.DEFAULT_CONFIGURATION + File.separatorChar + CONSTANTS.DEPLOY + File.separatorChar + JBOSS_PORTAL_SAR );
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBean.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBean.java 2012-01-30 19:30:30 UTC (rev 38298)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBean.java 2012-01-30 20:12:47 UTC (rev 38299)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2010 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,
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBeanLoader.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBeanLoader.java 2012-01-30 19:30:30 UTC (rev 38298)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBeanLoader.java 2012-01-30 20:12:47 UTC (rev 38299)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2012 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,
@@ -24,53 +24,68 @@
*/
public class ServerBeanLoader {
- public static final String SOAP_JBPM_JPDL_PATH = "jbpm-jpdl";//$NON-NLS-1$
+ private static JBossServerType[] typesInOrder = {
+ JBossServerType.AS, JBossServerType.EAP6, JBossServerType.AS7, JBossServerType.EAP_STD,
+ JBossServerType.SOAP, JBossServerType.SOAP_STD, JBossServerType.EPP, JBossServerType.EAP,
+ JBossServerType.EWP
+ };
- public ServerBean loadFromLocation(File location) {
- JBossServerType type = getServerType(location);
+ private ServerBean bean = null;
+ private File rootLocation = null;
+
+ public ServerBeanLoader(File location) {
+ rootLocation = location;
+ }
+
+ public ServerBean getServerBean() {
+ if( bean == null )
+ loadBeanInternal();
+ return bean;
+ }
+
+ public JBossServerType getServerType() {
+ if( bean == null )
+ loadBeanInternal();
+ return bean == null ? JBossServerType.UNKNOWN : bean.getType();
+ }
+
+ private void loadBeanInternal() {
+ JBossServerType type = loadTypeInternal(rootLocation);
String version = null;
if (!JBossServerType.UNKNOWN.equals(type)) {
- String fullVersion = getFullServerVersion(new File(location,type.getSystemJarPath()));
- if (fullVersion != null && fullVersion.startsWith("5.1.1") && JBossServerType.SOAP.equals(type)) { //$NON-NLS-1$
- // SOA-P 5.2
- String runJar = JBossServerType.JBOSS_AS_PATH + File.separatorChar +
- JBossServerType.BIN_PATH+ File.separatorChar + JBossServerType.RUN_JAR_NAME;
- fullVersion = getFullServerVersion(new File(location, runJar));
- }
+ String fullVersion = type.getFullVersion(rootLocation);
version = getServerVersion(fullVersion);
}
- ServerBean server = new ServerBean(location.getPath(),getName(location),type,version);
- return server;
+ ServerBean server = new ServerBean(rootLocation.getPath(),getName(rootLocation),type,version);
+ this.bean = server;
}
- public JBossServerType getServerType(File location) {
- if(JBossServerType.AS.isServerRoot(location)) {
- return JBossServerType.AS;
- } else if(JBossServerType.EAP6.isServerRoot(location)) {
- return JBossServerType.EAP6;
- } else if(JBossServerType.AS7.isServerRoot(location)) {
- return JBossServerType.AS7;
- } else if(JBossServerType.EAP_STD.isServerRoot(location)) {
- return JBossServerType.EAP_STD;
- } else if(JBossServerType.EAP.isServerRoot(location) && JBossServerType.SOAP.isServerRoot(location)) {
- return JBossServerType.SOAP;
- } else if(JBossServerType.SOAP_STD.isServerRoot(location)) {
- return JBossServerType.SOAP_STD;
- } else if(JBossServerType.EAP.isServerRoot(location) && JBossServerType.EPP.isServerRoot(location)) {
- return JBossServerType.EPP;
- } else if(JBossServerType.EAP.isServerRoot(location)) {
- return JBossServerType.EAP;
- } else if(JBossServerType.EWP.isServerRoot(location)) {
- return JBossServerType.EWP;
+ private JBossServerType loadTypeInternal(File location) {
+ for( int i = 0; i < typesInOrder.length; i++ ) {
+ if( typesInOrder[i].isServerRoot(location))
+ return typesInOrder[i];
}
return JBossServerType.UNKNOWN;
+
}
public String getName(File location) {
return location.getName();
}
- public String getFullServerVersion(File systemJarFile) {
+ public String getFullServerVersion() {
+ if( bean == null )
+ loadBeanInternal();
+ return bean.getType().getFullVersion(rootLocation);
+ }
+
+ public String getServerAdapterId() {
+ if( bean == null )
+ loadBeanInternal();
+ return bean.getType().getServerAdapterTypeId(bean.getVersion());
+ }
+
+ public static String getFullServerVersionFromZip(File systemJarFile) {
if (systemJarFile.isDirectory()) {
File[] files = systemJarFile.listFiles(new FilenameFilter() {
@@ -111,7 +126,7 @@
return version;
}
- public String getServerVersion(String version) {
+ public static String getServerVersion(String version) {
if(version==null) return "";//$NON-NLS-1$
String[] versions = JBossServerType.UNKNOWN.getVersions();
String adapterVersion = "";//$NON-NLS-1$
@@ -137,7 +152,7 @@
return adapterVersion;
}
- public String getAdapterVersion(String version) {
+ public static String getAdapterVersion(String version) {
String[] versions = JBossServerType.UNKNOWN.getVersions();
String adapterVersion = "";//$NON-NLS-1$
// trying to match adapter version by X.X version
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java 2012-01-30 19:30:30 UTC (rev 38298)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java 2012-01-30 20:12:47 UTC (rev 38299)
@@ -14,8 +14,10 @@
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.DEFAULT_MEM_ARGS_AS50;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.ENDORSED_DIRS;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.EQ;
+import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.FILE_COLON;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.JAVA_LIB_PATH;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.JAVA_PREFER_IP4_ARG;
+import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.LOGGING_CONFIG_PROP;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.PROGRAM_NAME_ARG;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.QUOTE;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.SERVER_ARG;
@@ -27,13 +29,10 @@
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.BIN;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.ENDORSED;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.LIB;
+import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.LOGGING_PROPERTIES;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.NATIVE;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.SERVER;
-import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.LOGGING_PROPERTIES;
-import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.FILE_COLON;
-import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.LOGGING_CONFIG_PROP;
-import java.io.File;
import java.util.HashMap;
import org.eclipse.core.runtime.IPath;
@@ -43,16 +42,13 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IRuntimeType;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
-import org.jboss.ide.eclipse.as.core.server.bean.JBossServerType;
import org.jboss.ide.eclipse.as.core.server.bean.ServerBeanLoader;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
-import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
public class LocalJBossServerRuntime extends AbstractLocalJBossServerRuntime implements IJBossServerRuntime {
@@ -124,8 +120,7 @@
@Override
public String getDefaultRunVMArgs(IPath serverHome) {
- File sysJar = new File(serverHome.toFile(), JBossServerType.AS.getSystemJarPath());
- String version = new ServerBeanLoader().getFullServerVersion(sysJar);
+ String version = new ServerBeanLoader(serverHome.toFile()).getFullServerVersion();
String name = getRuntime().getName();
String ret = QUOTE + SYSPROP + PROGRAM_NAME_ARG + EQ +
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBoss7RuntimeWizardFragment.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBoss7RuntimeWizardFragment.java 2012-01-30 19:30:30 UTC (rev 38298)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBoss7RuntimeWizardFragment.java 2012-01-30 20:12:47 UTC (rev 38299)
@@ -36,8 +36,8 @@
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
import org.eclipse.wst.server.core.TaskModel;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.bean.JBossServerType;
+import org.jboss.ide.eclipse.as.core.server.bean.ServerBeanLoader;
import org.jboss.ide.eclipse.as.core.server.internal.v7.LocalJBoss7ServerRuntime;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
@@ -214,8 +214,7 @@
}
// Forced error strings for as7.0 and 7.1 incompatabilities.
- File loc = new File(homeDir, getSystemJarPath() );
- String version = getVersionString(loc);
+ String version = getVersionString(new File(homeDir));
IRuntime rt = (IRuntime) getTaskModel().getObject(
TaskModel.TASK_RUNTIME);
String adapterVersion = rt.getRuntimeType().getVersion();
@@ -238,6 +237,8 @@
}
private boolean standaloneScriptExists() {
+ ServerBeanLoader loader = new ServerBeanLoader(new File(homeDir));
+ String version = loader.getFullServerVersion();
String s = JBossServerType.AS7.getSystemJarPath();
IPath p = new Path(homeDir).append(s);
return p.toFile().exists();
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeLocator.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeLocator.java 2012-01-30 19:30:30 UTC (rev 38298)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeLocator.java 2012-01-30 20:12:47 UTC (rev 38299)
@@ -52,17 +52,16 @@
@Override
public void searchForRuntimes(IPath path, IRuntimeSearchListener listener,
IProgressMonitor monitor) {
- ServerBeanLoader loader = new ServerBeanLoader();
- IRuntimeWorkingCopy wc = searchForRuntimes(path, loader, monitor);
+ IRuntimeWorkingCopy wc = searchForRuntimes(path, monitor);
if( wc != null )
listener.runtimeFound(wc);
}
- public IRuntimeWorkingCopy searchForRuntimes(IPath path, ServerBeanLoader loader, IProgressMonitor monitor) {
+ public IRuntimeWorkingCopy searchForRuntimes(IPath path, IProgressMonitor monitor) {
if( monitor.isCanceled())
return null;
-
- if( loader.getServerType(path.toFile()) != JBossServerType.UNKNOWN) {
+ ServerBeanLoader loader = new ServerBeanLoader(path.toFile());
+ if( loader.getServerType() != JBossServerType.UNKNOWN) {
// return found
IRuntimeWorkingCopy wc = createRuntime(path, loader);
if( wc == null )
@@ -76,7 +75,7 @@
for( int i = 0; i < children.length; i++ ) {
if( children[i].isDirectory()) {
SubProgressMonitor newMon = new SubProgressMonitor(monitor, 1);
- IRuntimeWorkingCopy wc = searchForRuntimes(path.append(children[i].getName()), loader, newMon);
+ IRuntimeWorkingCopy wc = searchForRuntimes(path.append(children[i].getName()), newMon);
if( wc != null ) {
monitor.done();
return wc;
@@ -91,11 +90,11 @@
}
public static IRuntimeWorkingCopy createRuntime(IPath path) {
- return createRuntime(path, new ServerBeanLoader());
+ return createRuntime(path, new ServerBeanLoader(path.toFile()));
}
public static IRuntimeWorkingCopy createRuntime(IPath path, ServerBeanLoader loader) {
- JBossServerType type = loader.getServerType(path.toFile());
+ JBossServerType type = loader.getServerType();
if( type == JBossServerType.AS)
return createASRuntime(path, loader);
if( type == JBossServerType.AS7)
@@ -110,7 +109,7 @@
}
private static IRuntimeWorkingCopy createAS7Runtime(IPath path, ServerBeanLoader loader) {
- String version = new ServerBeanLoader().getFullServerVersion(new File(path.toFile(), JBossServerType.AS7.getSystemJarPath()));
+ String version = loader.getFullServerVersion();
String runtimeTypeId;
if( version.startsWith(IJBossToolingConstants.V7_0))
runtimeTypeId = IJBossToolingConstants.AS_70;
@@ -136,7 +135,7 @@
}
private static IRuntimeWorkingCopy createASRuntime(IPath path, ServerBeanLoader loader) {
- String version = new ServerBeanLoader().getFullServerVersion(new File(path.toFile(), JBossServerType.AS.getSystemJarPath()));
+ String version = loader.getFullServerVersion();
String runtimeTypeId = null;
if( version.compareTo("4.0") < 0 ) //$NON-NLS-1$
runtimeTypeId=IJBossToolingConstants.AS_32;
@@ -160,7 +159,7 @@
return null;
}
private static IRuntimeWorkingCopy createEAPRuntime(IPath path, ServerBeanLoader loader) {
- String version = new ServerBeanLoader().getFullServerVersion(new File(path.toFile(), JBossServerType.EAP.getSystemJarPath()));
+ String version = loader.getFullServerVersion();
String runtimeTypeId = null;
if( version.compareTo("5.0") < 0 ) //$NON-NLS-1$
runtimeTypeId=IJBossToolingConstants.EAP_43;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java 2012-01-30 19:30:30 UTC (rev 38298)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java 2012-01-30 20:12:47 UTC (rev 38299)
@@ -650,7 +650,7 @@
}
protected String getVersionString(File loc) {
- String version = new ServerBeanLoader().getFullServerVersion(loc);
+ String version = new ServerBeanLoader(loc).getFullServerVersion();
return version;
}
@@ -659,7 +659,7 @@
}
protected String getHomeVersionWarning() {
- File loc = new File(homeDir, getSystemJarPath() );
+ File loc = new File(homeDir);
String version = getVersionString(loc);
IRuntime rt = (IRuntime) getTaskModel().getObject(
TaskModel.TASK_RUNTIME);
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/ServerBeanLoaderTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/ServerBeanLoaderTest.java 2012-01-30 19:30:30 UTC (rev 38298)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/ServerBeanLoaderTest.java 2012-01-30 20:12:47 UTC (rev 38299)
@@ -1,7 +1,5 @@
package org.jboss.ide.eclipse.as.test.server;
-import java.io.File;
-
import junit.framework.TestCase;
import org.eclipse.core.runtime.IPath;
@@ -40,28 +38,43 @@
serverBeanLoaderTestAS6AndBelow("serverEAP5/jbossas", IJBossToolingConstants.SERVER_EAP_50, JBossServerType.EAP_STD,IJBossToolingConstants.V5_0);
}
public void testEAP60() {
- serverBeanLoaderTestAS7Style("serverEap6", IJBossToolingConstants.SERVER_EAP_60, JBossServerType.EAP6,IJBossToolingConstants.V6_0);
+ serverBeanLoaderTestEAP6Style("serverEap6", IJBossToolingConstants.SERVER_EAP_60, JBossServerType.EAP6,IJBossToolingConstants.V6_0);
}
private void serverBeanLoaderTestAS6AndBelow(String name, String serverTypeId,
JBossServerType expected, String actualVersionPrefix) {
IPath serverDir = ServerRuntimeUtils.createAS6AndBelowMockServerDirectory(
name, ServerRuntimeUtils.asSystemJar.get(serverTypeId), "default");
- ServerBeanLoader loader = new ServerBeanLoader();
- JBossServerType type = loader.getServerType(serverDir.toFile());
+ ServerBeanLoader loader = new ServerBeanLoader(serverDir.toFile());
+ JBossServerType type = loader.getServerType();
assertTrue(type.equals(expected));
- String fullVersion = loader.getFullServerVersion(new File(serverDir.toFile(), type.getSystemJarPath()));
+ String fullVersion = loader.getFullServerVersion();
assertTrue(fullVersion.startsWith(actualVersionPrefix));
+ assertEquals(loader.getServerAdapterId(), serverTypeId);
}
private void serverBeanLoaderTestAS7Style(String name, String serverTypeId,
JBossServerType expected, String actualVersionPrefix) {
IPath serverDir = ServerRuntimeUtils.createAS7StyleMockServerDirectory(
name, serverTypeId, ServerRuntimeUtils.asSystemJar.get(serverTypeId));
- ServerBeanLoader loader = new ServerBeanLoader();
- JBossServerType type = loader.getServerType(serverDir.toFile());
+ ServerBeanLoader loader = new ServerBeanLoader(serverDir.toFile());
+ JBossServerType type = loader.getServerType();
assertTrue(type.equals(expected));
- String fullVersion = loader.getFullServerVersion(new File(serverDir.toFile(), type.getSystemJarPath()));
+ String fullVersion = loader.getFullServerVersion();
assertTrue(fullVersion.startsWith(actualVersionPrefix));
+ assertEquals(loader.getServerAdapterId(), serverTypeId);
}
+
+ private void serverBeanLoaderTestEAP6Style(String name, String serverTypeId,
+ JBossServerType expected, String actualVersionPrefix) {
+ IPath serverDir = ServerRuntimeUtils.createEAP6StyleMockServerDirectory(
+ name, serverTypeId, ServerRuntimeUtils.asSystemJar.get(serverTypeId));
+ ServerBeanLoader loader = new ServerBeanLoader(serverDir.toFile());
+ JBossServerType type = loader.getServerType();
+ assertTrue(type.equals(expected));
+ String fullVersion = loader.getFullServerVersion();
+ assertTrue(fullVersion.startsWith(actualVersionPrefix));
+ assertEquals(loader.getServerAdapterId(), serverTypeId);
+ }
+
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java 2012-01-30 19:30:30 UTC (rev 38298)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java 2012-01-30 20:12:47 UTC (rev 38299)
@@ -18,6 +18,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -28,6 +29,25 @@
import org.jboss.tools.test.util.JobUtils;
public class IOUtil {
+
+ public static void setContents(File file, String contents) throws IOException, CoreException {
+ byte[] buffer = new byte[65536];
+ InputStream in = new ByteArrayInputStream(contents.getBytes());
+ OutputStream out = null;
+ try {
+ out = new BufferedOutputStream(new FileOutputStream(file));
+ int avail = in.read(buffer);
+ while (avail > 0) {
+ out.write(buffer, 0, avail);
+ avail = in.read(buffer);
+ }
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
public static String getContents(IFile file) throws IOException, CoreException {
return getContents(file.getLocation().toFile());
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2012-01-30 19:30:30 UTC (rev 38298)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2012-01-30 20:12:47 UTC (rev 38299)
@@ -275,6 +275,27 @@
return loc;
}
+ public static IPath createEAP6StyleMockServerDirectory(String name, String serverTypeId, String serverJar) {
+ IPath loc = mockedServers.append(name);
+ try {
+ loc.toFile().mkdirs();
+ IPath productConf = loc.append("bin/product.conf");
+ loc.append("bin").toFile().mkdirs();
+ IOUtil.setContents(productConf.toFile(), "slot=eap");
+ loc.append("modules/org/jboss/as/product/eap/dir/META-INF").toFile().mkdirs();
+ IPath manifest = loc.append("modules/org/jboss/as/product/eap/dir/META-INF/MANIFEST.MF");
+ String manString = "JBoss-Product-Release-Name: EAP\nJBoss-Product-Release-Version: 6.0.0.Alpha\nJBoss-Product-Console-Slot: eap";
+ IOUtil.setContents(manifest.toFile(), manString);
+ } catch(CoreException ce) {
+ FileUtil.completeDelete(loc.toFile());
+ return null;
+ } catch(IOException ioe) {
+ FileUtil.completeDelete(loc.toFile());
+ return null;
+ }
+ return loc;
+ }
+
// Find a file in our bundle
protected static File getFileLocation(String path) throws CoreException {
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2012-01-30 19:30:30 UTC (rev 38298)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2012-01-30 20:12:47 UTC (rev 38299)
@@ -143,9 +143,9 @@
String ver = serverDefinition.getVersion();
String fullVersion;
if (EAP.equals(type) && "6.0".equals(ver)) {
- fullVersion = new ServerBeanLoader().getFullServerVersion(new File(asLocation, JBossServerType.EAP6.getSystemJarPath()));
+ fullVersion = new ServerBeanLoader(asLocation).getFullServerVersion();
} else {
- fullVersion = new ServerBeanLoader().getFullServerVersion(new File(asLocation, JBossServerType.AS.getSystemJarPath()));
+ fullVersion = new ServerBeanLoader(asLocation).getFullServerVersion();
}
if(fullVersion != null ) {
String version = fullVersion.substring(0, 3);
@@ -332,8 +332,8 @@
if (monitor.isCanceled() || root == null || !isEnabled()) {
return null;
}
- ServerBeanLoader loader = new ServerBeanLoader();
- ServerBean serverBean = loader.loadFromLocation(root);
+ ServerBeanLoader loader = new ServerBeanLoader(root);
+ ServerBean serverBean = loader.getServerBean();
if (!JBossServerType.UNKNOWN.equals(serverBean.getType())) {
ServerDefinition serverDefinition = new ServerDefinition(serverBean.getName(),
12 years, 11 months
JBoss Tools SVN: r38298 - in trunk: seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/hyperlink and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2012-01-30 14:30:30 -0500 (Mon, 30 Jan 2012)
New Revision: 38298
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/XHTMLDetectorAndValidatorTest.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/hyperlink/SeamViewHyperlinkPartitionerTest.java
Log:
JBIDE-10621
Redesign HyperlinkDetector so that partitioning and hyperlinks not do twice the same job.
JUnit tests are fixed
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/XHTMLDetectorAndValidatorTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/XHTMLDetectorAndValidatorTest.java 2012-01-30 19:28:30 UTC (rev 38297)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/XHTMLDetectorAndValidatorTest.java 2012-01-30 19:30:30 UTC (rev 38298)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.jsf.test.validation;
import java.io.File;
@@ -52,7 +62,6 @@
"/html_page_2.html"
};
-
IProject project;
/* (non-Javadoc)
@@ -185,6 +194,4 @@
return (content == null ? null : new Document(content));
}
-
-
}
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/hyperlink/SeamViewHyperlinkPartitionerTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/hyperlink/SeamViewHyperlinkPartitionerTest.java 2012-01-30 19:28:30 UTC (rev 38297)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/hyperlink/SeamViewHyperlinkPartitionerTest.java 2012-01-30 19:30:30 UTC (rev 38298)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.seam.ui.test.hyperlink;
import java.util.ArrayList;
@@ -111,20 +121,22 @@
for (int i = 0; i < document.getLength(); i++) {
TestData testData = new TestData(document, i);
- String[] partitionTypes = detector.getPartitionTypes(document, i);
+ IHyperlinkRegion[] partitions = detector.getPartitions(document, i);
boolean recognized = false;
- if (partitionTypes != null && partitionTypes.length > 0) {
- recognized = ("org.jboss.tools.seam.text.ext.SEAM_VIEW_LINK".equals(partitionTypes[0]));
+ if (partitions != null && partitions.length > 0) {
+ recognized = ("org.jboss.tools.seam.text.ext.SEAM_VIEW_LINK".equals(partitions[0].getType()));
}
if (recognized) {
- recognized &= seamViewPartitioner.recognize(testData.document, testData.getHyperlinkRegion());
+ recognized &= seamViewPartitioner.recognize(testData.document, i, testData.getHyperlinkRegion());
}
if (recognized) {
- String childPartitionType = seamViewPartitioner.getChildPartitionType(testData.document, testData.getHyperlinkRegion());
+ IHyperlinkRegion childPartition = seamViewPartitioner.getChildPartitionRegion(testData.document, i, testData.getHyperlinkRegion());
+ String childPartitionType = childPartition == null ? null : childPartition.getType();
+
// if (childPartitionType != null)
// System.out.println("position #" + i + " partitionType: " + childPartitionType);
@@ -279,10 +291,10 @@
* @param document -
* assumes document is not null
* @param offset
- * @return String partition types
+ * @return IHyperlinkRegion partitions
*/
- public String[] getPartitionTypes(IDocument document, int offset) {
- return super.getPartitionTypes(document, offset);
+ public IHyperlinkRegion[] getPartitions(IDocument document, int offset) {
+ return super.getPartitions(document, offset);
}
};
12 years, 11 months
JBoss Tools SVN: r38297 - trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2012-01-30 14:28:30 -0500 (Mon, 30 Jan 2012)
New Revision: 38297
Removed:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink0.java
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionMappingHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBeanNameHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleKeyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleKeyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormBeanHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormPropertyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigForwardPathHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPageHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsContextParamLinkHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormActionHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormBeanHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormValidationBundleKeyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsForwardHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPLinkHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsLogicPropertyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPageHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertiesFileHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationPropertyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationValidatorHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLContextParamLinkHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLLinkHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXModelBasedHyperlink.java
Log:
JBIDE-10621
Redesign HyperlinkDetector so that partitioning and hyperlinks not do twice the same job.
Hyperlinks and Hyperlink Partitioners are redesigned due to exclude duplication work on regions calculation.
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -81,11 +81,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String actionName = getAction(fLastRegion);
+ String actionName = getAction(getHyperlinkRegion());
if (actionName == null)
return MessageFormat.format(Messages.OpenAn, StrutsTextExtMessages.Action);
return MessageFormat.format(StrutsTextExtMessages.OpenAction, actionName);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionMappingHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionMappingHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionMappingHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -54,12 +54,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String actionName = getAction(fLastRegion);
+ String actionName = getAction(getHyperlinkRegion());
if (actionName == null)
return MessageFormat.format(Messages.OpenAn, StrutsTextExtMessages.ActionMapping);
return MessageFormat.format(StrutsTextExtMessages.OpenActionMapping, actionName);
}
-
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBeanNameHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBeanNameHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBeanNameHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -19,11 +19,11 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
-import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.StructuredSelectionHelper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.jst.web.project.WebProject;
import org.jboss.tools.jst.web.tld.TaglibMapping;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
@@ -32,7 +32,6 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -188,86 +187,6 @@
}
}
- IRegion fLastRegion = null;
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
-
- private IRegion getRegion(int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- try {
- smw.init(getDocument());
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr || n instanceof Text)) return null;
-
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
-
- if (start < 0 || start > offset || end < offset) return null;
-
- String text = getDocument().get(start, end - start);
- StringBuffer sb = new StringBuffer(text);
-
- //find start and end of path property
- int bStart = 0;
- int bEnd = text.length() - 1;
-
- while (bStart < bEnd && (Character.isWhitespace(sb.charAt(bStart))
- || sb.charAt(bStart) == '\"' || sb.charAt(bStart) == '\"')) {
- bStart++;
- }
- while (bEnd > bStart && (Character.isWhitespace(sb.charAt(bEnd))
- || sb.charAt(bEnd) == '\"' || sb.charAt(bEnd) == '\"')) {
- bEnd--;
- }
- bEnd++;
-
- final int propStart = bStart + start;
- final int propLength = bEnd - bStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
-
- IRegion region = new IRegion () {
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public int getLength() {
- return propLength;
- }
-
- public int getOffset() {
- return propStart;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+ "]";
- }
- };
-
- return region;
- } catch (BadLocationException x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- } finally {
- smw.dispose();
- }
- }
-
private String getPrefix(IRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
@@ -294,11 +213,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String forId = getForId(fLastRegion);
+ String forId = getForId(getHyperlinkRegion());
if (forId == null)
return MessageFormat.format(Messages.BrowseFor, Messages.BeanId);
return MessageFormat.format(Messages.BrowseForBeanId, forId);
}
-
}
\ No newline at end of file
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -23,8 +23,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsBundleHyperlink extends StrutsXModelBasedHyperlink {
@@ -56,11 +54,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String baseName = getBundle(fLastRegion);
+ String baseName = getBundle(getHyperlinkRegion());
if (baseName == null)
return MessageFormat.format(Messages.OpenA, Messages.Bundle);
return MessageFormat.format(Messages.OpenBundle, baseName);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleKeyHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleKeyHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleKeyHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -86,12 +86,11 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String baseName = getBundle(fLastRegion);
- String propertyName = getKey(fLastRegion);
+ String baseName = getBundle(getHyperlinkRegion());
+ String propertyName = getKey(getHyperlinkRegion());
if (baseName == null || propertyName == null)
return MessageFormat.format(Messages.OpenA, Messages.BundleProperty);
return MessageFormat.format(Messages.OpenBundleProperty, propertyName, baseName);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -23,8 +23,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsConfigBundleHyperlink extends StrutsXModelBasedHyperlink {
@@ -58,11 +56,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String baseName = getBundle(fLastRegion);
+ String baseName = getBundle(getHyperlinkRegion());
if (baseName == null)
return MessageFormat.format(Messages.OpenA, Messages.Bundle);
return MessageFormat.format(Messages.OpenBundle, baseName);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleKeyHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleKeyHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleKeyHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -85,12 +85,11 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String baseName = getBundle(fLastRegion);
- String propertyName = getKey(fLastRegion);
+ String baseName = getBundle(getHyperlinkRegion());
+ String propertyName = getKey(getHyperlinkRegion());
if (baseName == null || propertyName == null)
return MessageFormat.format(Messages.OpenA, Messages.BundleProperty);
return MessageFormat.format(Messages.OpenBundleProperty, propertyName, baseName);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormBeanHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormBeanHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormBeanHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -24,8 +24,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsConfigFormBeanHyperlink extends StrutsXModelBasedHyperlink {
@@ -61,11 +59,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String formBeanName = getAttributeValue(fLastRegion);
+ String formBeanName = getAttributeValue(getHyperlinkRegion());
if (formBeanName == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.FormBean);
return MessageFormat.format(StrutsTextExtMessages.OpenFormBean, formBeanName);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormPropertyHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormPropertyHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormPropertyHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -85,7 +85,7 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String formPropertyName = getName(fLastRegion);
+ String formPropertyName = getName(getHyperlinkRegion());
if (formPropertyName == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.FormProperty);
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigForwardPathHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigForwardPathHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigForwardPathHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -138,11 +138,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String path = getPath(fLastRegion);
+ String path = getPath(getHyperlinkRegion());
if (path == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.ForwardPath);
return MessageFormat.format(StrutsTextExtMessages.OpenForwardPath, path);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPageHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPageHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPageHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -24,8 +24,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsConfigPageHyperlink extends StrutsXModelBasedHyperlink {
@@ -56,12 +54,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String page = getPage(fLastRegion);
+ String page = getPage(getHyperlinkRegion());
if (page == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.Page);
return MessageFormat.format(StrutsTextExtMessages.OpenPage, page);
}
-
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -15,15 +15,10 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
-import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -54,80 +49,17 @@
return null;
}
}
-
- protected IRegion getRegion (int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- try {
- smw.init(getDocument());
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr)) return null;
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
- if (start < 0 || start > offset) return null;
-
- String attrText = getDocument().get(start, end - start);
-
- StringBuffer sb = new StringBuffer(attrText);
- //find start of bean property
- int bStart = offset - start;
- while (bStart >= 0) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bStart)) &&
- sb.charAt(bStart) != '\\' && sb.charAt(bStart) != '/' &&
- sb.charAt(bStart) != ':' && sb.charAt(bStart) != '-' &&
- sb.charAt(bStart) != '.' && sb.charAt(bStart) != '_' &&
- sb.charAt(bStart) != '%' && sb.charAt(bStart) != '?' &&
- sb.charAt(bStart) != '&' && sb.charAt(bStart) != '=') {
- bStart++;
- break;
- }
-
- if (bStart == 0) break;
- bStart--;
- }
- // find end of bean property
- int bEnd = offset - start;
- while (bEnd < sb.length()) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bEnd)) &&
- sb.charAt(bEnd) != '\\' && sb.charAt(bEnd) != '/' &&
- sb.charAt(bEnd) != ':' && sb.charAt(bEnd) != '-' &&
- sb.charAt(bEnd) != '.' && sb.charAt(bEnd) != '_' &&
- sb.charAt(bEnd) != '%' && sb.charAt(bEnd) != '?' &&
- sb.charAt(bEnd) != '&' && sb.charAt(bEnd) != '=') {
- break;
- }
- bEnd++;
- }
-
- int propStart = bStart + start;
- int propLength = bEnd - bStart;
- if (propStart > offset || propStart + propLength < offset) return null;
- IRegion region = new HyperlinkRegion(propStart, propLength);
- return region;
- } catch (BadLocationException x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- } finally {
- smw.dispose();
- }
- }
-
/*
* (non-Javadoc)
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getAttributeValue(fLastRegion);
+ String propertyName = getAttributeValue(getHyperlinkRegion());
if (propertyName == null)
return MessageFormat.format(Messages.OpenA, Messages.Setter);
return MessageFormat.format(Messages.OpenGetterOrSetterForProperty, Messages.Setter, propertyName);
}
-
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlinkPartitioner.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlinkPartitioner.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlinkPartitioner.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -73,13 +73,12 @@
private static final String VALID_CLASS_NAME_VALUE = "org.apache.struts.validator.ValidatorPlugIn";
private static final String VALID_PROPERTY_VALUE = "pathnames";
-
/**
* @see com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument, com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
- if (!super.recognize(document, region))
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
+ if (!super.recognize(document, offset, region))
return false;
if (!recognizeNature(document))
@@ -90,7 +89,7 @@
try {
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (n == null || !(n instanceof Attr)) return false;
Node node = ((Attr)n).getOwnerElement();
Node plugInNode = node.getParentNode();
@@ -120,5 +119,4 @@
return null;
}
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -62,11 +62,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getAttributeValue(fLastRegion, PROPERTY_ATTRNAME);
+ String propertyName = getAttributeValue(getHyperlinkRegion(), PROPERTY_ATTRNAME);
if (propertyName == null)
return MessageFormat.format(Messages.OpenA, Messages.Setter);
return MessageFormat.format(Messages.OpenGetterOrSetterForProperty, Messages.Setter, propertyName);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlinkPartitioner.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlinkPartitioner.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlinkPartitioner.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -68,10 +68,10 @@
/**
* @see com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument, com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
if(document == null || region == null) return false;
- if (!super.recognize(document, region))
+ if (!super.recognize(document, offset, region))
return false;
if (!recognizeNature(document))
@@ -83,7 +83,7 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (n == null || !(n instanceof Attr)) return false;
@@ -108,5 +108,4 @@
return null;
}
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsContextParamLinkHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsContextParamLinkHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsContextParamLinkHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,90 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IRegion;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.common.text.ext.util.Utils;
-import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
-
/**
* @author Jeremy
*/
public class StrutsContextParamLinkHyperlink extends StrutsLinkHyperlink {
-
- protected IRegion getRegion (int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Text)) return null;
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
-
- if (start < 0 || start > offset) return null;
-
- String attrText = getDocument().get(start, end - start);
-
- StringBuffer sb = new StringBuffer(attrText);
- //find start of bean property
- int bStart = offset - start;
- while (bStart >= 0) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bStart)) &&
- sb.charAt(bStart) != '\\' && sb.charAt(bStart) != '/' &&
- sb.charAt(bStart) != ':' && sb.charAt(bStart) != '-' &&
- sb.charAt(bStart) != '.' && sb.charAt(bStart) != '_' &&
- sb.charAt(bStart) != '%' && sb.charAt(bStart) != '?' &&
- sb.charAt(bStart) != '&' && sb.charAt(bStart) != '=') {
- bStart++;
- break;
- }
-
- if (bStart == 0) break;
- bStart--;
- }
- // find end of bean property
- int bEnd = offset - start;
- while (bEnd < sb.length()) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bEnd)) &&
- sb.charAt(bEnd) != '\\' && sb.charAt(bEnd) != '/' &&
- sb.charAt(bEnd) != ':' && sb.charAt(bEnd) != '-' &&
- sb.charAt(bEnd) != '.' && sb.charAt(bEnd) != '_' &&
- sb.charAt(bEnd) != '%' && sb.charAt(bEnd) != '?' &&
- sb.charAt(bEnd) != '&' && sb.charAt(bEnd) != '=') {
- break;
- }
- bEnd++;
- }
-
- int propStart = bStart + start;
- int propLength = bEnd - bStart;
- if (propStart > offset || propStart + propLength < offset) return null;
- IRegion region = new HyperlinkRegion(propStart, propLength);
- return region;
- } catch (BadLocationException x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- } finally {
- smw.dispose();
- }
- }
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormActionHyperlinkPartitioner.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormActionHyperlinkPartitioner.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormActionHyperlinkPartitioner.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,27 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPTagAttributeValueHyperlinkPartitioner;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -39,21 +37,20 @@
/**
* @see com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument, com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
- if (!super.recognize(document, region))
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
+ if (!super.recognize(document, offset, region))
return false;
-
-
- return checkTypeIsEmpty(document, region);
+
+ return checkTypeIsEmpty(document, offset);
}
- private boolean checkTypeIsEmpty(IDocument document, IRegion region) {
+ private boolean checkTypeIsEmpty(IDocument document, int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
try {
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (n == null || !(n instanceof Attr)) return false;
Node node = ((Attr)n).getOwnerElement();
Attr typeAttr = (Attr)node.getAttributes().getNamedItem("type");
@@ -67,5 +64,4 @@
smw.dispose();
}
}
-
}
\ No newline at end of file
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormBeanHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormBeanHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormBeanHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -24,8 +24,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsFormBeanHyperlink extends StrutsXModelBasedHyperlink {
@@ -56,7 +54,7 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String formBeanName = getFormBean(fLastRegion);
+ String formBeanName = getFormBean(getHyperlinkRegion());
if (formBeanName == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.FormBean);
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormValidationBundleKeyHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormValidationBundleKeyHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormValidationBundleKeyHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -15,7 +15,6 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
-
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
@@ -26,8 +25,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsFormValidationBundleKeyHyperlink extends StrutsXModelBasedHyperlink {
@@ -63,11 +60,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getKey(fLastRegion);
+ String propertyName = getKey(getHyperlinkRegion());
if (propertyName == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.ValidationBundleProperty);
return MessageFormat.format(StrutsTextExtMessages.OpenValidationBundleProperty, propertyName);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsForwardHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsForwardHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsForwardHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -24,8 +24,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsForwardHyperlink extends StrutsXModelBasedHyperlink {
@@ -56,11 +54,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String forward = getForward(fLastRegion);
+ String forward = getForward(getHyperlinkRegion());
if (forward == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.Forward);
return MessageFormat.format(StrutsTextExtMessages.OpenForward, forward);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPLinkHyperlinkPartitioner.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPLinkHyperlinkPartitioner.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPLinkHyperlinkPartitioner.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -14,12 +14,11 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
-
-import org.jboss.tools.struts.StrutsProject;
-import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
-import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPLinkHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPLinkHyperlinkPartitioner;
+import org.jboss.tools.struts.StrutsProject;
+import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.w3c.dom.Document;
public class StrutsJSPLinkHyperlinkPartitioner extends JSPLinkHyperlinkPartitioner {
@@ -65,8 +64,7 @@
/**
* @see com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument, com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
- return recognizeNature(document) ? super.recognize(document, region) : false;
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
+ return recognizeNature(document) ? super.recognize(document, offset, region) : false;
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -21,8 +21,8 @@
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.jboss.tools.struts.text.ext.StrutsTextExtMessages;
@@ -30,7 +30,6 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -63,7 +62,6 @@
}
}
-
protected Properties getRequestProperties(IRegion region) {
Properties p = new Properties();
@@ -132,15 +130,6 @@
}
}
- IRegion fLastRegion = null;
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
-
private String getTagAttributeName(IRegion region) {
if(region == null || getDocument() == null) return null;
try {
@@ -151,77 +140,6 @@
}
}
- protected IRegion getRegion (int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- try {
- smw.init(getDocument());
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr || n instanceof Text)) return null;
-
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
-
- if (start > offset || end < offset) return null;
-
- String text = getDocument().get(start, end - start);
- StringBuffer sb = new StringBuffer(text);
-
- //find start and end of class property
- int bStart = 0;
- int bEnd = text.length() - 1;
-
- while (bStart < bEnd && (Character.isWhitespace(sb.charAt(bStart))
- || sb.charAt(bStart) == '\"' || sb.charAt(bStart) == '\"')) {
- bStart++;
- }
- while (bEnd > bStart && (Character.isWhitespace(sb.charAt(bEnd))
- || sb.charAt(bEnd) == '\"' || sb.charAt(bEnd) == '\"')) {
- bEnd--;
- }
- bEnd++;
-
- final int propStart = bStart + start;
- final int propLength = bEnd - bStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
- IRegion region = new IRegion () {
- public int getLength() {
- return propLength;
- }
-
- public int getOffset() {
- return propStart;
- }
-
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+ "]";
- }
-
- };
-
- return region;
- } catch (BadLocationException x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- } finally {
- smw.dispose();
- }
- }
-
protected String getAttributeValue (IDocument document, Node node, String attrName) {
if(document == null || node == null || attrName == null) return null;
try {
@@ -239,12 +157,11 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String tagName = getTagName(fLastRegion);
- String attrName = getTagAttributeName(fLastRegion);
+ String tagName = getTagName(getHyperlinkRegion());
+ String attrName = getTagAttributeName(getHyperlinkRegion());
if (tagName == null || attrName == null)
return StrutsTextExtMessages.OpenTagLibraryForAnAttribute;
return MessageFormat.format(StrutsTextExtMessages.OpenTagLibraryForAttributeName, attrName, tagName);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlinkPartitioner.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlinkPartitioner.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlinkPartitioner.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -42,7 +42,7 @@
/**
* @see com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument, com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ protected IHyperlinkRegion parse(IDocument document, int offset, IHyperlinkRegion superRegion) {
if(document == null || superRegion == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
@@ -50,18 +50,14 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
- IRegion r = getRegion(document, superRegion.getOffset());
+ IRegion r = getRegion(document, offset);
if (r == null) return null;
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = STRUTS_JSP_TAG_ATTRIBUTE_PARTITION;
- int length = r.getLength() - (superRegion.getOffset() - r.getOffset());
- int offset = superRegion.getOffset();
- IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType, type);
- return region;
+ return new HyperlinkRegion(r.getOffset(), r.getLength(), axis, contentType, type);
} finally {
smw.dispose();
}
@@ -70,7 +66,7 @@
/**
* @see com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument, com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
@@ -172,5 +168,4 @@
}
return superRegion.getAxis();
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -18,12 +18,11 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.jboss.tools.struts.text.ext.StrutsTextExtMessages;
@@ -63,7 +62,6 @@
openFileFailed();
}
}
-
protected Properties getRequestProperties(IRegion region) {
Properties p = new Properties();
@@ -131,64 +129,6 @@
}
}
- IRegion fLastRegion = null;
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
-
- protected IRegion getRegion (int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof IDOMElement)) return null;
-
- IDOMElement elem = (IDOMElement)n;
- String tagName = elem.getTagName();
- int start = elem.getStartOffset();
- final int nameStart = start + (elem.isEndTag() ? "</" : "<").length();
- final int nameEnd = nameStart + tagName.length();
-
- if (nameStart > offset || nameEnd <= offset) return null;
-
- IRegion region = new IRegion () {
-
- public int getLength() {
- return nameEnd - nameStart;
- }
-
- public int getOffset() {
- return nameStart;
- }
-
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+ "]";
- }
- };
-
- return region;
- } finally {
- smw.dispose();
- }
- }
-
protected String getAttributeValue (IDocument document, Node node, String attrName) {
if(document == null || node == null || attrName == null) return null;
try {
@@ -206,11 +146,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String tagName = getTagName(fLastRegion);
+ String tagName = getTagName(getHyperlinkRegion());
if (tagName == null)
return StrutsTextExtMessages.OpenTagLibraryForATag;
return MessageFormat.format(StrutsTextExtMessages.OpenTagLibraryForTagName, tagName);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlinkPartitioner.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlinkPartitioner.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlinkPartitioner.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -15,14 +15,15 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkPartitionRecognizer;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
-import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.struts.StrutsProject;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.w3c.dom.Document;
@@ -39,7 +40,7 @@
/**
* @see com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument, com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ protected IHyperlinkRegion parse(IDocument document, int offset, IHyperlinkRegion superRegion) {
if(document == null || superRegion == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
@@ -47,20 +48,14 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
-// Node n =
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
-// if (!recognize(document, superRegion)) return null;
- IRegion r = getRegion(document, superRegion.getOffset());
+ IRegion r = getRegion(document, offset);
if (r == null) return null;
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = STRUTS_JSP_TAG_NAME_PARTITION;
- int length = r.getLength() - (superRegion.getOffset() - r.getOffset());
- int offset = superRegion.getOffset();
- IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType, type);
- return region;
+ return new HyperlinkRegion(r.getOffset(), r.getLength(), axis, contentType, type);
} finally {
smw.dispose();
}
@@ -69,7 +64,7 @@
/**
* @see com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument, com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
try {
@@ -100,42 +95,17 @@
if (xmlDocument == null) return null;
Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
if (n == null || !(n instanceof IDOMElement)) return null;
IDOMElement elem = (IDOMElement)n;
String tagName = elem.getTagName();
int start = elem.getStartOffset();
+
final int nameStart = start + (elem.isEndTag() ? "</" : "<").length();
final int nameEnd = nameStart + tagName.length();
-
if (nameStart > offset || nameEnd <= offset) return null;
- IRegion region = new IRegion () {
-
- public int getLength() {
- return nameEnd - nameStart;
- }
-
- public int getOffset() {
- return nameStart;
- }
-
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+ "]";
- }
- };
-
- return region;
+ return new Region(nameStart, nameEnd-nameStart);
} finally {
smw.dispose();
}
@@ -148,5 +118,4 @@
}
return superRegion.getAxis();
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsLogicPropertyHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsLogicPropertyHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsLogicPropertyHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -19,13 +19,14 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
-import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.jst.web.project.WebProject;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
import org.jboss.tools.jst.web.tld.TaglibMapping;
@@ -35,7 +36,6 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -159,28 +159,7 @@
final int offset = Utils.getValueStart(element);
final int length = ((IDOMElement)element).getStartStructuredDocumentRegion().getLength();
- return new IRegion () {
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public int getLength() {
- return length;
- }
-
- public int getOffset() {
- return offset;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+ "]";
- }
- };
+ return new Region (offset, length);
} finally {
smw.dispose();
}
@@ -255,86 +234,6 @@
}
}
- IRegion fLastRegion = null;
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
-
- private IRegion getRegion(int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr || n instanceof Text)) return null;
-
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
-
- if (start > offset || end < offset) return null;
-
- String text = getDocument().get(start, end - start);
- StringBuffer sb = new StringBuffer(text);
-
- //find start and end of path property
- int bStart = 0;
- int bEnd = text.length() - 1;
-
- while (bStart < bEnd && (Character.isWhitespace(sb.charAt(bStart))
- || sb.charAt(bStart) == '\"' || sb.charAt(bStart) == '\"')) {
- bStart++;
- }
- while (bEnd > bStart && (Character.isWhitespace(sb.charAt(bEnd))
- || sb.charAt(bEnd) == '\"' || sb.charAt(bEnd) == '\"')) {
- bEnd--;
- }
- bEnd++;
-
- final int propStart = bStart + start;
- final int propLength = bEnd - bStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
-
- IRegion region = new IRegion () {
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public int getLength() {
- return propLength;
- }
-
- public int getOffset() {
- return propStart;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+ "]";
- }
- };
-
- return region;
- } catch (BadLocationException x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- } finally {
- smw.dispose();
- }
- }
-
private String getPrefix(IRegion region) {
if(region == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
@@ -362,11 +261,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String forId = getForId(fLastRegion);
+ String forId = getForId(getHyperlinkRegion());
if (forId == null)
return MessageFormat.format(Messages.BrowseFor, Messages.BeanId);
return MessageFormat.format(Messages.BrowseForBeanId, forId);
}
-
}
\ No newline at end of file
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPageHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPageHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPageHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -24,8 +24,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsPageHyperlink extends StrutsXModelBasedHyperlink {
@@ -56,12 +54,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String page = getPage(fLastRegion);
+ String page = getPage(getHyperlinkRegion());
if (page == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.Page);
return MessageFormat.format(StrutsTextExtMessages.OpenPage, page);
}
-
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertiesFileHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertiesFileHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertiesFileHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -55,11 +55,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getProperty(fLastRegion);
+ String propertyName = getProperty(getHyperlinkRegion());
if (propertyName == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.Property);
return MessageFormat.format(StrutsTextExtMessages.OpenProperty, propertyName);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertyHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertyHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertyHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -145,13 +145,11 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getProperty(fLastRegion);
- String actionName = getFormAction(fLastRegion);
+ String propertyName = getProperty(getHyperlinkRegion());
+ String actionName = getFormAction(getHyperlinkRegion());
if (propertyName == null || actionName == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.Property);
return MessageFormat.format(StrutsTextExtMessages.OpenPropertyForFormAction, propertyName, actionName);
}
-
-
}
\ No newline at end of file
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -16,7 +16,6 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.jboss.tools.common.text.ext.hyperlink.XModelBasedHyperlink;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
@@ -84,64 +83,16 @@
}
}
- protected IRegion getRegion(final int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr || n instanceof Node)) return null;
-
- if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
- if ((n == null) || !(n instanceof IDOMNode)) return null;
-
- IDOMNode node = (IDOMNode)n;
-
- final int propStart = node.getStartOffset();
- final int propLength = node.getEndOffset() - propStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
- IRegion region = new IRegion () {
-
- public int getLength() {
- return propLength;
- }
-
- public int getOffset() {
- return propStart;
- }
-
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
- };
- return region;
- } finally {
- smw.dispose();
- }
-
- }
-
/*
* (non-Javadoc)
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String uri = getTaglibUri(fLastRegion);
+ String uri = getTaglibUri(getHyperlinkRegion());
if (uri == null)
return MessageFormat.format(Messages.OpenA, Messages.TagLibrary);
return MessageFormat.format(Messages.OpenTagLibraryForUri, uri);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlinkPartitioner.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlinkPartitioner.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlinkPartitioner.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -15,11 +15,12 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
-import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPTagAttributeValueHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPTagAttributeValueHyperlinkPartitioner;
import org.jboss.tools.struts.StrutsProject;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.w3c.dom.Attr;
@@ -46,7 +47,7 @@
/**
* @see com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument, com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
if (!recognizeNature(document))
return false;
@@ -56,7 +57,7 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (!(n instanceof Attr || n instanceof Node) ) return false;
return true;
@@ -110,30 +111,9 @@
if (propStart > offset || propStart + propLength < offset) return null;
- IRegion region = new IRegion () {
- public int getLength() {
- return propLength;
- }
-
- public int getOffset() {
- return propStart;
- }
-
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
- };
- return region;
+ return new Region(propStart, propLength);
} finally {
smw.dispose();
}
-
}
-
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -24,8 +24,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsValidationBundleHyperlink extends StrutsXModelBasedHyperlink {
@@ -59,11 +57,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String baseName = getBundle(fLastRegion);
+ String baseName = getBundle(getHyperlinkRegion());
if (baseName == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.ValidationBundle);
return MessageFormat.format(StrutsTextExtMessages.OpenValidationBundle, baseName);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -87,12 +87,11 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getKey(fLastRegion);
- String baseName = getBundle(fLastRegion);
+ String propertyName = getKey(getHyperlinkRegion());
+ String baseName = getBundle(getHyperlinkRegion());
if (propertyName == null || baseName == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.ValidationBundleProperty);
return MessageFormat.format(StrutsTextExtMessages.OpenValidationBundlePropertyForBundle, propertyName, baseName);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlinkPartitioner.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlinkPartitioner.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlinkPartitioner.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,26 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import org.jboss.tools.common.text.ext.hyperlink.xml.XMLTagAttributeValueHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
-import org.jboss.tools.common.text.ext.hyperlink.xml.XMLTagAttributeValueHyperlinkPartitioner;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -43,8 +42,8 @@
/**
* @see com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument, com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
- if (!super.recognize(document, region))
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
+ if (!super.recognize(document, offset, region))
return false;
StructuredModelWrapper smw = new StructuredModelWrapper();
@@ -53,7 +52,7 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (!(n instanceof Attr)) return false;
Node parentNode = ((Attr)n).getOwnerElement();
@@ -78,6 +77,4 @@
return null;
}
}
-
-
}
\ No newline at end of file
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -22,8 +22,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsValidationMethodHyperlink extends ClassMethodHyperlink {
private static final String CLASSNAME_ATTRNAME = "classname";
@@ -54,12 +52,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String methodName = getMethodName(fLastRegion);
+ String methodName = getMethodName(getHyperlinkRegion());
if (methodName == null)
return MessageFormat.format(Messages.OpenA, Messages.ValidationMethod);
return MessageFormat.format(Messages.OpenValidationMethod, methodName);
}
-
-
}
Deleted: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink0.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink0.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink0.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,112 +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.struts.text.ext.hyperlink;
-
-import java.text.MessageFormat;
-import java.util.Properties;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IRegion;
-import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.common.text.ext.util.Utils;
-import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-/**
- * @author Jeremy
- */
-public class StrutsValidationMethodHyperlink0 extends StrutsXModelBasedHyperlink {
- private static final String CLASSNAME_ATTRNAME = "classname";
-// private static final String METHODPARAMS_ATTRNAME = "methodParams";
-
- protected String getRequestMethod() {
- return WebPromptingProvider.STRUTS_OPEN_METHOD;
- }
-
- protected Properties getRequestProperties(IRegion region) {
- Properties p = new Properties();
-
- String value = getMethodName(region);
- if (value != null) {
- p.setProperty(WebPromptingProvider.NAME, value);
- p.setProperty("prefix", value);
- }
-
-
- value = getClassName(region);
- if (value != null) {
- p.setProperty(WebPromptingProvider.TYPE, value);
- }
-
- /* Isn't used yet!!!
- *
- value = getMethodParams(region);
- if (value != null) {
- p.setProperty(WebPromptingProvider.TYPE, value);
- }
- */
-
- return p;
- }
-
-
-
- private String getMethodName(IRegion region) {
- if(region == null || getDocument() == null) return null;
- try {
- return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (BadLocationException x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- }
- }
-
- private String getClassName(IRegion region) {
- return getAttributeValue(region, CLASSNAME_ATTRNAME);
- }
-
- private String getAttributeValue(IRegion region, String attrName) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
- if (n == null || !(n instanceof Attr)) return null;
- Node node = ((Attr)n).getOwnerElement();
- Attr attr = (Attr)node.getAttributes().getNamedItem(attrName);
- return Utils.getTrimmedValue(getDocument(), attr);
- } catch (BadLocationException x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- } finally {
- smw.dispose();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see IHyperlink#getHyperlinkText()
- */
- public String getHyperlinkText() {
- String methodName = getMethodName(fLastRegion);
- if (methodName == null)
- return MessageFormat.format(Messages.OpenA, Messages.ValidationMethod);
-
- return MessageFormat.format(Messages.OpenValidationMethod, methodName);
- }
-
-}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationPropertyHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationPropertyHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationPropertyHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -88,12 +88,11 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getProperty(fLastRegion);
- String formName = getFormName(fLastRegion);
+ String propertyName = getProperty(getHyperlinkRegion());
+ String formName = getFormName(getHyperlinkRegion());
if (propertyName == null || formName == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.ValidationProperty);
return MessageFormat.format(StrutsTextExtMessages.OpenValidationProperty, propertyName, formName);
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationValidatorHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationValidatorHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationValidatorHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -16,14 +16,10 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.jboss.tools.struts.text.ext.StrutsTextExtMessages;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -55,92 +51,16 @@
}
}
- public IRegion getRegion (int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr)) return null;
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
- if (start < 0 || start > offset) return null;
-
- String attrText = getDocument().get(start, end - start);
-
- StringBuffer sb = new StringBuffer(attrText);
- //find start of bean property
- int bStart = offset - start;
- while (bStart >= 0) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bStart))) {
- bStart++;
- break;
- }
-
- if (bStart == 0) break;
- bStart--;
- }
- // find end of bean property
- int bEnd = offset - start;
- while (bEnd < sb.length()) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bEnd)))
- break;
- bEnd++;
- }
-
- final int propStart = bStart + start;
- final int propLength = bEnd - bStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
- IRegion region = new IRegion () {
- public int getLength() {
- return propLength;
- }
-
- public int getOffset() {
- return propStart;
- }
-
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+ "]";
- }
-
- };
-
- return region;
- } catch (BadLocationException x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- } finally {
- smw.dispose();
- }
- }
-
/*
* (non-Javadoc)
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String validator = getAttributeValue(fLastRegion);
+ String validator = getAttributeValue(getHyperlinkRegion());
if (validator == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.Validator);
return MessageFormat.format(StrutsTextExtMessages.OpenValidator, validator);
}
-
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLContextParamLinkHyperlinkPartitioner.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLContextParamLinkHyperlinkPartitioner.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLContextParamLinkHyperlinkPartitioner.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -81,7 +81,7 @@
/**
* @see com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument, com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
if (!recognizeNature(document))
return false;
@@ -92,7 +92,7 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (!(n instanceof Text)) return false;
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLLinkHyperlinkPartitioner.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLLinkHyperlinkPartitioner.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLLinkHyperlinkPartitioner.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -27,7 +27,6 @@
public static final String STRUTS_XML_LINK_PARTITION = "org.jboss.tools.common.text.ext.xml.STRUTS_XML_LINK";
private String[] STRUTS_PROJECT_NATURES = {StrutsProject.NATURE_ID };
-
/**
* @see org.jboss.tools.common.text.ext.hyperlink.XMLLinkHyperlinkPartitioner#getPartitionType()
@@ -39,7 +38,7 @@
/**
* @see com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument, com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
try {
@@ -61,5 +60,4 @@
smw.dispose();
}
}
-
}
Modified: trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXModelBasedHyperlink.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXModelBasedHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
+++ trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXModelBasedHyperlink.java 2012-01-30 19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -19,14 +19,11 @@
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
import org.w3c.dom.Node;
-import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -64,86 +61,6 @@
protected abstract Properties getRequestProperties(IRegion region);
- protected IRegion fLastRegion = null;
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
-
- protected IRegion getRegion (int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr || n instanceof Text)) return null;
-
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
-
- if (start > offset || end < offset) return null;
-
- String text = getDocument().get(start, end - start);
- StringBuffer sb = new StringBuffer(text);
-
- //find start and end of class property
- int bStart = 0;
- int bEnd = text.length() - 1;
-
- while (bStart < bEnd && (Character.isWhitespace(sb.charAt(bStart))
- || sb.charAt(bStart) == '\"' || sb.charAt(bStart) == '\"')) {
- bStart++;
- }
- while (bEnd > bStart && (Character.isWhitespace(sb.charAt(bEnd))
- || sb.charAt(bEnd) == '\"' || sb.charAt(bEnd) == '\"')) {
- bEnd--;
- }
- bEnd++;
-
- final int propStart = bStart + start;
- final int propLength = bEnd - bStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
- IRegion region = new IRegion () {
- public int getLength() {
- return propLength;
- }
-
- public int getOffset() {
- return propStart;
- }
-
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+ "]";
- }
-
- };
-
- return region;
- } catch (BadLocationException x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- } finally {
- smw.dispose();
- }
- }
-
protected String getAttributeValue (IDocument document, Node node, String attrName) {
if(document == null || node == null || attrName == null) return null;
try {
@@ -154,5 +71,4 @@
return null;
}
}
-
}
12 years, 11 months
JBoss Tools SVN: r38296 - trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2012-01-30 14:25:59 -0500 (Mon, 30 Jan 2012)
New Revision: 38296
Modified:
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/ComponentsHyperlink.java
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/ComponentsHyperlinkPartitioner.java
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamBeanHyperlinkPartitioner.java
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamViewHyperlinkPartitioner.java
Log:
JBIDE-10621
Redesign HyperlinkDetector so that partitioning and hyperlinks not do twice the same job.
Hyperlinks and Hyperlink Partitioners are redesigned due to exclude duplication work on regions calculation.
Modified: trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/ComponentsHyperlink.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/ComponentsHyperlink.java 2012-01-30 19:25:22 UTC (rev 38295)
+++ trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/ComponentsHyperlink.java 2012-01-30 19:25:59 UTC (rev 38296)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2009 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2009-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.seam.text.ext.hyperlink;
@@ -19,38 +19,17 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.seam.core.SeamProjectsSet;
import org.jboss.tools.seam.text.ext.SeamExtPlugin;
-import org.w3c.dom.Node;
public class ComponentsHyperlink extends AbstractHyperlink {
private String hyperlinkText = "";
- private String partitionType = null;
-
@Override
- protected IRegion doGetHyperlinkRegion(int offset) {
- Node node = ComponentsHyperlinkPartitioner.getNode(getDocument(),
- offset);
- partitionType = ComponentsHyperlinkPartitioner.getType(node);
- if (partitionType == null)
- return null;
-
- IndexedRegion text = (IndexedRegion) node;
-
- int regLength = text.getLength();
- int regOffset = text.getStartOffset();
-
- Region region = new Region(regOffset, regLength);
- return region;
- }
-
- @Override
protected void doHyperlink(IRegion region) {
if (region == null)
return;
@@ -63,11 +42,15 @@
SeamExtPlugin.getPluginLog().logError(ex);
}
+ IHyperlinkRegion partition = (getHyperlinkRegion() instanceof IHyperlinkRegion) ?
+ (IHyperlinkRegion)getHyperlinkRegion() : null;
+
+ String partitionType = partition == null ? null : partition.getType();
+
if (partitionType == ComponentsHyperlinkPartitioner.BPM_DEFINITION_PARTITION)
doBpmDefinitionHyperlink(region);
else if (partitionType == ComponentsHyperlinkPartitioner.DROOLS_RULE_PARTITION)
doDroolsRuleHyperlink(region);
-
}
private void doDroolsRuleHyperlink(IRegion region) {
@@ -153,5 +136,4 @@
public String getHyperlinkText() {
return hyperlinkText;
}
-
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/ComponentsHyperlinkPartitioner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/ComponentsHyperlinkPartitioner.java 2012-01-30 19:25:22 UTC (rev 38295)
+++ trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/ComponentsHyperlinkPartitioner.java 2012-01-30 19:25:59 UTC (rev 38296)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2009 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2009-2012 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
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.seam.text.ext.hyperlink;
@@ -21,7 +21,6 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;
-
public class ComponentsHyperlinkPartitioner extends
AbstractHyperlinkPartitioner {
public static final String BPM_DEFINITION_PARTITION = "org.jboss.tools.seam.text.ext.BPM_DEFINITION";
@@ -92,24 +91,23 @@
}
@Override
- protected IHyperlinkRegion parse(IDocument document,
+ protected IHyperlinkRegion parse(IDocument document, int offset,
IHyperlinkRegion superRegion) {
- Node node = getNode(document, superRegion.getOffset());
+ Node node = getNode(document, offset);
String type = getType(node);
if (type == null)
return null;
IndexedRegion text = (IndexedRegion) node;
- int length = text.getLength();
- int offset = text.getStartOffset();
+ int textLength = text.getLength();
+ int textOffset = text.getStartOffset();
String contentType = superRegion.getContentType();
String axis = getAxis(document, superRegion);
- IHyperlinkRegion hyperRegion = new HyperlinkRegion(offset, length,
+ IHyperlinkRegion hyperRegion = new HyperlinkRegion(textOffset, textLength,
axis, contentType, type);
return hyperRegion;
}
-
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamBeanHyperlinkPartitioner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamBeanHyperlinkPartitioner.java 2012-01-30 19:25:22 UTC (rev 38295)
+++ trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamBeanHyperlinkPartitioner.java 2012-01-30 19:25:59 UTC (rev 38296)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2011 Red Hat, Inc.
+ * Copyright (c) 2008-2012 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,
@@ -20,14 +20,11 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.jboss.tools.common.el.core.model.ELArgumentInvocation;
import org.jboss.tools.common.el.core.model.ELExpression;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
-import org.jboss.tools.common.el.core.parser.ELParserFactory;
-import org.jboss.tools.common.el.core.parser.ELParserUtil;
import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
@@ -55,37 +52,30 @@
public class SeamBeanHyperlinkPartitioner extends AbstractHyperlinkPartitioner implements IHyperlinkPartitionRecognizer, IHyperLinkPartitionPriority {
public static final String SEAM_MESSAGES_BEAN_PARTITION = "org.jboss.tools.seam.text.ext.SEAM_MESSAGES_BEAN";
- private ELParserFactory factory = ELParserUtil.getJbossFactory();
-
/**
* @see com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument, com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ protected IHyperlinkRegion parse(IDocument document, int offset, IHyperlinkRegion superRegion) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
- if (!recognize(document, superRegion)) return null;
- IHyperlinkRegion r = getRegion(document, superRegion.getOffset());
+ if (!recognize(document, offset, superRegion)) return null;
+ IHyperlinkRegion r = getRegion(document, offset);
if (r == null) return null;
- r = getWordRegion(document, superRegion.getOffset());
+ r = getWordRegion(document, offset);
if (r == null) return null;
- Map<String, ISeamMessages> messages = findMessagesComponents(document, superRegion);
+ Map<String, ISeamMessages> messages = findMessagesComponents(document, offset);
if (messages != null && !messages.isEmpty()) {
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = SEAM_MESSAGES_BEAN_PARTITION;
- int length = r.getLength() - (superRegion.getOffset() - r.getOffset());
- int offset = superRegion.getOffset();
-
- IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType, type);
- return region;
+ return new HyperlinkRegion(r.getOffset(), r.getLength(), axis, contentType, type);
}
return null;
@@ -93,8 +83,6 @@
smw.dispose();
}
}
-
-
protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
@@ -193,11 +181,9 @@
int propStart = bStart + start;
int propLength = bEnd - bStart;
-
if (propStart > offset || propStart + propLength < offset) return null;
- IHyperlinkRegion region = new HyperlinkRegion(propStart, propLength, null, null, null);
- return region;
+ return new HyperlinkRegion(propStart, propLength, null, null, null);
} catch (BadLocationException x) {
SeamExtPlugin.getPluginLog().logError(x);
return null;
@@ -205,6 +191,7 @@
smw.dispose();
}
}
+
public static IHyperlinkRegion getRegion(IDocument document, final int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
@@ -244,21 +231,19 @@
/**
* @see com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument, com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Utils.findNodeForOffset(xmlDocument, region.getOffset());
-
- Map<String, ISeamMessages> messages = findMessagesComponents(document, region);
+ Map<String, ISeamMessages> messages = findMessagesComponents(document, offset);
if (messages != null && !messages.isEmpty()) {
return true;
}
- List<IJavaElement> javaElements = findJavaElements(document, region);
+ List<IJavaElement> javaElements = findJavaElements(document, offset);
if (javaElements != null && !javaElements.isEmpty()) {
return true;
}
@@ -269,20 +254,17 @@
}
}
- public static List<IJavaElement> findJavaElements(IDocument document, IRegion region) {
+ public static List<IJavaElement> findJavaElements(IDocument document, int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- IHyperlinkRegion r = getRegion(document, region.getOffset());
+ IHyperlinkRegion r = getRegion(document, offset);
if (r == null) return null;
-
String propText = document.get(r.getOffset(), r.getLength());
-
-
IFile file = smw.getFile();
IProject project = (file == null ? null : file.getProject());
@@ -346,7 +328,7 @@
elText.append('.').append(app);
javaElements = engine.getJavaElementsForExpression(
- seamProject, file, elText.toString(), region.getOffset());
+ seamProject, file, elText.toString(), offset);
}
return javaElements;
} catch (BadLocationException x) {
@@ -357,14 +339,14 @@
}
}
- public static Map<String, ISeamMessages> findMessagesComponents(IDocument document, IRegion region) {
+ public static Map<String, ISeamMessages> findMessagesComponents(IDocument document, int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- IHyperlinkRegion r = getRegion(document, region.getOffset());
+ IHyperlinkRegion r = getRegion(document, offset);
if (r == null) return null;
String propText = document.get(r.getOffset(), r.getLength());
@@ -514,5 +496,4 @@
public int getPriority() {
return 0; // to be first
}
-
}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamViewHyperlinkPartitioner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamViewHyperlinkPartitioner.java 2012-01-30 19:25:22 UTC (rev 38295)
+++ trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamViewHyperlinkPartitioner.java 2012-01-30 19:25:59 UTC (rev 38296)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-2012 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,
@@ -16,8 +16,8 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
-import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPLinkHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPLinkHyperlinkPartitioner;
import org.jboss.tools.seam.internal.core.SeamProject;
import org.jboss.tools.seam.text.ext.SeamExtPlugin;
@@ -64,8 +64,7 @@
/**
* @see com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument, com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
- return recognizeNature(document) ? super.recognize(document, region) : false;
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
+ return recognizeNature(document) ? super.recognize(document, offset, region) : false;
}
-
}
12 years, 11 months