JBoss Tools SVN: r29244 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core: src/org/jboss/tools/deltacloud/core and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-02-18 11:42:20 -0500 (Fri, 18 Feb 2011)
New Revision: 29244
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudXMLBuilder.java
Log:
[JBIDE-8333] now persisting last selected realm and profile per cloud.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2011-02-18 15:39:12 UTC (rev 29243)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2011-02-18 16:42:20 UTC (rev 29244)
@@ -1,3 +1,17 @@
+2011-02-18 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java
+ (loadCloud):
+ (printCloud):
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (lastRealmName):
+ (lastProfileId):
+ (setLastProfileId):
+ (getLastProfileId):
+ (getLastRealmName):
+ (setLastRealmName):
+ [JBIDE-8333]
+
2011-02-15 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
* src/org/jboss/tools/deltacloud/core/DeltaCloud.java (update):
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2011-02-18 15:39:12 UTC (rev 29243)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2011-02-18 16:42:20 UTC (rev 29244)
@@ -50,7 +50,9 @@
private DeltaCloudDriver driver;
private String lastKeyname = "";
private String lastImageId = "";
-
+ private String lastRealmName = "";
+ private String lastProfileId = "";
+
private DeltaCloudClient client;
private DeltaCloudImagesRepository imagesRepo;
@@ -192,6 +194,22 @@
this.lastImageId = lastImageId;
}
+ public void setLastRealmName(String lastRealmName) {
+ this.lastRealmName = lastRealmName;
+ }
+
+ public String getLastRealmName() {
+ return lastRealmName;
+ }
+
+ public void setLastProfileId(String lastProfileId) {
+ this.lastProfileId = lastProfileId;
+ }
+
+ public String getLastProfileId() {
+ return lastProfileId;
+ }
+
private void setName(String name) {
firePropertyChange(PROP_NAME, this.name, this.name = name);
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java 2011-02-18 15:39:12 UTC (rev 29243)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java 2011-02-18 16:42:20 UTC (rev 29244)
@@ -108,11 +108,15 @@
String instanceFilterRules = getNodeValue(attrs.getNamedItem("instancefilter")); // $NON-NLS-1$
String lastKeyName = getNodeValue(attrs.getNamedItem(DeltaCloudXMLBuilder.ATTR_LASTKEYNAME)); // $NON-NLS-1$
String lastImageId = getNodeValue(attrs.getNamedItem(DeltaCloudXMLBuilder.ATTR_LASTIMAGE)); // $NON-NLS-1$
+ String lastRealmName = getNodeValue(attrs.getNamedItem(DeltaCloudXMLBuilder.ATTR_LASTREALM)); // $NON-NLS-1$
+ String lastProfileId = getNodeValue(attrs.getNamedItem(DeltaCloudXMLBuilder.ATTR_LASTPROFILE)); // $NON-NLS-1$
Collection<IInstanceAliasMapping> aliasMappings = getInstanceMappings(n);
cloud = new DeltaCloud(name, url, username, driver, imageFilterRules, instanceFilterRules, aliasMappings);
clouds.add(cloud);
cloud.setLastImageId(lastImageId);
cloud.setLastKeyname(lastKeyName);
+ cloud.setLastRealmName(lastRealmName);
+ cloud.setLastProfileId(lastProfileId);
return cloud;
} catch (DeltaCloudException e) {
throw e;
@@ -208,6 +212,8 @@
DeltaCloudXMLBuilder.ATTR_INSTANCEFILTER, d.getInstanceFilter().toString(), printWriter);
DeltaCloudXMLBuilder.attribute(DeltaCloudXMLBuilder.ATTR_LASTKEYNAME, d.getLastKeyname(), printWriter);
DeltaCloudXMLBuilder.attribute(DeltaCloudXMLBuilder.ATTR_LASTIMAGE, d.getLastImageId(), printWriter);
+ DeltaCloudXMLBuilder.attribute(DeltaCloudXMLBuilder.ATTR_LASTREALM, d.getLastRealmName(), printWriter);
+ DeltaCloudXMLBuilder.attribute(DeltaCloudXMLBuilder.ATTR_LASTPROFILE, d.getLastProfileId(), printWriter);
DeltaCloudXMLBuilder.closeTag(printWriter);
printInstances(d, printWriter);
DeltaCloudXMLBuilder.endTag(DeltaCloudXMLBuilder.TAG_CLOUD, printWriter);
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudXMLBuilder.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudXMLBuilder.java 2011-02-18 15:39:12 UTC (rev 29243)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudXMLBuilder.java 2011-02-18 16:42:20 UTC (rev 29244)
@@ -29,6 +29,8 @@
public static final String ATTR_INSTANCEFILTER = "instancefilter";
public static final String ATTR_LASTKEYNAME = "lastkeyname";
public static final String ATTR_LASTIMAGE = "lastimage";
+ public static final String ATTR_LASTPROFILE = "lastprofile";
+ public static final String ATTR_LASTREALM = "lastrealm";
public static final void xmlHeader(PrintWriter printWriter) {
printWriter.print("<?xml version=\"1.0\" encoding=\"");
13 years, 10 months
JBoss Tools SVN: r29243 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2011-02-18 10:39:12 -0500 (Fri, 18 Feb 2011)
New Revision: 29243
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
Log:
https://issues.jboss.org/browse/JBIDE-7003, removing printStackTrace exception
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java 2011-02-18 15:21:38 UTC (rev 29242)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java 2011-02-18 15:39:12 UTC (rev 29243)
@@ -200,9 +200,9 @@
is.close();
is = null;
} catch (CoreException e) {
- e.printStackTrace();
+ JspEditorPlugin.getDefault().logError(e);
} catch (IOException e) {
- e.printStackTrace();
+ JspEditorPlugin.getDefault().logError(e);
}
}
/*
13 years, 10 months
JBoss Tools SVN: r29242 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2011-02-18 10:21:38 -0500 (Fri, 18 Feb 2011)
New Revision: 29242
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java
Log:
https://issues.jboss.org/browse/JBIDE-7003, working on Externalize dialog, trying to removed dependency of dialog from JSPMultipage editor to make it usable without editor.
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java 2011-02-18 14:54:49 UTC (rev 29241)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java 2011-02-18 15:21:38 UTC (rev 29242)
@@ -79,7 +79,7 @@
public static final String EXTERNALIZE_STRINGS_DIALOG_NEW_FILE_PAGE =
"EXTERNALIZE_STRINGS_DIALOG_NEW_FILE_PAGE"; //$NON-NLS-1$
- ITextEditor editor = null;
+ private ITextEditor editor = null;
BundleMap bm = null;
ExternalizeStringsWizardPage page1 = null;
WizardNewFileCreationPage page2 = null;
@@ -134,7 +134,7 @@
if (null != containerFullPath) {
page2.setContainerFullPath(containerFullPath);
}
- String fileName = editor.getEditorInput().getName();
+ String fileName = getFileName();
int pos = fileName.lastIndexOf(Constants.DOT);
if (pos != -1) {
fileName = fileName.substring(0, pos) + Constants.PROPERTIES_EXTENTION;
@@ -210,8 +210,8 @@
*/
if (page1.isNewFile() && !page3.isUserDefined()) {
var = page3.getBundleName();
- if (editor.getEditorInput() instanceof IFileEditorInput) {
- IProject project = ((IFileEditorInput)editor.getEditorInput()).getFile().getProject();
+ if (getProject()!=null) {
+ IProject project = getProject();
String userDefinedPath = page2.getContainerFullPath().toString();
/*
* Get the source folders for the project
@@ -536,4 +536,16 @@
}
return containerFullPath;
}
+
+ protected String getFileName(){
+ return editor.getEditorInput().getName();
+ }
+
+ protected IProject getProject(){
+ IProject project = null;
+ if (editor.getEditorInput() instanceof IFileEditorInput) {
+ project = ((IFileEditorInput)editor.getEditorInput()).getFile().getProject();
+ }
+ return project;
+ }
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java 2011-02-18 14:54:49 UTC (rev 29241)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java 2011-02-18 15:21:38 UTC (rev 29242)
@@ -24,7 +24,6 @@
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.model.ui.ModelUIImages;
@@ -89,8 +88,7 @@
bundleName.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 1, 1));
String fileName = Constants.EMPTY;
if (getWizard() instanceof ExternalizeStringsWizard) {
- fileName = ((ExternalizeStringsWizard) getWizard()).editor
- .getEditorInput().getName();
+ fileName = ((ExternalizeStringsWizard) getWizard()).getFileName();
int pos = fileName.lastIndexOf(Constants.DOT);
if (pos != -1) {
fileName = fileName.substring(0, pos);
@@ -184,22 +182,22 @@
}
}
- /**
- * Gets the selected place.
- *
- * @return the selected place
- */
- private int getSelectedPlace() {
- int place = FACES_CONFIG;
- if (isInFacesConfig()) {
- place = FACES_CONFIG;
- } else if (isViaLoadBundle()) {
- place = LOAD_BUNDLE;
- } else if (isUserDefined()) {
- place = USER_DEFINED;
- }
- return place;
- }
+// /**
+// * Gets the selected place.
+// *
+// * @return the selected place
+// */
+// private int getSelectedPlace() {
+// int place = FACES_CONFIG;
+// if (isInFacesConfig()) {
+// place = FACES_CONFIG;
+// } else if (isViaLoadBundle()) {
+// place = LOAD_BUNDLE;
+// } else if (isUserDefined()) {
+// place = USER_DEFINED;
+// }
+// return place;
+// }
/**
* Update bundle name field.
@@ -223,8 +221,8 @@
boolean sourceFolderSelected = false;
if (getWizard() instanceof ExternalizeStringsWizard) {
ExternalizeStringsWizard wiz = (ExternalizeStringsWizard) getWizard();
- if (wiz.editor.getEditorInput() instanceof IFileEditorInput) {
- IProject project = ((IFileEditorInput)(wiz.editor.getEditorInput())).getFile().getProject();
+ if (wiz.getProject()!=null) {
+ IProject project = wiz.getProject();
WizardNewFileCreationPage page2 = (WizardNewFileCreationPage)wiz.getPage(
ExternalizeStringsWizard.EXTERNALIZE_STRINGS_DIALOG_NEW_FILE_PAGE);
String userDefinedPath = page2.getContainerFullPath().toString();
13 years, 10 months
JBoss Tools SVN: r29241 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2011-02-18 09:54:49 -0500 (Fri, 18 Feb 2011)
New Revision: 29241
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
Log:
https://issues.jboss.org/browse/JBIDE-7003, working on Externalize dialog, trying to removed dependency of dialog from JSPMultipage editor to make it usable without editor.
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2011-02-18 13:30:41 UTC (rev 29240)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2011-02-18 14:54:49 UTC (rev 29241)
@@ -109,15 +109,7 @@
ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_DEFAULT));
setDescription(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_DESCRIPTION);
setPageComplete(false);
-// if (bm != null) {
-// this.bm = bm;
-// } else {
-// /*
-// * When BundleMap is null create it manually
-// * with all necessary initialization
-// */
-// this.bm = createBundleMap(editor);
-// }
+ this.bm=bm;
this.document = document;
this.selectionProvider = selectionProvider;
propsKeyStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID, Constants.EMPTY);
13 years, 10 months
JBoss Tools SVN: r29240 - trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-02-18 08:30:41 -0500 (Fri, 18 Feb 2011)
New Revision: 29240
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/strutswebapp.meta
Log:
JBIDE-8443
https://issues.jboss.org/browse/JBIDE-8443
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 2011-02-18 13:27:48 UTC (rev 29239)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/strutswebapp.meta 2011-02-18 13:30:41 UTC (rev 29240)
@@ -2328,8 +2328,8 @@
<XModelAttribute name="description" xmlname="description.#text">
<Editor name="Note"/>
</XModelAttribute>
- <XModelAttribute PROPERTIES="id=true" name="role-name" xmlname="role-name.#text">
- <Constraint loader="JavaName">
+ <XModelAttribute PROPERTIES="id=true;save=always" name="role-name" xmlname="role-name.#text">
+ <Constraint loader="Nmtoken">
<value name="acceptIncorrect=true"/>
</Constraint>
<Editor name="Name"/>
@@ -2378,7 +2378,7 @@
<Editor name="Note"/>
</XModelAttribute>
<XModelAttribute PROPERTIES="id=true;save=always" name="role-name" xmlname="role-name.#text">
- <Constraint loader="JavaName"/>
+ <Constraint loader="Nmtoken"/>
<Editor name="Name"/>
</XModelAttribute>
<XModelAttribute PROPERTIES="save=always" name="role-link" xmlname="role-link.#text">
13 years, 10 months
JBoss Tools SVN: r29239 - in trunk/common/plugins/org.jboss.tools.common.model: src/org/jboss/tools/common/meta/constraint/impl and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-02-18 08:27:48 -0500 (Fri, 18 Feb 2011)
New Revision: 29239
Added:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintNmtoken.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model/plugin.xml
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelMessages.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/messages.properties
Log:
JBIDE-8433
https://issues.jboss.org/browse/JBIDE-8443
Modified: trunk/common/plugins/org.jboss.tools.common.model/plugin.xml
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/plugin.xml 2011-02-18 13:22:38 UTC (rev 29238)
+++ trunk/common/plugins/org.jboss.tools.common.model/plugin.xml 2011-02-18 13:27:48 UTC (rev 29239)
@@ -339,6 +339,8 @@
class="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintInt"/>
<xclass id="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintJavaName"
class="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintJavaName"/>
+ <xclass id="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintNmtoken"
+ class="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintNmtoken"/>
<xclass id="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintJavaNameOrEmpty"
class="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintJavaNameOrEmpty"/>
<xclass id="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintList"
Added: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintNmtoken.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintNmtoken.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintNmtoken.java 2011-02-18 13:27:48 UTC (rev 29239)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.meta.constraint.impl;
+
+import org.jboss.tools.common.model.XModelObjectConstants;
+import org.jboss.tools.common.model.plugin.ModelMessages;
+
+public class XAttributeConstraintNmtoken extends XAttributeConstraintProperties {
+
+ char[][] intervals = {
+ {':', ':'}, {'A', 'Z'}, {'_', '_'}, {'a', 'z'}, {0xC0, 0xD6},
+ {0xD8, 0xF6}, {0xF8 , 0x2FF}, {0x370, 0x37D}, {0x37F, 0x1FFF},
+ {0x200C, 0x200D}, {0x2070, 0x218F}, {0x2C00, 0x2FEF}, {0x3001, 0xD7FF},
+ {0xF900, 0xFDCF}, {0xFDF0, 0xFFFD}, // {0x10000, 0xEFFFF},
+ {'-', '-'}, {'.', '.'}, {'0', '9'},
+ {0xB7, 0xB7}, {0x0300, 0x036F}, {0x203F, 0x2040},
+ };
+
+ public XAttributeConstraintNmtoken() {}
+
+ public boolean accepts(String value) {
+ if(value == null) return false;
+ if(value.length() == 0) return true;
+ for (int i = 1; i < value.length(); i++) {
+ char ch = value.charAt(i);
+ boolean ok = false;
+ for (int k = 0; k < intervals.length; k++) {
+ if(ch >= intervals[k][0] && ch <= intervals[k][1]) {
+ ok = true;
+ break;
+ }
+ }
+ if(!ok) return false;
+ }
+ return true;
+ }
+
+ public String getError(String value) {
+ return (value.length() == 0) ? (isRequired() ? ModelMessages.CONSTRAINT_NONEMPTY : null) :
+ accepts(value) ? null :
+ ModelMessages.CONSTRAINT_NMTOKEN;
+ }
+
+ boolean isRequired() {
+ return attribute != null && "always".equals(attribute.getProperty("save")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public String getCorrectedValue(String value) {
+ if(value == null || value.length() == 0) return null;
+ if(XModelObjectConstants.TRUE.equals(getProperties().getProperty("acceptIncorrect"))) return value; //$NON-NLS-1$
+ //
+ return value;
+ }
+
+
+}
+
Property changes on: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintNmtoken.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelMessages.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelMessages.java 2011-02-18 13:22:38 UTC (rev 29238)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelMessages.java 2011-02-18 13:27:48 UTC (rev 29239)
@@ -18,6 +18,7 @@
public static String CONSTRAINT_NONEMPTY;
public static String CONSTRAINT_NO_JAVA_KEYWORD;
public static String CONSTRAINT_JAVA_NAME;
+ public static String CONSTRAINT_NMTOKEN;
public static String CONSTRAINT_INTEGER_OR_LIST;
public static String CONSTRAINT_RED_HAT_TEMPLATE_NAME;
public static String CONSTRAINT_XML_NAME;
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/messages.properties
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/messages.properties 2011-02-18 13:22:38 UTC (rev 29238)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/messages.properties 2011-02-18 13:27:48 UTC (rev 29239)
@@ -7,6 +7,7 @@
CONSTRAINT_NONEMPTY = cannot be empty
CONSTRAINT_NO_JAVA_KEYWORD = is a Java keyword
CONSTRAINT_JAVA_NAME = is not a Java name
+CONSTRAINT_NMTOKEN = is not a valid NMToken
CONSTRAINT_INTEGER_OR_LIST = must be an integer or be selected from the list
CONSTRAINT_RED_HAT_TEMPLATE_NAME = is not an Red Hat project template name
CONSTRAINT_XML_NAME = is not xml name
13 years, 10 months
JBoss Tools SVN: r29238 - in trunk: examples/plugins/org.jboss.tools.community.project.examples and 9 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2011-02-18 08:22:38 -0500 (Fri, 18 Feb 2011)
New Revision: 29238
Added:
trunk/download.jboss.org/jbosstools/examples/project-examples-maven-3.3.xml
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/job/
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/job/ProjectExamplesJob.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ArchetypeModel.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExample.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
Modified:
trunk/examples/plugins/org.jboss.tools.community.project.examples/plugin.properties
trunk/examples/plugins/org.jboss.tools.community.project.examples/plugin.xml
trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/META-INF/MANIFEST.MF
trunk/maven/plugins/org.jboss.tools.maven.project.examples/plugin.xml
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/MavenProjectExamplesActivator.java
Log:
JBIDE-7890 Create project example based on maven archetype
Added: trunk/download.jboss.org/jbosstools/examples/project-examples-maven-3.3.xml
===================================================================
--- trunk/download.jboss.org/jbosstools/examples/project-examples-maven-3.3.xml (rev 0)
+++ trunk/download.jboss.org/jbosstools/examples/project-examples-maven-3.3.xml 2011-02-18 13:22:38 UTC (rev 29238)
@@ -0,0 +1,39 @@
+<projects>
+
+ <project>
+ <category>Weld archetypes</category>
+ <name>jboss-javaee6-webapp</name>
+ <included-projects>jboss-javaee6-webapp</included-projects>
+ <shortDescription>Weld Java EE 6 example</shortDescription>
+ <description>
+The example demonstrates Weld Java EE 6 application.
+It will create the jboss-javaee6-webapp project in your workspace based on the org.jboss.weld.archetypes:jboss-javaee6-webapp:1.0.1.Beta2 archetype.
+ </description>
+ <size>8192</size>
+ <url/>
+ <fixes>
+ <fix type="wtpruntime">
+ <property name="allowed-types">org.jboss.ide.eclipse.as.runtime.60</property>
+ <property name="description">This project example requires JBoss AS 6.0</property>
+ </fix>
+ </fixes>
+ <importType>mavenArchetype</importType>
+ <importTypeDescription>The project example requires the m2eclipse-core, m2eclipse-wtp and JBoss Maven Project Examples feature.</importTypeDescription>
+ <mavenArchetype>
+ <archetypeGroupId>org.jboss.weld.archetypes</archetypeGroupId>
+ <archetypeArtifactId>jboss-javaee6-webapp</archetypeArtifactId>
+ <archetypeVersion>1.0.1.Beta2</archetypeVersion>
+ <!-- <archetypeRepository>http://repository.jboss.org/nexus/content/groups/public/</archetypeRepository> -->
+ <groupId>org.jboss.tools.examples</groupId>
+ <artifactId>jboss-javaee6-webapp</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <javaPackage>org.jboss.tools.examples</javaPackage>
+ <!--
+ <properties>
+ <property name="name" value="Java EE 6 webapp project"/>
+ </properties>
+ -->
+ </mavenArchetype>
+ </project>
+
+</projects>
\ No newline at end of file
Modified: trunk/examples/plugins/org.jboss.tools.community.project.examples/plugin.properties
===================================================================
--- trunk/examples/plugins/org.jboss.tools.community.project.examples/plugin.properties 2011-02-18 12:25:09 UTC (rev 29237)
+++ trunk/examples/plugins/org.jboss.tools.community.project.examples/plugin.properties 2011-02-18 13:22:38 UTC (rev 29238)
@@ -2,4 +2,5 @@
BundleName = JBoss Tools Community Project Examples
JBoss_Tools_Community_Examples = JBoss Tools 3.1 Community Examples
JBoss_Tools_Community_Maven_Examples = JBoss Tools 3.2 Community Maven Examples
+JBoss_Tools_33_Community_Maven_Examples = JBoss Tools 3.3 Community Maven Examples
JBoss_Tools_Community_BPEL_Examples=JBoss Tools Community BPEL Examples
Modified: trunk/examples/plugins/org.jboss.tools.community.project.examples/plugin.xml
===================================================================
--- trunk/examples/plugins/org.jboss.tools.community.project.examples/plugin.xml 2011-02-18 12:25:09 UTC (rev 29237)
+++ trunk/examples/plugins/org.jboss.tools.community.project.examples/plugin.xml 2011-02-18 13:22:38 UTC (rev 29238)
@@ -23,5 +23,11 @@
name="%JBoss_Tools_Community_Maven_Examples">
<url>http://download.jboss.org/jbosstools/examples/project-examples-maven-3.2.xml</url>
<experimental>false</experimental>
- </extension>
+ </extension>
+ <extension
+ point="org.jboss.tools.project.examples.projectExamplesXml"
+ name="%JBoss_Tools_33_Community_Maven_Examples">
+ <url>http://download.jboss.org/jbosstools/examples/project-examples-maven-3.3.xml</url>
+ <experimental>false</experimental>
+ </extension>
</plugin>
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF 2011-02-18 12:25:09 UTC (rev 29237)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF 2011-02-18 13:22:38 UTC (rev 29238)
@@ -39,6 +39,9 @@
org.jboss.tools.project.examples.dialog,
org.jboss.tools.project.examples.dialog.xpl,
org.jboss.tools.project.examples.filetransfer,
+ org.jboss.tools.project.examples.fixes,
+ org.jboss.tools.project.examples.job,
org.jboss.tools.project.examples.model,
+ org.jboss.tools.project.examples.preferences,
org.jboss.tools.project.examples.wizard
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java 2011-02-18 12:25:09 UTC (rev 29237)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java 2011-02-18 13:22:38 UTC (rev 29238)
@@ -54,6 +54,9 @@
public static final boolean SHOW_EXPERIMENTAL_SITES_VALUE = false;
public static final String SHOW_INVALID_SITES = "invalidSites"; //$NON-NLS-1$
public static final boolean SHOW_INVALID_SITES_VALUE = true;
+ public static final String MAVEN_ARCHETYPE = "mavenArchetype"; //$NON-NLS-1$
+ public static final Object PROJECT_EXAMPLES_FAMILY = new Object();
+
private static final String IMPORT_PROJECT_EXAMPLES_EXTENSION_ID = "org.jboss.tools.project.examples.importProjectExamples"; //$NON-NLS-1$
private static final String NAME = "name"; //$NON-NLS-1$
private static final String TYPE = "type"; //$NON-NLS-1$
@@ -68,6 +71,7 @@
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
+ Job.getJobManager().join(PROJECT_EXAMPLES_FAMILY, monitor);
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD,
monitor);
Job.getJobManager().join(
Added: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/job/ProjectExamplesJob.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/job/ProjectExamplesJob.java (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/job/ProjectExamplesJob.java 2011-02-18 13:22:38 UTC (rev 29238)
@@ -0,0 +1,20 @@
+package org.jboss.tools.project.examples.job;
+
+import org.eclipse.core.resources.WorkspaceJob;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+
+public abstract class ProjectExamplesJob extends WorkspaceJob {
+
+ public ProjectExamplesJob(String name) {
+ super(name);
+ }
+
+ @Override
+ public boolean belongsTo(Object family) {
+ if (family == ProjectExamplesActivator.PROJECT_EXAMPLES_FAMILY)
+ return true;
+
+ return super.belongsTo(family);
+ }
+
+}
Added: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ArchetypeModel.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ArchetypeModel.java (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ArchetypeModel.java 2011-02-18 13:22:38 UTC (rev 29238)
@@ -0,0 +1,102 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.project.examples.model;
+
+import java.util.Properties;
+
+/**
+ * @author snjeza
+ *
+ */
+public class ArchetypeModel {
+ private String groupId;
+ private String artifactId;
+ private String version;
+
+ private String archetypeGroupId;
+ private String archetypeArtifactId;
+ private String archetypeVersion;
+ private String archetypeRepository;
+ private String javaPackage;
+ private Properties archetypeProperties = new Properties();
+
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(String groupId) {
+ this.groupId = groupId;
+ }
+
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ public void setArtifactId(String artifactId) {
+ this.artifactId = artifactId;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getArchetypeGroupId() {
+ return archetypeGroupId;
+ }
+
+ public void setArchetypeGroupId(String archetypeGroupId) {
+ this.archetypeGroupId = archetypeGroupId;
+ }
+
+ public String getArchetypeArtifactId() {
+ return archetypeArtifactId;
+ }
+
+ public void setArchetypeArtifactId(String archetypeArtifactId) {
+ this.archetypeArtifactId = archetypeArtifactId;
+ }
+
+ public String getArchetypeVersion() {
+ return archetypeVersion;
+ }
+
+ public void setArchetypeVersion(String archetypeVersion) {
+ this.archetypeVersion = archetypeVersion;
+ }
+
+ public String getArchetypeRepository() {
+ return archetypeRepository;
+ }
+
+ public void setArchetypeRepository(String archetypeRepository) {
+ this.archetypeRepository = archetypeRepository;
+ }
+
+ public String getJavaPackage() {
+ return javaPackage;
+ }
+
+ public void setJavaPackage(String javaPackage) {
+ this.javaPackage = javaPackage;
+ }
+
+ public Properties getArchetypeProperties() {
+ return archetypeProperties;
+ }
+
+ public void addProperty(String key, String value) {
+ archetypeProperties.put(key, value);
+ }
+}
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java 2011-02-18 12:25:09 UTC (rev 29237)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java 2011-02-18 13:22:38 UTC (rev 29238)
@@ -14,6 +14,8 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+
/**
* @author snjeza
*
@@ -36,6 +38,7 @@
private String perspectiveId;
private String importType;
private String importTypeDescription;
+ private ArchetypeModel archetypeModel = new ArchetypeModel();
public Project() {
name=""; //$NON-NLS-1$
@@ -199,4 +202,12 @@
public void setImportTypeDescription(String importTypeDescription) {
this.importTypeDescription = importTypeDescription;
}
+
+ public ArchetypeModel getArchetypeModel() {
+ return archetypeModel;
+ }
+
+ public boolean isURLRequired() {
+ return !ProjectExamplesActivator.MAVEN_ARCHETYPE.equals(importType);
+ }
}
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2011-02-18 12:25:09 UTC (rev 29237)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2011-02-18 13:22:38 UTC (rev 29238)
@@ -338,6 +338,9 @@
project.setWelcomeURL(attribute.trim());
}
}
+ if (nodeName.equals("mavenArchetype")) { //$NON-NLS-1$
+ parseMavenArchetype(project, child);
+ }
}
}
}
@@ -367,11 +370,76 @@
Element child = (Element) cNode;
String nodeName = child.getNodeName();
if (nodeName.equals("fix")) { //$NON-NLS-1$
- parseFix(project,child);
+ parseFix(project, child);
}
}
}
}
+
+ private static void parseMavenArchetype(Project project, Element node) {
+ NodeList children = node.getChildNodes();
+ int cLen = children.getLength();
+ ArchetypeModel archetypeModel = project.getArchetypeModel();
+ for (int i = 0; i < cLen; i++) {
+ Node cNode = children.item(i);
+ if (cNode.getNodeType() == Node.ELEMENT_NODE) {
+ Element child = (Element) cNode;
+ String nodeName = child.getNodeName();
+ if (nodeName.equals("archetypeGroupId")) { //$NON-NLS-1$
+ archetypeModel.setArchetypeGroupId(getContent(child));
+ }
+ if (nodeName.equals("archetypeArtifactId")) { //$NON-NLS-1$
+ archetypeModel.setArchetypeArtifactId(getContent(child));
+ }
+ if (nodeName.equals("archetypeVersion")) { //$NON-NLS-1$
+ archetypeModel.setArchetypeVersion(getContent(child));
+ }
+ if (nodeName.equals("archetypeRepository")) { //$NON-NLS-1$
+ archetypeModel.setArchetypeRepository(getContent(child));
+ }
+ if (nodeName.equals("groupId")) { //$NON-NLS-1$
+ archetypeModel.setGroupId(getContent(child));
+ }
+ if (nodeName.equals("artifactId")) { //$NON-NLS-1$
+ archetypeModel.setArtifactId(getContent(child));
+ }
+ if (nodeName.equals("version")) { //$NON-NLS-1$
+ archetypeModel.setVersion(getContent(child));
+ }
+ if (nodeName.equals("javaPackage")) { //$NON-NLS-1$
+ archetypeModel.setJavaPackage(getContent(child));
+ }
+ if (nodeName.equals("properties")) { //$NON-NLS-1$
+ parseProperties(project, child);
+ }
+ }
+ }
+ }
+
+ private static void parseProperties(Project project, Element node) {
+ NodeList children = node.getChildNodes();
+ int cLen = children.getLength();
+ for (int i = 0; i < cLen; i++) {
+ Node cNode = children.item(i);
+ if (cNode.getNodeType() == Node.ELEMENT_NODE) {
+ Element child = (Element) cNode;
+ String nodeName = child.getNodeName();
+ if (nodeName.equals("property")) { //$NON-NLS-1$
+ String key = child.getAttribute("name"); //$NON-NLS-1$
+ if (key == null || key.trim().length() <= 0) {
+ ProjectExamplesActivator.log(Messages.ProjectUtil_Invalid_property);
+ return;
+ }
+ String value = child.getAttribute("value"); //$NON-NLS-1$
+ if (value == null || value.trim().length() <= 0) {
+ ProjectExamplesActivator.log(Messages.ProjectUtil_Invalid_property);
+ return;
+ }
+ project.getArchetypeModel().addProperty(key, value);
+ }
+ }
+ }
+ }
private static void parseFix(Project project, Element node) {
String type = node.getAttribute("type"); //$NON-NLS-1$
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2011-02-18 12:25:09 UTC (rev 29237)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2011-02-18 13:22:38 UTC (rev 29238)
@@ -155,24 +155,27 @@
Iterator iterator = selection.iterator();
projects.clear();
List<File> files = new ArrayList<File>();
+ File file = null;
while (iterator.hasNext()) {
Object object = iterator.next();
if (object instanceof Project) {
Project project = (Project) object;
- String urlString = project.getUrl();
- String name = project.getName();
- URL url = null;
- try {
- url = new URL(urlString);
- } catch (MalformedURLException e) {
- ProjectExamplesActivator.log(e);
- continue;
+ if (project.isURLRequired()) {
+ String urlString = project.getUrl();
+ String name = project.getName();
+ URL url = null;
+ try {
+ url = new URL(urlString);
+ } catch (MalformedURLException e) {
+ ProjectExamplesActivator.log(e);
+ continue;
+ }
+ file = ProjectUtil.getProjectExamplesFile(url, name,
+ ".zip", monitor); //$NON-NLS-1$
+ if (file == null) {
+ return Status.CANCEL_STATUS;
+ }
}
- final File file = ProjectUtil.getProjectExamplesFile(
- url, name, ".zip", monitor); //$NON-NLS-1$
- if (file == null) {
- return Status.CANCEL_STATUS;
- }
projects.add(project);
files.add(file);
}
@@ -199,7 +202,7 @@
});
return Status.OK_STATUS;
}
- projects = importProjectExample.importProject(project, files.get(i++), monitor);
+ importProjectExample.importProject(project, files.get(i++), monitor);
importProjectExample.fix(project, monitor);
}
}
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/META-INF/MANIFEST.MF 2011-02-18 12:25:09 UTC (rev 29237)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/META-INF/MANIFEST.MF 2011-02-18 13:22:38 UTC (rev 29238)
@@ -9,7 +9,8 @@
org.eclipse.core.runtime,
org.jboss.tools.maven.core,
org.jboss.tools.project.examples,
- org.eclipse.ui.ide
+ org.eclipse.ui.ide,
+ org.maven.ide.eclipse.archetype_common;bundle-version="[0.10.0,0.13.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: %Bundle-Vendor
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/plugin.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/plugin.xml 2011-02-18 12:25:09 UTC (rev 29237)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/plugin.xml 2011-02-18 13:22:38 UTC (rev 29238)
@@ -9,5 +9,14 @@
type="maven">
</importProjectExample>
</extension>
+
+ <extension
+ point="org.jboss.tools.project.examples.importProjectExamples">
+ <importProjectExample
+ class="org.jboss.tools.maven.project.examples.ImportMavenArchetypeProjectExample"
+ name="Import Maven Archetype Project Examples"
+ type="mavenArchetype">
+ </importProjectExample>
+ </extension>
</plugin>
Added: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExample.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExample.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExample.java 2011-02-18 13:22:38 UTC (rev 29238)
@@ -0,0 +1,190 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+
+package org.jboss.tools.maven.project.examples;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.maven.project.examples.wizard.ArchetypeExamplesWizard;
+import org.jboss.tools.project.examples.model.AbstractImportProjectExample;
+import org.jboss.tools.project.examples.model.Project;
+
+/**
+ * @author snjeza
+ *
+ */
+public class ImportMavenArchetypeProjectExample extends
+ AbstractImportProjectExample {
+
+ private static final String UNNAMED_PROJECTS = "UnnamedProjects"; //$NON-NLS-1$
+
+ private static final String JBOSS_TOOLS_MAVEN_PROJECTS = "/.JBossToolsMavenProjects"; //$NON-NLS-1$
+
+ private boolean confirm;
+
+ @Override
+ public List<Project> importProject(final Project projectDescription, File file,
+ IProgressMonitor monitor) throws Exception {
+ List<Project> projects = new ArrayList<Project>();
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IPath rootPath = workspaceRoot.getLocation();
+ IPath mavenProjectsRoot = rootPath.append(JBOSS_TOOLS_MAVEN_PROJECTS);
+ String projectName = projectDescription.getName();
+ if (projectName == null || projectName.isEmpty()) {
+ projectName = UNNAMED_PROJECTS;
+ }
+ IPath path = mavenProjectsRoot.append(projectName);
+ final File destination = new File(path.toOSString());
+ if (destination.exists()) {
+ final List<IProject> existingProjects = getExistingProjects(destination);
+ if (existingProjects.size() > 0) {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ String title = "Overwrite";
+ String msg = getMessage(destination, existingProjects);
+ confirm = MessageDialog.openQuestion(getActiveShell(),
+ title, msg);
+ }
+ });
+ if (confirm) {
+ monitor.setTaskName("Deleting ...");
+ for (IProject project : existingProjects) {
+ monitor.setTaskName("Deleting " + project.getName());
+ project.delete(false, true, monitor);
+ }
+ } else {
+ return projects;
+ }
+ }
+ boolean deleted = deleteDirectory(destination, monitor);
+ if (monitor.isCanceled()) {
+ return projects;
+ }
+ if (!deleted) {
+ Display.getDefault().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ MessageDialog.openError(getActiveShell(), "Error",
+ "Cannot delete the '" + destination + "' file.");
+ }
+ });
+ return projects;
+ }
+ }
+ monitor.setTaskName("");
+ if (monitor.isCanceled()) {
+ return projects;
+ }
+
+ Display.getDefault().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ ArchetypeExamplesWizard wizard = new ArchetypeExamplesWizard(destination, projectDescription);
+ WizardDialog wizardDialog = new WizardDialog(getActiveShell(), wizard);
+ wizardDialog.open();
+ }
+
+ });
+ return projects;
+ }
+
+
+ private static Shell getActiveShell() {
+ return Display.getDefault().getActiveShell();
+ }
+
+ private static boolean deleteDirectory(File path, IProgressMonitor monitor) {
+ if (path.exists()) {
+ File[] files = path.listFiles();
+ for (File file : files) {
+ if (monitor.isCanceled()) {
+ return false;
+ }
+ monitor.setTaskName("Deleting " + file);
+ if (file.isDirectory()) {
+ deleteDirectory(file, monitor);
+ } else {
+ file.delete();
+ }
+ }
+ }
+ return (path.delete());
+ }
+
+ private List<IProject> getExistingProjects(final File destination) {
+ List<IProject> existingProjects = new ArrayList<IProject>();
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
+ .getProjects();
+ for (IProject project : projects) {
+ if (project != null && project.exists()) {
+ File projectFile = project.getLocation().toFile();
+ if (projectFile.getAbsolutePath().startsWith(
+ destination.getAbsolutePath())) {
+ existingProjects.add(project);
+ }
+ }
+ }
+ return existingProjects;
+ }
+
+ private String getMessage(final File destination, List<IProject> projects) {
+ if (projects.size() > 0) {
+ StringBuilder builder = new StringBuilder();
+ if (projects.size() == 1) {
+ builder.append("\nThere is the '" + projects.get(0).getName()
+ + "' project on the destination location:\n\n");
+ builder.append("Would you like to overwrite it?");
+ } else {
+ builder.append("\nThere are the following projects on the destination location:\n\n");
+ for (IProject project : projects) {
+ builder.append(project.getName());
+ builder.append("\n"); //$NON-NLS-1$
+ }
+ builder.append("\n"); //$NON-NLS-1$
+ builder.append("Would you like to overwrite them?");
+ }
+ return builder.toString();
+ }
+ return null;
+ }
+
+ private String getWorkspaceMessage(final List<IProject> existingProjects) {
+ StringBuilder builder = new StringBuilder();
+ if (existingProjects.size() == 1) {
+ builder.append("There is the '" + existingProjects.get(0).getName()
+ + "' project in the workspace.\n\n");
+ builder.append("Would you like to delete it?");
+ } else {
+ builder.append("There are the following projects in the workspace:\n\n");
+ for (IProject project : existingProjects) {
+ builder.append(project.getName());
+ builder.append("\n"); //$NON-NLS-1$
+ }
+ builder.append("\n"); //$NON-NLS-1$
+ builder.append("Would you like to delete them?");
+ }
+ return builder.toString();
+ }
+
+}
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java 2011-02-18 12:25:09 UTC (rev 29237)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java 2011-02-18 13:22:38 UTC (rev 29238)
@@ -11,7 +11,6 @@
package org.jboss.tools.maven.project.examples;
-import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -26,39 +25,32 @@
import org.apache.maven.model.Model;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.progress.IProgressConstants;
+import org.jboss.tools.project.examples.job.ProjectExamplesJob;
import org.jboss.tools.project.examples.model.AbstractImportProjectExample;
import org.jboss.tools.project.examples.model.Project;
import org.maven.ide.eclipse.MavenPlugin;
import org.maven.ide.eclipse.actions.OpenMavenConsoleAction;
-import org.maven.ide.eclipse.core.IMavenConstants;
import org.maven.ide.eclipse.core.MavenConsole;
import org.maven.ide.eclipse.embedder.IMaven;
import org.maven.ide.eclipse.embedder.MavenModelManager;
import org.maven.ide.eclipse.project.AbstractProjectScanner;
-import org.maven.ide.eclipse.project.IMavenProjectImportResult;
import org.maven.ide.eclipse.project.LocalProjectScanner;
import org.maven.ide.eclipse.project.MavenProjectInfo;
import org.maven.ide.eclipse.project.ProjectImportConfiguration;
-import org.maven.ide.eclipse.project.ResolverConfiguration;
/**
* @author snjeza
@@ -145,7 +137,7 @@
}
private void importMavenProjects(final File destination) {
- Job job = new WorkspaceJob("Importing Maven projects") {
+ Job job = new ProjectExamplesJob("Importing Maven projects") {
public IStatus runInWorkspace(IProgressMonitor monitor) {
setProperty(IProgressConstants.ACTION_PROPERTY,
new OpenMavenConsoleAction());
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/MavenProjectExamplesActivator.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/MavenProjectExamplesActivator.java 2011-02-18 12:25:09 UTC (rev 29237)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/MavenProjectExamplesActivator.java 2011-02-18 13:22:38 UTC (rev 29238)
@@ -9,7 +9,7 @@
* The activator class controls the plug-in life cycle
*/
public class MavenProjectExamplesActivator extends AbstractUIPlugin {
-
+
// The plug-in ID
public static final String PLUGIN_ID = "org.jboss.tools.maven.project.examples"; //$NON-NLS-1$
Added: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java 2011-02-18 13:22:38 UTC (rev 29238)
@@ -0,0 +1,108 @@
+package org.jboss.tools.maven.project.examples.wizard;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Properties;
+
+import org.apache.maven.archetype.catalog.Archetype;
+import org.apache.maven.model.Model;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.progress.IProgressConstants;
+import org.jboss.tools.project.examples.job.ProjectExamplesJob;
+import org.jboss.tools.project.examples.model.Project;
+import org.maven.ide.eclipse.MavenImages;
+import org.maven.ide.eclipse.MavenPlugin;
+import org.maven.ide.eclipse.actions.OpenMavenConsoleAction;
+import org.maven.ide.eclipse.core.Messages;
+import org.maven.ide.eclipse.project.ProjectImportConfiguration;
+
+public class ArchetypeExamplesWizard extends Wizard implements INewWizard {
+
+ private Project projectDescription;
+ private File location;
+ private ProjectImportConfiguration configuration;
+ private ArchetypeExamplesWizardPage wizardPage;
+
+ public ArchetypeExamplesWizard(File location, Project projectDescription) {
+ super();
+ setWindowTitle("Project Examples Archetype");
+ setDefaultPageImageDescriptor(MavenImages.WIZ_NEW_PROJECT);
+ setNeedsProgressMonitor(true);
+ this.location = location;
+ this.projectDescription = projectDescription;
+ }
+
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ }
+
+ @Override
+ public boolean performFinish() {
+ final Model model = wizardPage.getModel();
+ final String groupId = model.getGroupId();
+ final String artifactId = model.getArtifactId();
+ final String version = model.getVersion();
+ final String javaPackage = wizardPage.getJavaPackage();
+ final Properties properties = wizardPage.getProperties();
+ final MavenPlugin plugin = MavenPlugin.getDefault();
+ final Archetype archetype = wizardPage.getArchetype();
+ final String projectName = configuration.getProjectName(model);
+ final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+
+ final IWorkspaceRunnable wr = new IWorkspaceRunnable() {
+ public void run(final IProgressMonitor monitor)
+ throws CoreException {
+ plugin.getProjectConfigurationManager().createArchetypeProject(
+ project, new Path(location.getAbsolutePath()), archetype,
+ groupId, artifactId, version, javaPackage, properties,
+ configuration, monitor);
+ }
+ };
+
+ final IRunnableWithProgress op = new IRunnableWithProgress() {
+ public void run(final IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ try {
+ final IWorkspace ws = ResourcesPlugin.getWorkspace();
+ ws.run(wr, ws.getRoot(), IWorkspace.AVOID_UPDATE, monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ };
+
+ try {
+ getContainer().run(true, false, op);
+ } catch (InterruptedException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public void addPages() {
+ configuration = new ProjectImportConfiguration();
+ wizardPage = new ArchetypeExamplesWizardPage(configuration, projectDescription);
+ addPage(wizardPage);
+ }
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java 2011-02-18 13:22:38 UTC (rev 29238)
@@ -0,0 +1,48 @@
+package org.jboss.tools.maven.project.examples.wizard;
+
+import org.apache.maven.archetype.catalog.Archetype;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.project.examples.model.ArchetypeModel;
+import org.jboss.tools.project.examples.model.Project;
+import org.maven.ide.eclipse.project.ProjectImportConfiguration;
+import org.maven.ide.eclipse.wizards.MavenProjectWizardArchetypeParametersPage;
+
+public class ArchetypeExamplesWizardPage extends
+ MavenProjectWizardArchetypeParametersPage {
+
+ private Project projectDescription;
+
+ public ArchetypeExamplesWizardPage(
+ ProjectImportConfiguration configuration, Project projectDescription) {
+ super(configuration);
+ this.projectDescription = projectDescription;
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ Archetype archetype = new Archetype();
+ ArchetypeModel archetypeModel = projectDescription.getArchetypeModel();
+
+ final String groupId = archetypeModel.getGroupId();
+ final String artifactId = archetypeModel.getArtifactId();
+ final String version = archetypeModel.getVersion();
+ final String javaPackage = archetypeModel.getJavaPackage();
+
+ archetype.setGroupId(archetypeModel.getArchetypeGroupId());
+ archetype.setArtifactId(archetypeModel.getArchetypeArtifactId());
+ archetype.setVersion(archetypeModel.getArchetypeVersion());
+ archetype.setRepository(archetypeModel.getArchetypeRepository());
+ archetype.setProperties(archetypeModel.getArchetypeProperties());
+ setArchetype(archetype);
+ groupIdCombo.setText(groupId);
+ artifactIdCombo.setText(artifactId);
+ versionCombo.setText(version);
+ packageCombo.setText(javaPackage);
+ }
+
+ public Archetype getArchetype() {
+ return archetype;
+ }
+
+}
13 years, 10 months
JBoss Tools SVN: r29237 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2011-02-18 07:25:09 -0500 (Fri, 18 Feb 2011)
New Revision: 29237
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
Log:
https://issues.jboss.org/browse/JBIDE-7003, working on Externalize dialog, trying to removed dependency of dialog from JSPMultipage editor to make it usable without editor.
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java 2011-02-18 11:48:26 UTC (rev 29236)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java 2011-02-18 12:25:09 UTC (rev 29237)
@@ -13,31 +13,43 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
+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.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IStorageEditorInput;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools;
import org.eclipse.wst.xml.core.internal.document.AttrImpl;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.ui.internal.provisional.IDOMSourceEditingTextTools;
import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.meta.action.XActionInvoker;
import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateHandler;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.ui.ModelUIImages;
import org.jboss.tools.common.model.ui.editors.dnd.DropURI;
import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
@@ -52,10 +64,15 @@
import org.jboss.tools.jst.jsp.jspeditor.dnd.PaletteTaglibInserter;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.jsp.util.Constants;
+import org.jboss.tools.jst.jsp.util.FaceletsUtil;
+import org.jboss.tools.jst.web.project.WebProject;
+import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
import org.jboss.tools.jst.web.tld.TaglibData;
import org.jboss.tools.jst.web.tld.URIConstants;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
public class ExternalizeStringsWizard extends Wizard {
@@ -74,13 +91,16 @@
setWindowTitle(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE);
this.editor = editor;
this.bm = bm;
+ if(this.bm==null){
+ this.bm=createBundleMap(editor);
+ }
}
@Override
public void addPages() {
super.addPages();
page1 = new ExternalizeStringsWizardPage(
- ExternalizeStringsWizardPage.PAGE_NAME, editor, bm);
+ ExternalizeStringsWizardPage.PAGE_NAME, bm,getDocument(),getSelectionProvider());
page2 = new WizardNewFileCreationPage(EXTERNALIZE_STRINGS_DIALOG_NEW_FILE_PAGE,
(IStructuredSelection) getSelectionProvider().getSelection()) {
protected InputStream getInitialContents() {
@@ -358,6 +378,140 @@
return true;
}
+ /**
+ * Creates new bundle map if no one was specified
+ * during initialization of the page.
+ *
+ * @param editor the source editor
+ * @return the new bundle map
+ */
+ private BundleMap createBundleMap(ITextEditor editor) {
+ String uri = null;
+ String prefix = null;
+ int hash;
+ Map<?, ?> map = null;
+ BundleMap bm = new BundleMap();
+ bm.init(editor.getEditorInput());
+
+ /*
+ * Check JSF Nature
+ */
+ boolean hasJsfProjectNatureType = false;
+ try {
+ IEditorInput ei = editor.getEditorInput();
+ if(ei instanceof IFileEditorInput) {
+ IProject project = ((IFileEditorInput)ei).getFile().getProject();
+ if (project.exists() && project.isOpen()) {
+ if (project.hasNature(WebProject.JSF_NATURE_ID)) {
+ hasJsfProjectNatureType = true;
+ }
+ }
+ }
+ } catch (CoreException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+ /*
+ * Get Bundles from faces-config.xml
+ */
+ if (hasJsfProjectNatureType
+ && (editor.getEditorInput() instanceof IFileEditorInput)) {
+ IProject project = ((IFileEditorInput) editor.getEditorInput())
+ .getFile().getProject();
+ IModelNature modelNature = EclipseResourceUtil.getModelNature(project);
+ if (modelNature != null) {
+ XModel model = modelNature.getModel();
+ List<Object> l = WebPromptingProvider.getInstance().getList(model,
+ WebPromptingProvider.JSF_REGISTERED_BUNDLES, null, null);
+ if (l != null && l.size() > 1 && (l.get(1) instanceof Map)) {
+ map = (Map<?, ?>) l.get(1);
+ if ((null != map) && (map.keySet().size() > 0)) {
+ Iterator<?> it = map.keySet().iterator();
+ while (it.hasNext()) {
+ uri = it.next().toString();
+ prefix = map.get(uri).toString();
+ hash = (prefix + ":" + uri).hashCode(); //$NON-NLS-1$
+ bm.addBundle(hash, prefix, uri, false);
+ }
+ }
+ }
+ }
+ }
+ ISourceEditingTextTools sourceEditingTextTools =
+ (ISourceEditingTextTools) editor
+ .getAdapter(ISourceEditingTextTools.class);
+ IDOMSourceEditingTextTools domSourceEditingTextTools =
+ (IDOMSourceEditingTextTools) sourceEditingTextTools;
+ Document documentWithBundles = domSourceEditingTextTools.getDOMDocument();
+
+ /*
+ * When facelets are used -- get bundles from the template file
+ */
+ if (editor instanceof JSPTextEditor) {
+ IVisualContext context = ((JSPTextEditor) editor).getPageContext();
+ List<TaglibData> taglibs = null;
+ if (context instanceof SourceEditorPageContext) {
+ SourceEditorPageContext sourcePageContext = (SourceEditorPageContext) context;
+ taglibs = sourcePageContext.getTagLibs();
+ }
+ if (null == taglibs) {
+ JspEditorPlugin.getDefault().logError(
+ JstUIMessages.CANNOT_LOAD_TAGLIBS_FROM_PAGE_CONTEXT);
+ } else {
+ Element root = FaceletsUtil.findComponentElement(documentWithBundles.getDocumentElement());
+ if ((root != null) && FaceletsUtil.isFacelet(root, taglibs)
+ && root.hasAttribute("template")) { //$NON-NLS-1$
+ String filePath= root.getAttributeNode("template").getNodeValue(); //$NON-NLS-1$
+ if (((JSPTextEditor) editor).getEditorInput() instanceof FileEditorInput) {
+ FileEditorInput fei = (FileEditorInput) ((JSPTextEditor) editor).getEditorInput();
+ IResource webContentResource = EclipseResourceUtil.getFirstWebContentResource(fei.getFile().getProject());
+ if (webContentResource instanceof IContainer) {
+ IFile templateFile = (IFile) ((IContainer) webContentResource).findMember(filePath); //$NON-NLS-1$
+ Document document = null;
+ IDOMModel wtpModel = null;
+ try {
+ wtpModel = (IDOMModel)StructuredModelManager.getModelManager().getModelForRead(templateFile);
+ if (wtpModel != null) {
+ document = wtpModel.getDocument();
+ }
+ } catch(IOException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ } catch(CoreException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ } finally {
+ if(wtpModel!=null) {
+ wtpModel.releaseFromRead();
+ }
+ }
+ if (null != document) {
+ /*
+ * Change the document where to look bundles
+ */
+ documentWithBundles = document;
+ }
+ }
+ }
+ }
+ }
+ }
+ /*
+ * Add bundles from <f:loadBundle> tags on the current page
+ */
+ NodeList list = documentWithBundles.getElementsByTagName("f:loadBundle"); //$NON-NLS-1$
+ for (int i = 0; i < list.getLength(); i++) {
+ Element node = (Element) list.item(i);
+ uri = node.getAttribute("basename"); //$NON-NLS-1$
+ prefix = node.getAttribute("var"); //$NON-NLS-1$
+ hash = node.hashCode();
+ bm.addBundle(hash, prefix, uri, false);
+ }
+ return bm;
+ }
+
+ private IDocument getDocument(){
+ IDocumentProvider prov = editor.getDocumentProvider();
+ return prov.getDocument(editor.getEditorInput());
+ }
+
private ISelectionProvider getSelectionProvider(){
return editor.getSelectionProvider();
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2011-02-18 11:48:26 UTC (rev 29236)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2011-02-18 12:25:09 UTC (rev 29237)
@@ -16,16 +16,11 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import java.util.Set;
-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.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -37,6 +32,7 @@
import org.eclipse.jface.viewers.ColumnLayoutData;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableLayout;
@@ -57,38 +53,16 @@
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
-import org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools;
import org.eclipse.wst.xml.core.internal.document.AttrImpl;
import org.eclipse.wst.xml.core.internal.document.TextImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.ui.internal.provisional.IDOMSourceEditingTextTools;
-import org.jboss.tools.common.model.XModel;
-import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.ui.ModelUIImages;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.jst.jsp.bundle.BundleMap.BundleEntry;
-import org.jboss.tools.jst.jsp.editor.IVisualContext;
-import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
-import org.jboss.tools.jst.jsp.jspeditor.SourceEditorPageContext;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.jsp.util.Constants;
-import org.jboss.tools.jst.jsp.util.FaceletsUtil;
-import org.jboss.tools.jst.web.project.WebProject;
-import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-import org.jboss.tools.jst.web.tld.TaglibData;
import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
public class ExternalizeStringsWizardPage extends WizardPage {
@@ -99,7 +73,6 @@
private final char[] LINE_DELEMITERS = new char[] {'\r', '\n', '\t'};
private final int DIALOG_WIDTH = 450;
private final int DIALOG_HEIGHT = 650;
- private ITextEditor editor;
private Text propsKey;
private Text propsValue;
private Button newFile;
@@ -114,6 +87,8 @@
private Status duplicateKeyStatus;
private Status duplicateValueStatus;
private Table tagsTable;
+ private IDocument document;
+ private ISelectionProvider selectionProvider;
/**
* Creates the wizard page
@@ -123,10 +98,9 @@
* @param editor
* the source text editor
* @param bm
- * bundle map, or <code>null</code> - then the bundle map will be
- * created and initialized manually
+ * bundle map, or not null
*/
- public ExternalizeStringsWizardPage(String pageName, ITextEditor editor, BundleMap bm) {
+ public ExternalizeStringsWizardPage(String pageName, BundleMap bm, IDocument document, ISelectionProvider selectionProvider) {
/*
* Setting dialog Title, Description, Image.
*/
@@ -135,16 +109,17 @@
ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_DEFAULT));
setDescription(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_DESCRIPTION);
setPageComplete(false);
- this.editor = editor;
- if (bm != null) {
- this.bm = bm;
- } else {
- /*
- * When BundleMap is null create it manually
- * with all necessary initialization
- */
- this.bm = createBundleMap(editor);
- }
+// if (bm != null) {
+// this.bm = bm;
+// } else {
+// /*
+// * When BundleMap is null create it manually
+// * with all necessary initialization
+// */
+// this.bm = createBundleMap(editor);
+// }
+ this.document = document;
+ this.selectionProvider = selectionProvider;
propsKeyStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID, Constants.EMPTY);
propsValueStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID, Constants.EMPTY);
duplicateKeyStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID, Constants.EMPTY);
@@ -387,9 +362,8 @@
* Replaces the text in the current file
*/
public void replaceText(String replacement) {
- IDocumentProvider prov = editor.getDocumentProvider();
- IDocument doc = prov.getDocument(editor.getEditorInput());
- ISelection sel = editor.getSelectionProvider().getSelection();
+ IDocument doc = getDocument();
+ ISelection sel = getSelectionProvider().getSelection();
if (ExternalizeStringsUtils.isSelectionCorrect(sel)) {
try {
/*
@@ -458,7 +432,7 @@
* Fill in appropriate text and make validation.
*/
private void initializeFieldsAndAddLIsteners() {
- ISelection sel = editor.getSelectionProvider().getSelection();
+ ISelection sel = getSelectionProvider().getSelection();
if (ExternalizeStringsUtils.isSelectionCorrect(sel)) {
String text = Constants.EMPTY;
String stringToUpdate = Constants.EMPTY;
@@ -479,7 +453,7 @@
org.w3c.dom.Text textNode = (org.w3c.dom.Text) selectedElement;
if (textNode.getNodeValue().trim().length() > 0) {
stringToUpdate = textNode.getNodeValue();
- editor.getSelectionProvider().setSelection(new StructuredSelection(stringToUpdate));
+ getSelectionProvider().setSelection(new StructuredSelection(stringToUpdate));
}
} else if (selectedElement instanceof Attr) {
/*
@@ -488,7 +462,7 @@
Attr attrNode = (Attr) selectedElement;
if (attrNode.getNodeValue().trim().length() > 0) {
stringToUpdate = attrNode.getNodeValue();
- editor.getSelectionProvider().setSelection(new StructuredSelection(stringToUpdate));
+ getSelectionProvider().setSelection(new StructuredSelection(stringToUpdate));
}
}
if ((stringToUpdate.trim().length() > 0)) {
@@ -908,135 +882,6 @@
}
/**
- * Creates new bundle map if no one was specified
- * during initialization of the page.
- *
- * @param editor the source editor
- * @return the new bundle map
- */
- private BundleMap createBundleMap(ITextEditor editor) {
- String uri = null;
- String prefix = null;
- int hash;
- Map<?, ?> map = null;
- BundleMap bm = new BundleMap();
- bm.init(editor.getEditorInput());
-
- /*
- * Check JSF Nature
- */
- boolean hasJsfProjectNatureType = false;
- try {
- IEditorInput ei = editor.getEditorInput();
- if(ei instanceof IFileEditorInput) {
- IProject project = ((IFileEditorInput)ei).getFile().getProject();
- if (project.exists() && project.isOpen()) {
- if (project.hasNature(WebProject.JSF_NATURE_ID)) {
- hasJsfProjectNatureType = true;
- }
- }
- }
- } catch (CoreException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- /*
- * Get Bundles from faces-config.xml
- */
- if (hasJsfProjectNatureType
- && (editor.getEditorInput() instanceof IFileEditorInput)) {
- IProject project = ((IFileEditorInput) editor.getEditorInput())
- .getFile().getProject();
- IModelNature modelNature = EclipseResourceUtil.getModelNature(project);
- if (modelNature != null) {
- XModel model = modelNature.getModel();
- List<Object> l = WebPromptingProvider.getInstance().getList(model,
- WebPromptingProvider.JSF_REGISTERED_BUNDLES, null, null);
- if (l != null && l.size() > 1 && (l.get(1) instanceof Map)) {
- map = (Map<?, ?>) l.get(1);
- if ((null != map) && (map.keySet().size() > 0)) {
- Iterator<?> it = map.keySet().iterator();
- while (it.hasNext()) {
- uri = it.next().toString();
- prefix = map.get(uri).toString();
- hash = (prefix + ":" + uri).hashCode(); //$NON-NLS-1$
- bm.addBundle(hash, prefix, uri, false);
- }
- }
- }
- }
- }
- ISourceEditingTextTools sourceEditingTextTools =
- (ISourceEditingTextTools) editor
- .getAdapter(ISourceEditingTextTools.class);
- IDOMSourceEditingTextTools domSourceEditingTextTools =
- (IDOMSourceEditingTextTools) sourceEditingTextTools;
- Document documentWithBundles = domSourceEditingTextTools.getDOMDocument();
-
- /*
- * When facelets are used -- get bundles from the template file
- */
- if (editor instanceof JSPTextEditor) {
- IVisualContext context = ((JSPTextEditor) editor).getPageContext();
- List<TaglibData> taglibs = null;
- if (context instanceof SourceEditorPageContext) {
- SourceEditorPageContext sourcePageContext = (SourceEditorPageContext) context;
- taglibs = sourcePageContext.getTagLibs();
- }
- if (null == taglibs) {
- JspEditorPlugin.getDefault().logError(
- JstUIMessages.CANNOT_LOAD_TAGLIBS_FROM_PAGE_CONTEXT);
- } else {
- Element root = FaceletsUtil.findComponentElement(documentWithBundles.getDocumentElement());
- if ((root != null) && FaceletsUtil.isFacelet(root, taglibs)
- && root.hasAttribute("template")) { //$NON-NLS-1$
- String filePath= root.getAttributeNode("template").getNodeValue(); //$NON-NLS-1$
- if (((JSPTextEditor) editor).getEditorInput() instanceof FileEditorInput) {
- FileEditorInput fei = (FileEditorInput) ((JSPTextEditor) editor).getEditorInput();
- IResource webContentResource = EclipseResourceUtil.getFirstWebContentResource(fei.getFile().getProject());
- if (webContentResource instanceof IContainer) {
- IFile templateFile = (IFile) ((IContainer) webContentResource).findMember(filePath); //$NON-NLS-1$
- Document document = null;
- IDOMModel wtpModel = null;
- try {
- wtpModel = (IDOMModel)StructuredModelManager.getModelManager().getModelForRead(templateFile);
- if (wtpModel != null) {
- document = wtpModel.getDocument();
- }
- } catch(IOException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- } catch(CoreException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- } finally {
- if(wtpModel!=null) {
- wtpModel.releaseFromRead();
- }
- }
- if (null != document) {
- /*
- * Change the document where to look bundles
- */
- documentWithBundles = document;
- }
- }
- }
- }
- }
- }
- /*
- * Add bundles from <f:loadBundle> tags on the current page
- */
- NodeList list = documentWithBundles.getElementsByTagName("f:loadBundle"); //$NON-NLS-1$
- for (int i = 0; i < list.getLength(); i++) {
- Element node = (Element) list.item(i);
- uri = node.getAttribute("basename"); //$NON-NLS-1$
- prefix = node.getAttribute("var"); //$NON-NLS-1$
- hash = node.hashCode();
- bm.addBundle(hash, prefix, uri, false);
- }
- return bm;
- }
-
- /**
* Sets the resource bundle path according to the selection
* from the bundles list.
*
@@ -1056,4 +901,11 @@
propsFile.setText(bundlePath);
}
+ private ISelectionProvider getSelectionProvider(){
+ return selectionProvider;
+ }
+
+ private IDocument getDocument(){
+ return document;
+ }
}
13 years, 10 months
JBoss Tools SVN: r29236 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2011-02-18 06:48:26 -0500 (Fri, 18 Feb 2011)
New Revision: 29236
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
Log:
https://issues.jboss.org/browse/JBIDE-7003, working on Externalize dialog, trying to removed dependency of dialog from JSPMultipage editor.
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java 2011-02-18 10:32:25 UTC (rev 29235)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java 2011-02-18 11:48:26 UTC (rev 29236)
@@ -22,6 +22,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
@@ -31,7 +32,6 @@
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.eclipse.wst.xml.core.internal.document.AttrImpl;
-import org.eclipse.wst.xml.core.internal.document.ElementImpl;
import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.meta.action.XActionInvoker;
import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateHandler;
@@ -82,7 +82,7 @@
page1 = new ExternalizeStringsWizardPage(
ExternalizeStringsWizardPage.PAGE_NAME, editor, bm);
page2 = new WizardNewFileCreationPage(EXTERNALIZE_STRINGS_DIALOG_NEW_FILE_PAGE,
- (IStructuredSelection) editor.getSelectionProvider().getSelection()) {
+ (IStructuredSelection) getSelectionProvider().getSelection()) {
protected InputStream getInitialContents() {
return new ByteArrayInputStream(page1.getKeyValuePair().getBytes());
}
@@ -110,20 +110,7 @@
* https://jira.jboss.org/browse/JBIDE-7247
* Set initial values for the new properties file
*/
- IPath containerFullPath = null;
- if (editor.getEditorInput() instanceof IFileEditorInput) {
- IProject project = ((IFileEditorInput)editor.getEditorInput()).getFile().getProject();
- IResource[] src = EclipseUtil.getJavaSourceRoots(project);
- if (src.length > 0) {
- containerFullPath = src[0].getFullPath();
- }
- } else if (editor.getEditorInput() instanceof IStorageEditorInput) {
- try {
- containerFullPath = ((IStorageEditorInput) editor.getEditorInput()).getStorage().getFullPath();
- } catch (CoreException e) {
- JspEditorPlugin.getDefault().logError(e);
- }
- }
+ IPath containerFullPath = getContainerFullPath();
if (null != containerFullPath) {
page2.setContainerFullPath(containerFullPath);
}
@@ -288,7 +275,7 @@
* Add <f:loadBundle> tag to the current page.
* Insert the tag before currently selected tag.
*/
- ISelection sel = editor.getSelectionProvider().getSelection();
+ ISelection sel = getSelectionProvider().getSelection();
if (ExternalizeStringsUtils.isSelectionCorrect(sel)) {
IStructuredSelection structuredSelection = (IStructuredSelection) sel;
Object selectedElement = structuredSelection.getFirstElement();
@@ -321,7 +308,7 @@
*/
PaletteTaglibInserter PaletteTaglibInserter = new PaletteTaglibInserter();
Properties p = new Properties();
- p.put("selectionProvider", editor.getSelectionProvider()); //$NON-NLS-1$
+ p.put("selectionProvider", getSelectionProvider()); //$NON-NLS-1$
p.setProperty(URIConstants.LIBRARY_URI, DropURI.JSF_CORE_URI);
p.setProperty(URIConstants.LIBRARY_VERSION, ""); //$NON-NLS-1$
p.setProperty(URIConstants.DEFAULT_PREFIX, jsfCoreTaglibPrefix);
@@ -370,4 +357,29 @@
page1.replaceText(replacement);
return true;
}
+
+ private ISelectionProvider getSelectionProvider(){
+ return editor.getSelectionProvider();
+ }
+ /**
+ * https://jira.jboss.org/browse/JBIDE-7247
+ * returns initial path for new properties file
+ */
+ private IPath getContainerFullPath(){
+ IPath containerFullPath = null;
+ if (editor.getEditorInput() instanceof IFileEditorInput) {
+ IProject project = ((IFileEditorInput)editor.getEditorInput()).getFile().getProject();
+ IResource[] src = EclipseUtil.getJavaSourceRoots(project);
+ if (src.length > 0) {
+ containerFullPath = src[0].getFullPath();
+ }
+ } else if (editor.getEditorInput() instanceof IStorageEditorInput) {
+ try {
+ containerFullPath = ((IStorageEditorInput) editor.getEditorInput()).getStorage().getFullPath();
+ } catch (CoreException e) {
+ JspEditorPlugin.getDefault().logError(e);
+ }
+ }
+ return containerFullPath;
+ }
}
13 years, 10 months
JBoss Tools SVN: r29235 - in trunk: jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2011-02-18 05:32:25 -0500 (Fri, 18 Feb 2011)
New Revision: 29235
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2584Test.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java
Log:
https://issues.jboss.org/browse/JBIDE-8115 : Support for multiple selection in visual part
- SelectionManager.refreshVisualSelection() mathod has been splitted to refreshVisualNodeSelection() and refreshVisualTextSelection()
- other minor changes
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java 2011-02-18 08:23:53 UTC (rev 29234)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java 2011-02-18 10:32:25 UTC (rev 29235)
@@ -11,6 +11,7 @@
package org.jboss.tools.jsf.vpe.jsf.template;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.jboss.tools.jsf.vpe.jsf.template.util.JSF;
import org.jboss.tools.jsf.vpe.jsf.template.util.NodeProxyUtil;
@@ -198,8 +199,7 @@
@Override
public nsIDOMNode getVisualNodeBySourcePosition(
- VpeElementMapping elementMapping, int focusPosition,
- int anchorPosition, VpeDomMapping domMapping) {
+ VpeElementMapping elementMapping, Point selectionRange, VpeDomMapping domMapping) {
nsIDOMNode node = null;
if ((elementMapping.getElementData() instanceof VpeElementProxyData)
@@ -210,15 +210,13 @@
.getElementData();
VpeNodeMapping nodeMapping = NodeProxyUtil.findNodeByPosition(
- domMapping, elementProxyData.getNodelist(), focusPosition,
- anchorPosition);
+ domMapping, elementProxyData.getNodelist(), selectionRange);
if (nodeMapping != null) {
if (nodeMapping instanceof VpeElementMapping) {
node = super.getVisualNodeBySourcePosition(
- (VpeElementMapping) nodeMapping, focusPosition,
- anchorPosition, domMapping);
+ (VpeElementMapping) nodeMapping, selectionRange, domMapping);
} else {
node = nodeMapping.getVisualNode();
}
@@ -227,7 +225,7 @@
if (node == null) {
node = super.getVisualNodeBySourcePosition(elementMapping,
- focusPosition, anchorPosition, domMapping);
+ selectionRange, domMapping);
}
return node;
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java 2011-02-18 08:23:53 UTC (rev 29234)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java 2011-02-18 10:32:25 UTC (rev 29235)
@@ -12,6 +12,7 @@
import org.eclipse.jst.jsp.core.internal.domdocument.DOMModelForJSP;
import org.eclipse.jst.jsp.core.internal.parser.JSPSourceParser;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.wst.sse.core.internal.document.StructuredDocumentFactory;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
@@ -72,29 +73,25 @@
* @return
*/
static public VpeNodeMapping findNodeByPosition(VpeDomMapping domMapping,
- NodeList nodeList, int focusPosition, int anchorPosition) {
+ NodeList nodeList, Point selectionRange) {
+ int beginPosition = Math.min(selectionRange.x, selectionRange.x + selectionRange.y);
+ int endPosition = Math.max(selectionRange.x, selectionRange.x + selectionRange.y);
- if (anchorPosition < focusPosition) {
- focusPosition = anchorPosition;
- anchorPosition = focusPosition;
- }
-
for (int i = 0; i < nodeList.getLength(); i++) {
Node child = nodeList.item(i);
VpeNodeMapping result = null;
if (child.hasChildNodes()) {
-
result = findNodeByPosition(domMapping, child.getChildNodes(),
- focusPosition, anchorPosition);
+ selectionRange);
}
if (result != null)
return result;
- if ((focusPosition >= (NodesManagingUtil.getStartOffsetNode(child)))
- && (anchorPosition <= (NodesManagingUtil
+ if ((beginPosition >= (NodesManagingUtil.getStartOffsetNode(child)))
+ && (endPosition <= (NodesManagingUtil
.getEndOffsetNode(child)))) {
return VpeNodesManagingUtil.getNodeMapping(domMapping, child);
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2584Test.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2584Test.java 2011-02-18 08:23:53 UTC (rev 29234)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2584Test.java 2011-02-18 10:32:25 UTC (rev 29235)
@@ -12,6 +12,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.part.FileEditorInput;
import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
@@ -68,8 +69,8 @@
VpeTemplate simpleTextTemplate = simpleTextMapping.getTemplate();
-
- nsIDOMNode domNode = simpleTextTemplate.getVisualNodeBySourcePosition(simpleTextMapping, TestUtil.getLinePositionOffcet(itextViewer, 14, 10), 0, domMapping).getFirstChild();
+ int positionOffset = TestUtil.getLinePositionOffcet(itextViewer, 14, 10);
+ nsIDOMNode domNode = simpleTextTemplate.getVisualNodeBySourcePosition(simpleTextMapping, new Point(positionOffset, -positionOffset), domMapping).getFirstChild();
assertEquals(simpleTextNode ,domMapping.getNearElementMappingAtVisualNode(domNode).getSourceNode());
assertEquals("Node should be a text node", nsIDOMNode.TEXT_NODE,domNode.getNodeType()); //$NON-NLS-1$
@@ -107,7 +108,8 @@
VpeTemplate simpleTextTemplate = simpleTextMapping.getTemplate();
- nsIDOMNode domNode = simpleTextTemplate.getVisualNodeBySourcePosition(simpleTextMapping, TestUtil.getLinePositionOffcet(itextViewer, 15, 27), 0, domMapping).getFirstChild();
+ int positionOffset = TestUtil.getLinePositionOffcet(itextViewer, 15, 27);
+ nsIDOMNode domNode = simpleTextTemplate.getVisualNodeBySourcePosition(simpleTextMapping, new Point(positionOffset, -positionOffset), domMapping).getFirstChild();
assertEquals("Node should be a text node", nsIDOMNode.TEXT_NODE,domNode.getNodeType()); //$NON-NLS-1$
assertEquals(simpleTextNode ,domMapping.getNearElementMappingAtVisualNode(domNode).getSourceNode());
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java 2011-02-18 08:23:53 UTC (rev 29234)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java 2011-02-18 10:32:25 UTC (rev 29235)
@@ -90,8 +90,7 @@
SelectionUtil.setSourceSelection(getPageContext(),
selectionData.getSourceNode(),
selectionOffset, selectionLength);
- getPageContext().getVisualBuilder().setSelectionRectangle(
- selectionData.getVisualNode());
+ refreshVisualNodeSelection();
}
private SelectionData getSelectionData(nsIDOMNode visualNode) {
@@ -136,76 +135,88 @@
}
/**
- * Syncronization visual selection and source selection, actually moves
- * source selection to visual selection
+ * Synchronize visual selection and source selection (move
+ * source selection to visual selection).
*/
final public void refreshVisualSelection() {
+ refreshVisualNodeSelection();
+ refreshVisualTextSelection();
+ }
+
+ /**
+ * Draws selection rectangle in the Visual Part according to source selection.
+ */
+ private void refreshVisualNodeSelection() {
// checks for null, for case when we close editor and background
// update job is running
if (getSourceEditor().getTextViewer() == null) {
-
return;
}
-
- Point range = SelectionUtil
- .getSourceSelectionRange(getSourceEditor());
-
- if (range == null)
+
+ Point range = SelectionUtil.getSourceSelectionRange(getSourceEditor());
+ if (range == null) {
return;
-
- int focusOffcetInSourceDocument = range.x;
-
- int anchorOffcetInSourceDocument = focusOffcetInSourceDocument
- + range.y;
+ }
+
VpeNodeMapping nodeMapping = SelectionUtil
- .getNodeMappingBySourceSelection(getSourceEditor(),
- getDomMapping());
-
+ .getNodeMappingBySourceSelection(getSourceEditor(), getDomMapping());
if (nodeMapping == null) {
return;
}
-
+
// visual node which will be selected
- nsIDOMNode targetVisualNode;
-
- // int visualNodeOffcet =
- // TextUtil.visualPosition(((Node)targetSourceNode
- // ).getNodeValue(),offcetReferenceToSourceNode);
-
- // if mapping is elementMapping
+ nsIDOMNode targetVisualNode;
+ if (nodeMapping instanceof VpeElementMapping) {
+ VpeElementMapping elementMapping = (VpeElementMapping) nodeMapping;
+ targetVisualNode = elementMapping.getTemplate()
+ .getVisualNodeBySourcePosition(elementMapping,
+ range, getDomMapping());
+ } else {
+ targetVisualNode = nodeMapping.getVisualNode();
+ }
+ getPageContext().getVisualBuilder().setSelectionRectangle(
+ targetVisualNode);
+ }
+
+ /**
+ * Selects text in the Visual Part Visual Part according to source selection.
+ */
+ private void refreshVisualTextSelection() {
+ // checks for null, for case when we close editor and background
+ // update job is running
+ if (getSourceEditor().getTextViewer() == null) {
+ return;
+ }
+ Point range = SelectionUtil.getSourceSelectionRange(getSourceEditor());
+ if (range == null) {
+ return;
+ }
+
+ VpeNodeMapping nodeMapping = SelectionUtil
+ .getNodeMappingBySourceSelection(getSourceEditor(), getDomMapping());
+ if (nodeMapping == null) {
+ return;
+ }
+
SelectionUtil.clearSelection(selectionController);
+ // visual node which will be selected
+
if (nodeMapping instanceof VpeElementMapping) {
-
VpeElementMapping elementMapping = (VpeElementMapping) nodeMapping;
-
- VpeTemplate template = elementMapping.getTemplate();
-
- targetVisualNode = template.getVisualNodeBySourcePosition(
- elementMapping, focusOffcetInSourceDocument,
- anchorOffcetInSourceDocument, getDomMapping());
-
- NodeData nodeData = template.getNodeData(targetVisualNode,
+ nsIDOMNode targetVisualNode = elementMapping.getTemplate()
+ .getVisualNodeBySourcePosition(
+ elementMapping, range, getDomMapping());
+ NodeData nodeData = elementMapping.getTemplate().getNodeData(targetVisualNode,
elementMapping.getElementData(), getDomMapping());
// we can restore cursor position only if we have nodeData and
// range.y==0
if (nodeData != null) {
// restore cursor position in source document
- restoreVisualCursorPosition(template, nodeData,
- focusOffcetInSourceDocument,
- anchorOffcetInSourceDocument);
+ restoreVisualCursorPosition(elementMapping.getTemplate(), nodeData, range);
}
- } else {
-
- targetVisualNode = nodeMapping.getVisualNode();
- // restore cursor position for source node
-// restoreVisualCursorPositionForTextNode(targetVisualNode,
-// focusOffcetInSourceDocument, model);
}
- // here we restore only highlight
- getPageContext().getVisualBuilder().setSelectionRectangle(
- targetVisualNode);
}
/**
@@ -219,8 +230,7 @@
* and visual node, attribute
*/
private void restoreVisualCursorPosition(VpeTemplate template,
- NodeData nodeData, int focusOffcetInSourceDocument,
- int anchorOffsetrInSourceDocument) {
+ NodeData nodeData, Point selectionRange) {
nsIDOMNode visualNode = nodeData.getVisualNode();
@@ -230,10 +240,10 @@
Node targetSourceNode = nodeData.getSourceNode();
- int focusOffcetReferenceToSourceNode = focusOffcetInSourceDocument
+ int focusOffcetReferenceToSourceNode = selectionRange.x
- NodesManagingUtil.getStartOffsetNode(targetSourceNode);
- int anchorOffcetReferenceToSourceNode = anchorOffsetrInSourceDocument
+ int anchorOffcetReferenceToSourceNode = selectionRange.x + selectionRange.y
- NodesManagingUtil.getStartOffsetNode(targetSourceNode);
int length = visualNode.getNodeValue().length();
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2011-02-18 08:23:53 UTC (rev 29234)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2011-02-18 10:32:25 UTC (rev 29235)
@@ -1338,15 +1338,16 @@
* Gets the visual node by by source position.
*
* @param domMapping the dom mapping
- * @param focusPosition the focus position
- * @param anchorPosition the anchor position
+ * @param selectionRange the selection range
* @param elementMapping the element mapping
*
* @return the visual node by by source position
*/
+ @Override
public nsIDOMNode getVisualNodeBySourcePosition(
- VpeElementMapping elementMapping, int focusPosition,
- int anchorPosition, VpeDomMapping domMapping) {
+ VpeElementMapping elementMapping, Point selectionRange, VpeDomMapping domMapping) {
+ int focusPosition = selectionRange.x;
+ int anchorPosition = selectionRange.x + selectionRange.y;
// find focus attribute by position
nsIDOMNode focusNode = findNodeByPosition(elementMapping
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2011-02-18 08:23:53 UTC (rev 29234)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2011-02-18 10:32:25 UTC (rev 29235)
@@ -11,6 +11,7 @@
package org.jboss.tools.vpe.editor.template;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.swt.graphics.Point;
import org.jboss.tools.jst.jsp.editor.ITextFormatter;
import org.jboss.tools.jst.jsp.selection.SourceSelection;
import org.jboss.tools.vpe.editor.VpeSourceInnerDragInfo;
@@ -446,14 +447,13 @@
/**
*
* @param elementMapping
- * @param focusPosition
- * @param anchorPosition
+ * @param selectionRange
* @param domMapping
* @return
*/
public nsIDOMNode getVisualNodeBySourcePosition(
- VpeElementMapping elementMapping, int focusPosition,
- int anchorPosition, VpeDomMapping domMapping);
+ VpeElementMapping elementMapping,
+ Point selectionRange, VpeDomMapping domMapping);
public boolean isInvisible();
13 years, 10 months