JBoss Tools SVN: r23824 - in trunk/vpe: tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: dvinnichek
Date: 2010-07-30 04:45:26 -0400 (Fri, 30 Jul 2010)
New Revision: 23824
Added:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp.xml
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/FormBean.java
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/FieldValidator.java
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/src/org/jboss/tools/vpe/spring/test/SpringFormComponentTest.java
Log:
add tests for form:errors tag
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml 2010-07-30 08:33:03 UTC (rev 23823)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml 2010-07-30 08:45:26 UTC (rev 23824)
@@ -93,8 +93,18 @@
</vpe:tag>
<vpe:tag name="form:errors" case-sensitive="yes">
+ <vpe:if test="@path='*'">
+ <vpe:template children="no" modify="no">
+ <span id="{@id}" style="{@cssStyle}" class="{@cssClass}">
+ Errors for all validated fields.
+ </span>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:if>
<vpe:template children="no" modify="no">
- <span id="{@id}" style="{@cssStyle}" class="{@cssClass}">
+ <span id="{@id}" style="{@cssStyle}" class="{@cssClass}">
<vpe:value expr="Errors for {@path} field." />
</span>
<vpe:dnd>
Modified: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/FormBean.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/FormBean.java 2010-07-30 08:33:03 UTC (rev 23823)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/FormBean.java 2010-07-30 08:45:26 UTC (rev 23824)
@@ -8,6 +8,7 @@
import java.util.Set;
import org.jboss.tools.vpe.spring.test.springtest.data.CategoryType;
+import org.jboss.tools.vpe.spring.test.springtest.data.User;
public class FormBean {
@@ -19,7 +20,7 @@
private Set<Integer> selectedCategories = new HashSet<Integer>();
private List<CategoryType> favoriteCategories = new ArrayList<CategoryType>();
- private String newName;
+ private User user;
public FormBean() {
for (CategoryType categoryType : CategoryType.values()) {
@@ -78,11 +79,11 @@
this.favoriteCategories = favoriteCategories;
}
- public String getNewName() {
- return newName;
+ public User getUser() {
+ return user;
}
- public void setNewName(String newName) {
- this.newName = newName;
+ public void setUser(User user) {
+ this.user = user;
}
}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/FieldValidator.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/FieldValidator.java 2010-07-30 08:33:03 UTC (rev 23823)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/FieldValidator.java 2010-07-30 08:45:26 UTC (rev 23824)
@@ -11,6 +11,7 @@
}
public void validate(Object target, Errors errors) {
- ValidationUtils.rejectIfEmptyOrWhitespace(errors, "newName", "required","Name is required.");
+ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "user.firstName", "required", "First Name is required.");
+ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "user.lastName", "required", "Last Name is required.");
}
}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp 2010-07-30 08:33:03 UTC (rev 23823)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp 2010-07-30 08:45:26 UTC (rev 23824)
@@ -12,31 +12,29 @@
<h1>Test of form:errors</h1>
<form:form commandName="formBean" method="POST">
+ <form:errors id="allFieldsErrors" path="*" />
<table>
<tr>
- <td />
- <%-- Show errors for newName field --%>
+ <td>First Name:</td>
+ <td><form:input path="user.firstName" /></td>
<td>
- <form:errors id="nameErrors1" path="newName" />
- </td>
+ <form:errors id="firstNameErrors"
+ path="user.firstName"
+ cssClass="red-bordered-text" />
+ </td>
</tr>
<tr>
- <td />
- <%-- Show errors for newName field --%>
+ <td>Last Name:</td>
+ <td><form:input path="user.lastName" /></td>
<td>
- <form:errors id="nameErrors2" path="newName"
- cssClass="red-bordered-text"
- cssStyle="color: green;" />
- </td>
+ <form:errors id="lastNameErrors"
+ path="user.lastName"
+ cssStyle="color: red;" />
+ </td>
</tr>
<tr>
- <td>New Name:</td>
- <td><form:input path="newName" /></td>
+ <td colspan="2" align="right"><input type="submit" value="Test" /></td>
</tr>
- <tr>
- <td/>
- <td align="right"><input type="submit" value="Test" /></td>
- </tr>
</table>
</form:form>
</body>
Added: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp.xml
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp.xml (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp.xml 2010-07-30 08:45:26 UTC (rev 23824)
@@ -0,0 +1,17 @@
+<tests>
+ <test id="allFieldsErrors">
+ <span id="allFieldsErrors">
+ Errors for all validated fields.
+ </span>
+ </test>
+ <test id="firstNameErrors">
+ <span id="firstNameErrors" class="red-bordered-text">
+ Errors for user.firstName field.
+ </span>
+ </test>
+ <test id="nameErrors2">
+ <span id="lastNameErrors" style="color: red;">
+ Errors for user.lastName field.
+ </span>
+ </test>
+</tests>
\ No newline at end of file
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Modified: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/src/org/jboss/tools/vpe/spring/test/SpringFormComponentTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/src/org/jboss/tools/vpe/spring/test/SpringFormComponentTest.java 2010-07-30 08:33:03 UTC (rev 23823)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/src/org/jboss/tools/vpe/spring/test/SpringFormComponentTest.java 2010-07-30 08:45:26 UTC (rev 23824)
@@ -42,4 +42,9 @@
performTestForVpeComponent((IFile)TestUtil.getResource(
"src/main/webapp/WEB-INF/jsp/form.jsp", IMPORT_PROJECT_NAME)); //$NON-NLS-1$
}
+
+ public void testErrors() throws Throwable {
+ performTestForVpeComponent((IFile)TestUtil.getResource(
+ "src/main/webapp/WEB-INF/jsp/errors.jsp", IMPORT_PROJECT_NAME)); //$NON-NLS-1$
+ }
}
14 years, 5 months
JBoss Tools SVN: r23823 - trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2010-07-30 04:33:03 -0400 (Fri, 30 Jul 2010)
New Revision: 23823
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml
Log:
https://jira.jboss.org/browse/JBIDE-6711
- form:options template is added
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml 2010-07-30 08:20:18 UTC (rev 23822)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml 2010-07-30 08:33:03 UTC (rev 23823)
@@ -153,7 +153,7 @@
</vpe:template>
</vpe:tag>
- <vpe:tag name="form:option" case-sensitive="yes">
+ <vpe:tag name="form:option" case-sensitive="yes">
<vpe:if test="@disabled='true'">
<vpe:template children="yes" modify="yes">
<option id="{@id}" class="{@cssClass}" style="{@cssStyle}"
@@ -169,6 +169,39 @@
</option>
</vpe:template>
</vpe:tag>
+
+ <vpe:tag name="form:options" case-sensitive="yes">
+ <vpe:if test="@disabled='true'">
+ <vpe:if test="attrpresent('itemLabel')">
+ <vpe:template children="yes" modify="yes">
+ <option id="{@id}" class="{@cssClass}" style="{@cssStyle}"
+ dir="{@dir}" disabled="disabled">
+ <vpe:value expr="{@items}.{(a)itemLabel}" />
+ </option>
+ </vpe:template>
+ </vpe:if>
+ <vpe:template children="yes" modify="yes">
+ <option id="{@id}" class="{@cssClass}" style="{@cssStyle}"
+ dir="{@dir}" disabled="disabled">
+ <vpe:value expr="{@items}" />
+ </option>
+ </vpe:template>
+ </vpe:if>
+ <vpe:if test="attrpresent('itemLabel')">
+ <vpe:template children="yes" modify="yes">
+ <option id="{@id}" class="{@cssClass}" style="{@cssStyle}"
+ dir="{@dir}">
+ <vpe:value expr="{@items}.{(a)itemLabel}" />
+ </option>
+ </vpe:template>
+ </vpe:if>
+ <vpe:template children="yes" modify="yes">
+ <option id="{@id}" class="{@cssClass}" style="{@cssStyle}"
+ dir="{@dir}">
+ <vpe:value expr="{@items}" />
+ </option>
+ </vpe:template>
+ </vpe:tag>
<vpe:tag name="form:textarea" case-sensitive="no">
<vpe:template children="yes" modify="yes"
14 years, 5 months
JBoss Tools SVN: r23822 - in branches/smooks-dmb/plugins: org.jboss.tools.smooks.ui/META-INF and 5 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2010-07-30 04:20:18 -0400 (Fri, 30 Jul 2010)
New Revision: 23822
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IFieldMarker.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AbstractProcessGraphAction.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddNextTaskNodeAction.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddTaskNodeAction.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/DeleteTaskNodeAction.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/TaskTypeRules.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/ITaskNodeProvider.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/ProcessGraphContentProvider.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksTaskDetailsEditorSite.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/TaskTypeManager.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/IProcessProvider.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessFactory.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessGraphicalViewerLabelProvider.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessTaskAnalyzer.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessType.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessTypeImpl.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskNodeFigure.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskType.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskTypeImpl.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TemplateAppyTaskNode.java
Modified:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ecore.model/META-INF/MANIFEST.MF
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java
Log:
Modified: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ecore.model/META-INF/MANIFEST.MF
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ecore.model/META-INF/MANIFEST.MF 2010-07-30 07:57:07 UTC (rev 23821)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ecore.model/META-INF/MANIFEST.MF 2010-07-30 08:20:18 UTC (rev 23822)
@@ -11,7 +11,8 @@
org.jboss.tools.smooks.runtime,
org.eclipse.emf.ecore
Export-Package: org.jboss.tools.smooks.model,
- org.jboss.tools.smooks.model.core
+ org.jboss.tools.smooks.model.core,
+ org.jboss.tools.smooks.model.javabean
Bundle-ClassPath: .,
libs/commons-beanutils-1.8.3.jar,
libs/commons-beanutils-bean-collections-1.8.3.jar,
Modified: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2010-07-30 07:57:07 UTC (rev 23821)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2010-07-30 08:20:18 UTC (rev 23822)
@@ -16,7 +16,9 @@
org.eclipse.wst.sse.ui,
org.eclipse.emf.common,
org.jboss.tools.smooks.runtime,
- org.eclipse.emf.edit
+ org.eclipse.emf.edit,
+ org.eclipse.zest.core;bundle-version="1.2.0",
+ org.eclipse.zest.layouts;bundle-version="1.1.0"
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IFieldMarker.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IFieldMarker.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IFieldMarker.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.configuration.editors;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public interface IFieldMarker {
+
+ int TYPE_ERROR = 1;
+
+ int TYPE_WARINING = 2;
+
+ int TYPE_NONE = 0;
+
+ void setMessage(String message);
+
+ void setMarkerType(int type);
+
+ int getMarkerType();
+
+ String getMessage();
+
+ void clean();
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IFieldMarker.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java 2010-07-30 07:57:07 UTC (rev 23821)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -6,6 +6,7 @@
import org.eclipse.ui.PartInitException;
import org.jboss.tools.smooks.dbm.editor.SmooksConfigurationFormPage;
import org.jboss.tools.smooks.editor.AbstractSmooksFormEditor;
+import org.jboss.tools.smooks.graphical.editors.SmooksProcessGraphicalEditor;
/**
* @author Dart
@@ -18,7 +19,7 @@
@Override
protected void addPages() {
-
+ addProcessGraphicalEditor();
optionsPage = createSmooksConfigurationOverviewPage();
addSourceSynchronizeListener(optionsPage);
addSmooksEditorInitListener(optionsPage);
@@ -37,4 +38,18 @@
"options_page", Messages.SmooksMultiFormEditor_optinepage_name, this); //$NON-NLS-1$
}
+ private void addProcessGraphicalEditor() {
+ SmooksProcessGraphicalEditor processPage = new SmooksProcessGraphicalEditor(this,
+ "process", Messages.SmooksMultiFormEditor_processpage_name, this); //$NON-NLS-1$
+// addSourceSynchronizeListener(processPage);
+// addValidateListener(processPage);
+// addSmooksEditorInitListener(processPage);
+ try {
+ int index = this.addPage(processPage);
+ setPageText(index, Messages.SmooksMultiFormEditor_processtabel_label);
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ }
+
}
Modified: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java 2010-07-30 07:57:07 UTC (rev 23821)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -99,6 +99,7 @@
resourceChangeListener = new SmooksResourceTraker();
xmlDocumentTraker = new SmooksXMLEditorDocumentListener();
smooksEditorModelBuilder = new SmooksEditorModelBuilder();
+ initEditingDomain();
}
private void handleCommandStack(CommandStack commandStack) {
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AbstractProcessGraphAction.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AbstractProcessGraphAction.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AbstractProcessGraphAction.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * 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.graphical.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.IEditorPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.graphical.editors.process.TaskType;
+
+/**
+ * @author Dart
+ *
+ */
+public abstract class AbstractProcessGraphAction extends Action implements ISelectionChangedListener{
+
+ protected ISmooksModelProvider provider;
+
+ protected ISelection currentSelection = null;
+
+ protected IEditorPart editorPart;
+
+ public AbstractProcessGraphAction(String text , ISmooksModelProvider provider , IEditorPart editorPart){
+ super();
+ this.editorPart = editorPart;
+ this.provider = provider;
+ this.setText(text);
+ init();
+ }
+
+ protected void init(){
+
+ }
+
+ @Override
+ public void run() {
+ super.run();
+ }
+
+ public void update(){
+
+ }
+
+ public ISmooksModelProvider getProvider() {
+ return provider;
+ }
+
+ public void setProvider(ISmooksModelProvider provider) {
+ this.provider = provider;
+ }
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ currentSelection = event.getSelection();
+ update();
+ }
+
+ protected List<TaskType> getCurrentSelectedTask(){
+ if(currentSelection != null){
+ List<TaskType> selectedTasks = new ArrayList<TaskType>();
+ List<?> selections = ((IStructuredSelection)currentSelection).toList();
+ for (Iterator<?> iterator = selections.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ if(object != null && object instanceof TaskType){
+ selectedTasks.add((TaskType)object);
+ }
+ }
+ return selectedTasks;
+ }
+ return null;
+ }
+
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AbstractProcessGraphAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddNextTaskNodeAction.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddNextTaskNodeAction.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddNextTaskNodeAction.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * 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.graphical.actions;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.ui.IEditorPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.graphical.editors.TaskTypeManager;
+import org.jboss.tools.smooks.graphical.editors.process.ProcessFactory;
+import org.jboss.tools.smooks.graphical.editors.process.TaskType;
+import org.jboss.tools.smooks.model.SmooksModel;
+import org.milyn.javabean.dynamic.Model;
+
+/**
+ * @author Dart
+ *
+ */
+public class AddNextTaskNodeAction extends AddTaskNodeAction {
+
+ public AddNextTaskNodeAction(String taskID, String text, ISmooksModelProvider provider, IEditorPart editor) {
+ super(taskID, text, provider, editor);
+ }
+
+ @Override
+ protected void init() {
+ super.init();
+ }
+
+ protected void addFreemarkerTemplateTask(IWizard currentWizard, Model<SmooksModel> resourceList) {
+// if (currentWizard instanceof FreemarkerTemplateParametersProvider) {
+//
+// Freemarker freemarker = FreemarkerFactory.eINSTANCE.createFreemarker();
+//
+// Map<String, String> parameters = ((FreemarkerTemplateParametersProvider) currentWizard).getParameters();
+// Iterator<String> keys = parameters.keySet().iterator();
+// while (keys.hasNext()) {
+// String key = keys.next();
+// String value = parameters.get(key);
+//
+// ParamType param = SmooksFactory.eINSTANCE.createParamType();
+// param.setName(key);
+// param.setStringValue(value);
+//
+// freemarker.getParam().add(param);
+// }
+//
+// String type = ((FreemarkerTemplateParametersProvider) currentWizard).getTemplateType();
+// if (type != null) {
+// ParamType param = SmooksFactory.eINSTANCE.createParamType();
+// param.setName(SmooksModelUtils.KEY_TEMPLATE_TYPE);
+// param.setStringValue(type);
+// freemarker.getParam().add(param);
+// }
+//
+// Command addFreemarkerCommand = AddCommand.create(this.provider.getEditingDomain(), resourceList,
+// SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_RESOURCE_CONFIG_GROUP, FeatureMapUtil
+// .createEntry(FreemarkerPackage.Literals.DOCUMENT_ROOT__FREEMARKER, freemarker));
+//
+// if (addFreemarkerCommand.canExecute()) {
+// provider.getEditingDomain().getCommandStack().execute(addFreemarkerCommand);
+// TaskType parentTask = this.getCurrentSelectedTask().get(0);
+// TaskType childTask = ProcessFactory.eINSTANCE.createTemplateTask();
+// childTask.addSmooksModel(freemarker);
+// childTask.setType(type);
+// parentTask.addTask(childTask);
+// }
+// }
+ }
+
+ @Override
+ public void run() {
+ super.run();
+ if (this.provider != null) {
+ Model<SmooksModel> root = provider.getSmooksModel();
+// SmooksResourceListType resourceList = SmooksUIUtils.getSmooks11ResourceListType(provider.getSmooksModel());
+ if (taskID.equals(TaskTypeManager.TASK_ID_FREEMARKER_CSV_TEMPLATE)) {
+ // open wizard
+// TemplateMessageTypeWizard wizard = new TemplateMessageTypeWizard();
+// WizardDialog dialog = new WizardDialog(editorPart.getSite().getShell(), wizard);
+// if (dialog.open() == Dialog.OK) {
+// // init freemarker model
+// IWizard currentWizard = wizard.getWizard();
+// addFreemarkerTemplateTask(currentWizard, root);
+// } else {
+// return;
+// }
+ } else {
+ TaskType parentTask = this.getCurrentSelectedTask().get(0);
+ TaskType childTask = ProcessFactory.eINSTANCE.createTaskType();
+ childTask.setId(taskID);
+ childTask.setName(TaskTypeManager.getTaskLabel(childTask));
+ parentTask.addTask(childTask);
+ }
+ }
+ }
+
+ protected TaskType createTaskType() {
+ return ProcessFactory.eINSTANCE.createTaskType();
+ }
+
+ @Override
+ public void update() {
+ try{
+ super.update();
+ if (this.isEnabled()) {
+ TaskType testTaskType = ProcessFactory.eINSTANCE.createTaskType();
+ testTaskType.setId(taskID);
+ setEnabled(rules.isNextTask(this.getCurrentSelectedTask().get(0), testTaskType));
+ }
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ }
+
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddNextTaskNodeAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddTaskNodeAction.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddTaskNodeAction.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddTaskNodeAction.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,45 @@
+package org.jboss.tools.smooks.graphical.actions;
+
+import org.eclipse.ui.IEditorPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.graphical.editors.TaskTypeManager;
+import org.jboss.tools.smooks.graphical.editors.process.TaskType;
+
+public class AddTaskNodeAction extends AbstractProcessGraphAction {
+
+ protected String taskID = null;
+
+
+ protected TaskTypeRules rules = new TaskTypeRules();
+
+ public AddTaskNodeAction(String taskID, String text, ISmooksModelProvider provider, IEditorPart editorPart) {
+ super(text, provider,editorPart);
+ this.taskID = taskID;
+ }
+
+ @Override
+ protected void init() {
+ // TODO Auto-generated method stub
+ super.init();
+ }
+
+ @Override
+ public void run() {
+ // TODO Auto-generated method stub
+ super.run();
+ }
+
+ @Override
+ public void update() {
+ this.setEnabled(false);
+ if (this.getCurrentSelectedTask() != null && this.getCurrentSelectedTask().size() == 1) {
+ TaskType currentTask = this.getCurrentSelectedTask().get(0);
+ String taskID = currentTask.getId();
+ if (taskID != null) {
+ if (taskID.equals(TaskTypeManager.TASK_ID_INPUT) || taskID.equals(TaskTypeManager.TASK_ID_JAVA_MAPPING))
+ this.setEnabled(true);
+ }
+ }
+ }
+
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddTaskNodeAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/DeleteTaskNodeAction.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/DeleteTaskNodeAction.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/DeleteTaskNodeAction.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * 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.graphical.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.graphical.editors.TaskTypeManager;
+import org.jboss.tools.smooks.graphical.editors.process.IProcessProvider;
+import org.jboss.tools.smooks.graphical.editors.process.ProcessType;
+import org.jboss.tools.smooks.graphical.editors.process.TaskType;
+
+/**
+ * @author Dart
+ *
+ */
+public class DeleteTaskNodeAction extends AbstractProcessGraphAction {
+
+ private IProcessProvider processProvider;
+
+ public DeleteTaskNodeAction(IProcessProvider processProvider, ISmooksModelProvider modelProvider, IEditorPart editor) {
+ super(Messages.DeleteTaskNodeAction_Action_Delete, modelProvider, editor);
+ this.processProvider = processProvider;
+ }
+
+ @Override
+ protected void init() {
+ super.init();
+ ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
+ setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+ }
+
+ @Override
+ public void update() {
+ List<TaskType> taskList = this.getCurrentSelectedTask();
+ if (!taskList.isEmpty() && taskList.size() == 1) {
+ TaskType task = taskList.get(0);
+ if (TaskTypeManager.TASK_ID_INPUT.equals(task.getId())) {
+ this.setEnabled(false);
+ return;
+ }
+ }
+ this.setEnabled((taskList != null && !taskList.isEmpty() && taskList.size() == 1));
+ }
+
+ @Override
+ public void run() {
+ super.run();
+// if (getProvider() != null) {
+// if (processProvider != null) {
+// ProcessType process = processProvider.getProcess();
+// if (process != null) {
+// List<TaskType> currentTasks = getCurrentSelectedTask();
+// TaskType currentTask = currentTasks.get(0);
+// List<TaskType> allTask = new ArrayList<TaskType>();
+// SmooksUIUtils.fillAllTask(currentTask, allTask);
+// List<Object> associatedElements = new ArrayList<Object>();
+// SmooksResourceListType listType = SmooksUIUtils.getSmooks11ResourceListType(provider
+// .getSmooksModel());
+// if (listType != null) {
+// for (Iterator<?> iterator = allTask.iterator(); iterator.hasNext();) {
+// TaskType taskType = (TaskType) iterator.next();
+// List<Object> elements = TaskTypeManager.getAssociatedSmooksElements(taskType, listType);
+// if (elements != null && !elements.isEmpty()) {
+// associatedElements.addAll(elements);
+// }
+// }
+// }
+// Command remove = null;
+// if (associatedElements.isEmpty()) {
+// Object parent = currentTask.getParent();
+// if (parent instanceof Process) {
+// ((ProcessType) parent).removeTask(currentTask);
+// }
+// if (parent instanceof TaskType) {
+// ((TaskType) parent).removeTask(currentTask);
+// }
+// } else {
+// associatedElements = getDeletedObjects(associatedElements);
+// CompoundCommand ccommand = new CompoundCommand();
+// // Command removeTaskCommand =
+// // RemoveCommand.create(p.getEditingDomain(),
+// // currentTask.eContainer(),
+// // GraphPackage.Literals.TASK_TYPE__TASK, currentTask);
+// // if (removeTaskCommand.canExecute()) {
+// // ccommand.append(removeTaskCommand);
+// // }
+// remove = RemoveCommand.create(this.provider.getEditingDomain(), listType,
+// SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_RESOURCE_CONFIG_GROUP,
+// associatedElements);
+// if (remove.canExecute()) {
+// ccommand.append(remove);
+// Object parent = currentTask.getParent();
+// if (parent instanceof Process) {
+// ((ProcessType) parent).removeTask(currentTask);
+// }
+// if (parent instanceof TaskType) {
+// ((TaskType) parent).removeTask(currentTask);
+// }
+// }
+// provider.getEditingDomain().getCommandStack().execute(ccommand);
+// }
+// }
+// }
+// }
+ }
+
+ private List<Object> getDeletedObjects(List<Object> deletingObjects) {
+ List<Object> objs = new ArrayList<Object>();
+// for (Iterator<?> iterator = deletingObjects.iterator(); iterator.hasNext();) {
+// Object object = (Object) iterator.next();
+// EStructuralFeature feature = SmooksUIUtils.getFeature(object);
+// if (feature != null) {
+// object = FeatureMapUtil.createEntry(feature, object);
+// }
+// objs.add(object);
+// }
+ return objs;
+ }
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/DeleteTaskNodeAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/TaskTypeRules.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/TaskTypeRules.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/TaskTypeRules.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * 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.graphical.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.tools.smooks.graphical.editors.TaskTypeManager;
+import org.jboss.tools.smooks.graphical.editors.process.ProcessType;
+import org.jboss.tools.smooks.graphical.editors.process.TaskType;
+
+/**
+ * @author Dart
+ *
+ */
+public class TaskTypeRules {
+
+ public static void fillAllTask(TaskType task, List<TaskType> taskList) {
+ taskList.add(task);
+ List<TaskType> children = task.getTask();
+ for (Iterator<?> iterator = children.iterator(); iterator.hasNext();) {
+ TaskType taskType = (TaskType) iterator.next();
+ fillAllTask(taskType, taskList);
+ }
+ }
+
+ public boolean isNextTask(TaskType currentTask, TaskType testTask) {
+ TaskType parentTask = testTask;
+ String parentID = parentTask.getId();
+
+ Object parent = currentTask;
+ while (!(parent instanceof ProcessType) && parent != null) {
+ if (parent instanceof TaskType) {
+ parent = ((TaskType) parent).getParent();
+ }
+ }
+
+ if(parent == null) return false;
+
+ List<TaskType> currentList = ((ProcessType) parent).getTask();
+ List<TaskType> taskList = new ArrayList<TaskType>();
+ for (Iterator<?> iterator = currentList.iterator(); iterator.hasNext();) {
+ TaskType taskType = (TaskType) iterator.next();
+ TaskTypeRules.fillAllTask(taskType, taskList);
+ }
+
+ if (parentID.equals(TaskTypeManager.TASK_ID_INPUT)) {
+ // if (!SmooksConstants.TASK_ID_JAVA_MAPPING.equals(taskID))
+ return false;
+ }
+ if (parentID.equals(TaskTypeManager.TASK_ID_FREEMARKER_CSV_TEMPLATE)) {
+ if (!TaskTypeManager.TASK_ID_JAVA_MAPPING.equals(currentTask.getId())) {
+ return false;
+ }else{
+ for (Iterator<?> iterator = taskList.iterator(); iterator.hasNext();) {
+ TaskType taskType = (TaskType) iterator.next();
+ if (TaskTypeManager.TASK_ID_FREEMARKER_CSV_TEMPLATE.equals(taskType.getId())) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ if (parentID.equals(TaskTypeManager.TASK_ID_JAVA_MAPPING)) {
+ if (!TaskTypeManager.TASK_ID_INPUT.equals(currentTask.getId())) {
+ return false;
+ } else {
+ for (Iterator<?> iterator = taskList.iterator(); iterator.hasNext();) {
+ TaskType taskType = (TaskType) iterator.next();
+ if (TaskTypeManager.TASK_ID_JAVA_MAPPING.equals(taskType.getId())) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isPreTask(TaskType currentTask, TaskType testTask) {
+ TaskType parentTask = testTask;
+ String currentTaskID = parentTask.getId();
+ if (currentTaskID.equals(TaskTypeManager.TASK_ID_INPUT)) {
+ if (!TaskTypeManager.TASK_ID_JAVA_MAPPING.equals(currentTask.getId())) {
+ return false;
+ } else {
+ List<?> taskList = parentTask.getTask();
+ for (Iterator<?> iterator = taskList.iterator(); iterator.hasNext();) {
+ TaskType object = (TaskType) iterator.next();
+ if (TaskTypeManager.TASK_ID_JAVA_MAPPING.equals(object.getId())) {
+ return false;
+ }
+ }
+ }
+ }
+ if (currentTaskID.equals(TaskTypeManager.TASK_ID_JAVA_MAPPING)) {
+ // if (!SmooksConstants.TASK_ID_JAVA_MAPPING.equals(taskID))
+ return false;
+ }
+ return true;
+ }
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/TaskTypeRules.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/ITaskNodeProvider.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/ITaskNodeProvider.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/ITaskNodeProvider.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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.graphical.editors;
+
+import org.jboss.tools.smooks.graphical.editors.process.TaskType;
+
+/**
+ * @author Dart
+ *
+ */
+public interface ITaskNodeProvider {
+
+ public TaskType getTaskType();
+
+ public void setTaskType(TaskType taskType);
+
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/ITaskNodeProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/ProcessGraphContentProvider.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/ProcessGraphContentProvider.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/ProcessGraphContentProvider.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * 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.graphical.editors;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.zest.core.viewers.IGraphEntityContentProvider;
+import org.jboss.tools.smooks.graphical.editors.process.ProcessType;
+import org.jboss.tools.smooks.graphical.editors.process.TaskType;
+
+/**
+ * @author Dart
+ *
+ */
+public class ProcessGraphContentProvider implements IGraphEntityContentProvider {
+
+ private void collectTasks(List<Object> list, TaskType task) {
+ list.add(task);
+ List<?> tasks = task.getTask();
+ for (Iterator<?> iterator = tasks.iterator(); iterator.hasNext();) {
+ TaskType t = (TaskType) iterator.next();
+ collectTasks(list, t);
+ }
+ }
+
+ private void collectObjects(List<Object> list, ProcessType process) {
+ List<?> tasks = process.getTask();
+ for (Iterator<?> iterator = tasks.iterator(); iterator.hasNext();) {
+ TaskType t = (TaskType) iterator.next();
+ collectTasks(list, t);
+ }
+ }
+
+ public Object[] getElements(Object arg0) {
+ List<Object> list = new ArrayList<Object>();
+ if (arg0 instanceof ProcessType) {
+ collectObjects(list, (ProcessType) arg0);
+ }
+ return list.toArray();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface
+ * .viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.zest.core.viewers.IGraphEntityContentProvider#getConnectedTo
+ * (java.lang.Object)
+ */
+ public Object[] getConnectedTo(Object arg0) {
+ if (arg0 instanceof TaskType) {
+ return ((TaskType) arg0).getTask().toArray();
+ }
+ return new Object[] {};
+ }
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/ProcessGraphContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,849 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.graphical.editors;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IEditorActionBarContributor;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.IMessage;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
+import org.eclipse.zest.core.viewers.GraphViewer;
+import org.eclipse.zest.core.widgets.CGraphNode;
+import org.eclipse.zest.core.widgets.Graph;
+import org.eclipse.zest.core.widgets.GraphItem;
+import org.eclipse.zest.core.widgets.ZestStyles;
+import org.eclipse.zest.layouts.LayoutStyles;
+import org.eclipse.zest.layouts.algorithms.HorizontalTreeLayoutAlgorithm;
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
+import org.jboss.tools.smooks.editor.AbstractSmooksFormEditor;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.graphical.actions.AbstractProcessGraphAction;
+import org.jboss.tools.smooks.graphical.actions.AddNextTaskNodeAction;
+import org.jboss.tools.smooks.graphical.actions.DeleteTaskNodeAction;
+import org.jboss.tools.smooks.graphical.editors.TaskTypeManager.TaskTypeDescriptor;
+import org.jboss.tools.smooks.graphical.editors.process.IProcessProvider;
+import org.jboss.tools.smooks.graphical.editors.process.ProcessFactory;
+import org.jboss.tools.smooks.graphical.editors.process.ProcessGraphicalViewerLabelProvider;
+import org.jboss.tools.smooks.graphical.editors.process.ProcessTaskAnalyzer;
+import org.jboss.tools.smooks.graphical.editors.process.ProcessType;
+import org.jboss.tools.smooks.graphical.editors.process.TaskNodeFigure;
+import org.jboss.tools.smooks.graphical.editors.process.TaskType;
+import org.jboss.tools.smooks.graphical.editors.process.TemplateAppyTaskNode;
+
+/**
+ * @author Dart
+ *
+ */
+public class SmooksProcessGraphicalEditor extends FormPage implements IProcessProvider , PropertyChangeListener , IPropertyListener{
+
+ private boolean processMapActived = false;
+
+ private int currentMessageType = IMessageProvider.NONE;
+
+ private String currentMessage = null;
+
+ private boolean processChanged = false;
+
+ private boolean lockProcessChangeEvent = false;
+
+ private List<IAction> processPanelActions = new ArrayList<IAction>();
+
+ public static final int EXECUTE_COMMAND = 0;
+
+ public static final int REDO_COMMAND = 1;
+
+ public static final int UNDO_COMMAND = 2;
+
+ private Object emptyKey = new Object();
+
+ private ISmooksModelProvider smooksModelProvider = null;
+
+ private GraphViewer processGraphViewer;
+
+// private ScrolledPageBook pageBook;
+
+ private Map<String, Object> registedTaskPages = new HashMap<String, Object>();
+
+ private MenuManager manager;
+
+ protected boolean needupdatewhenshow = true;
+
+ private ProcessType process;
+
+ private Map<Object, String> smooksModelIdMap = new HashMap<Object, String>();
+
+ private Map<String,Object> detailsControlMap = new HashMap<String, Object>();
+
+ private Composite detailsContentsComposite;
+
+
+ public SmooksProcessGraphicalEditor(FormEditor editor, String id, String title, ISmooksModelProvider provider) {
+ super(editor, id, title);
+ this.smooksModelProvider = provider;
+ }
+
+ public SmooksProcessGraphicalEditor(String id, String title, ISmooksModelProvider provider) {
+ super(id, title);
+ this.smooksModelProvider = provider;
+ this.getManagedForm();
+ }
+
+ protected void createFormContent(IManagedForm managedForm) {
+ super.createFormContent(managedForm);
+ final ScrolledForm form = managedForm.getForm();
+ FormToolkit toolkit = managedForm.getToolkit();
+ toolkit.decorateFormHeading(form.getForm());
+ form.getBody().setLayout(new FillLayout());
+ form.setText(Messages.SmooksProcessGraphicalEditor_FormText);
+
+ Composite mainComposite = toolkit.createComposite(form.getBody());
+
+ GridLayout mgl = new GridLayout();
+ mgl.marginHeight = 13;
+ mgl.horizontalSpacing = 20;
+ mainComposite.setLayout(mgl);
+
+ SashForm sashForm = new SashForm(mainComposite, SWT.VERTICAL);
+ sashForm.SASH_WIDTH = 1;
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ sashForm.setLayoutData(gd);
+
+ createProcessGraphicalSection(toolkit, sashForm);
+
+ createTaskDetailsSection(toolkit, sashForm);
+
+ sashForm.setWeights(new int[] { 2, 8 });
+
+// validateEnd(null);
+ }
+
+ protected void createTaskDetailsSection(FormToolkit toolkit, Composite parent) {
+ Composite taskDetailsComposite = toolkit.createComposite(parent);
+ FillLayout taskDetailsFillLayout = new FillLayout();
+ taskDetailsFillLayout.marginWidth = 0;
+ taskDetailsFillLayout.marginHeight = 5;
+ taskDetailsComposite.setLayout(taskDetailsFillLayout);
+
+ Section section = toolkit.createSection(taskDetailsComposite, Section.TITLE_BAR);
+ section.setText(Messages.SmooksProcessGraphicalEditor_TaskConfigurationSectionTitle);
+ detailsContentsComposite = toolkit.createComposite(section);
+ section.setClient(detailsContentsComposite);
+// pageBook = new ScrolledPageBook(section);
+ section.setLayout(new FillLayout());
+// pageBook.setBackground(toolkit.getColors().getBackground());
+// section.setClient(pageBook);
+
+// Composite emptyComposite = pageBook.createPage(emptyKey);
+// emptyComposite.setLayout(new FillLayout());
+// createEmptyTaskPanel(emptyComposite, toolkit);
+// pageBook.showPage(emptyKey);
+ }
+
+
+ protected void createProcessGraphicalSection(FormToolkit toolkit, Composite parent) {
+ Section processGraphSection = toolkit.createSection(parent, Section.TITLE_BAR);
+ processGraphSection.setText(Messages.SmooksProcessGraphicalEditor_TasksMapSectionTitle);
+
+ Composite processGraphComposite = toolkit.createComposite(processGraphSection);
+
+ GridLayout processGraphGridLayoutLayout = new GridLayout();
+ // processGraphFillLayout.marginWidth = 1;
+ // processGraphFillLayout.marginHeight = 1;
+ processGraphComposite.setLayout(processGraphGridLayoutLayout);
+
+ processGraphSection.setClient(processGraphComposite);
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+
+ // Composite toolBarComposite =
+ // toolkit.createComposite(processGraphComposite);
+ // FillLayout l = new FillLayout();
+ // l.marginHeight = 1;
+ // l.marginWidth = 1;
+ // toolBarComposite.setLayout(l);
+
+ // toolBarComposite.setLayoutData(gd);
+ //
+ // toolBarComposite.setBackground(toolkit.getColors().getBorderColor());
+ //
+ // createProcessToolBar(toolBarComposite, toolkit);
+
+ Composite graphMainComposite = toolkit.createComposite(processGraphComposite);
+ FillLayout l1 = new FillLayout();
+ l1.marginHeight = 1;
+ l1.marginWidth = 1;
+ graphMainComposite.setLayout(l1);
+ gd = new GridData(GridData.FILL_BOTH);
+ graphMainComposite.setLayoutData(gd);
+ graphMainComposite.setBackground(toolkit.getColors().getBorderColor());
+
+ createProcessGraphicalPanel(graphMainComposite);
+
+ hookProcessGraphicalViewer();
+ configProcessGraphicalViewer();
+ initProcessGraphicalViewer();
+ }
+
+ protected void initProcessGraphicalViewer() {
+ boolean disableProcessViewer = false;
+ if (process == null) {
+ process = ProcessFactory.eINSTANCE.createProcessType();
+ process.addPropertyChangeListener(this);
+ }
+ ProcessTaskAnalyzer analyzer = new ProcessTaskAnalyzer();
+ lockProcessChangeEvent = true;
+ analyzer.analyzeTaskNode(process, smooksModelProvider.getSmooksModel());
+ lockProcessChangeEvent = false;
+ if (getProcessGraphViewer() != null) {
+ getProcessGraphViewer().setInput(process);
+ }
+ if (disableProcessViewer) {
+ getProcessGraphViewer().getControl().setBackground(
+ getManagedForm().getToolkit().getColors().getBorderColor());
+ getProcessGraphViewer().setInput(null);
+ getProcessGraphViewer().getControl().setEnabled(false);
+ }
+ }
+
+ public GraphViewer getProcessGraphViewer() {
+ return processGraphViewer;
+ }
+
+ protected void initProcessGraphicalPanelActions(IMenuManager manager) {
+
+ // AddTaskNodeAction addInputTaskAction = new
+ // AddInputTaskAction(smooksModelProvider);
+ // manager.add(addInputTaskAction);
+ // processPanelActions.add(addInputTaskAction);
+
+ MenuManager addNextTaskMenuManager = new MenuManager(Messages.SmooksProcessGraphicalEditor_AddTaskActionText);
+ manager.add(addNextTaskMenuManager);
+
+ generateNextTaskActions(addNextTaskMenuManager);
+
+ // MenuManager addPreTaskMenuManager = new
+ // MenuManager("Add Previous Task");
+ // manager.add(addPreTaskMenuManager);
+ //
+ // fillPreTaskMenu(addPreTaskMenuManager);
+
+ DeleteTaskNodeAction deleteAction = new DeleteTaskNodeAction(this, smooksModelProvider, this);
+ manager.add(deleteAction);
+
+ this.processPanelActions.add(deleteAction);
+
+ }
+
+ private void generateNextTaskActions(MenuManager addNextTaskMenuManager) {
+ List<TaskTypeDescriptor> list = TaskTypeManager.getAllTaskList();
+ for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
+ TaskTypeDescriptor taskTypeDescriptor = (TaskTypeDescriptor) iterator.next();
+ AddNextTaskNodeAction addNextInputAction = new AddNextTaskNodeAction(taskTypeDescriptor.getId(),
+ taskTypeDescriptor.getLabel(), smooksModelProvider, this);
+ this.processPanelActions.add(addNextInputAction);
+ addNextTaskMenuManager.add(addNextInputAction);
+ }
+ }
+
+
+ protected void configProcessGraphicalViewer() {
+ manager = new MenuManager();
+
+ initProcessGraphicalPanelActions(manager);
+
+ Menu menu = manager.createContextMenu(getProcessGraphViewer().getControl());
+ getProcessGraphViewer().getControl().setMenu(menu);
+ manager.addMenuListener(new IMenuListener() {
+
+ public void menuAboutToShow(IMenuManager manager) {
+ try {
+ manager.removeAll();
+ if (needupdatewhenshow) {
+ updateProcessActions(processGraphViewer.getSelection());
+ fillProcessMenu(manager);
+ } else {
+ for (Iterator<?> iterator = processPanelActions.iterator(); iterator.hasNext();) {
+ IAction action = (IAction) iterator.next();
+ if (action.isEnabled() && !(action instanceof DeleteTaskNodeAction)) {
+ manager.add(action);
+ }
+ }
+ }
+ needupdatewhenshow = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ needupdatewhenshow = true;
+ }
+ });
+ }
+
+ public void updateProcessActions(ISelection selection) {
+ try{
+ for (Iterator<?> iterator = processPanelActions.iterator(); iterator.hasNext();) {
+ IAction a = (IAction) iterator.next();
+ if (a instanceof AbstractProcessGraphAction) {
+ ((AbstractProcessGraphAction) a).selectionChanged(new SelectionChangedEvent(processGraphViewer,
+ selection));
+ }
+ }
+ manager.update();
+ }catch(Throwable t){
+ t.printStackTrace();
+ }
+ }
+
+ public void fillProcessMenu(IMenuManager manager) {
+ MenuManager addNextTaskMenuManager = new MenuManager(Messages.SmooksProcessGraphicalEditor_AddTaskActionText);
+ manager.add(addNextTaskMenuManager);
+
+ for (Iterator<?> iterator = processPanelActions.iterator(); iterator.hasNext();) {
+ IAction action = (IAction) iterator.next();
+ if (action instanceof DeleteTaskNodeAction) {
+ manager.add(action);
+ } else {
+ addNextTaskMenuManager.add(action);
+ }
+ }
+ }
+
+
+
+ protected void hookProcessGraphicalViewer() {
+ getProcessGraphViewer().addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ Object firstElement = selection.getFirstElement();
+ if (firstElement == null) {
+ unhighlightGraphNodes();
+ }
+ Graph graph = getProcessGraphViewer().getGraphControl();
+ List<?> nodes = graph.getNodes();
+ GraphItem item = null;
+ for (Iterator<?> iterator = nodes.iterator(); iterator.hasNext();) {
+ GraphItem graphItem = (GraphItem) iterator.next();
+ if (graphItem.getData() == firstElement) {
+ item = graphItem;
+ break;
+ }
+ }
+ if (item != null) {
+ unhighlightGraphNodes();
+ highlightGraphNode(item);
+ }
+// showTaskControl(firstElement);
+// SmooksProcessGraphicalEditor.this.selectionChanged(event);
+ updateGlobalActions();
+ }
+ });
+ // when focus change , update the actions in the Eclipse menu via
+ // EditorContributor
+ getProcessGraphViewer().getControl().addFocusListener(new FocusListener() {
+
+ public void focusLost(FocusEvent e) {
+ processMapActived = false;
+ updateGlobalActions();
+ }
+
+ public void focusGained(FocusEvent e) {
+ processMapActived = true;
+ updateGlobalActions();
+ }
+ });
+ }
+
+ private void updateGlobalActions() {
+ IEditorActionBarContributor contributor = getEditorSite().getActionBarContributor();
+ if (contributor != null && contributor instanceof MultiPageEditorActionBarContributor) {
+ // clean all actions
+ ((MultiPageEditorActionBarContributor) contributor).setActivePage(null);
+ // re-active the page and add all actions
+ ((MultiPageEditorActionBarContributor) contributor).setActivePage(SmooksProcessGraphicalEditor.this);
+ }
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (lockProcessChangeEvent)
+ return;
+ String name = evt.getPropertyName();
+ Object newtask = evt.getNewValue();
+ Object oldtask = evt.getOldValue();
+ if (ProcessType.PRO_ADD_CHILD.equals(name) || ProcessType.PRO_REMOVE_CHILD.equals(name)) {
+ if (getProcessGraphViewer() != null) {
+ getProcessGraphViewer().refresh();
+ getProcessGraphViewer().applyLayout();
+ }
+ processChanged = true;
+ getManagedForm().dirtyStateChanged();
+ }
+
+// if (ProcessType.PRO_ADD_CHILD.equals(name)) {
+// this.showTaskControl(newtask);
+// }
+// if (ProcessType.PRO_REMOVE_CHILD.equals(name)) {
+// this.showTaskControl(null);
+// disposeTaskDetails(oldtask);
+// }
+// validateEnd(null);
+ }
+
+ @Override
+ public boolean isDirty() {
+ boolean dirty = false;
+ Collection<Object> editors = registedTaskPages.values();
+ for (Iterator<?> iterator = editors.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ if (object instanceof IEditorPart) {
+ dirty = (((IEditorPart) object).isDirty() || dirty);
+ }
+ }
+ return (dirty || processChanged);
+ }
+
+ public void doSave(IProgressMonitor monitor) {
+ Collection<Object> editors = registedTaskPages.values();
+ for (Iterator<?> iterator = editors.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ if (object instanceof IEditorPart) {
+ ((IEditorPart) object).doSave(monitor);
+ }
+ }
+ processChanged = false;
+ firePropertyChange(PROP_DIRTY);
+ }
+
+
+ protected void unhighlightGraphNodes() {
+
+ Graph graph = this.getProcessGraphViewer().getGraphControl();
+ List<?> elements = graph.getNodes();
+ for (Iterator<?> iterator = elements.iterator(); iterator.hasNext();) {
+ GraphItem graphItem = (GraphItem) iterator.next();
+ unhighlightGraphNode(graphItem);
+ }
+ }
+
+ protected void unhighlightGraphNode(GraphItem item) {
+ if (item instanceof CGraphNode) {
+ IFigure figure = ((CGraphNode) item).getFigure();
+ if (figure instanceof TaskNodeFigure) {
+ ((TaskNodeFigure) figure).unhighlightLabel();
+ }
+ }
+ }
+
+ protected void highlightGraphNode(GraphItem item) {
+ if (item instanceof CGraphNode) {
+ IFigure figure = ((CGraphNode) item).getFigure();
+ if (figure instanceof TaskNodeFigure) {
+ ((TaskNodeFigure) figure).highlightLabel(org.eclipse.draw2d.ColorConstants.darkBlue);
+ }
+ }
+ }
+
+ private void showEmptyPage(){
+ Control[] childrens = detailsContentsComposite.getChildren();
+ for (int i = 0; i < childrens.length; i++) {
+ Control child = childrens[i];
+ GridData gd = new GridData();
+ gd.exclude = true;
+ child.setLayoutData(gd);
+ child.setVisible(false);
+ child.setBounds(new Rectangle(0, 0, 0, 0));
+ }
+ detailsContentsComposite.setLayout(new GridLayout());
+ detailsContentsComposite.layout(false);
+ }
+
+ protected boolean isSingltonEditor(Object taskID) {
+ if (taskID.equals(TaskTypeManager.TASK_ID_FREEMARKER_CSV_TEMPLATE)) {
+ return false;
+ }
+ return true;
+ }
+
+ protected String generateTaskSpecailID(TaskType task) {
+ if (task instanceof TemplateAppyTaskNode) {
+ if (!((TemplateAppyTaskNode) task).getSmooksModel().isEmpty()
+ && ((TemplateAppyTaskNode) task).getSmooksModel().size() == 1) {
+ Object freemarker = ((TemplateAppyTaskNode) task).getSmooksModel().get(0);
+ String taskID = smooksModelIdMap.get(freemarker);
+ if (taskID == null) {
+ String tempstamp = String.valueOf(System.currentTimeMillis());
+ taskID = "freemarker" + "_" + tempstamp; //$NON-NLS-1$ //$NON-NLS-2$
+ this.smooksModelIdMap.put(freemarker, taskID);
+ }
+ return taskID;
+ }
+ }
+ return null;
+ }
+
+ protected IEditorPart createEditorPart(Object taskID) {
+// if (taskID instanceof TemplateAppyTaskNode) {
+// String type = ((TemplateAppyTaskNode) taskID).getType();
+// SmooksFreemarkerTemplateGraphicalEditor freemarkerPart = new SmooksFreemarkerCSVTemplateGraphicalEditor(
+// smooksModelProvider);
+// if (SmooksModelUtils.FREEMARKER_TEMPLATE_TYPE_CSV.equals(type)) {
+// freemarkerPart = new SmooksFreemarkerCSVTemplateGraphicalEditor(smooksModelProvider);
+//
+// }
+// if (SmooksModelUtils.FREEMARKER_TEMPLATE_TYPE_XML.equals(type)) {
+// freemarkerPart = new SmooksFreemarkerTemplateGraphicalEditor(smooksModelProvider);
+//
+// }
+// return freemarkerPart;
+// }
+// if (taskID.equals(TaskTypeManager.TASK_ID_FREEMARKER_CSV_TEMPLATE)) {
+// SmooksFreemarkerTemplateGraphicalEditor freemarkerPart = new SmooksFreemarkerCSVTemplateGraphicalEditor(
+// smooksModelProvider);
+// return freemarkerPart;
+// }
+// if (taskID.equals(TaskTypeManager.TASK_ID_JAVA_MAPPING)) {
+// SmooksJavaMappingGraphicalEditor javaMappingPart = new SmooksJavaMappingGraphicalEditor(smooksModelProvider);
+// return javaMappingPart;
+// }
+// if (taskID.equals(TaskTypeManager.TASK_ID_INPUT)) {
+// SmooksReaderFormPage readerPage = new SmooksReaderFormPage(getEditor(), "input", "input"); //$NON-NLS-1$ //$NON-NLS-2$
+// return readerPage;
+// }
+ return null;
+ }
+
+ public void registeTaskDetailsPage(IEditorPart editor, String taskID) {
+ editor.addPropertyListener(this);
+ this.registedTaskPages.put(taskID, editor);
+ }
+
+ public Object getRegisteTaskPage(String id) {
+ return registedTaskPages.get(id);
+ }
+
+ protected Control createTaskPanel(Composite parent, FormToolkit toolkit, String taskID) {
+
+ if (taskID == null)
+ return null;
+
+ if (taskID.equals(TaskTypeManager.TASK_ID_JAVA_MAPPING)) {
+ return null;
+ }
+
+ if (taskID.equals(TaskTypeManager.TASK_ID_INPUT)) {
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ parent.setLayout(gl);
+ toolkit.createLabel(
+ parent,
+ "Click the link to switch to the \"Input\" tab to configurate the Smooks Input : ");
+ Hyperlink link = toolkit.createHyperlink(parent,
+ "Go to the Input page", SWT.NONE);
+ link.addHyperlinkListener(new IHyperlinkListener() {
+
+ public void linkExited(HyperlinkEvent e) {
+
+ }
+
+ public void linkEntered(HyperlinkEvent e) {
+
+ }
+
+ public void linkActivated(HyperlinkEvent e) {
+ if (smooksModelProvider instanceof AbstractSmooksFormEditor) {
+ ((AbstractSmooksFormEditor) smooksModelProvider)
+ .setActivePage("reader_page");
+ }
+ }
+ });
+
+ return parent;
+ }
+
+ return null;
+ }
+
+ protected IEditorSite createSite(IEditorPart editor) {
+ return new SmooksTaskDetailsEditorSite(this.getEditor(), editor, this);
+ }
+
+ protected void createTaskPage(IEditorPart editorPart, Composite parent) throws PartInitException {
+ IEditorSite site = createSite(editorPart);
+ editorPart.init(site, getEditorInput());
+ editorPart.createPartControl(parent);
+ }
+
+ protected void showTaskControl(Object model) {
+ if (detailsContentsComposite == null)
+ return;
+ if (model == null){
+ showEmptyPage();
+ }
+ final Object finalModel = model;
+ detailsContentsComposite.setLayout(new FillLayout());
+ detailsContentsComposite.getShell().getDisplay().syncExec(new Runnable() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ FormToolkit toolkit = ((AbstractSmooksFormEditor) smooksModelProvider).getToolkit();
+ if (finalModel instanceof TaskType) {
+ String id = ((TaskType) finalModel).getId();
+ if (!isSingltonEditor(id)) {
+ String idref = generateTaskSpecailID((TaskType) finalModel);
+ if (idref != null) {
+ // idref = id + "_" + idref;
+ if (getRegisteTaskPage(idref) == null) {
+ IEditorPart editor = createEditorPart(finalModel);
+ registeTaskDetailsPage(editor, idref);
+ }
+ id = idref;
+ } else {
+ id = id + "_unknown"; //$NON-NLS-1$
+ }
+ }
+ if (id != null) {
+ if (!detailsControlMap.containsKey(id)) {
+// Composite parent = pageBook.createPage(id);
+ Control[] childrens = detailsContentsComposite.getChildren();
+ for (int i = 0; i < childrens.length; i++) {
+ Control child = childrens[i];
+ child.setVisible(false);
+ child.setBounds(new Rectangle(0, 0, 0, 0));
+ if(child.getLayoutData() instanceof GridData){
+ ((GridData)child.getLayoutData()).exclude = true;
+ }
+ }
+ Object page = getRegisteTaskPage(id);
+ if (page != null && page instanceof IEditorPart) {
+ try {
+ detailsContentsComposite.setLayout(new GridLayout());
+ Composite contentParent = toolkit.createComposite(detailsContentsComposite);
+ contentParent.setLayout(new FillLayout());
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ contentParent.setLayoutData(gd);
+ ITaskNodeProvider nodeProvider = (ITaskNodeProvider) ((IEditorPart) page)
+ .getAdapter(ITaskNodeProvider.class);
+ if (nodeProvider != null) {
+ nodeProvider.setTaskType((TaskType) finalModel);
+ }
+ createTaskPage((IEditorPart) page, contentParent);
+ detailsContentsComposite.layout(false);
+ contentParent.setData(page);
+ detailsControlMap.put(id, contentParent);
+
+ } catch (Throwable e) {
+ e.printStackTrace();
+ detailsControlMap.remove(id);
+ showEmptyPage();
+ }
+ } else {
+ for (int i = 0; i < childrens.length; i++) {
+ Control child = childrens[i];
+ child.setVisible(false);
+ child.setBounds(new Rectangle(0, 0, 0, 0));
+ if(child.getLayoutData() instanceof GridData){
+ ((GridData)child.getLayoutData()).exclude = true;
+ }
+ }
+ Control control = createTaskPanel(detailsContentsComposite, toolkit, id);
+ if (control != null) {
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ control.setLayoutData(gd);
+ detailsContentsComposite.layout(false);
+ detailsControlMap.put(id, control);
+ } else {
+ detailsControlMap.remove(id);
+ showEmptyPage();
+// pageBook.removePage(id);
+// pageBook.showPage(emptyKey);
+ }
+ }
+ } else {
+ Object page = getRegisteTaskPage(id);
+ ITaskNodeProvider nodeProvider = (ITaskNodeProvider) ((IEditorPart) page)
+ .getAdapter(ITaskNodeProvider.class);
+ if (nodeProvider != null) {
+ nodeProvider.setTaskType((TaskType) finalModel);
+ }
+ Control[] childrens = detailsContentsComposite.getChildren();
+ for (int i = 0; i < childrens.length; i++) {
+ Control child = childrens[i];
+ GridData gd = new GridData();
+ gd.exclude = true;
+ child.setLayoutData(gd);
+ child.setVisible(false);
+ child.setBounds(new Rectangle(0, 0, 0, 0));
+ }
+ detailsContentsComposite.setLayout(new GridLayout());
+
+ Control contentParent = (Control)detailsControlMap.get(id);
+ contentParent.setVisible(true);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ contentParent.setLayoutData(gd);
+ detailsContentsComposite.layout(false);
+ }
+ }
+ } else {
+ showEmptyPage();
+ }
+ }
+
+ });
+ updateGlobalActions();
+ }
+
+ protected void createProcessGraphicalPanel(Composite parent) {
+ processGraphViewer = new GraphViewer(parent, SWT.NONE);
+ processGraphViewer.getControl().dispose();
+ processGraphViewer.setControl(new Graph(parent, SWT.NONE) {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.zest.core.widgets.Graph#dispose()
+ */
+ @Override
+ public void dispose() {
+ try {
+ super.dispose();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ });
+ // GridData gd = new GridData(GridData.FILL_BOTH);
+ // processGraphViewer.getControl().setLayoutData(gd);
+ // processGraphViewer.setNodeStyle(ZestStyles.NODES_FISHEYE);
+ processGraphViewer.setContentProvider(new ProcessGraphContentProvider());
+ processGraphViewer.setLabelProvider(new ProcessGraphicalViewerLabelProvider(this));
+ processGraphViewer.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);
+ HorizontalTreeLayoutAlgorithm layoutAlgorithm = new HorizontalTreeLayoutAlgorithm(
+ LayoutStyles.NO_LAYOUT_NODE_RESIZING);
+ processGraphViewer.setLayoutAlgorithm(layoutAlgorithm, true);
+ if (parent instanceof Section) {
+ ((Section) parent).setClient(processGraphViewer.getControl());
+ }
+ }
+
+
+ public void createPartControl(Composite parent) {
+ super.createPartControl(parent);
+ updateHeaderFormMessage();
+ }
+
+ protected void updateHeaderFormMessage() {
+ if (this.getManagedForm() != null) {
+ getManagedForm().getMessageManager().removeAllMessages();
+ getManagedForm().getMessageManager().update();
+ getProcessGraphViewer().getControl().setEnabled(true);
+ getProcessGraphViewer().getControl().setBackground(
+ getManagedForm().getToolkit().getColors().getBackground());
+ }
+ if (currentMessageType != IMessageProvider.NONE && currentMessage != null) {
+ if (this.getProcessGraphViewer() != null) {
+ getProcessGraphViewer().getControl().setBackground(GraphicsConstants.BORDER_CORLOR);
+ getProcessGraphViewer().getControl().setEnabled(false);
+ getProcessGraphViewer().setInput(new Object());
+// showTaskControl(null);
+ }
+ if (this.getManagedForm() != null) {
+
+ String[] messages = currentMessage.split("\n"); //$NON-NLS-1$
+ List<IMessage> messageList = new ArrayList<IMessage>();
+ for (int i = 0; i < messages.length; i++) {
+ String message = messages[i];
+ if (message != null)
+ message.trim();
+ if (message.length() == 0) {
+ continue;
+ }
+ messageList.add(new SmooksMessage(currentMessageType, message));
+ }
+ String mainMessage = null;
+ if (messageList.isEmpty()) {
+ mainMessage = currentMessage;
+ } else {
+ mainMessage = messageList.get(0).getMessage();
+ }
+
+ this.getManagedForm().getForm().getForm().setMessage(mainMessage, currentMessageType,
+ messageList.toArray(new IMessage[] {}));
+
+ }
+ }
+ }
+
+ /**
+ * @return the needupdatewhenshow
+ */
+ public boolean isNeedupdatewhenshow() {
+ return needupdatewhenshow;
+ }
+
+ /**
+ * @param needupdatewhenshow
+ * the needupdatewhenshow to set
+ */
+ public void setNeedupdatewhenshow(boolean needupdatewhenshow) {
+ this.needupdatewhenshow = needupdatewhenshow;
+ }
+
+ public ProcessType getProcess() {
+ return this.process;
+ }
+
+ public void propertyChanged(Object source, int propId) {
+ this.firePropertyChange(propId);
+ if (propId == PROP_DIRTY) {
+ this.getManagedForm().dirtyStateChanged();
+ }
+ }
+
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksTaskDetailsEditorSite.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksTaskDetailsEditorSite.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksTaskDetailsEditorSite.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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.graphical.editors;
+
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.part.MultiPageEditorPart;
+import org.eclipse.ui.part.MultiPageEditorSite;
+
+/**
+ * @author Dart
+ *
+ */
+public class SmooksTaskDetailsEditorSite extends MultiPageEditorSite {
+
+ private FormPage parentEditor = null;
+
+ public SmooksTaskDetailsEditorSite(MultiPageEditorPart multiPageEditor, IEditorPart editor,
+ FormPage parentEditor) {
+ super(multiPageEditor, editor);
+ this.parentEditor = parentEditor;
+ }
+
+ /**
+ * @return the parentEditor
+ */
+ public FormPage getParentEditor() {
+ return parentEditor;
+ }
+
+ /**
+ * @param parentEditor the parentEditor to set
+ */
+ public void setParentEditor(FormPage parentEditor) {
+ this.parentEditor = parentEditor;
+ }
+
+
+
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksTaskDetailsEditorSite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/TaskTypeManager.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/TaskTypeManager.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/TaskTypeManager.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,218 @@
+/*******************************************************************************
+ * 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.graphical.editors;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
+import org.jboss.tools.smooks.graphical.editors.process.TaskType;
+import org.jboss.tools.smooks.graphical.editors.process.TemplateAppyTaskNode;
+//import org.jboss.tools.smooks.model.freemarker.Freemarker;
+//import org.jboss.tools.smooks.model.javabean12.BeanType;
+//import org.jboss.tools.smooks.model.smooks.AbstractResourceConfig;
+//import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
+
+/**
+ * @author Dart
+ *
+ */
+public class TaskTypeManager {
+
+ public static final String TASK_ID_INPUT = "input"; //$NON-NLS-1$
+
+ public static final String TASK_ID_JAVA_MAPPING = "java_mapping"; //$NON-NLS-1$
+
+ public static final String TASK_ID_XSL_TEMPLATE = "xsl_template"; //$NON-NLS-1$
+
+ public static final String TASK_ID_FREEMARKER_CSV_TEMPLATE = "freemarker_csv_template"; //$NON-NLS-1$
+
+ public static final String TASK_ID_FREEMARKER_XML_TEMPLATE = "freemarker_xml_template"; //$NON-NLS-1$
+
+ private static List<TaskTypeDescriptor> allTaskList = null;
+
+ public static String[] getChildTaskIDs(String parentId) {
+ if (parentId == null)
+ return null;
+ if (parentId.equals(TaskTypeManager.TASK_ID_INPUT)) {
+ return new String[] { TaskTypeManager.TASK_ID_JAVA_MAPPING };
+ }
+ if (parentId.equals(TaskTypeManager.TASK_ID_JAVA_MAPPING)) {
+ return new String[] { TaskTypeManager.TASK_ID_FREEMARKER_CSV_TEMPLATE };
+ }
+ return null;
+ }
+
+ /**
+ * @return the allTaskList
+ */
+ public static List<TaskTypeDescriptor> getAllTaskList() {
+ if (allTaskList == null) {
+ allTaskList = new ArrayList<TaskTypeDescriptor>();
+
+ // init
+ allTaskList.add(new TaskTypeDescriptor(TASK_ID_INPUT, Messages.TaskTypeManager_Input,
+ GraphicsConstants.IMAGE_INPUT_TASK));
+ allTaskList.add(new TaskTypeDescriptor(TASK_ID_JAVA_MAPPING, Messages.TaskTypeManager_JavaMappingTaskLabel,
+ GraphicsConstants.IMAGE_JAVA_AMPPING_TASK));
+ allTaskList.add(new TaskTypeDescriptor(TASK_ID_FREEMARKER_CSV_TEMPLATE,
+ Messages.TaskTypeManager_ApplyTemplateTaskLabel, GraphicsConstants.IMAGE_APPLY_FREEMARKER_TASK));
+ }
+ return allTaskList;
+ }
+
+ public static List<Object> getAssociatedSmooksElementsType(TaskType taskType) {
+ return null;
+ }
+
+// public static List<Object> getAssociatedSmooksElementsType(String taskID) {
+// List<Object> elementsType = new ArrayList<Object>();
+// if (taskID == null)
+// return null;
+// if (TASK_ID_JAVA_MAPPING.equals(taskID)) {
+// elementsType.add(BeanType.class);
+// }
+// if (TASK_ID_FREEMARKER_CSV_TEMPLATE.equals(taskID)) {
+// elementsType.add(Freemarker.class);
+// }
+// return elementsType;
+// }
+
+ public static String getTaskLabel(TaskType task) {
+ if (task != null) {
+ String taskId = task.getId();
+ if (taskId != null) {
+ if (taskId.equals(TASK_ID_FREEMARKER_CSV_TEMPLATE)) {
+ String messageType = ""; //$NON-NLS-1$
+ if (task instanceof TemplateAppyTaskNode) {
+ messageType = ((TemplateAppyTaskNode) task).getType();
+ }
+ if (messageType == null)
+ messageType = ""; //$NON-NLS-1$
+ if (messageType.length() > 0){
+ return Messages.TaskTypeManager_ApplyTemplateTaskLabel + " (" + messageType +")"; //$NON-NLS-1$ //$NON-NLS-2$
+ }else{
+ return Messages.TaskTypeManager_ApplyTemplateTaskLabel;
+ }
+ }
+ if (taskId.equals(TASK_ID_INPUT)) {
+ return Messages.TaskTypeManager_InputTaskLabel;
+ }
+ if (taskId.equals(TASK_ID_JAVA_MAPPING)) {
+ return Messages.TaskTypeManager_JavaMappingTaskLabel;
+ }
+ if (taskId.equals(TASK_ID_XSL_TEMPLATE)) {
+ return Messages.TaskTypeManager_ApplyXSLTemplateTaskLabel;
+ }
+ }
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+// /**
+// *
+// * @param taskID
+// * @param smooksResourceList
+// * @return
+// */
+// public static List<Object> getAssociatedSmooksElements(TaskType taskType, SmooksResourceListType smooksResourceList) {
+// List<Object> elementTypes = getAssociatedSmooksElementsType(taskType.getId());
+// List<AbstractResourceConfig> resourceConfigList = smooksResourceList.getAbstractResourceConfig();
+// List<Object> associatedElements = new ArrayList<Object>();
+// for (Iterator<?> iterator = resourceConfigList.iterator(); iterator.hasNext();) {
+// AbstractResourceConfig abstractResourceConfig = (AbstractResourceConfig) iterator.next();
+// if (isSameType(abstractResourceConfig, elementTypes) && canRemove(abstractResourceConfig, taskType)) {
+// associatedElements.add(abstractResourceConfig);
+// }
+// }
+// return associatedElements;
+// }
+//
+// private static boolean canRemove(AbstractResourceConfig abstractResourceConfig, TaskType taskType) {
+// if (abstractResourceConfig instanceof Freemarker) {
+// return taskType.inTheTask(abstractResourceConfig);
+// }
+// return true;
+// }
+
+ private static boolean isSameType(Object element, List<Object> elementTypes) {
+ for (Iterator<?> iterator = elementTypes.iterator(); iterator.hasNext();) {
+ Class<?> object = (Class<?>) iterator.next();
+ if (object.isInstance(element)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static final class TaskTypeDescriptor {
+
+ private String id;
+
+ private String label;
+
+ private String imagePath;
+
+ public TaskTypeDescriptor(String id, String label, String imagePath) {
+ this.id = id;
+ this.label = label;
+ this.imagePath = imagePath;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id
+ * the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the label
+ */
+ public String getLabel() {
+ return label;
+ }
+
+ /**
+ * @param label
+ * the label to set
+ */
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ /**
+ * @return the imagePath
+ */
+ public String getImagePath() {
+ return imagePath;
+ }
+
+ /**
+ * @param imagePath
+ * the imagePath to set
+ */
+ public void setImagePath(String imagePath) {
+ this.imagePath = imagePath;
+ }
+
+ }
+
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/TaskTypeManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/IProcessProvider.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/IProcessProvider.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/IProcessProvider.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * 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.graphical.editors.process;
+
+
+/**
+ * @author Dart
+ *
+ */
+public interface IProcessProvider {
+ ProcessType getProcess();
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/IProcessProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessFactory.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessFactory.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessFactory.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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.graphical.editors.process;
+
+/**
+ * @author Dart
+ *
+ */
+public class ProcessFactory {
+ public static ProcessFactory eINSTANCE = new ProcessFactory();
+
+ public TaskType createTaskType(){
+ return new TaskTypeImpl();
+ }
+
+ public ProcessType createProcessType(){
+ return new ProcessTypeImpl();
+ }
+
+ public TemplateAppyTaskNode createTemplateTask(){
+ return new TemplateAppyTaskNode();
+ }
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessGraphicalViewerLabelProvider.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessGraphicalViewerLabelProvider.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessGraphicalViewerLabelProvider.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * 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.graphical.editors.process;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.zest.core.viewers.IFigureProvider;
+import org.eclipse.zest.core.viewers.ISelfStyleProvider;
+import org.eclipse.zest.core.widgets.CGraphNode;
+import org.eclipse.zest.core.widgets.GraphConnection;
+import org.eclipse.zest.core.widgets.GraphNode;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
+import org.jboss.tools.smooks.configuration.editors.IFieldMarker;
+import org.jboss.tools.smooks.graphical.editors.SmooksProcessGraphicalEditor;
+import org.jboss.tools.smooks.graphical.editors.TaskTypeManager;
+import org.jboss.tools.smooks.graphical.editors.TaskTypeManager.TaskTypeDescriptor;
+
+/**
+ * @author Dart
+ *
+ */
+public class ProcessGraphicalViewerLabelProvider extends LabelProvider implements IFigureProvider, ISelfStyleProvider {
+
+ private SmooksProcessGraphicalEditor processEditor;
+
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ }
+
+ public ProcessGraphicalViewerLabelProvider(SmooksProcessGraphicalEditor graph) {
+ this.processEditor = graph;
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof TaskType) {
+ String id = ((TaskType) element).getId();
+ List<TaskTypeDescriptor> des = TaskTypeManager.getAllTaskList();
+ for (Iterator<?> iterator = des.iterator(); iterator.hasNext();) {
+ TaskTypeDescriptor taskTypeDescriptor = (TaskTypeDescriptor) iterator.next();
+ if (taskTypeDescriptor.getId().equals(id)) {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ taskTypeDescriptor.getImagePath());
+ }
+ }
+ }
+ return super.getImage(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof TaskType) {
+ String label = TaskTypeManager.getTaskLabel((TaskType)element);
+ if(label == null){
+ label = ((TaskType) element).getId();
+ }
+ return label;
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.zest.core.viewers.IFigureProvider#getFigure(java.lang.Object)
+ */
+ public IFigure getFigure(Object element) {
+ if (element instanceof TaskType) {
+ // if(TaskTypeManager.TASK_ID_INPUT.equals(((TaskType)element).getId())){
+ Image image = getImage(element);
+ String text = getText(element);
+ return new TaskNodeFigure(processEditor, image, text);
+ // }
+ }
+ return null;
+ }
+
+ public void selfStyleConnection(Object element, GraphConnection connection) {
+ connection.setLineColor(GraphicsConstants.BORDER_CORLOR);
+ }
+
+ private String getProblemMessage(List<String> message){
+ String m = null;
+ if(message != null && !message.isEmpty()){
+ m = ""; //$NON-NLS-1$
+ for (Iterator<String> iterator = message.iterator(); iterator.hasNext();) {
+ String string = (String) iterator.next();
+ m = m + " - " + string +" \n"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ return m;
+ }
+
+ public void selfStyleNode(Object element, GraphNode node) {
+ if (node instanceof CGraphNode) {
+ IFigure figure = ((CGraphNode) node).getFigure();
+ if(figure instanceof TaskNodeFigure && element instanceof TaskType){
+ int problem = ((TaskType)element).getProblemType();
+ List<String> problemMessages = ((TaskType)element).getProblemMessages();
+
+ String message = getProblemMessage(problemMessages);
+
+ ImageRegistry ir = SmooksConfigurationActivator.getDefault().getImageRegistry();
+ switch(problem){
+ case IFieldMarker.TYPE_NONE:
+ ((TaskNodeFigure)figure).getLabel().setIcon(null);
+ break;
+ case IFieldMarker.TYPE_ERROR:
+ ((TaskNodeFigure)figure).getLabel().setIcon(ir.get(GraphicsConstants.IMAGE_ERROR));
+ break;
+ case IFieldMarker.TYPE_WARINING:
+ ((TaskNodeFigure)figure).getLabel().setIcon(ir.get(GraphicsConstants.IMAGE_WARNING));
+ break;
+ }
+ ((TaskNodeFigure)figure).setProblemMessage(message);
+ }
+ Dimension size = figure.getLayoutManager().getPreferredSize(figure, -1, -1);
+ figure.setSize(size);
+ }
+ }
+
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessGraphicalViewerLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessTaskAnalyzer.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessTaskAnalyzer.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessTaskAnalyzer.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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.graphical.editors.process;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.tools.smooks.graphical.editors.TaskTypeManager;
+import org.jboss.tools.smooks.model.SmooksModel;
+import org.jboss.tools.smooks.model.core.IComponent;
+import org.jboss.tools.smooks.model.javabean.IBean;
+import org.milyn.javabean.dynamic.Model;
+
+/**
+ * @author Dart
+ *
+ */
+public class ProcessTaskAnalyzer {
+
+ public void analyzeTaskNode(ProcessType process,
+ Model<SmooksModel> rootSmooksModel) {
+ process.getTask().clear();
+ if (rootSmooksModel == null)
+ return;
+ // Input task node must be in process:
+ TaskType inputTask = ProcessFactory.eINSTANCE.createTaskType();
+ inputTask.setId(TaskTypeManager.TASK_ID_INPUT);
+ inputTask.setName(TaskTypeManager.getTaskLabel(inputTask));
+
+ process.addTask(inputTask);
+
+
+ List<IComponent> compoenents = rootSmooksModel.getModelRoot()
+ .getComponents();
+
+ // the java mapping is the next task node of input task:
+ TaskType javaMappingTask = null;
+ for (Iterator<?> iterator = compoenents.iterator(); iterator.hasNext();) {
+ IComponent component = (IComponent) iterator.next();
+ if (component instanceof IBean) {
+ javaMappingTask = ProcessFactory.eINSTANCE.createTaskType();
+ javaMappingTask.setId(TaskTypeManager.TASK_ID_JAVA_MAPPING);
+ javaMappingTask.setName(TaskTypeManager
+ .getTaskLabel(javaMappingTask));
+ inputTask.addTask(javaMappingTask);
+ break;
+ }
+ }
+
+ // the apply template is the next task node of java mapping task:
+ if (javaMappingTask != null) {
+// for (Iterator<?> iterator = compoenents.iterator(); iterator
+// .hasNext();) {
+// Component component = (Component) iterator.next();
+// if (component instanceof FreeMarkerTemplate) {
+// TemplateAppyTaskNode templateTask = (TemplateAppyTaskNode) ProcessFactory.eINSTANCE
+// .createTemplateTask();
+// templateTask.setType("XML");
+// templateTask.addSmooksModel(component);
+// templateTask.setName(TaskTypeManager
+// .getTaskLabel(templateTask));
+// javaMappingTask.addTask(templateTask);
+// }
+// }
+// for (Iterator<?> iterator = resourceConfigList.iterator(); iterator
+// .hasNext();) {
+// AbstractResourceConfig abstractResourceConfig = (AbstractResourceConfig) iterator
+// .next();
+// if (abstractResourceConfig instanceof Freemarker) {
+// String messageType = SmooksModelUtils.getParamValue(
+// ((Freemarker) abstractResourceConfig).getParam(),
+// SmooksModelUtils.KEY_TEMPLATE_TYPE);
+// if (SmooksModelUtils.FREEMARKER_TEMPLATE_TYPE_CSV
+// .equals(messageType)
+// || SmooksModelUtils.FREEMARKER_TEMPLATE_TYPE_XML
+// .equals(messageType)) {
+// TemplateAppyTaskNode templateTask = (TemplateAppyTaskNode) ProcessFactory.eINSTANCE
+// .createTemplateTask();
+// templateTask.setType(messageType);
+// templateTask.addSmooksModel(abstractResourceConfig);
+// templateTask.setName(TaskTypeManager
+// .getTaskLabel(templateTask));
+// javaMappingTask.addTask(templateTask);
+// }
+// }
+// }
+ }
+ }
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessTaskAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessType.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessType.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessType.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,120 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.jboss.tools.smooks.graphical.editors.process;
+
+
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Process Type</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.jboss.tools.smooks.model.graphics.ext.ProcessType#getTask <em>Task</em>}</li>
+ * <li>{@link org.jboss.tools.smooks.model.graphics.ext.ProcessType#getId <em>Id</em>}</li>
+ * <li>{@link org.jboss.tools.smooks.model.graphics.ext.ProcessType#getName <em>Name</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.jboss.tools.smooks.model.graphics.ext.GraphPackage#getProcessType()
+ * @model extendedMetaData="name='process_._type' kind='elementOnly'"
+ * @generated
+ */
+public interface ProcessType {
+
+ public static final String PRO_NAME_CHANGE = "pro_name_change"; //$NON-NLS-1$
+
+ public static final String PRO_ID_CHANGE = "pro_id_change"; //$NON-NLS-1$
+
+ public static final String PRO_ADD_CHILD = "pro_add_child"; //$NON-NLS-1$
+
+ public static final String PRO_REMOVE_CHILD = "pro_remove_child"; //$NON-NLS-1$
+
+ public void addPropertyChangeListener(PropertyChangeListener listener);
+
+ public void removePropertyChangeListener(PropertyChangeListener listener);
+
+ /**
+ * Returns the value of the '<em><b>Task</b></em>' containment reference list.
+ * The list contents are of type {@link org.jboss.tools.smooks.model.graphics.ext.TaskType}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Task</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Task</em>' containment reference list.
+ * @see org.jboss.tools.smooks.model.graphics.ext.GraphPackage#getProcessType_Task()
+ * @model containment="true"
+ * extendedMetaData="kind='element' name='task' namespace='##targetNamespace'"
+ * @generated
+ */
+ List<TaskType> getTask();
+
+ /**
+ * Returns the value of the '<em><b>Id</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Id</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Id</em>' attribute.
+ * @see #setId(String)
+ * @see org.jboss.tools.smooks.model.graphics.ext.GraphPackage#getProcessType_Id()
+ * @model dataType="org.eclipse.emf.ecore.xml.type.String"
+ * extendedMetaData="kind='attribute' name='id'"
+ * @generated
+ */
+ String getId();
+
+ /**
+ * Sets the value of the '{@link org.jboss.tools.smooks.model.graphics.ext.ProcessType#getId <em>Id</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Id</em>' attribute.
+ * @see #getId()
+ * @generated
+ */
+ void setId(String value);
+
+ /**
+ * Returns the value of the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Name</em>' attribute.
+ * @see #setName(String)
+ * @see org.jboss.tools.smooks.model.graphics.ext.GraphPackage#getProcessType_Name()
+ * @model dataType="org.eclipse.emf.ecore.xml.type.String"
+ * extendedMetaData="kind='attribute' name='name'"
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link org.jboss.tools.smooks.model.graphics.ext.ProcessType#getName <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Name</em>' attribute.
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+ public void addTask(TaskType task);
+
+ public void removeTask(TaskType task);
+
+} // ProcessType
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessTypeImpl.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessTypeImpl.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessTypeImpl.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,191 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.jboss.tools.smooks.graphical.editors.process;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <!-- begin-user-doc --> An implementation of the model object '
+ * <em><b>Process Type</b></em>'. <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>
+ * {@link org.jboss.tools.smooks.model.graphics.ext.impl.ProcessTypeImpl#getTask
+ * <em>Task</em>}</li>
+ * <li>
+ * {@link org.jboss.tools.smooks.model.graphics.ext.impl.ProcessTypeImpl#getId
+ * <em>Id</em>}</li>
+ * <li>
+ * {@link org.jboss.tools.smooks.model.graphics.ext.impl.ProcessTypeImpl#getName
+ * <em>Name</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class ProcessTypeImpl implements ProcessType {
+
+ private PropertyChangeSupport support = new PropertyChangeSupport(this);
+
+ /**
+ * The cached value of the '{@link #getTask() <em>Task</em>}' containment
+ * reference list. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see #getTask()
+ * @generated
+ * @ordered
+ */
+ protected List<TaskType> task;
+
+ /**
+ * The default value of the '{@link #getId() <em>Id</em>}' attribute. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see #getId()
+ * @generated
+ * @ordered
+ */
+ protected static final String ID_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getId() <em>Id</em>}' attribute. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see #getId()
+ * @generated
+ * @ordered
+ */
+ protected String id = ID_EDEFAULT;
+
+ /**
+ * The default value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected static final String NAME_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected String name = NAME_EDEFAULT;
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected ProcessTypeImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public List<TaskType> getTask() {
+ if (task == null) {
+ task = new ArrayList<TaskType>();
+ }
+ return task;
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ support.removePropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ support.addPropertyChangeListener(listener);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void setId(String newId) {
+ String oldId = name;
+ id = newId;
+ support.firePropertyChange(PRO_ID_CHANGE, oldId, newId);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void setName(String newName) {
+ String oldName = name;
+ name = newName;
+ support.firePropertyChange(PRO_NAME_CHANGE, oldName, newName);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public String toString() {
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (id: "); //$NON-NLS-1$
+ result.append(id);
+ result.append(", name: "); //$NON-NLS-1$
+ result.append(name);
+ result.append(')');
+ return result.toString();
+ }
+
+ public void addTask(TaskType task) {
+ if (task != null) {
+ this.getTask().add(task);
+ task.setParent(this);
+ task.setPropertyChangeSupport(support);
+ support.firePropertyChange(PRO_ADD_CHILD, null, task);
+ }
+ }
+
+ public void removeTask(TaskType task) {
+ if (task != null) {
+ this.getTask().remove(task);
+ task.setParent(null);
+ task.setPropertyChangeSupport(support);
+ support.firePropertyChange(PRO_REMOVE_CHILD, task, null);
+ }
+ }
+
+} // ProcessTypeImpl
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessTypeImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskNodeFigure.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskNodeFigure.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskNodeFigure.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,303 @@
+/*******************************************************************************
+ * 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.graphical.editors.process;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.draw2d.ActionEvent;
+import org.eclipse.draw2d.ActionListener;
+import org.eclipse.draw2d.Clickable;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.GridData;
+import org.eclipse.draw2d.GridLayout;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.MouseEvent;
+import org.eclipse.draw2d.MouseMotionListener;
+import org.eclipse.draw2d.ToolbarLayout;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.zest.core.widgets.CGraphNode;
+import org.eclipse.zest.core.widgets.Graph;
+import org.eclipse.zest.core.widgets.GraphItem;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
+import org.jboss.tools.smooks.graphical.editors.SmooksProcessGraphicalEditor;
+
+/**
+ * @author Dart
+ *
+ */
+public class TaskNodeFigure extends Figure {
+
+ private Label problemTooltip;
+
+ private IFigure mainFigure;
+
+ private IFigure addTaskFigure;
+
+ private Image image;
+
+ private String labelText;
+
+ private SmooksProcessGraphicalEditor processGraphicalViewerEditor;
+
+ private Label label;
+
+ private IFigure imageFigure;
+
+ private Color oldLabelColor = null;
+
+ private boolean showAddFigure = false;
+
+ private Rectangle imageSourceRectangle = null;
+
+ public TaskNodeFigure(SmooksProcessGraphicalEditor graph, Image image, String labelText) {
+ super();
+ this.image = image;
+ this.labelText = labelText;
+ this.processGraphicalViewerEditor = graph;
+ this.problemTooltip = new Label();
+ initFigure();
+ hookTaskNodeFigure();
+ }
+
+ public void setProblemMessage(String message){
+ if(message == null){
+ this.setToolTip(null);
+ }else{
+ this.problemTooltip.setText(message);
+ this.setToolTip(problemTooltip);
+ }
+ }
+
+ public Label getLabel() {
+ return label;
+ }
+
+ private void hookTaskNodeFigure() {
+ // this.addMouseMotionListener(new MouseMotionListener() {
+ //
+ // public void mouseDragged(MouseEvent me) {
+ // }
+ //
+ // public void mouseEntered(MouseEvent me) {
+ // showAddFigure = true;
+ // imageSourceRectangle = null;
+ // addTaskFigure.repaint();
+ // }
+ //
+ // public void mouseExited(MouseEvent me) {
+ // showAddFigure = false;
+ // addTaskFigure.repaint();
+ // }
+ //
+ // public void mouseHover(MouseEvent me) {
+ // }
+ //
+ // public void mouseMoved(MouseEvent me) {
+ // }
+ //
+ // });
+ addTaskFigure.addMouseMotionListener(new MouseMotionListener() {
+
+ public void mouseDragged(MouseEvent me) {
+ }
+
+ public void mouseEntered(MouseEvent me) {
+ showAddFigure = true;
+ imageSourceRectangle = null;
+ addTaskFigure.repaint();
+ }
+
+ public void mouseExited(MouseEvent me) {
+ showAddFigure = false;
+ addTaskFigure.repaint();
+ }
+
+ public void mouseHover(MouseEvent me) {
+ }
+
+ public void mouseMoved(MouseEvent me) {
+ }
+
+ });
+ }
+
+ protected void initFigure() {
+ initMainFigure();
+ initAddTaskFigure();
+ GridLayout girdlLayout = new GridLayout();
+ girdlLayout.numColumns = 2;
+ this.setLayoutManager(girdlLayout);
+ GridData d = new GridData(GridData.FILL_VERTICAL);
+ // ToolbarLayout layout = new ToolbarLayout(true);
+ // layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+ this.add(mainFigure);
+ this.add(addTaskFigure);
+ girdlLayout.setConstraint(addTaskFigure, d);
+ // this.setLayoutManager(layout);
+ }
+
+ private void initAddTaskFigure() {
+ addTaskFigure = new Clickable() {
+ @Override
+ protected void paintBorder(Graphics graphics) {
+ }
+
+ @Override
+ protected void paintFigure(Graphics graphics) {
+ super.paintFigure(graphics);
+ Rectangle rect = getBounds();
+ Point center = rect.getCenter();
+ if (!showAddFigure) {
+// int feet = 4;
+ graphics.fillRectangle(rect);
+ return;
+ // imageSourceRectangle = new Rectangle(rect.x + feet,
+ // rect.y + feet, rect.width - feet * 2,
+ // rect.height - feet * 2);
+ }
+ Image image = SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_ADD_TASK_BUTTON);
+ if (image != null) {
+// System.out.println(center.x - image.getBounds().width / 2);
+ Point location = new Point(center.x - image.getBounds().width / 2, center.y
+ - image.getBounds().height / 2);
+ graphics.drawImage(image, location);
+ if (imageSourceRectangle == null) {
+// graphics.drawImage(image, getLocation());
+ } else {
+// graphics.drawImage(image, sourceRectangle, imageSourceRectangle);
+ }
+ }
+ }
+
+ };
+ ((Clickable) addTaskFigure).addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent event) {
+ if (!showAddFigure)
+ return;
+ Graph g = processGraphicalViewerEditor.getProcessGraphViewer().getGraphControl();
+ processGraphicalViewerEditor.setNeedupdatewhenshow(false);
+ List<?> nodes = g.getNodes();
+ for (Iterator<?> iterator = nodes.iterator(); iterator.hasNext();) {
+ GraphItem item = (GraphItem) iterator.next();
+ if (item instanceof CGraphNode) {
+ if (TaskNodeFigure.this == ((CGraphNode) item).getFigure()) {
+ processGraphicalViewerEditor.updateProcessActions(new StructuredSelection(item.getData()));
+ break;
+ }
+ }
+ }
+ Menu menu = processGraphicalViewerEditor.getProcessGraphViewer().getGraphControl().getMenu();
+ menu.setVisible(true);
+ // processGraphicalViewerEditor.setNeedupdatewhenshow(true);
+ }
+ });
+ addTaskFigure.setSize(16, 16);
+ }
+
+ private void initMainFigure() {
+ mainFigure = new Figure();
+ imageFigure = new Figure() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics
+ * )
+ */
+ @Override
+ protected void paintFigure(Graphics graphics) {
+ super.paintFigure(graphics);
+ if (image != null) {
+ graphics.drawImage(image, getLocation());
+ } else {
+ graphics.drawRectangle(0, 0, 24, 24);
+ }
+ }
+
+ };
+ if (image != null) {
+ imageFigure.setSize(new Dimension(image.getBounds().width, image.getBounds().height));
+ } else {
+ imageFigure.setSize(24, 24);
+ }
+
+ mainFigure.add(imageFigure);
+
+ label = new Label();
+ label.setForegroundColor(GraphicsConstants.BORDER_CORLOR);
+ label.setText(labelText);
+
+ oldLabelColor = label.getForegroundColor();
+
+ mainFigure.add(label);
+
+ ToolbarLayout layout = new ToolbarLayout(false);
+ layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+ mainFigure.setLayoutManager(layout);
+ }
+
+ /**
+ * @return the image
+ */
+ public Image getImage() {
+ return image;
+ }
+
+ /**
+ * @param image
+ * the image to set
+ */
+ public void setImage(Image image) {
+ this.image = image;
+ }
+
+ /**
+ * @return the labelText
+ */
+ public String getLabelText() {
+ return labelText;
+ }
+
+ /**
+ * @param labelText
+ * the labelText to set
+ */
+ public void setLabelText(String labelText) {
+ this.labelText = labelText;
+ }
+
+ public void highlightLabel(Color highlightColor) {
+ oldLabelColor = label.getForegroundColor();
+ label.setForegroundColor(highlightColor);
+ label.repaint();
+ }
+
+ public void unhighlightLabel() {
+ if (oldLabelColor != null) {
+ label.setForegroundColor(oldLabelColor);
+ label.repaint();
+ }
+ }
+
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskNodeFigure.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskType.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskType.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskType.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,163 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.jboss.tools.smooks.graphical.editors.process;
+
+
+import java.beans.PropertyChangeSupport;
+import java.util.List;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Task Type</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.jboss.tools.smooks.model.graphics.ext.TaskType#getTask <em>Task</em>}</li>
+ * <li>{@link org.jboss.tools.smooks.model.graphics.ext.TaskType#getId <em>Id</em>}</li>
+ * <li>{@link org.jboss.tools.smooks.model.graphics.ext.TaskType#getName <em>Name</em>}</li>
+ * <li>{@link org.jboss.tools.smooks.model.graphics.ext.TaskType#getType <em>Type</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.jboss.tools.smooks.model.graphics.ext.GraphPackage#getTaskType()
+ * @model extendedMetaData="name='task_._type' kind='elementOnly'"
+ * @generated
+ */
+public interface TaskType {
+
+ int getProblemType();
+
+ /**
+ *
+ * @param type
+ */
+ void setProblemType(int type);
+
+ List<String> getProblemMessages();
+
+ void cleanProblemMessages();
+
+ void removeProblemMessage(String message);
+
+ void addProblemMessage(String message);
+
+ void setPropertyChangeSupport(PropertyChangeSupport support);
+
+ Object getParent();
+
+ void setParent(Object parent);
+
+ public void addTask(TaskType task);
+
+ public void removeTask(TaskType task);
+ /**
+ * Returns the value of the '<em><b>Task</b></em>' containment reference list.
+ * The list contents are of type {@link org.jboss.tools.smooks.model.graphics.ext.TaskType}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Task</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Task</em>' containment reference list.
+ * @see org.jboss.tools.smooks.model.graphics.ext.GraphPackage#getTaskType_Task()
+ * @model containment="true"
+ * extendedMetaData="kind='element' name='task' namespace='##targetNamespace'"
+ * @generated
+ */
+ List<TaskType> getTask();
+
+ /**
+ * Returns the value of the '<em><b>Id</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Id</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Id</em>' attribute.
+ * @see #setId(String)
+ * @see org.jboss.tools.smooks.model.graphics.ext.GraphPackage#getTaskType_Id()
+ * @model dataType="org.eclipse.emf.ecore.xml.type.String"
+ * extendedMetaData="kind='attribute' name='id'"
+ * @generated
+ */
+ String getId();
+
+ /**
+ * Sets the value of the '{@link org.jboss.tools.smooks.model.graphics.ext.TaskType#getId <em>Id</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Id</em>' attribute.
+ * @see #getId()
+ * @generated
+ */
+ void setId(String value);
+
+ /**
+ * Returns the value of the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Name</em>' attribute.
+ * @see #setName(String)
+ * @see org.jboss.tools.smooks.model.graphics.ext.GraphPackage#getTaskType_Name()
+ * @model dataType="org.eclipse.emf.ecore.xml.type.String"
+ * extendedMetaData="kind='attribute' name='name'"
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link org.jboss.tools.smooks.model.graphics.ext.TaskType#getName <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Name</em>' attribute.
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+ /**
+ * Returns the value of the '<em><b>Type</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Type</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Type</em>' attribute.
+ * @see #setType(String)
+ * @see org.jboss.tools.smooks.model.graphics.ext.GraphPackage#getTaskType_Type()
+ * @model dataType="org.eclipse.emf.ecore.xml.type.String"
+ * extendedMetaData="kind='attribute' name='type'"
+ * @generated
+ */
+ String getType();
+
+ /**
+ * Sets the value of the '{@link org.jboss.tools.smooks.model.graphics.ext.TaskType#getType <em>Type</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Type</em>' attribute.
+ * @see #getType()
+ * @generated
+ */
+ void setType(String value);
+
+ boolean inTheTask(Object smooksModel);
+
+ void addSmooksModel(Object smooksModel);
+
+ void removeSmooksModel(Object smooksModel);
+
+} // TaskType
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskTypeImpl.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskTypeImpl.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskTypeImpl.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,320 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.jboss.tools.smooks.graphical.editors.process;
+
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.smooks.configuration.editors.IFieldMarker;
+
+/**
+ * <!-- begin-user-doc --> An implementation of the model object '
+ * <em><b>Task Type</b></em>'. <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>
+ * {@link org.jboss.tools.smooks.model.graphics.ext.impl.TaskTypeImpl#getTask
+ * <em>Task</em>}</li>
+ * <li>{@link org.jboss.tools.smooks.model.graphics.ext.impl.TaskTypeImpl#getId
+ * <em>Id</em>}</li>
+ * <li>
+ * {@link org.jboss.tools.smooks.model.graphics.ext.impl.TaskTypeImpl#getName
+ * <em>Name</em>}</li>
+ * <li>
+ * {@link org.jboss.tools.smooks.model.graphics.ext.impl.TaskTypeImpl#getType
+ * <em>Type</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class TaskTypeImpl implements TaskType {
+
+ private PropertyChangeSupport propertyChangeSupport = null;
+
+ private Object parent;
+
+ private List<Object> smooksModel = null;
+
+ private int problemType = IFieldMarker.TYPE_NONE;
+
+ private List<String> problemMessages = null;
+
+ public List<String> getProblemMessages() {
+ if (problemMessages == null) {
+ problemMessages = new ArrayList<String>();
+ }
+ return problemMessages;
+ }
+
+ public void addProblemMessage(String message) {
+ getProblemMessages().add(message);
+ }
+
+ public void removeProblemMessage(String message) {
+ getProblemMessages().remove(message);
+ }
+
+ public void cleanProblemMessages() {
+ getProblemMessages().clear();
+ }
+
+ public int getProblemType() {
+ return problemType;
+ }
+
+ public void setProblemType(int problemType) {
+ if (this.problemType == IFieldMarker.TYPE_ERROR && problemType == IFieldMarker.TYPE_WARINING) {
+ return;
+ }
+ this.problemType = problemType;
+ }
+
+ /**
+ * @return the propertyChangeSupport
+ */
+ public PropertyChangeSupport getPropertyChangeSupport() {
+ return propertyChangeSupport;
+ }
+
+ /**
+ * @param propertyChangeSupport
+ * the propertyChangeSupport to set
+ */
+ public void setPropertyChangeSupport(PropertyChangeSupport propertyChangeSupport) {
+ this.propertyChangeSupport = propertyChangeSupport;
+ }
+
+ /**
+ * @return the parent
+ */
+ public Object getParent() {
+ return parent;
+ }
+
+ /**
+ * @param parent
+ * the parent to set
+ */
+ public void setParent(Object parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * @return the smooksModel
+ */
+ public List<Object> getSmooksModel() {
+ if (smooksModel == null) {
+ smooksModel = new ArrayList<Object>();
+ }
+ return smooksModel;
+ }
+
+ /**
+ * The cached value of the '{@link #getTask() <em>Task</em>}' containment
+ * reference list. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see #getTask()
+ * @generated
+ * @ordered
+ */
+ protected List<TaskType> task;
+
+ /**
+ * The default value of the '{@link #getId() <em>Id</em>}' attribute. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see #getId()
+ * @generated
+ * @ordered
+ */
+ protected static final String ID_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getId() <em>Id</em>}' attribute. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see #getId()
+ * @generated
+ * @ordered
+ */
+ protected String id = ID_EDEFAULT;
+
+ /**
+ * The default value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected static final String NAME_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected String name = NAME_EDEFAULT;
+
+ /**
+ * The default value of the '{@link #getType() <em>Type</em>}' attribute.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see #getType()
+ * @generated
+ * @ordered
+ */
+ protected static final String TYPE_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getType() <em>Type</em>}' attribute.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see #getType()
+ * @generated
+ * @ordered
+ */
+ protected String type = TYPE_EDEFAULT;
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected TaskTypeImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public List<TaskType> getTask() {
+ if (task == null) {
+ task = new ArrayList<TaskType>();
+ }
+ return task;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void setId(String newId) {
+ String oldId = name;
+ id = newId;
+ if (propertyChangeSupport != null)
+ propertyChangeSupport.firePropertyChange(ProcessType.PRO_ID_CHANGE, oldId, newId);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void setName(String newName) {
+ String oldName = name;
+ name = newName;
+ if (propertyChangeSupport != null)
+ propertyChangeSupport.firePropertyChange(ProcessType.PRO_NAME_CHANGE, oldName, newName);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void setType(String newType) {
+ type = newType;
+ }
+
+ public void addTask(TaskType task) {
+ if (task != null) {
+ this.getTask().add(task);
+ task.setParent(this);
+ task.setPropertyChangeSupport(propertyChangeSupport);
+ if (propertyChangeSupport != null)
+ propertyChangeSupport.firePropertyChange(ProcessType.PRO_ADD_CHILD, null, task);
+ }
+ }
+
+ public void removeTask(TaskType task) {
+ if (task != null) {
+ this.getTask().remove(task);
+ task.setParent(null);
+ task.setPropertyChangeSupport(null);
+ if (propertyChangeSupport != null)
+ propertyChangeSupport.firePropertyChange(ProcessType.PRO_REMOVE_CHILD, task, null);
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public String toString() {
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (id: "); //$NON-NLS-1$
+ result.append(id);
+ result.append(", name: "); //$NON-NLS-1$
+ result.append(name);
+ result.append(", type: "); //$NON-NLS-1$
+ result.append(type);
+ result.append(')');
+ return result.toString();
+ }
+
+ public void addSmooksModel(Object smooksModel) {
+ getSmooksModel().add(smooksModel);
+ }
+
+ public boolean inTheTask(Object smooksModel) {
+ return true;
+ }
+
+ public void removeSmooksModel(Object smooksModel) {
+ getSmooksModel().remove(smooksModel);
+ }
+
+} // TaskTypeImpl
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskTypeImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TemplateAppyTaskNode.java
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TemplateAppyTaskNode.java (rev 0)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TemplateAppyTaskNode.java 2010-07-30 08:20:18 UTC (rev 23822)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * 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.graphical.editors.process;
+
+import org.jboss.tools.smooks.graphical.editors.TaskTypeManager;
+
+/**
+ * @author Dart
+ *
+ */
+public class TemplateAppyTaskNode extends TaskTypeImpl {
+
+ public TemplateAppyTaskNode() {
+ super();
+ this.setId(TaskTypeManager.TASK_ID_FREEMARKER_CSV_TEMPLATE);
+ this.setName(TaskTypeManager.getTaskLabel(this));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.graphical.editors.process.TaskTypeImpl#inTheTask
+ * (java.lang.Object)
+ */
+ @Override
+ public boolean inTheTask(Object smooksModel) {
+ return this.getSmooksModel().contains(smooksModel);
+ }
+
+}
Property changes on: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TemplateAppyTaskNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 5 months
JBoss Tools SVN: r23821 - trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates.
by jbosstools-commits@lists.jboss.org
Author: dvinnichek
Date: 2010-07-30 03:57:07 -0400 (Fri, 30 Jul 2010)
New Revision: 23821
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml
Log:
some minor changes with template for form:errors
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml 2010-07-30 07:53:09 UTC (rev 23820)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml 2010-07-30 07:57:07 UTC (rev 23821)
@@ -94,8 +94,8 @@
<vpe:tag name="form:errors" case-sensitive="yes">
<vpe:template children="no" modify="no">
- <span id="{@id}" style="{@cssStyle}" class="{@cssClass}">
- Errors will be here.
+ <span id="{@id}" style="{@cssStyle}" class="{@cssClass}">
+ <vpe:value expr="Errors for {@path} field." />
</span>
<vpe:dnd>
<vpe:drag start-enable="yes" />
14 years, 5 months
JBoss Tools SVN: r23820 - in trunk/vpe: tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest and 5 other directories.
by jbosstools-commits@lists.jboss.org
Author: dvinnichek
Date: 2010-07-30 03:53:09 -0400 (Fri, 30 Jul 2010)
New Revision: 23820
Added:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/ErrorsController.java
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/FieldValidator.java
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/FormBean.java
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/springapp-servlet.xml
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/index.jsp
Log:
add template for <form:errors> according to https://jira.jboss.org/browse/JBIDE-6711
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml 2010-07-30 00:37:15 UTC (rev 23819)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml 2010-07-30 07:53:09 UTC (rev 23820)
@@ -91,6 +91,17 @@
</vpe:dnd>
</vpe:template>
</vpe:tag>
+
+ <vpe:tag name="form:errors" case-sensitive="yes">
+ <vpe:template children="no" modify="no">
+ <span id="{@id}" style="{@cssStyle}" class="{@cssClass}">
+ Errors will be here.
+ </span>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
<vpe:tag name="form:form" case-sensitive="yes">
<vpe:template children="yes" modify="yes">
Modified: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/FormBean.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/FormBean.java 2010-07-30 00:37:15 UTC (rev 23819)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/FormBean.java 2010-07-30 07:53:09 UTC (rev 23820)
@@ -18,6 +18,8 @@
private Map<Integer, String> availableCategories = new HashMap<Integer, String>();
private Set<Integer> selectedCategories = new HashSet<Integer>();
private List<CategoryType> favoriteCategories = new ArrayList<CategoryType>();
+
+ private String newName;
public FormBean() {
for (CategoryType categoryType : CategoryType.values()) {
@@ -75,4 +77,12 @@
public void setFavoriteCategories(List<CategoryType> favoriteCategories) {
this.favoriteCategories = favoriteCategories;
}
+
+ public String getNewName() {
+ return newName;
+ }
+
+ public void setNewName(String newName) {
+ this.newName = newName;
+ }
}
Added: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/ErrorsController.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/ErrorsController.java (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/ErrorsController.java 2010-07-30 07:53:09 UTC (rev 23820)
@@ -0,0 +1,19 @@
+package org.jboss.tools.vpe.spring.test.springtest.controller;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.tools.vpe.spring.test.springtest.FormBean;
+import org.springframework.web.servlet.mvc.SimpleFormController;
+
+/**
+ *
+ * @author Denis Vinnichek (dvinnichek)
+ */
+public class ErrorsController extends SimpleFormController {
+
+ protected final Log logger = LogFactory.getLog(getClass());
+ public ErrorsController() {
+ setCommandClass(FormBean.class);
+ setCommandName("formBean");
+ }
+}
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/ErrorsController.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/FieldValidator.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/FieldValidator.java (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/FieldValidator.java 2010-07-30 07:53:09 UTC (rev 23820)
@@ -0,0 +1,16 @@
+package org.jboss.tools.vpe.spring.test.springtest.validator;
+
+import org.springframework.validation.Errors;
+import org.springframework.validation.ValidationUtils;
+import org.springframework.validation.Validator;
+
+public class FieldValidator implements Validator{
+
+ public boolean supports(Class<?> clazz) {
+ return true;
+ }
+
+ public void validate(Object target, Errors errors) {
+ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "newName", "required","Name is required.");
+ }
+}
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/FieldValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp 2010-07-30 07:53:09 UTC (rev 23820)
@@ -0,0 +1,43 @@
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
+<html>
+<head>
+<style>
+.red-bordered-text {
+ border: 1px solid red;
+}
+</style>
+</head>
+<body>
+<h1>Test of form:errors</h1>
+
+<form:form commandName="formBean" method="POST">
+ <table>
+ <tr>
+ <td />
+ <%-- Show errors for newName field --%>
+ <td>
+ <form:errors id="nameErrors1" path="newName" />
+ </td>
+ </tr>
+ <tr>
+ <td />
+ <%-- Show errors for newName field --%>
+ <td>
+ <form:errors id="nameErrors2" path="newName"
+ cssClass="red-bordered-text"
+ cssStyle="color: green;" />
+ </td>
+ </tr>
+ <tr>
+ <td>New Name:</td>
+ <td><form:input path="newName" /></td>
+ </tr>
+ <tr>
+ <td/>
+ <td align="right"><input type="submit" value="Test" /></td>
+ </tr>
+ </table>
+</form:form>
+</body>
+</html>
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/springapp-servlet.xml
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/springapp-servlet.xml 2010-07-30 00:37:15 UTC (rev 23819)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/springapp-servlet.xml 2010-07-30 07:53:09 UTC (rev 23820)
@@ -10,10 +10,13 @@
<bean name="/form.htm" class="org.jboss.tools.vpe.spring.test.springtest.FormController"/>
<bean name="/checkbox.htm" class="org.jboss.tools.vpe.spring.test.springtest.FormController"/>
<bean name="/checkboxes.htm" class="org.jboss.tools.vpe.spring.test.springtest.FormController"/>
+ <bean name="/errors.htm" class="org.jboss.tools.vpe.spring.test.springtest.controller.ErrorsController">
+ <property name="validator" ref="fieldValidator"/>
+ </bean>
+ <bean id="fieldValidator" class="org.jboss.tools.vpe.spring.test.springtest.validator.FieldValidator"/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
- <property name="prefix" value="/WEB-INF/jsp"></property>
+ <property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
Modified: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/index.jsp
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/index.jsp 2010-07-30 00:37:15 UTC (rev 23819)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/index.jsp 2010-07-30 07:53:09 UTC (rev 23820)
@@ -4,4 +4,6 @@
<br/>
<a href="form.htm">form.htm</a>
<br/>
+<a href="errors.htm">errors.htm</a>
+<br/>
14 years, 5 months
JBoss Tools SVN: r23816 - in trunk/maven/tests/org.jboss.tools.maven.ui.bot.test: src/org/jboss/tools/maven/ui/bot/test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2010-07-29 18:54:26 -0400 (Thu, 29 Jul 2010)
New Revision: 23816
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/META-INF/MANIFEST.MF
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6714 Add SWTBot tests for JBoss Maven Integration
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/META-INF/MANIFEST.MF 2010-07-29 20:55:00 UTC (rev 23815)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/META-INF/MANIFEST.MF 2010-07-29 22:54:26 UTC (rev 23816)
@@ -16,13 +16,21 @@
org.eclipse.swtbot.swt.finder,
org.junit4,
org.jboss.tools.seam.core,
+ org.jboss.tools.maven.core,
+ org.jboss.tools.maven.hibernate,
+ org.jboss.tools.maven.jsf,
+ org.jboss.tools.maven.portlet,
+ org.jboss.tools.maven.seam,
+ org.jboss.tools.maven.ui,
org.eclipse.wst.server.core,
org.eclipse.datatools.connectivity;visibility:=reexport,
org.eclipse.datatools.connectivity.db.generic,
org.jboss.tools.common,
org.jboss.tools.tests,
org.maven.ide.eclipse;bundle-version="0.10.0",
- org.jboss.ide.eclipse.as.core
+ org.jboss.ide.eclipse.as.core,
+ org.maven.ide.eclipse.maven_model_edit;bundle-version="0.10.0",
+ org.hamcrest
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Eclipse-RegisterBuddy: org.apache.log4j
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java 2010-07-29 20:55:00 UTC (rev 23815)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java 2010-07-29 22:54:26 UTC (rev 23816)
@@ -11,6 +11,7 @@
package org.jboss.tools.maven.ui.bot.test;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -19,6 +20,7 @@
import java.util.List;
import java.util.Properties;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -47,12 +49,15 @@
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotViewMenu;
+import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.results.Result;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@@ -64,6 +69,7 @@
import org.eclipse.ui.internal.IPreferenceConstants;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.util.PrefUtil;
+import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IRuntimeType;
import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
@@ -74,17 +80,24 @@
import org.eclipse.wst.server.core.ServerUtil;
import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
+import org.eclipse.wst.validation.ValidationFramework;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.core.project.facet.SeamVersion;
import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.ResourcesUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.maven.ide.components.pom.Model;
+import org.maven.ide.components.pom.Parent;
+import org.maven.ide.components.pom.util.PomResourceImpl;
+import org.maven.ide.eclipse.MavenPlugin;
import org.maven.ide.eclipse.core.IMavenConstants;
+import org.maven.ide.eclipse.embedder.MavenModelManager;
/**
* @author Snjeza
@@ -93,24 +106,16 @@
@RunWith(SWTBotJunit4ClassRunner.class)
public class CreateMavenizedSeamProjectTest {
- /**
- *
- */
+ protected static final int IDLE_TIME = 60000;
+
private static final String CONNECTION_PROFILE_NAME = "DefaultDS";
- /**
- *
- */
private static final String SEAM_RUNTIME_NAME = "Seam 2.2";
- /**
- *
- */
private static final String JBOSS_AS_RUNTIME_NAME = "JBoss AS 5.1 Runtime";
- /**
- *
- */
+ public static final String PACKAGE_EXPLORER = "Package Explorer"; //$NON-NLS-1$
+
private static final String JBOSS_AS_SERVER_NAME = "JBoss AS 5.1 Server";
public static final String JBOSS_AS_HOST = "localhost"; //$NON-NLS-1$
@@ -142,6 +147,13 @@
public static final String HSQLDB_DRIVER_LOCATION = "/common/lib/" + HSQLDB_DRIVER_JAR_NAME; //$NON-NLS-1$
+ public static final String PROJECT_NAME_WAR = "MavenizedSeamProjectWar";
+
+ public static final String TEST_PROJECT_NAME_WAR = "MavenizedSeamProjectWar-test";
+
+ public static final String PARENT_PROJECT_NAME_WAR = "MavenizedSeamProjectWar-parent";
+
+
public static final String PROJECT_NAME = "MavenizedSeamProject";
public static final String EAR_PROJECT_NAME = "MavenizedSeamProject-ear";
@@ -152,8 +164,10 @@
public static final String PARENT_PROJECT_NAME = "MavenizedSeamProject-parent";
- public static final String DEPOY_TYPE = "EAR";
+ public static final String DEPLOY_TYPE_EAR = "EAR";
+ public static final String DEPLOY_TYPE_WAR = "WAR";
+
protected static SWTWorkbenchBot bot;
@BeforeClass
@@ -174,14 +188,18 @@
createDriver(asLocation, HSQLDB_DRIVER_LOCATION);
- createNewSeamWebProjectWizard(PROJECT_NAME, DEPOY_TYPE);
+ activateSchell();
+
+ createNewSeamWebProjectWizard(PROJECT_NAME, DEPLOY_TYPE_EAR);
+
+ createNewSeamWebProjectWizard(PROJECT_NAME_WAR, DEPLOY_TYPE_WAR);
}
private static void initSWTBot() throws CoreException {
bot = new SWTWorkbenchBot();
SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
SWTBotPreferences.TIMEOUT = 1000;
- SWTBotPreferences.PLAYBACK_DELAY = 25;
+ SWTBotPreferences.PLAYBACK_DELAY = 5;
JobUtils.waitForIdle(60000);
try {
SWTBotView view = bot.viewByTitle("Welcome");
@@ -232,6 +250,20 @@
}, new NullProgressMonitor());
}
+ private static void removeServers() throws CoreException {
+ IServer server = ServerCore.findServer(JBOSS_AS_SERVER_NAME);
+ IServerWorkingCopy wc = server.createWorkingCopy();
+ IModule[] modules = wc.getModules();
+ IProgressMonitor monitor = new NullProgressMonitor();
+ wc.modifyModules(new IModule[] {} , modules, monitor);
+ wc.save(true, monitor);
+ server.publish(IServer.PUBLISH_INCREMENTAL, monitor);
+ JobUtils.waitForIdle(IDLE_TIME);
+ server.getRuntime().delete();
+ server.delete();
+ JobUtils.waitForIdle(IDLE_TIME);
+ }
+
protected static void switchPerspective(final String pid) {
Display.getDefault().syncExec(new Runnable() {
@@ -249,13 +281,17 @@
@Before
public void setUp() throws Exception {
- UIThreadRunnable.syncExec(new VoidResult() {
+ activateSchell();
+ }
+
+ private static void activateSchell() {
+ UIThreadRunnable.syncExec(new VoidResult() {
public void run() {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()
.forceActive();
}
});
- }
+ }
@After
public void tearDown() throws Exception {
@@ -264,7 +300,16 @@
@AfterClass
public final static void afterClass() throws Exception {
- removeProjects();
+ boolean buildAutomatically = ResourcesUtils.setBuildAutomatically(false);
+ ValidationFramework.getDefault().suspendAllValidation(true);
+ try {
+ removeServers();
+ removeProjects();
+ } finally {
+ ResourcesUtils.setBuildAutomatically(buildAutomatically);
+ ValidationFramework.getDefault().suspendAllValidation(false);
+ }
+ JobUtils.waitForIdle(IDLE_TIME);
}
protected static void createJBossServer(File asLocation, String serverType, String runtimeType, String name, String runtimeName) throws CoreException {
@@ -442,7 +487,7 @@
bot.button("Next >").click();
bot.comboBox(0).setSelection(SEAM_RUNTIME_NAME);
- bot.radio(DEPOY_TYPE).click();
+ bot.radio(deployType).click();
bot.comboBox(1).setSelection("HSQL");
bot.comboBox(2).setSelection(CONNECTION_PROFILE_NAME);
bot.button("Finish").click();
@@ -458,6 +503,9 @@
checkErrors(EJB_PROJECT_NAME);
checkErrors(TEST_PROJECT_NAME);
checkErrors(PARENT_PROJECT_NAME);
+ checkErrors(PROJECT_NAME_WAR);
+ checkErrors(TEST_PROJECT_NAME_WAR);
+ checkErrors(PARENT_PROJECT_NAME_WAR);
}
private void checkErrors(String projectName) throws CoreException {
@@ -482,6 +530,9 @@
isMavenProject(EJB_PROJECT_NAME);
isMavenProject(TEST_PROJECT_NAME);
isMavenProject(PARENT_PROJECT_NAME);
+ isMavenProject(PROJECT_NAME_WAR);
+ isMavenProject(TEST_PROJECT_NAME_WAR);
+ isMavenProject(PARENT_PROJECT_NAME_WAR);
}
private void isMavenProject(String projectName) throws CoreException {
@@ -489,4 +540,33 @@
assertTrue("The '" + projectName + "' project isn't a Maven project.", project.hasNature(IMavenConstants.NATURE_ID));
}
+ // see https://jira.jboss.org/browse/JBIDE-6587
+ @Test
+ public void testMavenWarArchive() throws Exception {
+ final SWTBotView packageExplorer = bot.viewByTitle(PACKAGE_EXPLORER);
+ SWTBot innerBot = packageExplorer.bot();
+ innerBot.activeShell().activate();
+ final SWTBotTree tree = innerBot.tree();
+ final SWTBotTreeItem warProjectItem = tree.getTreeItem(PROJECT_NAME_WAR);
+ warProjectItem.select();
+
+ SWTBotMenu runAs = tree.contextMenu("Run As");
+ runAs.menu("6 Maven build...").click();
+
+ SWTBotShell shell = bot.shell("Edit Configuration");
+ shell.activate();
+
+ bot.textWithLabel("Goals:").setText("clean package");
+ bot.button("Run").click();
+
+ JobUtils.waitForIdle(IDLE_TIME);
+
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME_WAR);
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ IPath webInfPath = new Path("target/" + PROJECT_NAME_WAR + "-0.0.1-SNAPSHOT/WEB-INF");
+ assertFalse(project.getFolder(webInfPath.append("src")).exists());
+ assertFalse(project.getFolder(webInfPath.append("dev")).exists());
+ assertTrue(project.getFolder(webInfPath.append("lib")).exists());
+
+ }
}
14 years, 5 months
JBoss Tools SVN: r23815 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core: src/org/jboss/tools/deltacloud/core/client and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: jjohnstn
Date: 2010-07-29 16:55:00 -0400 (Thu, 29 Jul 2010)
New Revision: 23815
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudObject.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Instance.java
Log:
2010-07-29 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (buildHardwareProfile): XML
has changed element name to hardware_profile from hardware-profile.
(buildInstance): Ditto.
* src/org/jboss/tools/deltacloud/core/client/DeltaCloudObject.java (getId): Denote as
XMLAttribute now that id is no longer an element.
* src/org/jboss/tools/deltacloud/core/client/Instance.java (publicAddresses): Change
XML element name to public_addresses from public-addresses.
(privateAddresses): Similar except for private-addresses to private_addresses.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-07-29 20:18:16 UTC (rev 23814)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-07-29 20:55:00 UTC (rev 23815)
@@ -1,3 +1,14 @@
+2010-07-29 Jeff Johnston <jjohnstn(a)redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (buildHardwareProfile): XML
+ has changed element name to hardware_profile from hardware-profile.
+ (buildInstance): Ditto.
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudObject.java (getId): Denote as
+ XMLAttribute now that id is no longer an element.
+ * src/org/jboss/tools/deltacloud/core/client/Instance.java (publicAddresses): Change
+ XML element name to public_addresses from public-addresses.
+ (privateAddresses): Similar except for private-addresses to private_addresses.
+
2010-07-28 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (findCloud): New
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java 2010-07-29 20:18:16 UTC (rev 23814)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java 2010-07-29 20:55:00 UTC (rev 23815)
@@ -244,8 +244,8 @@
Document document = db.parse(new InputSource(new StringReader(xml)));
instance.setImageId(getIdFromHref(getAttributeValues(document, "image", "href").get(0)));
- instance.setProfileId(getIdFromHref(getAttributeValues(document, "hardware-profile", "href").get(0)));
- getProfileProperties(instance, getPropertyNodes(document, "hardware-profile"));
+ instance.setProfileId(getIdFromHref(getAttributeValues(document, "hardware_profile", "href").get(0)));
+ getProfileProperties(instance, getPropertyNodes(document, "hardware_profile"));
instance.setRealmId(getIdFromHref(getAttributeValues(document, "realm", "href").get(0)));
instance.setState(getElementText(document, "state").get(0));
@@ -275,7 +275,7 @@
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(new InputSource(new StringReader(xml)));
- List<Node> nodes = getPropertyNodes(document, "hardware-profile");
+ List<Node> nodes = getPropertyNodes(document, "hardware_profile");
for (Node n : nodes) {
Property p = new Property();
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudObject.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudObject.java 2010-07-29 20:18:16 UTC (rev 23814)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudObject.java 2010-07-29 20:55:00 UTC (rev 23815)
@@ -2,13 +2,12 @@
import java.io.Serializable;
-import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlAttribute;
public abstract class DeltaCloudObject implements Serializable
{
private static final long serialVersionUID = 1L;
- @XmlElement
protected String id;
@SuppressWarnings("unused")
@@ -16,7 +15,8 @@
{
this.id = id;
}
-
+
+ @XmlAttribute
public String getId()
{
return id;
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Instance.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Instance.java 2010-07-29 20:18:16 UTC (rev 23814)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Instance.java 2010-07-29 20:55:00 UTC (rev 23815)
@@ -35,10 +35,10 @@
private List<Action> actions;
- @XmlElement(name="public-addresses")
+ @XmlElement(name="public_addresses")
private AddressList publicAddresses;
- @XmlElement(name="private-addresses")
+ @XmlElement(name="private_addresses")
private AddressList privateAddresses;
private Instance()
14 years, 5 months