JBoss Tools SVN: r14934 - in trunk/as/plugins: org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-04-27 05:19:15 -0400 (Mon, 27 Apr 2009)
New Revision: 14934
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/FilesetContentProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java
Log:
JBIDE-4242 - moving filesets out of the server object since they don't belong there
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF 2009-04-27 07:06:36 UTC (rev 14933)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF 2009-04-27 09:19:15 UTC (rev 14934)
@@ -19,7 +19,8 @@
org.eclipse.ui.ide;bundle-version="3.4.0",
org.jboss.ide.eclipse.as.ui;bundle-version="1.0.0",
org.eclipse.core.filesystem;bundle-version="1.2.0",
- org.eclipse.ui.navigator;bundle-version="3.3.100"
+ org.eclipse.ui.navigator;bundle-version="3.3.100",
+ org.jboss.tools.jmx.core;bundle-version="0.2.1"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.jboss.ide.eclipse.archives.webtools,
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/FilesetContentProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/FilesetContentProvider.java 2009-04-27 07:06:36 UTC (rev 14933)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/ui/FilesetContentProvider.java 2009-04-27 09:19:15 UTC (rev 14934)
@@ -10,6 +10,10 @@
******************************************************************************/
package org.jboss.ide.eclipse.archives.webtools.ui;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -23,10 +27,16 @@
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.archives.core.asf.DirectoryScanner;
import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathCategory;
import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.tools.jmx.core.IMemento;
+import org.jboss.tools.jmx.core.util.XMLMemento;
public class FilesetContentProvider implements ITreeContentProvider {
private static final String FILESET_KEY = "org.jboss.ide.eclipse.as.ui.views.server.providers.FilesetViewProvider.PropertyKey"; //$NON-NLS-1$
+ private static final String FILESET_FILE_NAME = "filesets.xml"; //$NON-NLS-1$
public static class PathWrapper {
private IPath path;
@@ -144,11 +154,20 @@
}
private Fileset[] loadFilesets() {
+ if( getFile(server).exists()) {
+ return FilesetContentProvider.loadFilesets(server);
+ } else {
+ return loadFilesets_LEGACY();
+ }
+ }
+
+ @Deprecated
+ private Fileset[] loadFilesets_LEGACY() {
Fileset[] filesets = new Fileset[0];
if (server != null) {
ServerAttributeHelper helper = ServerAttributeHelper
.createHelper(server);
- List tmp = helper.getAttribute(FILESET_KEY, new ArrayList());
+ List<String> tmp = (ArrayList<String>)helper.getAttribute(FILESET_KEY, new ArrayList<String>());
String[] asStrings = (String[]) tmp.toArray(new String[tmp
.size()]);
filesets = new Fileset[asStrings.length];
@@ -160,18 +179,53 @@
}
public void saveFilesets() {
- if (server != null) {
- ArrayList<String> list = new ArrayList<String>();
- for (int i = 0; i < children.length; i++) {
- list.add(children[i].toString());
- }
- ServerAttributeHelper helper = ServerAttributeHelper
- .createHelper(server);
- helper.setAttribute(FILESET_KEY, list);
- helper.save();
+ FilesetContentProvider.saveFilesets(server, children);
+ }
+ }
+
+ protected static Fileset[] loadFilesets(IServer server) {
+ Fileset[] filesets = null;
+ try {
+ File file = getFile(server);
+ XMLMemento memento = XMLMemento.createReadRoot(new FileInputStream(file));
+ IMemento[] categoryMementos = memento.getChildren("fileset");//$NON-NLS-1$
+ filesets = new Fileset[categoryMementos.length];
+ String name, folder, includes, excludes;
+ for( int i = 0; i < categoryMementos.length; i++ ) {
+ name = categoryMementos[i].getString("name"); //$NON-NLS-1$
+ folder = categoryMementos[i].getString("folder");//$NON-NLS-1$
+ includes = categoryMementos[i].getString("includes");//$NON-NLS-1$
+ excludes = categoryMementos[i].getString("excludes");//$NON-NLS-1$
+ filesets[i] = new Fileset(name, folder, includes, excludes);
}
+ } catch( IOException ioe) {
+ // TODO LOG
}
+ return filesets == null ? new Fileset[] { } : filesets;
}
+
+ protected static void saveFilesets(IServer server, Fileset[] sets) {
+ if( server != null ) {
+ XMLMemento memento = XMLMemento.createWriteRoot("filesets"); //$NON-NLS-1$
+ for( int i = 0; i < sets.length; i++ ) {
+ XMLMemento child = (XMLMemento)memento.createChild("fileset");//$NON-NLS-1$
+ child.putString("name", sets[i].getName());//$NON-NLS-1$
+ child.putString("folder", sets[i].getFolder());//$NON-NLS-1$
+ child.putString("includes", sets[i].getIncludesPattern());//$NON-NLS-1$
+ child.putString("excludes", sets[i].getExcludesPattern());//$NON-NLS-1$
+ }
+ try {
+ memento.save(new FileOutputStream(getFile(server)));
+ } catch( IOException ioe) {
+ // TODO LOG
+ }
+ }
+ }
+
+ protected static File getFile(IServer server) {
+ return JBossServerCorePlugin.getServerStateLocation(server)
+ .append(FILESET_FILE_NAME).toFile();
+ }
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof IServer) {
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java 2009-04-27 07:06:36 UTC (rev 14933)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java 2009-04-27 09:19:15 UTC (rev 14934)
@@ -54,7 +54,6 @@
private static final String DELIMITER = ","; //$NON-NLS-1$
private static final String CATEGORY_LIST =
"org.jboss.ide.eclipse.as.core.model.descriptor.Categories"; //$NON-NLS-1$
- private static final IPath STATE_LOCATION = JBossServerCorePlugin.getDefault().getStateLocation();
/* Singleton */
private static XPathModel instance;
@@ -160,7 +159,7 @@
* Loading and saving is below
*/
protected File getFile(IServer server) {
- return STATE_LOCATION.append(server.getId().replace(' ', '_')).append(IJBossToolingConstants.XPATH_FILE_NAME).toFile();
+ return JBossServerCorePlugin.getServerStateLocation(server).append(IJBossToolingConstants.XPATH_FILE_NAME).toFile();
}
public void save(IServer server) {
16 years, 11 months
JBoss Tools SVN: r14933 - trunk/as/tests/org.jboss.ide.eclipse.as.test/META-INF.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-04-27 03:06:36 -0400 (Mon, 27 Apr 2009)
New Revision: 14933
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/META-INF/MANIFEST.MF
Log:
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/META-INF/MANIFEST.MF 2009-04-27 06:58:22 UTC (rev 14932)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/META-INF/MANIFEST.MF 2009-04-27 07:06:36 UTC (rev 14933)
@@ -18,7 +18,9 @@
org.eclipse.jdt.launching,
org.eclipse.jst.jee;bundle-version="1.0.100",
org.eclipse.jst.server.core;bundle-version="1.1.0",
- org.jboss.tools.jmx.core.test
+ org.jboss.tools.jmx.core.test,
+ org.jboss.ide.eclipse.as.ui;bundle-version="1.0.0",
+ org.eclipse.ui.navigator;bundle-version="3.3.101"
Eclipse-LazyStart: true
Bundle-ClassPath: jbossastest.jar
Bundle-Vendor: %Bundle-Vendor.0
16 years, 11 months
JBoss Tools SVN: r14932 - in trunk/as/plugins/org.jboss.ide.eclipse.as.ui: jbossui/org/jboss/tools/as/wst/server/ui/xpl and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-04-27 02:58:22 -0400 (Mon, 27 Apr 2009)
New Revision: 14932
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerDecorator.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerContentProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
JBIDE-4241 - removing extra decorator
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerContentProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerContentProvider.java 2009-04-27 06:53:28 UTC (rev 14931)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerContentProvider.java 2009-04-27 06:58:22 UTC (rev 14932)
@@ -278,7 +278,6 @@
try {
if( viewer != null && !viewer.getControl().isDisposed()) {
viewer.update(server, null);
- ServerDecorator.getDefault().redecorate(server);
}
} catch (Exception e) {
// ignore
@@ -300,7 +299,6 @@
ISelection sel = viewer.getSelection();
viewer.setSelection(sel);
}
- ServerDecorator.getDefault().redecorate(server);
}
} catch (Exception e) {
// ignore
@@ -344,7 +342,6 @@
for (int i = 0; i < size; i++) {
IServer server = ServerCore.findServer(servers[i]);
if (server != null ) {
- ServerDecorator.animate();
updateServerLabel(server);
}
}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerDecorator.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerDecorator.java 2009-04-27 06:53:28 UTC (rev 14931)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerDecorator.java 2009-04-27 06:58:22 UTC (rev 14932)
@@ -1,207 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation 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:
- * IBM Corporation - Base Code
- * Red Hat - Refactor for CNF
- *******************************************************************************/
-package org.jboss.tools.as.wst.server.ui.xpl;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.viewers.IDecoration;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILightweightLabelDecorator;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerType;
-import org.eclipse.wst.server.core.internal.Server;
-import org.eclipse.wst.server.ui.ServerUICore;
-import org.eclipse.wst.server.ui.internal.ImageResource;
-import org.eclipse.wst.server.ui.internal.Messages;
-import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
-import org.eclipse.wst.server.ui.internal.provisional.UIDecoratorManager;
-import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
-
-public class ServerDecorator extends LabelProvider implements ILightweightLabelDecorator {
-
- public static final String[] syncState = new String[] {
- Messages.viewSyncOkay,
- Messages.viewSyncRestart,
- Messages.viewSyncPublish,
- Messages.viewSyncRestartPublish,
- Messages.viewSyncPublishing};
-
- public static final String[] syncStateUnmanaged = new String[] {
- Messages.viewSyncOkay2,
- Messages.viewSyncRestart2,
- Messages.viewSyncPublish2,
- Messages.viewSyncRestartPublish2,
- Messages.viewSyncPublishing2};
-
- public static final String[] modulePublishState = new String[] {
- "",
- Messages.viewSyncOkay,
- Messages.viewSyncPublish,
- Messages.viewSyncPublish};
-
- private static ServerDecorator instance;
- public static ServerDecorator getDefault() {
- return instance;
- }
-
- private static int count = 0;
- public static void animate() {
- count = (count + 1)%3;
- }
- public static int getCount() {
- return count;
- }
-
- public ServerDecorator() {
- instance = this;
- }
-
- public void decorate(Object element, IDecoration decoration) {
- if( element instanceof IServer ) {
- String state = getServerStateLabel((IServer)element);
- String status = getServerStatusLabel((IServer)element);
- decoration.addSuffix(combine(state, status));
- } else if( element instanceof ModuleServer ) {
- String state = getModuleStateText((ModuleServer)element);
- String status = getModuleStatusText((ModuleServer)element);
- decoration.addSuffix(combine(state, status));
- }
- }
-
- protected String combine(String state, String status) {
- if(isEmpty(state) && isEmpty(status))
- return "";
- if( isEmpty(state))
- return " [" + status + "]";
- if( isEmpty(status))
- return " [" + state + "]";
- return " [" + state + ", " + status + "]";
- }
-
- protected boolean isEmpty(String s) {
- return (s == null || "".equals(s));
- }
-
- public void redecorate(IServer server) {
- fireLabelProviderChanged(new LabelProviderChangedEvent(this));
- }
-
-
-
- /*
- * Utility methods
- */
- public static Image getServerImage(IServer server) {
- return server == null ? null :
- server.getServerType() == null ? null :
- ImageResource.getImage(server.getServerType().getId());
- }
-
- public static String getServerStateLabel(IServer server) {
- return server == null ? null :
- server.getServerType() == null ? null :
- getStateLabel(server.getServerType(), server.getServerState(), server.getMode());
- }
-
- public static String getStateLabel(IServerType serverType, int state, String mode) {
- return serverType == null ? null :
- UIDecoratorManager.getUIDecorator(serverType).getStateLabel(state, mode, count);
- }
-
- public static String getServerStatusLabel(IServer server) {
- IStatus status = ((Server) server).getServerStatus();
- if (status != null)
- return status.getMessage();
-
- if (server.getServerType() == null)
- return "";
-
- if (server.getServerState() == IServer.STATE_UNKNOWN)
- return "";
-
- String serverId = server.getId();
- if (ServerContentProvider.publishing.contains(serverId))
- return ServerDecorator.syncState[4];
-
- // republish
- int i = 0;
- if (server.shouldPublish()) {
- if (((Server)server).isPublishUnknown())
- return "";
- i += 2;
- }
-
- if (server.shouldRestart())
- i = 1;
-
- return syncState[i];
- }
-
- public static Image getServerStateImage(IServer server) {
- return server == null ? null :
- getStateImage(server.getServerType(), server.getServerState(), server.getMode());
- }
-
- public static Image getStateImage(IServerType serverType, int state, String mode) {
- return serverType == null ? null :
- UIDecoratorManager.getUIDecorator(serverType).getStateImage(state, mode, getCount());
- }
-
- public static String getModuleText(ModuleServer ms ) {
- if (ms == null || ms.module == null)
- return "";
- int size = ms.module.length;
- return ms.module[size - 1].getName();
- }
-
- public static Image getModuleImage(ModuleServer ms) {
- if( ms != null ) {
- ILabelProvider labelProvider = ServerUICore.getLabelProvider();
- Image image = labelProvider.getImage(ms.module[ms.module.length - 1]);
- labelProvider.dispose();
- return image;
- }
- return null;
- }
-
- public static String getModuleStateText(ModuleServer ms) {
- return "";
- }
-
- public static String getModuleStatusText(ModuleServer ms) {
- if( ms != null && ms.server != null && ms.module != null ) {
- IStatus status = ((Server) ms.server).getModuleStatus(ms.module);
- if (status != null)
- return status.getMessage();
-
- return modulePublishState[ms.server.getModulePublishState(ms.module)];
- }
- return "";
- }
-
- public static Image getModuleStatusImage(ModuleServer ms) {
- IStatus status = ((Server) ms.server).getModuleStatus(ms.module);
- if (status != null) {
- ISharedImages sharedImages = ServerUIPlugin.getInstance().getWorkbench().getSharedImages();
- if (status.getSeverity() == IStatus.ERROR)
- return sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
- else if (status.getSeverity() == IStatus.WARNING)
- return sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK);
- else if (status.getSeverity() == IStatus.INFO)
- return sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK);
- }
- return null;
- }
-}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2009-04-27 06:53:28 UTC (rev 14931)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2009-04-27 06:58:22 UTC (rev 14932)
@@ -303,27 +303,6 @@
</view>
</extension>
- <extension point="org.eclipse.ui.decorators">
- <decorator
- class="org.jboss.tools.as.wst.server.ui.xpl.ServerDecorator"
- icon="icons/cview16/servers_view.gif"
- id="org.jboss.tools.as.wst.server.ui.navigatorDecorator"
- label="Server State Decorator"
- lightweight="true"
- location="BOTTOM_RIGHT">
- <enablement>
- <or>
- <objectClass
- name="org.eclipse.wst.server.core.IServer">
- </objectClass>
- <objectClass
- name="org.eclipse.wst.server.ui.internal.view.servers.ModuleServer">
- </objectClass>
- </or>
- </enablement>
- </decorator>
- </extension>
-
<extension
point="org.eclipse.ui.navigator.navigatorContent">
<navigatorContent
16 years, 11 months
JBoss Tools SVN: r14931 - trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-04-27 02:53:28 -0400 (Mon, 27 Apr 2009)
New Revision: 14931
Added:
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/BindingConfigFileTestCase.java
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/Csv2XMLConfigFileTestCase.java
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/DBExtractTransformConfigFileTestCase.java
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/DatasourcesConfigFileTestCase.java
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/EDI2JavaConfigFileTestCase.java
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/EdiOrderparserConfigFileTestCase.java
Modified:
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/AbstractSmooks11ModelTestCase.java
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/ParseConfigFileTestCase.java
Log:
JBIDE-4217
Add unit test cases
Modified: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/AbstractSmooks11ModelTestCase.java
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/AbstractSmooks11ModelTestCase.java 2009-04-27 06:46:56 UTC (rev 14930)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/AbstractSmooks11ModelTestCase.java 2009-04-27 06:53:28 UTC (rev 14931)
@@ -51,9 +51,12 @@
import org.jboss.tools.smooks.model.jmsrouting.provider.JmsroutingItemProviderAdapterFactory;
import org.jboss.tools.smooks.model.json.JsonPackage;
import org.jboss.tools.smooks.model.json.provider.JsonItemProviderAdapterFactory;
+import org.jboss.tools.smooks.model.medi.DocumentRoot;
import org.jboss.tools.smooks.model.medi.MEdiPackage;
+import org.jboss.tools.smooks.model.medi.MappingNode;
import org.jboss.tools.smooks.model.medi.provider.MEdiItemProviderAdapterFactory;
import org.jboss.tools.smooks.model.smooks.SmooksPackage;
+import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
import org.jboss.tools.smooks.model.smooks.provider.SmooksItemProviderAdapterFactory;
import org.jboss.tools.smooks.model.xsl.XslPackage;
import org.jboss.tools.smooks.model.xsl.provider.XslItemProviderAdapterFactory;
@@ -69,8 +72,8 @@
protected ComposedAdapterFactory adapterFactory;
protected AdapterFactoryEditingDomain editingDomain;
protected EObject smooksModel;
-
- static{
+
+ static {
// regist emf model uri mapping
Registry.INSTANCE.put(SmooksPackage.eNS_URI, SmooksPackage.eINSTANCE);
Registry.INSTANCE.put(CalcPackage.eNS_URI, CalcPackage.eINSTANCE);
@@ -89,10 +92,15 @@
Registry.INSTANCE.put(JsonPackage.eNS_URI, JsonPackage.eINSTANCE);
Registry.INSTANCE.put(MEdiPackage.eNS_URI, MEdiPackage.eINSTANCE);
Registry.INSTANCE.put(XslPackage.eNS_URI, XslPackage.eINSTANCE);
-
- Registry.INSTANCE.put(org.jboss.tools.smooks10.model.smooks.SmooksPackage.eNS_URI, org.jboss.tools.smooks10.model.smooks.SmooksPackage.eINSTANCE);
+
+ Registry.INSTANCE.put(org.jboss.tools.smooks10.model.smooks.SmooksPackage.eNS_URI,
+ org.jboss.tools.smooks10.model.smooks.SmooksPackage.eINSTANCE);
}
+ public void testModel() {
+ // do nothing
+ }
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -105,9 +113,10 @@
adapterFactory.addAdapterFactory(new JavabeanItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new CommonItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new SmooksItemProviderAdapterFactory());
-
- adapterFactory.addAdapterFactory(new org.jboss.tools.smooks10.model.smooks.provider.SmooksItemProviderAdapterFactory());
-
+
+ adapterFactory
+ .addAdapterFactory(new org.jboss.tools.smooks10.model.smooks.provider.SmooksItemProviderAdapterFactory());
+
adapterFactory.addAdapterFactory(new MEdiItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new EdiItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new IoroutingItemProviderAdapterFactory());
@@ -120,22 +129,26 @@
adapterFactory.addAdapterFactory(new GroovyItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new FileRoutingItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
-
+
BasicCommandStack commandStack = new BasicCommandStack();
editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
-
- loadConfigFile() ;
+
+ loadConfigFile();
}
- protected void loadConfigFile() throws IOException{
+ protected void loadConfigFile() throws IOException {
Resource smooksResource = new SmooksResourceFactoryImpl().createResource(null);
- smooksResource.load(getConfigFileContents() , Collections.emptyMap());
+ smooksResource.load(getConfigFileContents(), Collections.emptyMap());
smooksModel = smooksResource.getContents().get(0);
editingDomain.getResourceSet().getResources().add(smooksResource);
}
-
- abstract protected InputStream getConfigFileContents();
+ protected InputStream getConfigFileContents() {
+ return this.getClass().getClassLoader().getResourceAsStream(getFilePath());
+ }
+
+ abstract protected String getFilePath();
+
@Override
protected void tearDown() throws Exception {
super.tearDown();
@@ -165,6 +178,34 @@
this.smooksModel = smooksModel;
}
+ public MappingNode getMappingNode10(){
+ EObject root = this.getSmooksModel();
+ if (root instanceof DocumentRoot) {
+ DocumentRoot documentRoot = (DocumentRoot) root;
+ MappingNode mapping = (MappingNode) documentRoot.eContents().get(0);
+ return mapping;
+ }
+ return null;
+ }
+
+ public SmooksResourceListType getSmooksResourceList11() {
+ EObject root = this.getSmooksModel();
+ if (root instanceof org.jboss.tools.smooks.model.smooks.DocumentRoot) {
+ org.jboss.tools.smooks.model.smooks.DocumentRoot documentRoot = (org.jboss.tools.smooks.model.smooks.DocumentRoot) root;
+ SmooksResourceListType resourceConfig = (SmooksResourceListType) documentRoot.eContents().get(0);
+ return resourceConfig;
+ }
+ return null;
+ }
+ public org.jboss.tools.smooks10.model.smooks.SmooksResourceListType getSmooksResourceList10() {
+ EObject root = this.getSmooksModel();
+ if (root instanceof org.jboss.tools.smooks10.model.smooks.DocumentRoot) {
+ org.jboss.tools.smooks10.model.smooks.DocumentRoot documentRoot = (org.jboss.tools.smooks10.model.smooks.DocumentRoot) root;
+ org.jboss.tools.smooks10.model.smooks.SmooksResourceListType resourceConfig = (org.jboss.tools.smooks10.model.smooks.SmooksResourceListType) documentRoot.eContents().get(0);
+ return resourceConfig;
+ }
+ return null;
+ }
}
Added: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/BindingConfigFileTestCase.java
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/BindingConfigFileTestCase.java (rev 0)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/BindingConfigFileTestCase.java 2009-04-27 06:53:28 UTC (rev 14931)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.test.model11;
+
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.jboss.tools.smooks.model.javabean.BindingsType;
+import org.jboss.tools.smooks.model.javabean.DecodeParamType;
+import org.jboss.tools.smooks.model.javabean.ValueType;
+import org.jboss.tools.smooks.model.smooks.AbstractResourceConfig;
+import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
+
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class BindingConfigFileTestCase extends AbstractSmooks11ModelTestCase {
+
+ @Override
+ protected String getFilePath() {
+ return "org/jboss/tools/smooks/test/model/configfiles/smooks112/bindings.xml";
+ }
+
+ @Override
+ public void testModel() {
+
+ SmooksResourceListType resourceConfig = getSmooksResourceList11();
+
+ Assert.assertNotNull(resourceConfig);
+ List<AbstractResourceConfig> resourceConfigList = resourceConfig.getAbstractResourceConfig();
+
+ Assert.assertEquals(3, resourceConfigList.size());
+
+ BindingsType bindings1 = (BindingsType) resourceConfigList.get(0);
+ Assert.assertEquals("message", bindings1.getBeanId());
+ Assert.assertEquals("java.util.HashMap", bindings1.getClass_());
+ Assert.assertEquals("message-header", bindings1.getCreateOnElement());
+
+ Assert.assertEquals(1, bindings1.getValue().size());
+ ValueType jb1Value = bindings1.getValue().get(0);
+ Assert.assertEquals("date", jb1Value.getProperty().trim());
+ Assert.assertEquals("message-header/date", jb1Value.getData().trim());
+ Assert.assertEquals("Date", jb1Value.getDecoder().trim());
+
+ DecodeParamType decode = jb1Value.getDecodeParam().get(0);
+ Assert.assertEquals("format", decode.getName());
+
+
+ BindingsType bindings2 = (BindingsType) resourceConfigList.get(1);
+ Assert.assertEquals("order", bindings2.getBeanId().trim());
+ Assert.assertEquals("java.util.HashMap", bindings2.getClass_().trim());
+ Assert.assertEquals("order", bindings2.getCreateOnElement().trim());
+
+
+ Assert.assertEquals(5, bindings2.getValue().size());
+
+ ValueType jb2Value1 = bindings2.getValue().get(0);
+ Assert.assertEquals("orderNum", jb2Value1.getProperty().trim());
+ Assert.assertEquals("order/order-id", jb2Value1.getData().trim());
+ Assert.assertEquals("Integer", jb2Value1.getDecoder().trim());
+
+ ValueType jb2Value2 = bindings2.getValue().get(1);
+ Assert.assertEquals("customerUname", jb2Value2.getProperty().trim());
+ Assert.assertEquals("order/customer-details/username", jb2Value2.getData().trim());
+
+ ValueType jb2Value3 = bindings2.getValue().get(2);
+ Assert.assertEquals("status", jb2Value3.getProperty().trim());
+ Assert.assertEquals("order/status-code", jb2Value3.getData().trim());
+ Assert.assertEquals("Integer", jb2Value3.getDecoder().trim());
+
+
+ ValueType jb2Value4 = bindings2.getValue().get(3);
+ Assert.assertEquals("net", jb2Value4.getProperty().trim());
+ Assert.assertEquals("order/net-amount", jb2Value4.getData().trim());
+ Assert.assertEquals("BigDecimal", jb2Value4.getDecoder().trim());
+
+
+ ValueType jb2Value5 = bindings2.getValue().get(4);
+ Assert.assertEquals("total", jb2Value5.getProperty().trim());
+ Assert.assertEquals("order/total-amount", jb2Value5.getData().trim());
+ Assert.assertEquals("BigDecimal", jb2Value5.getDecoder().trim());
+
+ BindingsType bindings3 = (BindingsType) resourceConfigList.get(2);
+ Assert.assertEquals("orderItem", bindings3.getBeanId().trim());
+ Assert.assertEquals("java.util.HashMap", bindings3.getClass_().trim());
+ Assert.assertEquals("order-item", bindings3.getCreateOnElement().trim());
+
+
+ Assert.assertEquals(1, bindings3.getValue().size());
+
+ ValueType jb3Value1 = bindings3.getValue().get(0);
+ Assert.assertEquals("order-item/*", jb3Value1.getData().trim());
+
+ }
+
+}
Property changes on: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/BindingConfigFileTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/Csv2XMLConfigFileTestCase.java
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/Csv2XMLConfigFileTestCase.java (rev 0)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/Csv2XMLConfigFileTestCase.java 2009-04-27 06:53:28 UTC (rev 14931)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.test.model11;
+
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.jboss.tools.smooks.model.csv.CsvReader;
+import org.jboss.tools.smooks.model.smooks.AbstractReader;
+import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
+
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class Csv2XMLConfigFileTestCase extends AbstractSmooks11ModelTestCase {
+
+ @Override
+ protected String getFilePath() {
+ return "org/jboss/tools/smooks/test/model/configfiles/smooks112/csv-xml.xml";
+ }
+
+ @Override
+ public void testModel() {
+ SmooksResourceListType resourceConfig = getSmooksResourceList11();
+
+ Assert.assertNotNull(resourceConfig);
+ List<AbstractReader> readerList = resourceConfig.getAbstractReader();
+ Assert.assertEquals(readerList.size(), 1);
+
+ CsvReader reader = (CsvReader) readerList.get(0);
+
+ Assert.assertEquals("firstname,lastname,gender,age,country", reader.getFields());
+ }
+
+}
Property changes on: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/Csv2XMLConfigFileTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/DBExtractTransformConfigFileTestCase.java
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/DBExtractTransformConfigFileTestCase.java (rev 0)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/DBExtractTransformConfigFileTestCase.java 2009-04-27 06:53:28 UTC (rev 14931)
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.test.model11;
+
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.jboss.tools.smooks.model.dbrouting.Executor;
+import org.jboss.tools.smooks.model.smooks.AbstractResourceConfig;
+import org.jboss.tools.smooks.model.smooks.ImportType;
+import org.jboss.tools.smooks.model.smooks.ParamType;
+import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
+
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class DBExtractTransformConfigFileTestCase extends AbstractSmooks11ModelTestCase {
+
+ @Override
+ protected String getFilePath() {
+ return "org/jboss/tools/smooks/test/model/configfiles/smooks112/db-extract-transform-load.xml";
+ }
+
+ @Override
+ public void testModel() {
+ SmooksResourceListType resourceConfig = getSmooksResourceList11();
+
+ Assert.assertNotNull(resourceConfig);
+
+ Assert.assertEquals("stream.filter.type", resourceConfig.getParams().getParam().get(0).getName());
+ Assert.assertEquals("SAX", ((ParamType) resourceConfig.getParams().getParam().get(0)).getStringValue());
+
+ List<AbstractResourceConfig> imports = resourceConfig.getAbstractResourceConfig();
+ int importCount = 0;
+ int executorCount = 0;
+ for (Iterator<?> iterator = imports.iterator(); iterator.hasNext();) {
+ AbstractResourceConfig abstractResourceConfig = (AbstractResourceConfig) iterator.next();
+ if(abstractResourceConfig instanceof ImportType){
+ if(importCount <=2){
+ ImportType import1 = (ImportType)abstractResourceConfig;
+ if(importCount == 0){
+ Assert.assertEquals("edi-orders-parser.xml", import1.getFile());
+ }
+ if(importCount == 1){
+ Assert.assertEquals("datasources.xml", import1.getFile());
+ }
+ if(importCount == 2){
+ Assert.assertEquals("bindings.xml", import1.getFile());
+ }
+ importCount++;
+ }
+ }
+
+ if(abstractResourceConfig instanceof Executor){
+ if(executorCount <= 2){
+ Executor executor = (Executor)abstractResourceConfig;
+ if(executorCount == 0){
+ Assert.assertEquals("customer-details", executor.getExecuteOnElement());
+ Assert.assertEquals("DBExtractTransformLoadDS", executor.getDatasource());
+ Assert.assertEquals(true, executor.isExecuteBefore());
+ Assert.assertEquals("select ORDERNUMBER from ORDERS where ORDERNUMBER = ${order.orderNum}", executor.getStatement().trim());
+ Assert.assertEquals("orderExistsRS", executor.getResultSet().getName());
+ }
+ if(executorCount == 1){
+ Assert.assertEquals("customer-details", executor.getExecuteOnElement());
+ Assert.assertEquals("DBExtractTransformLoadDS", executor.getDatasource());
+ Assert.assertEquals(false, executor.isExecuteBefore());
+ Assert.assertEquals("INSERT INTO ORDERS VALUES(${order.orderNum}, ${order.customerUname}, ${order.status}, ${order.net}, ${order.total}, ${message.date})", executor.getStatement().trim());
+ Assert.assertEquals("orderExistsRS.isEmpty()", executor.getCondition().getValue());
+ }
+ if(executorCount == 2){
+ Assert.assertEquals("order-item", executor.getExecuteOnElement());
+ Assert.assertEquals("DBExtractTransformLoadDS", executor.getDatasource());
+ Assert.assertEquals(false, executor.isExecuteBefore());
+ Assert.assertEquals("INSERT INTO ORDERITEMS VALUES (${order.orderNum}, ${orderItem.quantity}, ${orderItem.productId}, ${orderItem.title}, ${orderItem.price})", executor.getStatement().trim());
+ Assert.assertEquals("orderExistsRS.isEmpty()", executor.getCondition().getValue());
+ }
+ executorCount ++;
+ }
+ }
+ }
+
+ Assert.assertEquals(3, executorCount);
+ Assert.assertEquals(3, importCount);
+ }
+
+}
Property changes on: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/DBExtractTransformConfigFileTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/DatasourcesConfigFileTestCase.java
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/DatasourcesConfigFileTestCase.java (rev 0)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/DatasourcesConfigFileTestCase.java 2009-04-27 06:53:28 UTC (rev 14931)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.test.model11;
+
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.jboss.tools.smooks.model.datasource.Direct;
+import org.jboss.tools.smooks.model.smooks.AbstractResourceConfig;
+import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
+
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class DatasourcesConfigFileTestCase extends AbstractSmooks11ModelTestCase {
+
+ @Override
+ protected String getFilePath() {
+ return "org/jboss/tools/smooks/test/model/configfiles/smooks112/datasources.xml";
+ }
+
+ @Override
+ public void testModel() {
+ SmooksResourceListType resourceConfig = getSmooksResourceList11();
+
+ Assert.assertNotNull(resourceConfig);
+ List<AbstractResourceConfig> readerList = resourceConfig.getAbstractResourceConfig();
+ Assert.assertEquals(readerList.size(), 1);
+
+ Direct direct = (Direct) readerList.get(0);
+
+ Assert.assertEquals("$document", direct.getBindOnElement());
+ Assert.assertEquals("DBExtractTransformLoadDS", direct.getDatasource());
+ Assert.assertEquals("org.hsqldb.jdbcDriver", direct.getDriver());
+ Assert.assertEquals("jdbc:hsqldb:hsql://localhost:9201/milyn-hsql-9201", direct.getUrl());
+ Assert.assertEquals("sa", direct.getUsername());
+ Assert.assertEquals("$document", direct.getBindOnElement());
+ Assert.assertEquals(false, direct.isAutoCommit());
+ }
+
+}
Property changes on: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/DatasourcesConfigFileTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/EDI2JavaConfigFileTestCase.java
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/EDI2JavaConfigFileTestCase.java (rev 0)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/EDI2JavaConfigFileTestCase.java 2009-04-27 06:53:28 UTC (rev 14931)
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.test.model11;
+
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.jboss.tools.smooks.model.edi.EDIReader;
+import org.jboss.tools.smooks.model.javabean.BindingsType;
+import org.jboss.tools.smooks.model.javabean.ValueType;
+import org.jboss.tools.smooks.model.javabean.WiringType;
+import org.jboss.tools.smooks.model.smooks.AbstractReader;
+import org.jboss.tools.smooks.model.smooks.AbstractResourceConfig;
+import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
+
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class EDI2JavaConfigFileTestCase extends AbstractSmooks11ModelTestCase {
+
+ @Override
+ protected String getFilePath() {
+ return "org/jboss/tools/smooks/test/model/configfiles/smooks112/edi-to-java.xml";
+ }
+
+ @Override
+ public void testModel() {
+
+ SmooksResourceListType resourceConfig = getSmooksResourceList11();
+
+ Assert.assertNotNull(resourceConfig);
+
+ List<AbstractReader> readerList = resourceConfig.getAbstractReader();
+ Assert.assertEquals(readerList.size(), 1);
+
+ EDIReader reader = (EDIReader) readerList.get(0);
+
+ Assert.assertEquals("/example/edi-to-xml-order-mapping.xml", reader.getMappingModel());
+
+ List<AbstractResourceConfig> resourceConfigList = resourceConfig.getAbstractResourceConfig();
+
+
+ Assert.assertEquals(5, resourceConfigList.size());
+
+ BindingsType bindings1 = (BindingsType) resourceConfigList.get(0);
+ Assert.assertEquals("order", bindings1.getBeanId());
+ Assert.assertEquals("example.model.Order", bindings1.getClass_());
+ Assert.assertEquals("order", bindings1.getCreateOnElement());
+
+ Assert.assertEquals(2, bindings1.getWiring().size());
+
+ WiringType jb1Wiring = bindings1.getWiring().get(0);
+ Assert.assertEquals("header", jb1Wiring.getProperty().trim());
+ Assert.assertEquals("header", jb1Wiring.getBeanIdRef());
+
+ WiringType jb1Wiring2 = bindings1.getWiring().get(1);
+ Assert.assertEquals("orderItems", jb1Wiring2.getProperty().trim());
+ Assert.assertEquals("orderItemList", jb1Wiring2.getBeanIdRef());
+
+
+ BindingsType bindings2 = (BindingsType) resourceConfigList.get(1);
+ Assert.assertEquals("header", bindings2.getBeanId().trim());
+ Assert.assertEquals("example.model.Header", bindings2.getClass_().trim());
+ Assert.assertEquals("order", bindings2.getCreateOnElement().trim());
+
+ WiringType jb2Wiring = bindings2.getWiring().get(0);
+ Assert.assertEquals("customer", jb2Wiring.getProperty().trim());
+ Assert.assertEquals("customer", jb2Wiring.getBeanIdRef());
+
+ Assert.assertEquals(6, bindings2.getValue().size());
+
+ ValueType jb2Value1 = bindings2.getValue().get(0);
+ Assert.assertEquals("orderId", jb2Value1.getProperty().trim());
+ Assert.assertEquals("header/order-id", jb2Value1.getData().trim());
+
+ ValueType jb2Value2 = bindings2.getValue().get(1);
+ Assert.assertEquals("orderStatus", jb2Value2.getProperty().trim());
+ Assert.assertEquals("header/status-code", jb2Value2.getData().trim());
+ Assert.assertEquals("Long", jb2Value2.getDecoder().trim());
+
+
+ ValueType jb2Value3 = bindings2.getValue().get(2);
+ Assert.assertEquals("netAmount", jb2Value3.getProperty().trim());
+ Assert.assertEquals("header/net-amount", jb2Value3.getData().trim());
+ Assert.assertEquals("BigDecimal", jb2Value3.getDecoder().trim());
+
+
+ ValueType jb2Value4 = bindings2.getValue().get(3);
+ Assert.assertEquals("totalAmount", jb2Value4.getProperty().trim());
+ Assert.assertEquals("header/total-amount", jb2Value4.getData().trim());
+ Assert.assertEquals("BigDecimal", jb2Value4.getDecoder().trim());
+
+
+ ValueType jb2Value5 = bindings2.getValue().get(4);
+ Assert.assertEquals("tax", jb2Value5.getProperty().trim());
+ Assert.assertEquals("header/tax", jb2Value5.getData().trim());
+ Assert.assertEquals("BigDecimal", jb2Value5.getDecoder().trim());
+
+
+ ValueType jb2Value6 = bindings2.getValue().get(5);
+ Assert.assertEquals("date", jb2Value6.getProperty().trim());
+ Assert.assertEquals("header/date", jb2Value6.getData().trim());
+ Assert.assertEquals("Date", jb2Value6.getDecoder().trim());
+ Assert.assertEquals("format", jb2Value6.getDecodeParam().get(0).getName());
+ Assert.assertEquals("EEE MMM dd HH:mm:ss z yyyy", jb2Value6.getDecodeParam().get(0).getValue());
+
+
+ BindingsType bindings3 = (BindingsType) resourceConfigList.get(2);
+ Assert.assertEquals("customer", bindings3.getBeanId().trim());
+ Assert.assertEquals("example.model.Customer", bindings3.getClass_().trim());
+ Assert.assertEquals("customer-details", bindings3.getCreateOnElement().trim());
+
+ Assert.assertEquals(4, bindings3.getValue().size());
+
+ ValueType jb3Value1 = bindings3.getValue().get(0);
+ Assert.assertEquals("userName", jb3Value1.getProperty().trim());
+ Assert.assertEquals("customer-details/username", jb3Value1.getData().trim());
+
+ ValueType jb3Value2 = bindings3.getValue().get(1);
+ Assert.assertEquals("firstName", jb3Value2.getProperty().trim());
+ Assert.assertEquals("customer-details/name/firstname", jb3Value2.getData().trim());
+
+ ValueType jb3Value3 = bindings3.getValue().get(2);
+ Assert.assertEquals("lastName", jb3Value3.getProperty().trim());
+ Assert.assertEquals("customer-details/name/lastname", jb3Value3.getData().trim());
+
+ ValueType jb3Value4 = bindings3.getValue().get(3);
+ Assert.assertEquals("state", jb3Value4.getProperty().trim());
+ Assert.assertEquals("customer-details/state", jb3Value4.getData().trim());
+
+ BindingsType bindings5 = (BindingsType) resourceConfigList.get(3);
+ Assert.assertEquals("orderItemList", bindings5.getBeanId().trim());
+ Assert.assertEquals("java.util.ArrayList", bindings5.getClass_().trim());
+ Assert.assertEquals("order", bindings5.getCreateOnElement().trim());
+
+ Assert.assertEquals("orderItem", bindings5.getWiring().get(0).getBeanIdRef());
+
+ BindingsType bindings4 = (BindingsType) resourceConfigList.get(4);
+ Assert.assertEquals("orderItem", bindings4.getBeanId().trim());
+ Assert.assertEquals("example.model.OrderItem", bindings4.getClass_().trim());
+ Assert.assertEquals("order-item", bindings4.getCreateOnElement().trim());
+
+ Assert.assertEquals(4, bindings4.getValue().size());
+
+ ValueType jb4Value1 = bindings4.getValue().get(0);
+ Assert.assertEquals("quantity", jb4Value1.getProperty().trim());
+ Assert.assertEquals("order-item/quantity", jb4Value1.getData().trim());
+ Assert.assertEquals("Integer", jb4Value1.getDecoder());
+
+ ValueType jb4Value2 = bindings4.getValue().get(1);
+ Assert.assertEquals("productId", jb4Value2.getProperty().trim());
+ Assert.assertEquals("order-item/product-id", jb4Value2.getData().trim());
+ Assert.assertEquals("String", jb4Value2.getDecoder());
+
+ ValueType jb4Value3 = bindings4.getValue().get(2);
+ Assert.assertEquals("price", jb4Value3.getProperty().trim());
+ Assert.assertEquals("order-item/price", jb4Value3.getData().trim());
+ Assert.assertEquals("BigDecimal", jb4Value3.getDecoder());
+
+ ValueType jb4Value4 = bindings4.getValue().get(3);
+ Assert.assertEquals("title", jb4Value4.getProperty().trim());
+ Assert.assertEquals("order-item/title", jb4Value4.getData().trim());
+
+
+
+ }
+
+}
Property changes on: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/EDI2JavaConfigFileTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/EdiOrderparserConfigFileTestCase.java
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/EdiOrderparserConfigFileTestCase.java (rev 0)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/EdiOrderparserConfigFileTestCase.java 2009-04-27 06:53:28 UTC (rev 14931)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.test.model11;
+
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.jboss.tools.smooks.model.edi.EDIReader;
+import org.jboss.tools.smooks.model.smooks.AbstractReader;
+import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
+
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class EdiOrderparserConfigFileTestCase extends AbstractSmooks11ModelTestCase {
+
+ @Override
+ protected String getFilePath() {
+ return "org/jboss/tools/smooks/test/model/configfiles/smooks112/edi-orders-parser.xml";
+ }
+
+ @Override
+ public void testModel() {
+ SmooksResourceListType resourceConfig = getSmooksResourceList11();
+
+ Assert.assertNotNull(resourceConfig);
+ List<AbstractReader> readerList = resourceConfig.getAbstractReader();
+ Assert.assertEquals(readerList.size(), 1);
+
+ EDIReader reader = (EDIReader) readerList.get(0);
+
+ Assert.assertEquals("/edi-to-sax-order-mapping.xml", reader.getMappingModel());
+ }
+
+}
Property changes on: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/EdiOrderparserConfigFileTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/ParseConfigFileTestCase.java
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/ParseConfigFileTestCase.java 2009-04-27 06:46:56 UTC (rev 14930)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/model11/ParseConfigFileTestCase.java 2009-04-27 06:53:28 UTC (rev 14931)
@@ -39,6 +39,12 @@
return null;
}
+ @Override
+ protected String getFilePath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
private void loadFile(File file) throws IOException {
if (file.exists() && file.isDirectory()) {
File[] configFiles = file.listFiles();
16 years, 11 months
JBoss Tools SVN: r14930 - trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-04-27 02:46:56 -0400 (Mon, 27 Apr 2009)
New Revision: 14930
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/JBIDE4184Test.java
Log:
constant was moved
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/JBIDE4184Test.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/JBIDE4184Test.java 2009-04-27 06:44:54 UTC (rev 14929)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/JBIDE4184Test.java 2009-04-27 06:46:56 UTC (rev 14930)
@@ -12,6 +12,7 @@
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.test.ASTest;
import org.jboss.ide.eclipse.as.test.server.StartupShutdownTest;
@@ -22,7 +23,7 @@
public void setUp() {
try {
tmpPath = new Path(ASTest.JBOSS_AS_42_HOME);
- tmpPath = tmpPath.append("server").append("default").append("tmp").append(IDeployableServer.JBOSSTOOLS_TMP);
+ tmpPath = tmpPath.append("server").append("default").append("tmp").append(IJBossServerConstants.JBOSSTOOLS_TMP);
if( tmpPath.toFile().exists())
FileUtil.safeDelete(tmpPath.toFile());
assertFalse(tmpPath.toFile().exists());
16 years, 11 months
JBoss Tools SVN: r14929 - trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-04-27 02:44:54 -0400 (Mon, 27 Apr 2009)
New Revision: 14929
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/AbstractDeploymentTest.java
Log:
JBIDE-4237 - unit test didn't set temporary deploy location
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/AbstractDeploymentTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/AbstractDeploymentTest.java 2009-04-27 04:24:58 UTC (rev 14928)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/AbstractDeploymentTest.java 2009-04-27 06:44:54 UTC (rev 14929)
@@ -41,12 +41,19 @@
protected IRuntime runtime;
protected IServer server;
protected String deployLocation;
+ protected String tempDeployLocation;
public AbstractDeploymentTest(String[] projectNames, String[] testProperties) {
try {
this.sourceProjectName = projectNames;
this.testProperties = testProperties;
- this.deployLocation = getFileLocation("/testOutputs").getAbsolutePath();
+ File f = getFileLocation("/testOutputs");
+ File fDeploy = new File(f, "1");
+ File fTmpDeploy = new File(f, "2");
+ fDeploy.mkdir();
+ fTmpDeploy.mkdir();
+ deployLocation = fDeploy.getAbsolutePath();
+ tempDeployLocation = fDeploy.getAbsolutePath();
this.provider = new TestProjectProvider[sourceProjectName.length];
this.workspaceProject = new IProject[sourceProjectName.length];
} catch( CoreException ce ) {
@@ -157,7 +164,9 @@
ServerWorkingCopy swc = (ServerWorkingCopy) st.createServer("testServer", null, null);
swc.setServerConfiguration(null);
swc.setName("testServer");
+ swc.setRuntime(runtime);
swc.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLocation);
+ swc.setAttribute(DeployableServer.TEMP_DEPLOY_DIRECTORY, tempDeployLocation);
server = swc.save(true, null);
}
16 years, 11 months
JBoss Tools SVN: r14928 - in branches/jbosstools-3.0.x/ws: plugins/org.jboss.tools.ws.creation.core/META-INF and 7 other directories.
by jbosstools-commits@lists.jboss.org
Author: Grid.Qian
Date: 2009-04-27 00:24:58 -0400 (Mon, 27 Apr 2009)
New Revision: 14928
Added:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/Java2WSCommand.java
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/ClasspathParser.java
Removed:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java
Modified:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/.classpath
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSDL2JavaCommand.java
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/projects/JavaFirstTestProject/.classpath
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java
Log:
JBIDE-3783: can't generate WS from a java class in the java project not dynamic web project and update the unit tests for this issue
Modified: branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/.classpath
===================================================================
--- branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/.classpath 2009-04-25 18:43:22 UTC (rev 14927)
+++ branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/.classpath 2009-04-27 04:24:58 UTC (rev 14928)
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry exported="true" kind="lib" path="lib/wsdl4j.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry exported="true" kind="lib" path="lib/wsdl4j.jar" sourcepath="org.jboss.tools.ws.creation.coresrc.zip"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
===================================================================
--- branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2009-04-25 18:43:22 UTC (rev 14927)
+++ branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2009-04-27 04:24:58 UTC (rev 14928)
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name.0
-Bundle-SymbolicName: org.jboss.tools.ws.creation.core
+Bundle-SymbolicName: org.jboss.tools.ws.creation.core;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: org.jboss.tools.ws.creation.core.JBossWSCreationCore
Bundle-Vendor: %Bundle-Vendor.0
@@ -16,7 +16,6 @@
org.eclipse.wst.wsdl,
org.eclipse.wst.command.env.core,
org.eclipse.wst.command.env,
- org.eclipse.jst.ws.axis2.consumption.core,
org.apache.ant,
org.apache.xerces,
org.eclipse.jst.j2ee,
@@ -32,7 +31,9 @@
org.jboss.tools.common,
org.jboss.ide.eclipse.as.classpath.core;bundle-version="1.0.0",
org.eclipse.jst.server.core;bundle-version="1.1.0",
- org.eclipse.jdt;bundle-version="3.4.0"
+ org.eclipse.jdt;bundle-version="3.4.0",
+ org.eclipse.jdt.launching;bundle-version="3.4.0",
+ org.eclipse.debug.core;bundle-version="3.4.0"
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.creation.core,
org.jboss.tools.ws.creation.core.commands,
Modified: branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java
===================================================================
--- branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java 2009-04-25 18:43:22 UTC (rev 14927)
+++ branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java 2009-04-27 04:24:58 UTC (rev 14928)
@@ -5,6 +5,8 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
@@ -16,6 +18,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.osgi.util.NLS;
@@ -46,20 +49,22 @@
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
model.getWebProjectName());
- String projectRoot = JBossWSCreationUtils.getProjectRoot(
- model.getWebProjectName()).toOSString();
- IJavaProject javaProject = JavaCore.create(project);
try {
String runtimeLocation = JBossWSCreationUtils
.getJBossWSRuntimeLocation(project);
String commandLocation = runtimeLocation + Path.SEPARATOR + "bin";
IPath path = new Path(commandLocation);
- StringBuffer command = new StringBuffer();
+
+ List<String> command = new ArrayList<String>();
+
if (System.getProperty("os.name").toLowerCase().indexOf("win") >= 0) {
- command.append("cmd.exe /c ").append(cmdFileName_win);
+ command.add("cmd.exe");
+ command.add("/c");
+ command.add(cmdFileName_win);
path = path.append(cmdFileName_win);
} else {
- command.append("sh ").append(cmdFileName_linux);
+ command.add("sh");
+ command.add(cmdFileName_linux);
path = path.append(cmdFileName_linux);
}
@@ -71,18 +76,11 @@
new String[] { path.toOSString() }));
}
- String args = getCommandlineArgs();
- command.append(" -k ").append(args).append(" ");
- if(model.getWsdlURI() != null){
- command.append(model.getWsdlURI());
- }
- command.append(" -o ").append(projectRoot).append(Path.SEPARATOR)
- .append(
- javaProject.getOutputLocation()
- .removeFirstSegments(1).toOSString());
- Runtime rt = Runtime.getRuntime();
- Process proc = rt.exec(command.toString(), null, new File(
- commandLocation));
+ addCommandlineArgs(command);
+ addCommonArgs(command, project);
+
+ Process proc = DebugPlugin.exec(command.toArray(new String[command
+ .size()]), new File(commandLocation));
StringBuffer errorResult = new StringBuffer();
StringBuffer inputResult = new StringBuffer();
@@ -97,9 +95,10 @@
String resultInput = inputResult.toString();
if (resultInput != null && resultInput.indexOf("[ERROR]") >= 0) {
JBossWSCreationCore.getDefault().logError(resultInput);
- IStatus errorStatus = StatusUtils.errorStatus(resultInput);
+ IStatus errorStatus = StatusUtils
+ .warningStatus(resultInput);
status = StatusUtils
- .errorStatus(
+ .warningStatus(
JBossWSCreationCoreMessages.Error_Message_Failed_To_Generate_Code,
new CoreException(errorStatus));
} else {
@@ -107,15 +106,16 @@
}
}
- } catch (IOException e) {
+ } catch (InterruptedException e) {
JBossWSCreationCore.getDefault().logError(e);
-
- } catch (InterruptedException e) {
- // ignore
+ return StatusUtils.errorStatus(e);
} catch (CoreException e) {
JBossWSCreationCore.getDefault().logError(e);
// unable to get runtime location
return e.getStatus();
+ } catch (Exception e) {
+ JBossWSCreationCore.getDefault().logError(e);
+ return StatusUtils.errorStatus(e);
}
refreshProject(model.getWebProjectName(), monitor);
@@ -123,6 +123,28 @@
return status;
}
+ private void addCommonArgs(List<String> command, IProject project) throws Exception {
+ String projectRoot = JBossWSCreationUtils.getProjectRoot(
+ model.getWebProjectName()).toOSString();
+ IJavaProject javaProject = JavaCore.create(project);
+
+ command.add("-k");
+
+ command.add("-s");
+ command.add(JBossWSCreationUtils.getJavaProjectSrcLocation(project));
+
+ command.add("-o");
+ StringBuffer opDir = new StringBuffer();
+ opDir.append(projectRoot).append(Path.SEPARATOR).append(
+ javaProject.getOutputLocation().removeFirstSegments(1)
+ .toOSString());
+ command.add(opDir.toString());
+ if (model.getWsdlURI() != null) {
+ command.add(model.getWsdlURI());
+ }
+
+ }
+
private void convertInputStreamToString(final StringBuffer result,
final InputStream input) {
@@ -160,7 +182,8 @@
}
}
- abstract protected String getCommandlineArgs();
+ abstract protected void addCommandlineArgs(List<String> command)
+ throws Exception;
abstract protected String getCommandLineFileName_linux();
Added: branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/Java2WSCommand.java
===================================================================
--- branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/Java2WSCommand.java (rev 0)
+++ branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/Java2WSCommand.java 2009-04-27 04:24:58 UTC (rev 14928)
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.creation.core.commands;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.creation.core.utils.ClasspathParser;
+import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
+
+/**
+ * @author Grid Qian
+ */
+public class Java2WSCommand extends AbstractGenerateCodeCommand {
+
+ private static String WSPROVIDER_FILE_NAME_LINUX = "wsprovide.sh";
+ private static String WSPROVIDER_FILE_NAME_WIN = "wsprovide.bat";
+
+ public Java2WSCommand(ServiceModel model) {
+ super(model);
+ }
+
+ @Override
+ protected String getCommandLineFileName_linux() {
+ return WSPROVIDER_FILE_NAME_LINUX;
+ }
+
+ @Override
+ protected String getCommandLineFileName_win() {
+ return WSPROVIDER_FILE_NAME_WIN;
+ }
+
+ @Override
+ protected void addCommandlineArgs(List<String> command) throws IOException {
+
+ String projectName = model.getWebProjectName();
+ String projectRoot = JBossWSCreationUtils.getProjectRoot(projectName)
+ .toOSString();
+
+ IProject iProject = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(projectName);
+
+ if (model.isGenWSDL()) {
+ command.add("-w");
+ }
+ command.add("-r");
+ command.add(projectRoot + Path.SEPARATOR + "wsdl");
+ command.add(model.getServiceClasses().get(0));
+
+ command.add("-c");
+ command.add(getClasspath(iProject));
+ }
+
+ private String getClasspath(IProject iProject) throws IOException {
+ String cpStr = ClasspathParser.getInstance().getClasspathString(
+ iProject);
+
+ if (isLongCommandLines(cpStr)) {
+ File tempJar = null;
+ tempJar = File.createTempFile("temp", ".jar");
+ Manifest mf = new Manifest();
+
+ // replace space with "%20"
+ cpStr = cpStr.replace(" ", "%20");
+ // replace \ with /
+ cpStr = cpStr.replace("\\", "/");
+ // get classpath array
+ String[] cpArray = cpStr.split(";");
+ StringBuffer cpBF = new StringBuffer();
+ for (int i = 0; i < cpArray.length; i++) {
+ // if the classpath entry is a directory, it should be added a /
+ // after it
+ if (!cpArray[i].endsWith(".jar") && !cpArray[i].endsWith("/")) {
+ cpArray[i] = cpArray[i] + "/";
+ }
+ // if the system is windows, the classpath entry should be added
+ // a / before it
+ if (System.getProperty("os.name").toLowerCase().indexOf("win") >= 0)
+ cpArray[i] = "/" + cpArray[i];
+ // there should be a space between classpath entries
+ cpBF.append(cpArray[i]).append(" ");
+ }
+ cpStr = cpBF.toString();
+ cpStr.trim();
+
+ mf.getMainAttributes().put(Attributes.Name.CLASS_PATH, cpStr);
+ mf.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.2");
+
+ try {
+ FileUtil.jar(new File[0], tempJar.getAbsolutePath(), mf);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ cpStr = tempJar.getAbsolutePath();
+ } else {
+ // if the system is not windows, the split should be :
+ if (System.getProperty("os.name").toLowerCase().indexOf("win") < 0)
+ cpStr = cpStr.replace(";", ":");
+ }
+ return cpStr;
+ }
+
+ public boolean isLongCommandLines(String command) {
+ if (command == null)
+ return false;
+ return command.length() > 1024 ? true : false;
+ }
+
+ // private String getClasspathEntries(IJavaProject javaProject) {
+ // IClasspathEntry[] iniEntries = null;
+ // List<IClasspathEntry> pathList = new ArrayList<IClasspathEntry>();
+ // IClasspathEntry[] resolvedEntries = null;
+ // try {
+ // iniEntries = javaProject.getRawClasspath();
+ // for (IClasspathEntry entry : iniEntries) {
+ // IClasspathContainer container = JavaCore.getClasspathContainer(
+ // entry.getPath(), javaProject);
+ // if (!(container instanceof JBossWSRuntimeClasspathContainer)) {
+ // if (!(container instanceof RuntimeClasspathContainer && container
+ // .getDescription().contains("JBoss"))) {
+ // pathList.add(entry);
+ // }
+ // }
+ // }
+ // resolvedEntries = ((JavaProject) javaProject)
+ // .resolveClasspath(pathList
+ // .toArray(new IClasspathEntry[pathList.size()]));
+ // } catch (JavaModelException e) { // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ // StringBuffer path = new StringBuffer();
+ // for (IClasspathEntry entry : resolvedEntries) {
+ // if (entry.getEntryKind() == 3) {
+ // path.append(workspaceRoot);
+ // continue;
+ // }
+ // if (entry.getEntryKind() == 2) {
+ // String projectRoot = JBossWSCreationUtils.getProjectRoot(
+ // entry.getPath().segment(0)).toOSString();
+ // IProject refProject = ResourcesPlugin.getWorkspace().getRoot()
+ // .getProject(entry.getPath().segment(0));
+ // IJavaProject refJavaProject = JavaCore.create(refProject);
+ // try {
+ // path.append(projectRoot).append(Path.SEPARATOR).append(
+ // refJavaProject.getOutputLocation()
+ // .removeFirstSegments(1).toOSString())
+ // .append(seperator);
+ // } catch (JavaModelException e) {
+ // e.printStackTrace();
+ // }
+ // } else {
+ // path.append(entry.getPath().toOSString()).append(seperator);
+ // }
+ // }
+ // String str = path.toString();
+ // if (str.endsWith(seperator)) {
+ // str = str.substring(0, str.length() - 1);
+ // }
+ // return str;
+ //
+ // }
+
+}
\ No newline at end of file
Property changes on: branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/Java2WSCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSDL2JavaCommand.java
===================================================================
--- branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSDL2JavaCommand.java 2009-04-25 18:43:22 UTC (rev 14927)
+++ branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSDL2JavaCommand.java 2009-04-27 04:24:58 UTC (rev 14928)
@@ -3,9 +3,7 @@
import java.io.File;
import java.util.List;
-import org.eclipse.core.runtime.Path;
import org.jboss.tools.ws.creation.core.data.ServiceModel;
-import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
public class WSDL2JavaCommand extends AbstractGenerateCodeCommand{
@@ -26,39 +24,36 @@
protected String getCommandLineFileName_win() {
return WSCONSUEM_FILE_NAME_WIN;
}
-
+
@Override
- protected String getCommandlineArgs() {
- String commandLine;
- String project = model.getWebProjectName();
- String projectRoot = JBossWSCreationUtils.getProjectRoot(project).toOSString();
- commandLine = "-s " + projectRoot + Path.SEPARATOR + "src";
+ protected void addCommandlineArgs(List<String> command) {
if(model.getCustomPackage() != null && !"".equals(model.getCustomPackage())){
- commandLine += " -p " + model.getCustomPackage();
+ command.add("-p");
+ command.add(model.getCustomPackage());
}
List<String> bindingFiles = model.getBindingFiles();
for(String bindingFileLocation: bindingFiles){
File bindingFile = new File(bindingFileLocation);
if(bindingFile.exists()){
- commandLine += " -b " + bindingFileLocation;
+ command.add("-b");
+ command.add(bindingFileLocation);
}
}
if(model.getCatalog() != null && !"".equals(model.getCatalog().trim())){
File catalog = new File(model.getCatalog());
if(catalog.exists()){
- commandLine += " -c " + model.getCatalog();
+ command.add("-c");
+ command.add(model.getCatalog());
}
}
if(model.getTarget() != null){
- commandLine += " -t " + model.getTarget();
+ command.add("-t");
+ command.add(model.getTarget());
}
-
-
- return commandLine;
}
}
Deleted: branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java
===================================================================
--- branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java 2009-04-25 18:43:22 UTC (rev 14927)
+++ branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java 2009-04-27 04:24:58 UTC (rev 14928)
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.creation.core.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.internal.core.JavaProject;
-import org.eclipse.jst.server.core.internal.RuntimeClasspathContainer;
-import org.jboss.tools.ws.core.classpath.JBossWSRuntimeClassPathInitializer.JBossWSRuntimeClasspathContainer;
-import org.jboss.tools.ws.creation.core.data.ServiceModel;
-import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
-
-/**
- * @author Grid Qian
- */
-@SuppressWarnings("restriction")
-public class WSProviderInvokeCommand extends AbstractGenerateCodeCommand {
-
- private static String WSPROVIDER_FILE_NAME_LINUX = "wsprovide.sh";
- private static String WSPROVIDER_FILE_NAME_WIN = "wsprovide.bat";
- private static String SEPERATOR_WIN = ";";
- private static String SEPERATOR_LINUX = ":";
- private String seperator;
-
- public WSProviderInvokeCommand(ServiceModel model) {
- super(model);
- }
-
- @Override
- protected String getCommandLineFileName_linux() {
- return WSPROVIDER_FILE_NAME_LINUX;
- }
-
- @Override
- protected String getCommandLineFileName_win() {
- return WSPROVIDER_FILE_NAME_WIN;
- }
-
- @Override
- protected String getCommandlineArgs() {
- if (System.getProperty("os.name").toLowerCase().indexOf("win") >= 0) {
- seperator = SEPERATOR_WIN;
- } else {
- seperator = SEPERATOR_LINUX;
- }
- StringBuffer commandLine = new StringBuffer();
- String projectName = model.getWebProjectName();
- String projectRoot = JBossWSCreationUtils.getProjectRoot(projectName)
- .toOSString();
-
- IProject iProject = ResourcesPlugin.getWorkspace().getRoot()
- .getProject(projectName);
- IJavaProject javaProject = JavaCore.create(iProject);
-
- commandLine.append(" -s ").append(projectRoot).append(Path.SEPARATOR)
- .append("src");
-
- try {
- commandLine.append(" -c ");
- if(seperator.equals(SEPERATOR_WIN)){
- commandLine.append("\"");
- }
-
- commandLine.append(projectRoot).append(Path.SEPARATOR).append(
- javaProject.getOutputLocation().removeFirstSegments(1)
- .toOSString()).append(seperator);
- commandLine.append(getClasspathEntries(javaProject));
- if(seperator.equals(SEPERATOR_WIN)){
- commandLine.append("\"");
- }
- commandLine.append(" ");
- } catch (JavaModelException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- if (model.isGenWSDL()) {
- commandLine.append(" -w ");
- }
- commandLine.append(" -r ").append(projectRoot).append(Path.SEPARATOR).append("wsdl ");
- commandLine.append(model.getServiceClasses().get(0));
-
- return commandLine.toString();
-
- }
-
- private String getClasspathEntries(IJavaProject javaProject) {
- IClasspathEntry[] iniEntries = null;
- List<IClasspathEntry> pathList = new ArrayList<IClasspathEntry>();
- IClasspathEntry[] resolvedEntries = null;
- try {
- iniEntries = javaProject.getRawClasspath();
- for (IClasspathEntry entry : iniEntries) {
- IClasspathContainer container = JavaCore.getClasspathContainer(
- entry.getPath(), javaProject);
- if (!(container instanceof JBossWSRuntimeClasspathContainer)) {
- if (!(container instanceof RuntimeClasspathContainer && container
- .getDescription().contains("JBoss"))) {
- pathList.add(entry);
- }
- }
- }
- resolvedEntries = ((JavaProject) javaProject)
- .resolveClasspath(pathList
- .toArray(new IClasspathEntry[pathList.size()]));
- } catch (JavaModelException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- StringBuffer path = new StringBuffer();
- for (IClasspathEntry entry : resolvedEntries) {
- if (entry.getEntryKind() == 3 || entry.getEntryKind() == 2) {
- // path.append(workspaceRoot);
- continue;
- }
- path.append(entry.getPath().toOSString()).append(seperator);
- }
- String str = path.toString();
- if(str.endsWith(seperator)){
- str = str.substring(0, str.length()-1);
- }
- return str;
-
- }
-}
Added: branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/ClasspathParser.java
===================================================================
--- branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/ClasspathParser.java (rev 0)
+++ branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/ClasspathParser.java 2009-04-27 04:24:58 UTC (rev 14928)
@@ -0,0 +1,278 @@
+package org.jboss.tools.ws.creation.core.utils;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
+
+public class ClasspathParser {
+
+ private static ClasspathParser instance;
+
+ private ClasspathParser() {
+ }
+
+ public static ClasspathParser getInstance() {
+ if (instance == null)
+ instance = new ClasspathParser();
+ return instance;
+ }
+
+ public String getClasspathString(IProject project) {
+ StringBuffer classpath = new StringBuffer();
+ String[] classpathEntries = getClasspath(project, false);
+
+ Vector<String> classpathVector = new Vector<String>();
+ for (int i = 0; i < classpathEntries.length; i++) {
+ if (!classpathVector.contains(classpathEntries[i])) {
+ classpathVector.add(classpathEntries[i]);
+ classpath.append(classpathEntries[i]);
+ classpath.append(";");
+ }
+ }
+ return classpath.toString();
+ }
+
+ @SuppressWarnings("restriction")
+ private String[] getClasspath(IProject project, boolean isDependent) {
+ String[] cClasspath = new String[0];
+ ArrayList<String> projectClasspath = new ArrayList<String>();
+ boolean needJavaClasspath = false;
+
+ IVirtualComponent comp = ComponentCore.createComponent(project);
+ if (comp != null) {
+
+ // get a ear component classpath
+ if (J2EEUtils.isEARComponent(comp)) {
+ cClasspath = getClasspathOfEARProject(project, comp
+ .getName());
+
+ // add component classpath to the project classpath
+ for (int j = 0; j < cClasspath.length; j++) {
+ projectClasspath.add(cClasspath[j]);
+ }
+ } else if (J2EEUtils.isWebComponent(comp)
+ || J2EEUtils.isJavaComponent(comp)) {
+ needJavaClasspath = true;
+
+ IContainer outputContainer = null;
+ IResource fragmentRoot = null;
+ IPackageFragmentRoot[] pkgFragmentRoot = ResourceUtils
+ .getJavaPackageFragmentRoots(project);
+ ArrayList<String> webComponentClasspath = new ArrayList<String>();
+ try {
+ for (int i = 0; i < pkgFragmentRoot.length; i++) {
+ fragmentRoot = pkgFragmentRoot[i]
+ .getCorrespondingResource();
+ if (fragmentRoot != null
+ && (fragmentRoot.getProject().equals(project))
+ && (fragmentRoot.getType() != IResource.FILE)) {
+ outputContainer = J2EEProjectUtilities
+ .getOutputContainer(project,
+ pkgFragmentRoot[i]);
+ if (outputContainer != null) {
+ webComponentClasspath.add(outputContainer
+ .getLocation().toOSString());
+ }
+ }
+ }
+ } catch (JavaModelException e) {
+ }
+
+ // add Web component classpath to the project classpath
+ Iterator<String> iter = webComponentClasspath.iterator();
+ while (iter.hasNext()) {
+ projectClasspath.add((String) iter.next());
+ }
+ }
+
+ if (!isDependent) {
+ if (J2EEUtils.isWebComponent(comp)) {
+ needJavaClasspath = true;
+ cClasspath = getWebInfLib(project);
+ for (int j = 0; j < cClasspath.length; j++) {
+ projectClasspath.add(cClasspath[j]);
+ }
+ }
+ }
+
+ } else {
+ needJavaClasspath = true;
+ }
+
+ // a Web or Java component in the project, get the project's Java classpath
+ if (needJavaClasspath) {
+ String[] javaClasspath;
+ try {
+ IJavaProject javaProj = (IJavaProject) project
+ .getNature(JavaCore.NATURE_ID);
+ if (javaProj != null) {
+ javaClasspath = getClasspathForJavaProject(javaProj);
+ for (int j = 0; j < javaClasspath.length; j++) {
+ projectClasspath.add(javaClasspath[j]);
+ }
+ }
+ } catch (CoreException e) {
+ // can't get Java classpath, ignore
+ }
+ }
+
+ return (String[]) projectClasspath.toArray(new String[projectClasspath
+ .size()]);
+ }
+
+ // Need to get all components in the project. If there's a EAR component, get the
+ // utility Jars
+ @SuppressWarnings("restriction")
+ private String[] getUtilityJarClasspath(IProject project) {
+ String[] utilityJarString = new String[0];
+ String[] cClasspath = new String[0];
+ ArrayList<String> utilityJarsClasspath = new ArrayList<String>();
+
+ String component;
+ IVirtualComponent comp = ComponentCore.createComponent(project);
+ if (comp != null) {
+ component = comp.getName();
+ if (J2EEUtils.isEARComponent(comp)) {
+ cClasspath = getClasspathOfEARProject(project, component);
+ for (int j = 0; j < cClasspath.length; j++) {
+ utilityJarsClasspath.add(cClasspath[j]);
+ }
+ utilityJarString = (String[]) utilityJarsClasspath
+ .toArray(new String[utilityJarsClasspath.size()]);
+ }
+ }
+
+ return utilityJarString;
+ }
+
+ private String[] getClasspathOfEARProject(IProject project, String component) {
+ IPath projectPath = project.getProject().getLocation()
+ .addTrailingSeparator().append(component).addTrailingSeparator();
+ return getDirectoryJarFiles(projectPath);
+ }
+
+ private String[] getDirectoryJarFiles(IPath iPath) {
+ File dir = iPath.toFile();
+ Vector<Object> jarsVector = new Vector<Object>();
+ if (dir.exists() && dir.isDirectory()) {
+ String[] filenames = dir.list();
+ for (int i = 0; i < filenames.length; i++) {
+ if (filenames[i].endsWith(".jar"))
+ jarsVector.add(pathToString(iPath) + filenames[i]);
+ }
+ }
+ String[] jars = new String[jarsVector.size()];
+ jarsVector.copyInto(jars);
+ return jars;
+ }
+
+ private String[] getWebInfLib(IProject project) {
+ String[] webinfLibJars = new String[0];
+ ArrayList<String> anArrayList = new ArrayList<String>();
+ try {
+ IVirtualComponent component = ComponentCore
+ .createComponent(project);
+ if (component != null) {
+
+ IVirtualFolder webInfLib = component.getRootFolder().getFolder(
+ new Path("/WEB-INF/lib"));
+ if (webInfLib != null) {
+ IVirtualResource[] resources = webInfLib.members();
+ IResource aResource = null;
+ for (int i = 0; i < resources.length; i++) {
+ aResource = resources[i].getUnderlyingResource();
+ if ("jar".equalsIgnoreCase(aResource.getFileExtension()))
+ anArrayList.add(aResource.getLocation()
+ .toOSString());
+ }
+ if (anArrayList.size() != 0)
+ webinfLibJars = (String[]) anArrayList
+ .toArray(new String[anArrayList.size()]);
+ }
+ }
+ } catch (CoreException e) {
+ }
+ return webinfLibJars;
+ }
+
+ private String[] getClasspathForJavaProject(IJavaProject javaProject) {
+ ArrayList<String> projectClasspath = new ArrayList<String>();
+ try {
+ IClasspathEntry[] buildPath = javaProject
+ .getResolvedClasspath(true);
+ for (int i = 0; i < buildPath.length; i++) {
+ String[] buildPathString = classpathEntryToString(buildPath[i],
+ javaProject.getProject());
+ for (int j = 0; j < buildPathString.length; j++) {
+ projectClasspath.add(buildPathString[j]);
+ }
+ }
+ } catch (JavaModelException jme) {
+ }
+
+ String[] utilityJarsClasspath;
+ IProject project = javaProject.getProject();
+ IProject[] referencingProjects = project.getReferencingProjects();
+ for (int i = 0; i < referencingProjects.length; i++) {
+ utilityJarsClasspath = getUtilityJarClasspath(referencingProjects[i]);
+ for (int j = 0; j < utilityJarsClasspath.length; j++) {
+ projectClasspath.add(utilityJarsClasspath[j]);
+ }
+ }
+
+ return (String[]) projectClasspath.toArray(new String[projectClasspath
+ .size()]);
+ }
+
+ private String[] classpathEntryToString(IClasspathEntry entry,
+ IProject project) {
+ switch (entry.getEntryKind()) {
+ case IClasspathEntry.CPE_LIBRARY: {
+ return new String[] { pathToString(entry.getPath()) };
+ }
+ case IClasspathEntry.CPE_PROJECT: {
+ return getClasspath(ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(entry.getPath().lastSegment()), true);
+ }
+ case IClasspathEntry.CPE_SOURCE: {
+ IPath path = entry.getPath();
+ if (path.segment(0).equals(project.getName()))
+ path = path.removeFirstSegments(1);
+ return new String[] { pathToString(project.getLocation()
+ .addTrailingSeparator().append(path)) };
+ }
+ case IClasspathEntry.CPE_VARIABLE: {
+ return classpathEntryToString(JavaCore
+ .getResolvedClasspathEntry(entry), project);
+ }
+ default: {
+ return new String[] { pathToString(entry.getPath()) };
+ }
+ }
+ }
+
+ private String pathToString(IPath path) {
+ return path.toOSString();
+ }
+}
Property changes on: branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/ClasspathParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
===================================================================
--- branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2009-04-25 18:43:22 UTC (rev 14927)
+++ branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2009-04-27 04:24:58 UTC (rev 14928)
@@ -4,7 +4,7 @@
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
-* This is free software; you can redistribute it and/or modify it
+ * This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
@@ -23,14 +23,18 @@
import java.io.File;
import java.text.Collator;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import java.util.Locale;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaModel;
@@ -53,156 +57,156 @@
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
public class JBossWSCreationUtils {
-
- static final String javaKeyWords[] =
- {
- "abstract", "assert", "boolean", "break", "byte", "case",
- "catch", "char", "class", "const", "continue",
- "default", "do", "double", "else", "extends",
- "false", "final", "finally", "float", "for",
- "goto", "if", "implements", "import", "instanceof",
- "int", "interface", "long", "native", "new",
- "null", "package", "private", "protected", "public",
- "return", "short", "static", "strictfp", "super",
- "switch", "synchronized", "this", "throw", "throws",
- "transient", "true", "try", "void", "volatile",
- "while"
- };
-
- public static boolean isJavaKeyword(String keyword) {
- if (hasUpperCase(keyword)) {
- return false;
- }
- return (Arrays.binarySearch(javaKeyWords, keyword, Collator.getInstance(Locale.ENGLISH)) >= 0);
- }
- private static boolean hasUpperCase(String nodeName) {
- if (nodeName == null) {
- return false;
- }
- for (int i = 0; i < nodeName.length(); i++) {
- if (Character.isUpperCase(nodeName.charAt(i))) {
- return true;
- }
- }
- return false;
- }
-
- public static IPath getWorkspace(){
+ static final String javaKeyWords[] = { "abstract", "assert", "boolean",
+ "break", "byte", "case", "catch", "char", "class", "const",
+ "continue", "default", "do", "double", "else", "extends", "false",
+ "final", "finally", "float", "for", "goto", "if", "implements",
+ "import", "instanceof", "int", "interface", "long", "native",
+ "new", "null", "package", "private", "protected", "public",
+ "return", "short", "static", "strictfp", "super", "switch",
+ "synchronized", "this", "throw", "throws", "transient", "true",
+ "try", "void", "volatile", "while" };
+
+ public static boolean isJavaKeyword(String keyword) {
+ if (hasUpperCase(keyword)) {
+ return false;
+ }
+ return (Arrays.binarySearch(javaKeyWords, keyword, Collator
+ .getInstance(Locale.ENGLISH)) >= 0);
+ }
+
+ private static boolean hasUpperCase(String nodeName) {
+ if (nodeName == null) {
+ return false;
+ }
+ for (int i = 0; i < nodeName.length(); i++) {
+ if (Character.isUpperCase(nodeName.charAt(i))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static IPath getWorkspace() {
return ResourcesPlugin.getWorkspace().getRoot().getLocation();
}
-
- public static IProject getProjectByName(String project){
+
+ public static IProject getProjectByName(String project) {
String projectString = replaceEscapecharactors(project);
return ResourcesPlugin.getWorkspace().getRoot().getProject(
getProjectNameFromFramewokNameString(projectString));
}
-
- public static IPath getProjectRoot(String project){
+
+ public static IPath getProjectRoot(String project) {
String projectString = replaceEscapecharactors(project);
return ResourcesPlugin.getWorkspace().getRoot().getProject(
- getProjectNameFromFramewokNameString(projectString)).getLocation();
+ getProjectNameFromFramewokNameString(projectString))
+ .getLocation();
}
- public static String pathToWebProjectContainer(String project) {
+ public static String pathToWebProjectContainer(String project) {
IPath projectRoot = getProjectRoot(project);
- IPath currentDynamicWebProjectDir = J2EEUtils.getWebContentPath(
- getProjectByName(project));
- IPath currentDynamicWebProjectDirWithoutProjectRoot = J2EEUtils.getWebContentPath(
- getProjectByName(project)).removeFirstSegments(1).makeAbsolute();
- if(projectRoot.toOSString().contains(getWorkspace().toOSString())){
- return getWorkspace()
- .append(currentDynamicWebProjectDir).toOSString();
- }else{
- return projectRoot
- .append(currentDynamicWebProjectDirWithoutProjectRoot).toOSString();
+ IPath currentDynamicWebProjectDir = J2EEUtils
+ .getWebContentPath(getProjectByName(project));
+ IPath currentDynamicWebProjectDirWithoutProjectRoot = J2EEUtils
+ .getWebContentPath(getProjectByName(project))
+ .removeFirstSegments(1).makeAbsolute();
+ if (projectRoot.toOSString().contains(getWorkspace().toOSString())) {
+ return getWorkspace().append(currentDynamicWebProjectDir)
+ .toOSString();
+ } else {
+ return projectRoot.append(
+ currentDynamicWebProjectDirWithoutProjectRoot).toOSString();
}
-
+
}
-
- public static String pathToWebProjectContainerWEBINF(String project) {
+
+ public static String pathToWebProjectContainerWEBINF(String project) {
IPath projectRoot = getProjectRoot(project);
- IPath webContainerWEBINFDir = J2EEUtils.getWebInfPath(
- getProjectByName(project));
- IPath webContainerWEBINFDirWithoutProjectRoot = J2EEUtils.getWebInfPath(
- getProjectByName(project)).removeFirstSegments(1).makeAbsolute();
- if(projectRoot.toOSString().contains(getWorkspace().toOSString())){
- return getWorkspace()
- .append(webContainerWEBINFDir).toOSString();
- }else{
- return projectRoot
- .append(webContainerWEBINFDirWithoutProjectRoot).toOSString();
+ IPath webContainerWEBINFDir = J2EEUtils
+ .getWebInfPath(getProjectByName(project));
+ IPath webContainerWEBINFDirWithoutProjectRoot = J2EEUtils
+ .getWebInfPath(getProjectByName(project))
+ .removeFirstSegments(1).makeAbsolute();
+ if (projectRoot.toOSString().contains(getWorkspace().toOSString())) {
+ return getWorkspace().append(webContainerWEBINFDir).toOSString();
+ } else {
+ return projectRoot.append(webContainerWEBINFDirWithoutProjectRoot)
+ .toOSString();
}
}
-
-
- private static String replaceEscapecharactors(String vulnarableString){
- if (vulnarableString.indexOf("/")!=-1){
- vulnarableString = vulnarableString.replace('/', File.separator.charAt(0));
+
+ private static String replaceEscapecharactors(String vulnarableString) {
+ if (vulnarableString.indexOf("/") != -1) {
+ vulnarableString = vulnarableString.replace('/', File.separator
+ .charAt(0));
}
return vulnarableString;
}
-
-
- private static String getProjectNameFromFramewokNameString(String frameworkProjectString){
- if (frameworkProjectString.indexOf(getSplitCharactor())== -1){
+
+ private static String getProjectNameFromFramewokNameString(
+ String frameworkProjectString) {
+ if (frameworkProjectString.indexOf(getSplitCharactor()) == -1) {
return frameworkProjectString;
- }else{
+ } else {
return frameworkProjectString.split(getSplitCharactors())[1];
}
}
-
-
- private static String getSplitCharactor(){
- //Windows check (because from inside wtp in return I received a hard coded path)
- if (File.separatorChar == '\\'){
- return "\\" ;
- }else{
+
+ private static String getSplitCharactor() {
+ // Windows check (because from inside wtp in return I received a hard
+ // coded path)
+ if (File.separatorChar == '\\') {
+ return "\\";
+ } else {
return File.separator;
}
}
-
-
- private static String getSplitCharactors(){
- //Windows check (because from inside wtp in return I received a hard coded path)
- if (File.separatorChar == '\\'){
+
+ private static String getSplitCharactors() {
+ // Windows check (because from inside wtp in return I received a hard
+ // coded path)
+ if (File.separatorChar == '\\') {
return "\\" + File.separator;
- }else{
+ } else {
return File.separator;
}
}
-
- public static String classNameFromQualifiedName(String qualifiedCalssName){
- //This was done due to not splitting with . Strange
- qualifiedCalssName = qualifiedCalssName.replace('.', ':');
- String[] parts = qualifiedCalssName.split(":");
- if (parts.length == 0){
- return "";
- }
- return parts[parts.length-1];
- }
-
+
+ public static String classNameFromQualifiedName(String qualifiedCalssName) {
+ // This was done due to not splitting with . Strange
+ qualifiedCalssName = qualifiedCalssName.replace('.', ':');
+ String[] parts = qualifiedCalssName.split(":");
+ if (parts.length == 0) {
+ return "";
+ }
+ return parts[parts.length - 1];
+ }
+
// JDT utils
/**
* get JavaProject object from project name
*/
- public static IJavaProject getJavaProjectByName(String projectName) throws JavaModelException {
+ public static IJavaProject getJavaProjectByName(String projectName)
+ throws JavaModelException {
- IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
- model.open(null);
+ IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace()
+ .getRoot());
+ model.open(null);
- IJavaProject[] projects = model.getJavaProjects();
+ IJavaProject[] projects = model.getJavaProjects();
- for (IJavaProject proj : projects) {
- if (proj.getProject().getName().equals(projectName)) {
- return proj;
- }
- }
+ for (IJavaProject proj : projects) {
+ if (proj.getProject().getName().equals(projectName)) {
+ return proj;
+ }
+ }
- return null;
- }
-
- public static ICompilationUnit findUnitByFileName(IJavaElement javaElem,
+ return null;
+ }
+
+ public static ICompilationUnit findUnitByFileName(IJavaElement javaElem,
String filePath) throws Exception {
ICompilationUnit unit = null;
@@ -252,26 +256,30 @@
return null;
}
-
- /**
- * get Java compilation unit by file path
- * @param javaFile the java sour file to look
- * @return ICompilationUnit, JDK compilation unit for this java file.
- */
- public static ICompilationUnit getJavaUnitFromFile(IFile javaFile) {
- try {
- IJavaProject project = getJavaProjectByName(javaFile.getProject().getName());
- if (project == null) {
- return null;
- }
+ /**
+ * get Java compilation unit by file path
+ *
+ * @param javaFile
+ * the java sour file to look
+ * @return ICompilationUnit, JDK compilation unit for this java file.
+ */
+ public static ICompilationUnit getJavaUnitFromFile(IFile javaFile) {
+ try {
+ IJavaProject project = getJavaProjectByName(javaFile.getProject()
+ .getName());
- return findUnitByFileName(project, javaFile.getFullPath().toString());
- } catch (Exception e) {
- return null;
- }
- }
-
+ if (project == null) {
+ return null;
+ }
+
+ return findUnitByFileName(project, javaFile.getFullPath()
+ .toString());
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
public static boolean validateJBossWSLocation() {
String location = JBossWSCorePlugin.getDefault().getPreferenceStore()
.getString(JBossWSCoreMessages.WS_Location);
@@ -280,7 +288,7 @@
}
return true;
}
-
+
public static String getJBossWSRuntimeLocation(IProject project)
throws CoreException {
@@ -319,11 +327,12 @@
runtimeTypeName = "";
}
if (runtimeTypeName.toUpperCase().indexOf("JBOSS") >= 0) {
- String runtimeLocation = serverRuntime.getLocation().toOSString();
- if(runtimeLocation.endsWith("bin")){
+ String runtimeLocation = serverRuntime.getLocation()
+ .toOSString();
+ if (runtimeLocation.endsWith("bin")) {
return serverRuntime.getLocation().removeLastSegments(1)
- .toOSString();
- }else{
+ .toOSString();
+ } else {
return runtimeLocation;
}
}
@@ -347,23 +356,57 @@
return "";
}
-
- public static IRuntime getRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime runtime) {
+
+ public static IRuntime getRuntime(
+ org.eclipse.wst.common.project.facet.core.runtime.IRuntime runtime) {
if (runtime == null)
throw new IllegalArgumentException();
-
+
String id = runtime.getProperty("id");
if (id == null)
return null;
-
- org.eclipse.wst.server.core.IRuntime[] runtimes = ServerCore.getRuntimes();
+
+ org.eclipse.wst.server.core.IRuntime[] runtimes = ServerCore
+ .getRuntimes();
int size = runtimes.length;
for (int i = 0; i < size; i++) {
if (id.equals(runtimes[i].getId()))
return runtimes[i];
}
-
+
return null;
}
-
+
+ public static String getJavaProjectSrcLocation(IProject project) throws JavaModelException {
+ IResource[] rs = getJavaSourceRoots(project);
+ String src = "";
+ if (rs == null || rs.length == 0)
+ return src;
+ for (int i = 0; i < rs.length; i++) {
+ IPath p = rs[i].getLocation();
+ if (p != null) {
+ src = p.toOSString();
+ }
+ }
+ return src;
+ }
+
+ public static IResource[] getJavaSourceRoots(IProject project) throws JavaModelException {
+ IJavaProject javaProject = JavaCore.create(project);
+ if (javaProject == null)
+ return null;
+ List<IResource> resources = new ArrayList<IResource>();
+ IClasspathEntry[] es = javaProject.getResolvedClasspath(true);
+ for (int i = 0; i < es.length; i++) {
+ if (es[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) {
+ IResource findMember = ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(es[i].getPath());
+ if (findMember != null && findMember.exists()) {
+ resources.add(findMember);
+ }
+ }
+ }
+ return resources.toArray(new IResource[resources.size()]);
+ }
+
}
Modified: branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml
===================================================================
--- branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml 2009-04-25 18:43:22 UTC (rev 14927)
+++ branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml 2009-04-27 04:24:58 UTC (rev 14928)
@@ -50,7 +50,7 @@
<widgetFactory
class="org.jboss.tools.ws.creation.ui.wsrt.JBossWSProviderInvokeConfigWidgetFactory"
id="JBossWSProviderInvokeConfig"
- insertBeforeCommandId="org.jboss.tools.ws.creation.core.commands.WSProviderInvokeCommand">
+ insertBeforeCommandId="org.jboss.tools.ws.creation.core.commands.Java2WSCommand">
</widgetFactory>
</extension>
<extension
Modified: branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java
===================================================================
--- branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java 2009-04-25 18:43:22 UTC (rev 14927)
+++ branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java 2009-04-27 04:24:58 UTC (rev 14928)
@@ -13,10 +13,10 @@
import org.jboss.tools.ws.creation.core.commands.BindingFilesValidationCommand;
import org.jboss.tools.ws.creation.core.commands.ImplementationClassCreationCommand;
import org.jboss.tools.ws.creation.core.commands.InitialCommand;
+import org.jboss.tools.ws.creation.core.commands.Java2WSCommand;
import org.jboss.tools.ws.creation.core.commands.MergeWebXMLCommand;
import org.jboss.tools.ws.creation.core.commands.ValidateWSImplCommand;
import org.jboss.tools.ws.creation.core.commands.WSDL2JavaCommand;
-import org.jboss.tools.ws.creation.core.commands.WSProviderInvokeCommand;
import org.jboss.tools.ws.creation.core.data.ServiceModel;
public class JBossWebService extends AbstractWebService {
@@ -57,7 +57,7 @@
else if (ctx.getScenario().getValue() == WebServiceScenario.BOTTOMUP){
commands.add(new InitialCommand(model, this, WebServiceScenario.BOTTOMUP));
commands.add(new ValidateWSImplCommand(model));
- commands.add(new WSProviderInvokeCommand(model));
+ commands.add(new Java2WSCommand(model));
commands.add(new MergeWebXMLCommand(model));
//commands.add(new JBossWSRuntimeCommand(ResourcesPlugin.getWorkspace().getRoot().getProject(project)));
}
Modified: branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/projects/JavaFirstTestProject/.classpath
===================================================================
--- branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/projects/JavaFirstTestProject/.classpath 2009-04-25 18:43:22 UTC (rev 14927)
+++ branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/projects/JavaFirstTestProject/.classpath 2009-04-27 04:24:58 UTC (rev 14928)
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JAVA1.5"/>
- <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
- <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
- <classpathentry kind="output" path="build/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="output" path="build/classes"/>
+</classpath>
Modified: branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java
===================================================================
--- branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java 2009-04-25 18:43:22 UTC (rev 14927)
+++ branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java 2009-04-27 04:24:58 UTC (rev 14928)
@@ -18,6 +18,7 @@
import org.jboss.tools.ws.core.test.classpath.JBossWSRuntimeManagerTest;
import org.jboss.tools.ws.core.test.command.JBossWSJavaFirstCommandTest;
import org.jboss.tools.ws.core.test.command.JBossWSClientCommandTest;
+import org.jboss.tools.ws.core.test.command.JBossWSTopDownCommandTest;
public class JBossWSCoreAllTests extends TestCase {
public static final String PLUGIN_ID = "org.jboss.tools.common.test";
@@ -27,7 +28,7 @@
suite.addTestSuite(JBossWSRuntimeManagerTest.class);
suite.addTestSuite(JBossWSJavaFirstCommandTest.class);
suite.addTestSuite(JBossWSClientCommandTest.class);
-
+ suite.addTestSuite(JBossWSTopDownCommandTest.class);
return suite;
}
}
\ No newline at end of file
Modified: branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java
===================================================================
--- branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java 2009-04-25 18:43:22 UTC (rev 14927)
+++ branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java 2009-04-27 04:24:58 UTC (rev 14928)
@@ -69,7 +69,7 @@
protected static final int DEFAULT_STARTUP_TIME = 150000;
protected static final int DEFAULT_SHUTDOWN_TIME = 90000;
- protected static final String JBOSSWS_HOME_DEFAULT = "D:/softinstall/jboss-4.2.2.GA/jboss-4.2.2.GA";
+ protected static final String JBOSSWS_HOME_DEFAULT = "/home/fugang/jboss-all/jboss-soa-p.4.3.0/jboss-as";
public static final String JBOSSWS_42_HOME="jbosstools.test.jboss.home.4.2";
public static final String JBOSS_RUNTIME_42 = "org.jboss.ide.eclipse.as.runtime.42";
public static final String JBOSS_AS_42_HOME = System.getProperty(JBOSSWS_42_HOME, JBOSSWS_HOME_DEFAULT);
Modified: branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java
===================================================================
--- branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java 2009-04-25 18:43:22 UTC (rev 14927)
+++ branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java 2009-04-27 04:24:58 UTC (rev 14928)
@@ -22,6 +22,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
@@ -49,7 +50,7 @@
import org.jboss.tools.ws.creation.core.commands.MergeWebXMLCommand;
import org.jboss.tools.ws.creation.core.commands.RemoveClientJarsCommand;
import org.jboss.tools.ws.creation.core.commands.ValidateWSImplCommand;
-import org.jboss.tools.ws.creation.core.commands.WSProviderInvokeCommand;
+import org.jboss.tools.ws.creation.core.commands.Java2WSCommand;
import org.jboss.tools.ws.creation.core.data.ServiceModel;
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
import org.jboss.tools.ws.creation.ui.wsrt.JBossWebService;
@@ -61,7 +62,7 @@
protected static final IWorkspace ws = ResourcesPlugin.getWorkspace();
protected static final IWorkbench wb = PlatformUI.getWorkbench();
- protected static final String JBOSSWS_HOME_DEFAULT = "/home/grid/Software/jboss-4.2.2.GA";
+ protected static final String JBOSSWS_HOME_DEFAULT = "D:\\softinstall\\jboss-4.2.3GA\\jboss-4.2.3.GA";
private static final String RuntimeName;
private static final boolean isDeployed;
@@ -135,13 +136,13 @@
fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
- WSProviderInvokeCommand command = new WSProviderInvokeCommand(model);
+ Java2WSCommand command = new Java2WSCommand(model);
IStatus status = command.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
+ assertFalse(status.getMessage(), Status.ERROR == status.getSeverity());
assertTrue(project.getFile(
"src/org/example/www/helloworld/jaxws/SayHello.java").exists());
- assertTrue(project.getFile("WebContent/wsdl/HelloWorldService.wsdl")
+ assertTrue(project.getFile("wsdl/HelloWorldService.wsdl")
.exists());
}
@@ -164,7 +165,7 @@
fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
- cmd = new WSProviderInvokeCommand(model);
+ cmd = new Java2WSCommand(model);
status = cmd.execute(null, null);
assertTrue(status.getMessage(), status.isOK());
16 years, 11 months
JBoss Tools SVN: r14927 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2009-04-25 14:43:22 -0400 (Sat, 25 Apr 2009)
New Revision: 14927
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java
Log:
- VpeCustomTemplates - the code has been reformatted.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java 2009-04-25 18:40:08 UTC (rev 14926)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java 2009-04-25 18:43:22 UTC (rev 14927)
@@ -53,50 +53,53 @@
IPath pathToFile = CustomTLDReference
.getCustomElementPath(sourceNode, pageContext);
if (pathToFile != null) {
- //add attributes to EL list
+ //add attributes to EL list
-
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(
- pathToFile);
- if (file != null && file.exists()) {
-
-
-
- if (!pageContext.getVisualBuilder().isFileInIncludeStack(
- file)) {
- Document document = pageContext.getVisualBuilder()
- .getIncludeDocuments().get(file);
- if (document == null) {
- document = VpeCreatorUtil.getDocumentForRead(file);
- if (document != null)
- pageContext.getVisualBuilder()
- .getIncludeDocuments().put(file,
- document);
- }
- if (document != null) {
- VpeCreationData creationData = createInclude(
- document, visualDocument);
- ResourceReference [] oldResourceReferences = VpeCustomTemplate.addAttributesToELExcpressions(sourceNode, file);
- creationData.setData(new TransferObject(oldResourceReferences, file));
- pageContext.getVisualBuilder().pushIncludeStack(
- new VpeIncludeInfo((Element) sourceNode,
- file, document));
- return creationData;
- }
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(
+ pathToFile);
+ if (file != null && file.exists()) {
+ if (!pageContext.getVisualBuilder().isFileInIncludeStack(
+ file)) {
+ Document document = pageContext.getVisualBuilder()
+ .getIncludeDocuments().get(file);
+ if (document == null) {
+ document = VpeCreatorUtil.getDocumentForRead(file);
+ if (document != null)
+ pageContext.getVisualBuilder()
+ .getIncludeDocuments().put(file, document);
}
+ if (document != null) {
+ VpeCreationData creationData = createInclude(
+ document, visualDocument);
+ ResourceReference [] oldResourceReferences
+ = VpeCustomTemplate
+ .addAttributesToELExcpressions(
+ sourceNode, file);
+ creationData.setData(new TransferObject(
+ oldResourceReferences, file));
+ pageContext.getVisualBuilder().pushIncludeStack(
+ new VpeIncludeInfo((Element) sourceNode,
+ file, document));
+ return creationData;
+ }
}
+ }
}
- VpeCreationData creationData = createStub(sourceNode.getNodeName(), visualDocument);
+
+ VpeCreationData creationData = createStub(sourceNode.getNodeName(),
+ visualDocument);
creationData.setData(null);
return creationData;
}
@Override
- public void openIncludeEditor(VpePageContext pageContext, Element sourceElement, Object data) {
+ public void openIncludeEditor(VpePageContext pageContext,
+ Element sourceElement, Object data) {
IFile file = getFileForOpenOn(pageContext, sourceElement);
if(file!=null && file.exists()) {
- IWorkbenchPage workbenchPage = VpePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPage workbenchPage = VpePlugin.getDefault()
+ .getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
IDE.openEditor(workbenchPage, file,true);
} catch (PartInitException e) {
@@ -111,7 +114,8 @@
if(data.getData() instanceof TransferObject) {
TransferObject trObject = (TransferObject) data.getData();
- ELReferenceList.getInstance().setAllResources(trObject.getCustomFile(), trObject.getResourceReferebces());
+ ELReferenceList.getInstance().setAllResources(
+ trObject.getCustomFile(), trObject.getResourceReferebces());
data.setData(trObject.getCustomFile());
}
@@ -125,22 +129,26 @@
* @param processedFile processed File
* @return resourceReferences - unchanged resource references
*/
- private static final ResourceReference[] addAttributesToELExcpressions(final Node sourceNode,
- final IFile processedFile){
+ private static final ResourceReference[] addAttributesToELExcpressions(
+ final Node sourceNode, final IFile processedFile){
//obtain old resource references for this file
- ResourceReference[] resourceReferences = ELReferenceList.getInstance().getAllResources(processedFile);
+ ResourceReference[] resourceReferences = ELReferenceList.getInstance()
+ .getAllResources(processedFile);
//obtain attribute resource references for file
NamedNodeMap attributesMap = sourceNode.getAttributes();
- List<ResourceReference> addedAttrToElExpressions = new ArrayList<ResourceReference>();
+ List<ResourceReference> addedAttrToElExpressions
+ = new ArrayList<ResourceReference>();
for(int i=0;i<attributesMap.getLength();i++) {
Attr attr = (Attr) attributesMap.item(i);
//adds attribute if such attribute not exists for page
- ResourceReference resRef = new ResourceReference(attr.getName(), ResourceReference.FILE_SCOPE);
+ ResourceReference resRef = new ResourceReference(attr.getName(),
+ ResourceReference.FILE_SCOPE);
resRef.setProperties(attr.getValue());
addedAttrToElExpressions.add(resRef);
}
- ELReferenceList.getInstance().setAllResources(processedFile,addedAttrToElExpressions.toArray(new ResourceReference[0]));
+ ELReferenceList.getInstance().setAllResources(processedFile,
+ addedAttrToElExpressions.toArray(new ResourceReference[0]));
return resourceReferences;
}
/**
@@ -149,7 +157,8 @@
* @param sourceElement
* @return file, if file has been founded or null otherwise
*/
- private static IFile getFileForOpenOn(VpePageContext pageContext, Element sourceElement) {
+ private static IFile getFileForOpenOn(VpePageContext pageContext,
+ Element sourceElement) {
IPath pathToFile = CustomTLDReference
.getCustomElementPath(sourceElement, pageContext);
@@ -161,7 +170,8 @@
}
//if we cann't find source file, then just open tld definition file
if(file==null || !file.exists()) {
- pathToFile = CustomTLDReference.getCustomTLDPath(pageContext, sourceElement);
+ pathToFile = CustomTLDReference.getCustomTLDPath(pageContext,
+ sourceElement);
file = ResourcesPlugin.getWorkspace().getRoot().getFile(
pathToFile);
}
@@ -169,7 +179,8 @@
}
@Override
- public void beforeRemove(VpePageContext pageContext, Node sourceNode, nsIDOMNode visualNode, Object data) {
+ public void beforeRemove(VpePageContext pageContext, Node sourceNode,
+ nsIDOMNode visualNode, Object data) {
IFile file = null;
if(data instanceof TransferObject) {
file = ((TransferObject)data).getCustomFile();
16 years, 11 months
JBoss Tools SVN: r14926 - in trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe: editor/menu/action and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2009-04-25 14:40:08 -0400 (Sat, 25 Apr 2009)
New Revision: 14926
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertType.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction2.java
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/AbstractActionManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/BaseActionManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
Log:
CODING IN PROGRESS - issue JBIDE-3819: Create action 'Insert Into' in the context menu of VPE
https://jira.jboss.org/jira/browse/JBIDE-3819
- the action has been created for the text editor context menu.
- code of the context menu has been refactored.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/AbstractActionManager.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/AbstractActionManager.java 2009-04-25 15:59:55 UTC (rev 14925)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/AbstractActionManager.java 2009-04-25 18:40:08 UTC (rev 14926)
@@ -413,17 +413,6 @@
}
}
- public void fillContextMenu(IMenuManager menuManager, ISelection selection) {
- List selectionList = new ArrayList();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection es = (IStructuredSelection) selection;
- for (Iterator i = es.iterator(); i.hasNext();) {
- selectionList.add(i.next());
- }
- }
- contributeActions(menuManager, selectionList);
- }
-
public void fillContextMenuForVpe(IMenuManager menuManager,
ISelection selection) {
List selectionList = new ArrayList();
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/BaseActionManager.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/BaseActionManager.java 2009-04-25 15:59:55 UTC (rev 14925)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/BaseActionManager.java 2009-04-25 18:40:08 UTC (rev 14926)
@@ -30,7 +30,6 @@
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction;
import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.ModelQueryActionHelper;
import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.ModelQueryImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.ui.internal.actions.MenuBuilder;
import org.eclipse.wst.xml.ui.internal.util.XMLCommonResources;
import org.w3c.dom.Attr;
@@ -53,9 +52,8 @@
public static final String INSERT_AROUND_MENU = "Insert Around";
public static final String INSERT_BEFORE_MENU = "Insert Before";
public static final String INSERT_AFTER_MENU = "Insert After";
+ public static final String REPLACE_TAG_MENU = "Replace With";
public static final String INSERT_TAG_MENU = "Insert Tag";
- public static final String REPLACE_TAG_MENU = XMLCommonResources
- .getInstance().getString("_UI_MENU_REPLACE_WITH"); //$NON-NLS-1$
private ActionHelper actionHelper;
@@ -100,54 +98,12 @@
abstract protected Action createDeleteAction(List selection);
- public void contributeActions(IMenuManager menu, List selection) {
- int editMode = modelQuery.getEditMode();
- int ic = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.INCLUDE_CHILD_NODES
- | ModelQuery.INCLUDE_SEQUENCE_GROUPS
- : ModelQuery.INCLUDE_CHILD_NODES;
- int vc = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.VALIDITY_STRICT
- : ModelQuery.VALIDITY_NONE;
-
- List implicitlySelectedNodeList = null;
-
- if (selection.size() > 0) {
- implicitlySelectedNodeList = getSelectedNodes(selection, true);
-
- // contribute delete actions
- contributeDeleteActions(menu, implicitlySelectedNodeList, ic, vc);
- }
-
- if (selection.size() == 1) {
- Node node = (Node) selection.get(0);
-
- // contribute edit actions
- contributeEditActions(menu, node);
-
- // contribute add child actions
- contributeAddChildActions(menu, node, ic, vc);
-
- // contribute add before actions
- contributeAddSiblingActions(menu, node, ic, vc, false);
- }
-
- if (selection.size() > 0) {
- // contribute replace actions
- contributeReplaceActions(menu, implicitlySelectedNodeList, ic, vc);
- }
-
- if (selection.size() == 0) {
- Document document = ((IDOMModel) model).getDocument();
- contributeAddDocumentChildActions(menu, document, ic, vc);
- contributeEditGrammarInformationActions(menu, document);
- }
- }
-
public void contributeActionsForVpe(IMenuManager menu, List selection) {
int editMode = modelQuery.getEditMode();
- int ic = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.INCLUDE_CHILD_NODES
+ int includeOptions = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.INCLUDE_CHILD_NODES
| ModelQuery.INCLUDE_SEQUENCE_GROUPS
: ModelQuery.INCLUDE_CHILD_NODES;
- int vc = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.VALIDITY_STRICT
+ int validityChecking = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.VALIDITY_STRICT
: ModelQuery.VALIDITY_NONE;
List implicitlySelectedNodeList = null;
@@ -158,12 +114,12 @@
Node node = (Node) selection.get(0);
// contribute add before actions
- contributeAddSiblingActions(menu, node, ic, vc, true);
+ contributeAddSiblingActions(menu, node, true);
}
// contribute replace actions
- contributeReplaceActions(menu, implicitlySelectedNodeList, ic, vc);
- } else if (selection.size() == 0) {
+ contributeReplaceActions(menu, implicitlySelectedNodeList, includeOptions, validityChecking);
+ } else {
IMenuManager addTagMenu = new MyMenuManager(INSERT_TAG_MENU, true);
menu.add(addTagMenu);
}
@@ -171,10 +127,10 @@
public void contributeDeleteActionForVpe(IMenuManager menu, List selection) {
int editMode = modelQuery.getEditMode();
- int ic = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.INCLUDE_CHILD_NODES
+ int includeOptions = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.INCLUDE_CHILD_NODES
| ModelQuery.INCLUDE_SEQUENCE_GROUPS
: ModelQuery.INCLUDE_CHILD_NODES;
- int vc = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.VALIDITY_STRICT
+ int validityChecking = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.VALIDITY_STRICT
: ModelQuery.VALIDITY_NONE;
List implicitlySelectedNodeList = null;
@@ -184,7 +140,7 @@
menu.add(new Separator());
// contribute delete actions
- contributeDeleteActions(menu, implicitlySelectedNodeList, ic, vc);
+ contributeDeleteActions(menu, implicitlySelectedNodeList, includeOptions, validityChecking);
}
}
@@ -227,7 +183,7 @@
}
protected void contributeAddChildActions(IMenuManager menu, Node node,
- int ic, int vc) {
+ int includeOptions, int validityChecking) {
int nodeType = node.getNodeType();
if (nodeType == Node.ELEMENT_NODE) {
@@ -251,14 +207,14 @@
List modelQueryActionList = new ArrayList();
modelQuery
.getInsertActions(element, ed, -1,
- ModelQuery.INCLUDE_ATTRIBUTES, vc,
+ ModelQuery.INCLUDE_ATTRIBUTES, validityChecking,
modelQueryActionList);
addActionHelper(addAttributeMenu, modelQueryActionList, 2);
// add insert child node actions
//
modelQueryActionList = new ArrayList();
- modelQuery.getInsertActions(element, ed, -1, ic, vc,
+ modelQuery.getInsertActions(element, ed, -1, includeOptions, validityChecking,
modelQueryActionList);
addActionHelper(addChildMenu, modelQueryActionList, 2);
}
@@ -280,87 +236,17 @@
}
protected void contributeAddSiblingActions(IMenuManager menu, Node node,
- int ic, int vc, boolean visible) {
+ boolean visible) {
IMenuManager addAroundMenu = new MyMenuManager(INSERT_AROUND_MENU, visible);
IMenuManager addBeforeMenu = new MyMenuManager(INSERT_BEFORE_MENU, visible);
IMenuManager addAfterMenu = new MyMenuManager(INSERT_AFTER_MENU, visible);
menu.add(addAroundMenu);
menu.add(addBeforeMenu);
menu.add(addAfterMenu);
-
-// Node parentNode = node.getParentNode();
-// if (parentNode != null) {
-// int index = getIndex(parentNode, node);
-// if (textNodeSplitter != null)
-// index = textNodeSplitter.getSplitIndex(index);
-// if (parentNode.getNodeType() == Node.ELEMENT_NODE) {
-// Element parentElement = (Element) parentNode;
-// CMElementDeclaration parentED = modelQuery
-// .getCMElementDeclaration(parentElement);
-// if (parentED != null) {
-// // 'Add Before...' and 'Add After...' actions
-// //
-//
-// List modelQueryActionList = new ArrayList();
-// modelQuery.getInsertActions(parentElement, parentED, index,
-// ic, vc, modelQueryActionList);
-// modelQueryActionList = actionHelper
-// .modifyActionList(modelQueryActionList);
-// addActionHelper(addAroundMenu, modelQueryActionList, 1);
-//
-// modelQueryActionList = new ArrayList();
-// modelQuery.getInsertActions(parentElement, parentED, index,
-// ic, vc, modelQueryActionList);
-// addActionHelper(addBeforeMenu, modelQueryActionList, 2);
-//
-// modelQueryActionList = new ArrayList();
-// ActionHelper helper = new ActionHelper(
-// (ModelQueryImpl) modelQuery);
-// if (textNodeSplitter != null)
-// helper.getInsertActions(parentElement, parentED, index,
-// ic, vc, modelQueryActionList);
-// else
-// helper.getInsertActions(parentElement, parentED,
-// index + 1, ic, vc, modelQueryActionList);
-// addActionHelper(addAfterMenu, modelQueryActionList, 3);
-// }
-// contributeUnconstrainedAddElementAction(addBeforeMenu,
-// parentElement, parentED, index);
-// contributeUnconstrainedAddElementAction(addAfterMenu,
-// parentElement, parentED, index + 1);
-// } else if (parentNode.getNodeType() == Node.DOCUMENT_NODE) {
-// Document document = (Document) parentNode;
-// CMDocument cmDocument = modelQuery
-// .getCorrespondingCMDocument(parentNode);
-// if (cmDocument != null) {
-// // add possible root element insertions
-// //
-// List modelQueryActionList = new ArrayList();
-// modelQuery.getInsertActions(document, cmDocument, index,
-// ic, vc, modelQueryActionList);
-// modelQueryActionList = actionHelper
-// .modifyActionList(modelQueryActionList);
-// addActionHelper(addAroundMenu, modelQueryActionList, 1);
-//
-// modelQueryActionList = new ArrayList();
-// modelQuery.getInsertActions(document, cmDocument, index,
-// ic, vc, modelQueryActionList);
-// addActionHelper(addAfterMenu, modelQueryActionList, 2);
-//
-// modelQueryActionList = new ArrayList();
-// modelQuery.getInsertActions(document, cmDocument,
-// index + 1, ic, vc, modelQueryActionList);
-// addActionHelper(addAfterMenu, modelQueryActionList, 3);
-// }
-//
-// contributeUnconstrainedAddElementAction(addBeforeMenu, document, index);
-// contributeUnconstrainedAddElementAction(addAfterMenu, document, index + 1);
-// }
-// }
}
protected void contributeAddDocumentChildActions(IMenuManager menu,
- Document document, int ic, int vc) {
+ Document document) {
IMenuManager addChildMenu = new MyMenuManager(XMLCommonResources
.getInstance().getString("_UI_MENU_ADD_CHILD")); //$NON-NLS-1$
menu.add(addChildMenu);
@@ -373,7 +259,7 @@
}
protected void contributeReplaceActions(IMenuManager menu,
- List selectedNodeList, int ic, int vc) {
+ List selectedNodeList, int includeOptions, int validityChecking) {
// 'Replace With...' actions
//
//Fix for JBIDE-3428
@@ -393,7 +279,8 @@
if (parentED != null) {
List replaceActionList = new Vector();
modelQuery.getReplaceActions(parentElement, parentED,
- selectedNodeList, ic, vc, replaceActionList);
+ selectedNodeList, includeOptions, validityChecking,
+ replaceActionList);
addActionHelper(replaceWithMenu, replaceActionList, 2);
}
}
@@ -407,8 +294,8 @@
}
protected void contributeDeleteActions(IMenuManager menu, List list,
- int ic, int vc) {
- boolean canRemove = modelQuery.canRemove(list, vc);
+ int includeOptions, int validityChecking) {
+ boolean canRemove = modelQuery.canRemove(list, validityChecking);
// a delete action with an empty list will produce a disabled menu item
//
@@ -451,7 +338,9 @@
Element parentElement, CMElementDeclaration parentEd, int index) {
if (isUnconstrainedActionAllowed()) {
if (parentEd == null
- || parentEd.getProperty("isInferred") == Boolean.TRUE || (modelQuery.getEditMode() != ModelQuery.EDIT_MODE_CONSTRAINED_STRICT && isElementAllowed(parentEd))) { //$NON-NLS-1$
+ || parentEd.getProperty("isInferred") == Boolean.TRUE
+ || ( modelQuery.getEditMode() != ModelQuery.EDIT_MODE_CONSTRAINED_STRICT
+ && isElementAllowed(parentEd) )) { //$NON-NLS-1$
contributeAction(menu, createAddElementAction(parentElement,
null, index, 2));
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java 2009-04-25 15:59:55 UTC (rev 14925)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java 2009-04-25 18:40:08 UTC (rev 14926)
@@ -1,17 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2007-2008 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
+ * Copyright (c) 2007-2009 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 Contributor: Red Hat,
+ * Inc. - initial API and implementation
******************************************************************************/
-
package org.jboss.tools.vpe.editor.menu;
-import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.action.ContributionItem;
@@ -32,7 +28,7 @@
import org.jboss.tools.jst.web.tld.URIConstants;
import org.jboss.tools.vpe.editor.VpeEditorPart;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.menu.action.InsertAction;
+import org.jboss.tools.vpe.editor.menu.action.InsertAction2;
import org.jboss.tools.vpe.editor.util.Constants;
import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
import org.jboss.tools.vpe.editor.util.SelectionUtil;
@@ -42,46 +38,24 @@
/**
* @author Sergey Dzmitrovich
- *
+ *
*/
public class InsertContributionItem extends ContributionItem {
- private StructuredTextEditor sourceEditor;
-
- private VpePageContext pageContext;
-
- private final static String NAME_PROPERTY = "name"; //$NON-NLS-1$
-
- private final static String HIDDEN_PROPERTY = "hidden"; //$NON-NLS-1$
-
- private final static String ELEMENT_TYPE_PROPERTY = "element type"; //$NON-NLS-1$
-
- private final static String END_TEXT_PROPERTY = "end text";//$NON-NLS-1$
-
- private final static String TAG_ELEMENT_TYPE = "macro"; //$NON-NLS-1$
-
+ private final StructuredTextEditor sourceEditor;
+ private final VpePageContext pageContext;
+ private final static String NAME_PROPERTY = "name"; //$NON-NLS-1$
+ private final static String HIDDEN_PROPERTY = "hidden"; //$NON-NLS-1$
+ private final static String ELEMENT_TYPE_PROPERTY
+ = "element type"; //$NON-NLS-1$
+ private final static String END_TEXT_PROPERTY = "end text"; //$NON-NLS-1$
+ private final static String TAG_ELEMENT_TYPE = "macro"; //$NON-NLS-1$
private final static String TAGLIB_ELEMENT_TYPE = "sub-group"; //$NON-NLS-1$
+ private final static String LEFT_ANGLE_BRACKET = "<"; //$NON-NLS-1$
+ private final static String RIGHT_ANGLE_BRACKET = ">"; //$NON-NLS-1$
- private final static String LEFT_ANGLE_BRACKET = "<"; //$NON-NLS-1$
- private final static String RIGHT_ANGLE_BRACKET = ">"; //$NON-NLS-1$
-
- private static List<String> INSERT_ITEMS;
- static {
- INSERT_ITEMS = new ArrayList<String>();
- INSERT_ITEMS.add(VpeUIMessages.INSERT_AROUND); // id = 0
- INSERT_ITEMS.add(VpeUIMessages.INSERT_BEFORE); // id = 1
- INSERT_ITEMS.add(VpeUIMessages.INSERT_AFTER); // id = 2
- INSERT_ITEMS.add(VpeUIMessages.REPLACE_WITH); // id = 3
- }
-
- // ids correspond to order of items in INSERT_ITEMS
- private int INSERT_AROUND = 0;
- private int INSERT_BEFORE = 1;
- private int INSERT_AFTER = 2;
- private int REPLACE_WITH = 3;
-
public InsertContributionItem() {
- JSPMultiPageEditor editor = (JSPMultiPageEditor) PlatformUI
+ final JSPMultiPageEditor editor = (JSPMultiPageEditor) PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.getActiveEditor();
this.sourceEditor = editor.getSourceEditor();
@@ -97,199 +71,133 @@
@Override
public void fill(Menu menu, int index) {
-
- for (int i = 0; i < INSERT_ITEMS.size(); i++) {
-
- String itemName = INSERT_ITEMS.get(i);
-
- MenuItem item = new MenuItem(menu, SWT.CASCADE, index + i);
+ for (final InsertType insertItem : InsertType.values()) {
+ final String itemName = insertItem.getMessage();
+ final MenuItem item = new MenuItem(menu,
+ SWT.CASCADE, index + insertItem.ordinal());
item.setText(itemName);
- Menu paletteManu = new Menu(menu);
-
+ final Menu paletteManu = new Menu(menu);
item.setMenu(paletteManu);
- MenuManager paletteManuManager = new MenuManager(
+ final MenuManager paletteManuManager = new MenuManager(
VpeUIMessages.FROM_PALETTE);
+ final XModelObject model = ModelUtilities.getPreferenceModel()
+ .getByPath("%Palette%"); //$NON-NLS-1$
- XModelObject model = ModelUtilities.getPreferenceModel().getByPath(
- "%Palette%"); //$NON-NLS-1$
-
- paletteManuManager.addMenuListener(new InsertMenuListener(model, i,
- getSelectionRange(sourceEditor)));
-
+ paletteManuManager.addMenuListener(
+ new InsertMenuListener(model, insertItem));
paletteManuManager.setRemoveAllWhenShown(true);
-
paletteManuManager.fill(paletteManu, -1);
-
}
-
}
/**
- *
- * @param sourceEditor
- * @return
- */
- private Point getSelectionRange(StructuredTextEditor sourceEditor) {
-
- // IStructuredSelection selection = (IStructuredSelection) sourceEditor
- // .getSelectionProvider().getSelection();
-
- // Object[] selectedObjects = selection.toArray();
-
- // Node firstElement = (Node) selectedObjects[0];
- // Node endElement = (Node) selectedObjects[selectedObjects.length - 1];
-
- Point selectionRange = SelectionUtil
- .getSourceSelectionRange(sourceEditor);
-
- int start = selectionRange.x;
- int length = selectionRange.y;
-
- Node firstElement = SelectionUtil.getNodeBySourcePosition(sourceEditor,
- selectionRange.x);
- Node endElement = SelectionUtil.getNodeBySourcePosition(sourceEditor,
- selectionRange.x + selectionRange.y);
-
- if (firstElement != null)
- if (firstElement.getNodeType() == Node.TEXT_NODE)
- start = selectionRange.x;
- else
- start = NodesManagingUtil.getStartOffsetNode(firstElement);
-
- if (endElement != null)
- if (endElement.getNodeType() == Node.TEXT_NODE)
- length = selectionRange.x + selectionRange.y - start;
- else
- length = NodesManagingUtil.getEndOffsetNode(endElement) - start;
-
- return new Point(start, length);
-
- }
-
- /**
+ * Fills contextMenu at run-time.
+ *
* @author Sergey Dzmitrovich
- *
- * fill contextMenu run-time
- *
*/
public class InsertMenuListener implements IMenuListener {
- private XModelObject modelObject;
- private int typeAction;
- private Point selectionRange;
+ private final XModelObject modelObject;
+ private final InsertType insertionType;
- public InsertMenuListener(XModelObject modelObject, int typeAction,
- Point selectionRange) {
+ public InsertMenuListener(XModelObject modelObject,
+ InsertType insertionType) {
this.modelObject = modelObject;
- this.typeAction = typeAction;
- this.selectionRange = selectionRange;
+ this.insertionType = insertionType;
}
public void menuAboutToShow(IMenuManager manager) {
+ final XModelObject[] modelObjectChildren
+ = modelObject.getChildren();
- XModelObject[] modelObjects = modelObject.getChildren();
-
String prefix = null;
- if (TAGLIB_ELEMENT_TYPE.equals(modelObject
- .getAttributeValue(ELEMENT_TYPE_PROPERTY))) {
+ if (TAGLIB_ELEMENT_TYPE.equals(
+ modelObject.getAttributeValue(ELEMENT_TYPE_PROPERTY))) {
prefix = getPrefix(modelObject);
}
- for (int i = 0; i < modelObjects.length; i++) {
- if (Constants.YES_STRING.equals(modelObjects[i]
- .getAttributeValue(HIDDEN_PROPERTY))) {
+ for (final XModelObject modelObjectChild : modelObjectChildren) {
+ if (Constants.YES_STRING.equals(
+ modelObjectChild.getAttributeValue(HIDDEN_PROPERTY))) {
continue;
}
- if (TAG_ELEMENT_TYPE.equals(modelObjects[i]
+ if (TAG_ELEMENT_TYPE.equals(modelObjectChild
.getAttributeValue(ELEMENT_TYPE_PROPERTY))) {
- String endText = modelObjects[i]
+ final String endText = modelObjectChild
.getAttributeValue(END_TEXT_PROPERTY);
- if (!((typeAction == INSERT_AROUND) && ((endText == null) || (endText
- .length() == 0)))) {
+ if (insertionType != InsertType.INSERT_AROUND
+ || (endText != null && endText.length() > 0)) {
- if (typeAction == INSERT_BEFORE) {
- selectionRange.y = 0;
- } else if (typeAction == INSERT_AFTER) {
- selectionRange.x += selectionRange.y;
- selectionRange.y = 0;
- }
-
- String name = LEFT_ANGLE_BRACKET
- + (prefix == null || prefix.length() == 0 ? Constants.EMPTY
+ final String name = LEFT_ANGLE_BRACKET
+ + (prefix == null || prefix.length() == 0
+ ? Constants.EMPTY
: prefix + Constants.COLON)
- + modelObjects[i]
+ + modelObjectChild
.getAttributeValue(NAME_PROPERTY)
+ RIGHT_ANGLE_BRACKET;
- manager.add(new InsertAction(name, selectionRange,
- modelObjects[i], pageContext, sourceEditor,
- REPLACE_WITH == this.typeAction));
+ manager.add(new InsertAction2(name, modelObjectChild,
+ pageContext, sourceEditor, insertionType));
}
- }
-
- else {
- MenuManager subMenu = new InsertSubMenuManager(
- modelObjects[i].getAttributeValue(NAME_PROPERTY));
+ } else {
+ final MenuManager subMenu = new InsertSubMenuManager(
+ modelObjectChild.getAttributeValue(NAME_PROPERTY));
subMenu.setRemoveAllWhenShown(true);
subMenu.addMenuListener(new InsertMenuListener(
- modelObjects[i], typeAction, selectionRange));
+ modelObjectChild, insertionType));
manager.add(subMenu);
- subMenu.fill(((MenuManager) manager).getMenu(), -1);
-
+ subMenu.fill(( (MenuManager) manager).getMenu(), -1);
}
-
}
-
}
private String getPrefix(XModelObject modelObject) {
-
- List<TaglibData> taglibs = XmlUtil.getTaglibsForNode(
+ final List<TaglibData> taglibs = XmlUtil.getTaglibsForNode(
(Node) ((IStructuredSelection) sourceEditor
.getSelectionProvider().getSelection())
.getFirstElement(), pageContext);
- String uri = modelObject
+ final String uri = modelObject
.getAttributeValue(URIConstants.LIBRARY_URI);
String prefix = null;
- TaglibData sourceNodeTaglib = XmlUtil.getTaglibForURI(uri, taglibs);
+ final TaglibData sourceNodeTaglib = XmlUtil
+ .getTaglibForURI(uri, taglibs);
- if (sourceNodeTaglib == null)
+ if (sourceNodeTaglib == null) {
prefix = modelObject
.getAttributeValue(URIConstants.DEFAULT_PREFIX);
- else
+ } else {
prefix = sourceNodeTaglib.getPrefix();
+ }
return prefix;
}
-
}
/**
- * @author Sergey Dzmitrovich
+ * This class was created to override method isVisible.
+ * Because of it there is a possibility to fill context
+ * menu at run-time).
*
- * class was created to override method isVisible ( because of it
- * there is possibility to fill context menu run-time )
+ * @author Sergey Dzmitrovich
*/
public class InsertSubMenuManager extends MenuManager {
- @Override
- public boolean isVisible() {
- return true;
- }
-
public InsertSubMenuManager(String text) {
super(text);
}
+ @Override
+ public boolean isVisible() {
+ return true;
+ }
}
-
}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertType.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertType.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertType.java 2009-04-25 18:40:08 UTC (rev 14926)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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 Contributor: Red Hat,
+ * Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.menu;
+
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+
+/**
+ * Contains items for the VPE context menu.
+ *
+ * @author yradtsevich
+ */
+public enum InsertType {
+ INSERT_AROUND(VpeUIMessages.INSERT_AROUND),
+ INSERT_BEFORE(VpeUIMessages.INSERT_BEFORE),
+ INSERT_AFTER(VpeUIMessages.INSERT_AFTER),
+ REPLACE_WITH(VpeUIMessages.REPLACE_WITH),
+ INSERT_INTO(VpeUIMessages.INSERT_INTO);
+
+ private String message;
+
+ private InsertType(String message) {
+ this.message = message;
+ }
+ public String getMessage() {
+ return message;
+ }
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction.java 2009-04-25 15:59:55 UTC (rev 14925)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction.java 2009-04-25 18:40:08 UTC (rev 14926)
@@ -28,7 +28,9 @@
* Class is used to handle insert action.
*
* @author Igor Zhukov (izhukov(a)exadel.com)
+ * @deprecated use {@link InsertAction2} instead.
*/
+@Deprecated
public class InsertAction extends Action {
private XModelObject item;
private Point region;
@@ -45,8 +47,8 @@
* @param pageContext the VpePageContext element
* @param sourceEditor the StructuredTextEditor element
*/
- public InsertAction(String title, Point region, XModelObject item, VpePageContext pageContext,
- StructuredTextEditor sourceEditor) {
+ public InsertAction(String title, Point region, XModelObject item,
+ VpePageContext pageContext, StructuredTextEditor sourceEditor) {
this(title, region, item, pageContext, sourceEditor, false);
}
@@ -59,7 +61,8 @@
* @param pageContext the VpePageContext element
* @param sourceEditor the StructuredTextEditor element
*/
- public InsertAction(String title, Point region, XModelObject item, VpePageContext pageContext,
+ public InsertAction(String title, Point region,
+ XModelObject item, VpePageContext pageContext,
StructuredTextEditor sourceEditor, boolean replace) {
super(title);
this.item = item;
@@ -78,8 +81,12 @@
XModelObject parent = item.getParent();
String uri = (parent == null) ? Constants.EMPTY : parent.getAttributeValue(URIConstants.LIBRARY_URI);
- String libraryVersion = (parent == null) ? Constants.EMPTY : parent.getAttributeValue(URIConstants.LIBRARY_VERSION);
- String defaultPrefix = (parent == null) ? Constants.EMPTY : parent.getAttributeValue(URIConstants.DEFAULT_PREFIX);
+ String libraryVersion = (parent == null)
+ ? Constants.EMPTY
+ : parent.getAttributeValue(URIConstants.LIBRARY_VERSION);
+ String defaultPrefix = (parent == null)
+ ? Constants.EMPTY
+ : parent.getAttributeValue(URIConstants.DEFAULT_PREFIX);
/*
* Fixes https://jira.jboss.org/jira/browse/JBIDE-1363. Fixes
@@ -88,8 +95,10 @@
* instead of VpeSelectionProvider. It helps automatically update
* selection range after taglib insertion.
*/
- String startText = Constants.EMPTY + item.getAttributeValue("start text"); //$NON-NLS-1$
- String endText = Constants.EMPTY + item.getAttributeValue("end text"); //$NON-NLS-1$
+ String startText = Constants.EMPTY
+ + item.getAttributeValue("start text"); //$NON-NLS-1$
+ String endText = Constants.EMPTY
+ + item.getAttributeValue("end text"); //$NON-NLS-1$
if (region != null) {
if (this.replace) {
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction2.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction2.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction2.java 2009-04-25 18:40:08 UTC (rev 14926)
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.menu.action;
+
+import java.util.Properties;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
+import org.jboss.tools.jst.web.tld.TLDToPaletteHelper;
+import org.jboss.tools.jst.web.tld.URIConstants;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.menu.InsertType;
+import org.jboss.tools.vpe.editor.util.Constants;
+import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
+import org.jboss.tools.vpe.editor.util.SelectionUtil;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Class is used to handle insert action.
+ *
+ * @author Igor Zhukov (izhukov(a)exadel.com)
+ * @author yradtsevich
+ */
+public class InsertAction2 extends Action {
+
+ private final XModelObject item;
+ private final VpePageContext pageContext;
+ private final StructuredTextEditor sourceEditor;
+ private final InsertType insertType;
+
+ /**
+ * Constructor.
+ *
+ * @param title the name of the action
+ * @param region the Point object
+ * @param item XModelObject object
+ * @param pageContext the VpePageContext element
+ * @param sourceEditor the StructuredTextEditor element
+ * @param insertType the type of the action
+ */
+ public InsertAction2(String title, XModelObject item,
+ VpePageContext pageContext, StructuredTextEditor sourceEditor,
+ InsertType insertType) {
+ super(title);
+ this.item = item;
+ this.pageContext = pageContext;
+ this.sourceEditor = sourceEditor;
+ this.insertType = insertType;
+ }
+
+ /**
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ prepareInsertion();
+ doInsertion();
+ }
+
+ /**
+ * Sets the cursor to an appropriate position.
+ * If REPLACE_WITH action is selected, it removes the selected text.
+ */
+ private void prepareInsertion() {
+ final Point selectionRange = SelectionUtil
+ .getSourceSelectionRange(sourceEditor);
+ int start = selectionRange.x;
+ int length = selectionRange.y;
+
+ final Node firstNode = SelectionUtil
+ .getNodeBySourcePosition(sourceEditor, selectionRange.x);
+ final Node endNode = SelectionUtil
+ .getNodeBySourcePosition(sourceEditor,
+ selectionRange.x + selectionRange.y);
+
+ if (firstNode != null) {
+ if (firstNode.getNodeType() == Node.TEXT_NODE) {
+ start = selectionRange.x;
+ } else {
+ start = NodesManagingUtil.getStartOffsetNode(firstNode);
+ }
+ }
+
+ if (endNode != null) {
+ if (endNode.getNodeType() == Node.TEXT_NODE) {
+ length = (selectionRange.x - start) + selectionRange.y;
+ } else {
+ length = NodesManagingUtil.getEndOffsetNode(endNode) - start;
+ }
+ }
+
+ final int insertionStart;
+ final int insertionLength;
+ switch (insertType) {
+ case INSERT_BEFORE:
+ insertionStart = start;
+ insertionLength = 0;
+ break;
+ case INSERT_AFTER:
+ insertionStart = start + length;
+ insertionLength = 0;
+ break;
+ case INSERT_INTO:
+ if (endNode.getNodeType() == Node.ELEMENT_NODE) {
+ final Element endElement = (Element) endNode;
+ Node prevNode = endElement
+ .getOwnerDocument().createTextNode(""); //$NON-NLS-1$
+ try {
+ endElement.appendChild(prevNode);
+ } catch(DOMException e) {
+ prevNode = endElement;
+ }
+
+ insertionStart
+ = NodesManagingUtil.getEndOffsetNode(prevNode);
+ insertionLength = 0;
+ } else {
+ insertionStart = start + length;
+ insertionLength = 0;
+ }
+ break;
+ default:
+ insertionStart = start;
+ insertionLength = length;
+ break;
+ }
+
+ if (insertType == InsertType.REPLACE_WITH) {
+ getSourceEditor().getTextViewer().getTextWidget()
+ .replaceTextRange(insertionStart, insertionLength,
+ ""); //$NON-NLS-1$
+ } else {
+ // set source selection
+ SelectionUtil.setSourceSelection(pageContext,
+ insertionStart, insertionLength);
+ }
+ }
+
+ /**
+ * Inserts selected tag at the cursor.
+ */
+ private void doInsertion() {
+ String tagName = item.getAttributeValue("name"); //$NON-NLS-1$
+
+ XModelObject parent = item.getParent();
+ String uri = (parent == null)
+ ? Constants.EMPTY
+ : parent.getAttributeValue(URIConstants.LIBRARY_URI);
+ String libraryVersion = (parent == null)
+ ? Constants.EMPTY
+ : parent.getAttributeValue(URIConstants.LIBRARY_VERSION);
+ String defaultPrefix = (parent == null)
+ ? Constants.EMPTY
+ : parent.getAttributeValue(URIConstants.DEFAULT_PREFIX);
+
+ /*
+ * Fixes https://jira.jboss.org/jira/browse/JBIDE-1363. Fixes
+ * https://jira.jboss.org/jira/browse/JBIDE-2442. author:
+ * dmaliarevich StructuredSelectionProvider from source view is used
+ * instead of VpeSelectionProvider. It helps automatically update
+ * selection range after taglib insertion.
+ */
+ String startText = Constants.EMPTY
+ + item.getAttributeValue("start text"); //$NON-NLS-1$
+ String endText = Constants.EMPTY
+ + item.getAttributeValue("end text"); //$NON-NLS-1$
+
+
+ // Gets source editor's selection provider with updated text selection.
+ ISelectionProvider selProvider = sourceEditor.getSelectionProvider();
+
+ Properties p = new Properties();
+ p.setProperty("tag name", tagName); //$NON-NLS-1$
+ p.setProperty("start text", startText); //$NON-NLS-1$
+ p.setProperty("end text", endText); //$NON-NLS-1$
+ p.setProperty("automatically reformat tag body", //$NON-NLS-1$
+ item.getAttributeValue(
+ "automatically reformat tag body")); //$NON-NLS-1$
+ p.setProperty(URIConstants.LIBRARY_URI, uri);
+ p.setProperty(URIConstants.LIBRARY_VERSION, libraryVersion);
+ String addTaglib = item.getParent().getAttributeValue(
+ TLDToPaletteHelper.ADD_TAGLIB);
+ p.setProperty(URIConstants.DEFAULT_PREFIX, defaultPrefix);
+ p.setProperty(PaletteInsertHelper.PROPOPERTY_ADD_TAGLIB, addTaglib);
+ /*
+ * Added by Dzmitry Sakovich Fix for JBIDE-1626
+ */
+ // if(((Node)region).getNodeType() == Node.ELEMENT_NODE)
+ p.put("selectionProvider", selProvider); //$NON-NLS-1$
+ PaletteInsertHelper.insertIntoEditor(sourceEditor.getTextViewer(), p);
+ }
+
+ /**
+ * @return the pageContext
+ */
+ protected VpePageContext getPageContext() {
+ return pageContext;
+ }
+
+ /**
+ * @return the sourceEditor
+ */
+ protected StructuredTextEditor getSourceEditor() {
+ return sourceEditor;
+ }
+
+
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2009-04-25 15:59:55 UTC (rev 14925)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2009-04-25 18:40:08 UTC (rev 14926)
@@ -83,6 +83,7 @@
public static String INSERT_AROUND;
public static String INSERT_BEFORE;
public static String INSERT_AFTER;
+ public static String INSERT_INTO;
public static String REPLACE_WITH;
public static String FROM_PALETTE;
public static String PAGE_DESIGN_OPTIONS_ABOUT;
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2009-04-25 15:59:55 UTC (rev 14925)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2009-04-25 18:40:08 UTC (rev 14926)
@@ -64,6 +64,7 @@
INSERT_BEFORE=Insert Before
INSERT_AFTER=Insert After
REPLACE_WITH=Replace With
+INSERT_INTO=Insert Into
FROM_PALETTE=From Palette
PAGE_DESIGN_OPTIONS_ABOUT=Here you can configure Visual Page Editor options, which will be used for generating a preview
ACTUAL_RUN_TIME_FOLDERS_ABOUT=These options will be used by Visual Page Editor for replacing absolute and relative path values when generating a preview
16 years, 11 months
JBoss Tools SVN: r14925 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-04-25 11:59:55 -0400 (Sat, 25 Apr 2009)
New Revision: 14925
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java
Log:
JBIDE-4235
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java 2009-04-25 15:16:10 UTC (rev 14924)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java 2009-04-25 15:59:55 UTC (rev 14925)
@@ -22,6 +22,9 @@
package org.hibernate.eclipse.console.views;
+import java.io.FileNotFoundException;
+
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@@ -40,6 +43,7 @@
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.part.ViewPart;
@@ -161,6 +165,13 @@
if(consoleConfiguration.isSessionFactoryCreated() ) {
String hql = node.getHQL();
if(StringHelper.isNotEmpty( hql )) {
+ try {
+ if (getSite() != null && getSite().getPage() != null) {
+ getSite().getPage().showView(QueryPageTabView.ID);
+ }
+ } catch (PartInitException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("Can't show QueryPageTabView.", e); //$NON-NLS-1$
+ }
consoleConfiguration.executeHQLQuery( hql );
}
}
@@ -173,9 +184,13 @@
IEditorPart res = null;
try {
res = OpenMappingAction.run(path, consoleConfiguration);
- } catch (Exception e) {
+ } catch (PartInitException e) {
HibernateConsolePlugin.getDefault().logErrorMessage("Can't find mapping file.", e); //$NON-NLS-1$
- }
+ } catch (JavaModelException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("Can't find mapping file.", e); //$NON-NLS-1$
+ } catch (FileNotFoundException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("Can't find mapping file.", e); //$NON-NLS-1$
+ }
}
else {
for (int i = 0; i < paths.length; i++) {
16 years, 11 months