Author: DartPeng
Date: 2009-11-09 03:38:00 -0500 (Mon, 09 Nov 2009)
New Revision: 18491
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksConfigurationOverviewPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors_10/Smooks10MultiFormEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/CreateConnectionCommand.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/DeleteTaskNodeAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/ProcessAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/TaskTypeManager.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/TriggerConnectionEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/ValueBindingConnectionEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/JavaBeanGraphModel.java
Log:
JBIDE-5157
Change the metadata of smooks-resource-config element
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksConfigurationOverviewPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksConfigurationOverviewPage.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksConfigurationOverviewPage.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -64,7 +64,6 @@
import org.jboss.tools.smooks.configuration.SmooksConstants;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.configuration.validate.ISmooksModelValidateListener;
-import org.jboss.tools.smooks.editor.AbstractSmooksFormEditor;
import org.jboss.tools.smooks.editor.ISmooksModelProvider;
import org.jboss.tools.smooks.editor.ISourceSynchronizeListener;
import org.jboss.tools.smooks.model.common.AbstractAnyType;
@@ -1396,12 +1395,16 @@
public void sourceChange(Object model) {
lockEventFire = true;
+ SmooksGraphicsExtType extType = smooksModelProvider.getSmooksGraphicsExt();
+ if (extType == null) {
+ return;
+ }
- String name = smooksModelProvider.getSmooksGraphicsExt().getName();
+ String name = extType.getName();
if (name != null)
smooksNameText.setText(name);
- String author = smooksModelProvider.getSmooksGraphicsExt().getAuthor();
+ String author = extType.getAuthor();
if (author != null)
smooksAuthorText.setText(author);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -88,16 +88,16 @@
// addSmooksGraphicalEditor();
- // configurationPage = createSmooksConfigurationFormPage();
- // addValidateListener(configurationPage);
- // addSourceSynchronizeListener(configurationPage);
- // addSmooksGraphExtetionListener(configurationPage);
- // try {
- // int index = this.addPage(configurationPage);
- // setPageText(index, "Message Filter");
- // } catch (PartInitException e) {
- // e.printStackTrace();
- // }
+// configurationPage = createSmooksConfigurationFormPage();
+// addValidateListener(configurationPage);
+// addSourceSynchronizeListener(configurationPage);
+// addSmooksGraphExtetionListener(configurationPage);
+// try {
+// int index = this.addPage(configurationPage);
+// setPageText(index, "Message Filter");
+// } catch (PartInitException e) {
+// e.printStackTrace();
+// }
super.addPages();
}
@@ -232,4 +232,13 @@
public String getContributorId() {
return getSite().getId();
}
+
+ @Override
+ public void dispose() {
+ try {
+ super.dispose();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -314,7 +314,10 @@
private void initReaderConfigSection() {
Object reader = getCurrentReaderModel();
- String type = getSmooksGraphicsExtType().getInputType();
+ SmooksGraphicsExtType extType = getSmooksGraphicsExtType();
+ if (extType == null)
+ return;
+ String type = extType.getInputType();
if (reader instanceof EObject && type != null) {
SmooksResourceListType list = getSmooksConfigResourceList();
createReaderPanel((EObject) list.getAbstractReader().get(0));
@@ -626,25 +629,28 @@
Collection<?> collections = provider.getNewChildDescriptors(resourceList,
editDomain, null);
SmooksGraphicsExtType extType = getSmooksGraphicsExtType();
- String version = extType.getPlatformVersion();
- OnlyReaderViewerFilter filter = new OnlyReaderViewerFilter();
- for (Iterator<?> iterator = collections.iterator(); iterator.hasNext();) {
- Object object = (Object) iterator.next();
- if (object instanceof CommandParameter) {
- Object value = ((CommandParameter) object).getValue();
- value = AdapterFactoryEditingDomain.unwrap(value);
+ if (extType != null) {
+ String version = extType.getPlatformVersion();
+ OnlyReaderViewerFilter filter = new OnlyReaderViewerFilter();
+ for (Iterator<?> iterator = collections.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ if (object instanceof CommandParameter) {
+ Object value = ((CommandParameter) object).getValue();
- if (filter.select(null, null, value)) {
- if (SmooksUIUtils.isUnSupportElement(version, (EObject) value)) {
- continue;
+ value = AdapterFactoryEditingDomain.unwrap(value);
+
+ if (filter.select(null, null, value)) {
+ if (SmooksUIUtils.isUnSupportElement(version, (EObject) value)) {
+ continue;
+ }
+
+ IItemLabelProvider lp = (IItemLabelProvider)
editDomain.getAdapterFactory().adapt(value,
+ IItemLabelProvider.class);
+ String text = lp.getText(value);
+ readerCombo.add(text);
+ readerTypeList.add(value);
}
-
- IItemLabelProvider lp = (IItemLabelProvider)
editDomain.getAdapterFactory().adapt(value,
- IItemLabelProvider.class);
- String text = lp.getText(value);
- readerCombo.add(text);
- readerTypeList.add(value);
}
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -168,6 +168,7 @@
import org.jboss.tools.smooks.model.graphics.ext.ParamType;
import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphExtensionDocumentRoot;
import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
+import org.jboss.tools.smooks.model.graphics.ext.TaskType;
import org.jboss.tools.smooks.model.graphics.ext.util.GraphResourceFactoryImpl;
import org.jboss.tools.smooks.model.groovy.GroovyPackage;
import org.jboss.tools.smooks.model.javabean.BindingsType;
@@ -186,6 +187,7 @@
import org.jboss.tools.smooks.model.json12.Json12Package;
import org.jboss.tools.smooks.model.json12.Json12Reader;
import org.jboss.tools.smooks.model.persistence12.Persistence12Package;
+import org.jboss.tools.smooks.model.rules10.RuleBasesType;
import org.jboss.tools.smooks.model.rules10.Rules10Package;
import org.jboss.tools.smooks.model.smooks.AbstractReader;
import org.jboss.tools.smooks.model.smooks.AbstractResourceConfig;
@@ -1279,6 +1281,10 @@
if (model == null)
return null;
final Resource resource = ((EObject) model).eResource();
+ return getResource(resource);
+ }
+
+ public static IResource getResource(Resource resource) {
if (resource == null)
return null;
URI uri = resource.getURI();
@@ -2430,6 +2436,15 @@
return types;
}
+ 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 static boolean isActivedInput(InputType input) {
List<ParamType> params = input.getParam();
for (Iterator<?> iterator2 = params.iterator(); iterator2.hasNext();) {
@@ -2916,7 +2931,8 @@
}
public static boolean isSmooksFile(IFile file) {
- if(file.getName().indexOf(".xml") != -1) return true;
+ if (file.getName().indexOf(".xml") != -1)
+ return true;
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
IContentType[] types = contentTypeManager.findContentTypesFor(file.getName());
for (IContentType contentType : types) {
@@ -2933,4 +2949,23 @@
}
return false;
}
+
+ public static EStructuralFeature getFeature(Object model) {
+ if (model instanceof BindingsType) {
+ return JavabeanPackage.Literals.DOCUMENT_ROOT__BINDINGS;
+ }
+ if (model instanceof BeanType) {
+ return Javabean12Package.Literals.JAVABEAN12_DOCUMENT_ROOT__BEAN;
+ }
+ if (model instanceof Xsl) {
+ return XslPackage.Literals.DOCUMENT_ROOT__XSL;
+ }
+ if(model instanceof Freemarker){
+ return FreemarkerPackage.Literals.DOCUMENT_ROOT__FREEMARKER;
+ }
+ if(model instanceof RuleBasesType){
+ return Rules10Package.Literals.RULES10_DOCUMENT_ROOT__RULE_BASES;
+ }
+ return null;
+ }
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors_10/Smooks10MultiFormEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors_10/Smooks10MultiFormEditor.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors_10/Smooks10MultiFormEditor.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -118,8 +118,8 @@
}
@Override
- protected void generateSmooksGraphExt() {
- super.generateSmooksGraphExt();
+ protected void generateSmooksGraphExtWithSave() {
+ super.generateSmooksGraphExtWithSave();
}
private Smooks10ConfigurationOverviewPage createSmooksConfigurationOverviewPage() {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormEditor.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormEditor.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -149,8 +149,8 @@
}
@Override
- protected void generateSmooksGraphExt() {
- super.generateSmooksGraphExt();
+ protected void generateSmooksGraphExtWithSave() {
+ super.generateSmooksGraphExtWithSave();
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -3,6 +3,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Collection;
@@ -15,7 +16,13 @@
import java.util.Timer;
import java.util.TimerTask;
+import org.dom4j.Document;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.SAXReader;
+import org.dom4j.io.XMLWriter;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.command.BasicCommandStack;
@@ -59,6 +66,7 @@
import org.jboss.tools.smooks.configuration.validate.ISmooksModelValidateListener;
import org.jboss.tools.smooks.configuration.validate.SmooksMarkerHelper;
import org.jboss.tools.smooks.configuration.validate.SmooksModelValidator;
+import org.jboss.tools.smooks.graphical.editors.ProcessAnalyzer;
import org.jboss.tools.smooks.model.calc.provider.CalcItemProviderAdapterFactory;
import org.jboss.tools.smooks.model.common.provider.CommonItemProviderAdapterFactory;
import org.jboss.tools.smooks.model.csv.provider.CsvItemProviderAdapterFactory;
@@ -170,6 +178,46 @@
return textEditor;
}
+ protected ByteArrayOutputStream getFormattedXMLContentsStream(InputStream outstream)
throws IOException {
+ XMLWriter writer = null;
+ try {
+ SAXReader parser = new SAXReader();
+ Document doc = parser.read(outstream);
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ OutputFormat format = OutputFormat.createPrettyPrint();
+ writer = new XMLWriter(stream, format);
+ writer.write(doc);
+ return stream;
+ } catch (Throwable t) {
+
+ } finally {
+ if (writer != null) {
+ writer.close();
+ }
+ }
+ return null;
+ }
+
+ protected String getFormattedXMLContents(String contents) throws IOException {
+ InputStream istream = null;
+ ByteArrayOutputStream stream = null;
+ try {
+ istream = new ByteArrayInputStream(contents.getBytes());
+ stream = getFormattedXMLContentsStream(istream);
+ return new String(stream.toByteArray());
+ } catch (Throwable t) {
+
+ } finally {
+ if (istream != null) {
+ istream.close();
+ }
+ if (stream != null) {
+ stream.close();
+ }
+ }
+ return null;
+ }
+
protected void handleEMFModelChange() {
IDocument document =
textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
@@ -178,6 +226,8 @@
smooksModel.eResource().save(out, null);
String newContent = out.toString();
+ newContent = getFormattedXMLContents(newContent);
+
String oldContent = document.get();
int startIndex = 0;
@@ -382,6 +432,10 @@
this.smooksModel = resource.getContents().get(0);
SmooksGraphicsExtType oldGraphModel = smooksGraphicsExt;
smooksGraphicsExt = createSmooksGraphcsExtType(smooksModel);
+ if (smooksGraphicsExt == null) {
+ generateSmooksGraphExt(false);
+ analyzeSmooksProcess(false);
+ }
if (oldGraphModel != null) {
smooksGraphicsExt.getChangeListeners().addAll(oldGraphModel.getChangeListeners());
oldGraphModel.getChangeListeners().clear();
@@ -444,7 +498,29 @@
for (Iterator<Resource> iterator = resourceList.iterator();
iterator.hasNext();) {
handleEMFModelChange = true;
Resource resource = (Resource) iterator.next();
- resource.save(options);
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ resource.save(outputStream, options);
+ IResource file = SmooksUIUtils.getResource(resource);
+ if (file.exists() && file instanceof IFile) {
+ ByteArrayInputStream inputStream = new
ByteArrayInputStream(outputStream.toByteArray());
+ ByteArrayOutputStream newOutputStream =
getFormattedXMLContentsStream(inputStream);
+ try {
+ ((IFile) file).setContents(new
ByteArrayInputStream(newOutputStream.toByteArray()),
+ IResource.FORCE, monitor);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ } finally {
+ if (outputStream != null) {
+ outputStream.close();
+ }
+ if (newOutputStream != null) {
+ newOutputStream.close();
+ }
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ }
+ }
monitor.worked(1);
}
((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone();
@@ -564,7 +640,7 @@
smooksResource.save(Collections.emptyMap());
}
} else {
- generateSmooksGraphExt();
+ generateSmooksGraphExtWithSave();
}
} catch (Exception e) {
@@ -573,9 +649,48 @@
if (smooksGraphicsExt != null) {
smooksGraphicsExt.addSmooksGraphChangeListener(this);
}
+
+ // analyze procss contents
+ analyzeSmooksProcess(true);
}
- protected void generateSmooksGraphExt() {
+ protected void analyzeSmooksProcess(boolean forceSave) {
+ ProcessAnalyzer processAnalyzer = new ProcessAnalyzer(this);
+ EObject smooksModel = getSmooksResourceList();
+ if (smooksModel != null && smooksModel instanceof SmooksResourceListType) {
+ boolean needSave = processAnalyzer.analyzeSmooksModels((SmooksResourceListType)
smooksModel);
+ if (needSave && forceSave) {
+ ResourceSet rs = this.getEditingDomain().getResourceSet();
+ List<Resource> resourceLis = rs.getResources();
+ for (Iterator<?> iterator = resourceLis.iterator(); iterator.hasNext();) {
+ Resource resource = (Resource) iterator.next();
+ try {
+ resource.save(Collections.emptyMap());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+ }
+
+ public EObject getSmooksResourceList() {
+ EObject m = null;
+ EObject smooksModel = getSmooksModel();
+ if (smooksModel instanceof org.jboss.tools.smooks10.model.smooks.DocumentRoot) {
+ m = ((org.jboss.tools.smooks10.model.smooks.DocumentRoot)
smooksModel).getSmooksResourceList();
+ }
+ if (smooksModel instanceof DocumentRoot) {
+ m = ((DocumentRoot) smooksModel).getSmooksResourceList();
+ }
+ return m;
+ }
+
+ protected void generateSmooksGraphExtWithSave() {
+ generateSmooksGraphExt(true);
+ }
+
+ protected void generateSmooksGraphExt(boolean forceSave) {
String version = SmooksUIUtils.judgeSmooksPlatformVersion(smooksModel);
String inputType = SmooksUIUtils.judgeInputType(smooksModel);
@@ -597,10 +712,12 @@
FeatureMapUtil.createEntry(
GraphPackage.Literals.SMOOKS_GRAPH_EXTENSION_DOCUMENT_ROOT__SMOOKS_GRAPHICS_EXT,
smooksGraphicsExt)).execute();
- try {
- smooksModel.eResource().save(Collections.emptyMap());
- } catch (IOException e) {
- e.printStackTrace();
+ if (forceSave) {
+ try {
+ smooksModel.eResource().save(Collections.emptyMap());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/CreateConnectionCommand.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/CreateConnectionCommand.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/CreateConnectionCommand.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -37,7 +37,8 @@
connection = new BeanReferenceConnection(source, target);
}
- if (target instanceof InputDataTreeNodeModel && connection == null) {
+ // default connection type
+ if (source instanceof InputDataTreeNodeModel && connection == null) {
connection = new TriggerConnection(source, target);
}
if (connection == null) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/DeleteTaskNodeAction.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/DeleteTaskNodeAction.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/DeleteTaskNodeAction.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -10,17 +10,25 @@
******************************************************************************/
package org.jboss.tools.smooks.graphical.actions;
+import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.editor.ISmooksModelProvider;
-import org.jboss.tools.smooks.model.graphics.ext.ProcessType;
+import org.jboss.tools.smooks.graphical.editors.TaskTypeManager;
import org.jboss.tools.smooks.model.graphics.ext.ProcessesType;
import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
import org.jboss.tools.smooks.model.graphics.ext.TaskType;
+import org.jboss.tools.smooks.model.smooks.SmooksPackage;
+import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
/**
* @author Dart
@@ -38,28 +46,69 @@
ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
}
-
@Override
public void update() {
List<TaskType> taskList = this.getCurrentSelectedTask();
- this.setEnabled((taskList != null && !taskList.isEmpty()));
+ this.setEnabled((taskList != null && !taskList.isEmpty() &&
taskList.size() == 1));
}
@Override
public void run() {
super.run();
- if(getProvider() != null){
+ if (getProvider() != null) {
ISmooksModelProvider p = getProvider();
SmooksGraphicsExtType graph = p.getSmooksGraphicsExt();
- if(graph != null){
+ if (graph != null) {
ProcessesType processes = graph.getProcesses();
- if(processes != null){
- ProcessType process = processes.getProcess();
- Command remove = RemoveCommand.create(p.getEditingDomain(),
getCurrentSelectedTask());
- p.getEditingDomain().getCommandStack().execute(remove);
+ if (processes != 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(p.getSmooksModel());
+ if (listType != null) {
+ for (Iterator<?> iterator = allTask.iterator(); iterator.hasNext();) {
+ TaskType taskType = (TaskType) iterator.next();
+ List<Object> elements =
TaskTypeManager.getAssociatedSmooksElements(taskType.getId(),
+ listType);
+ if (elements != null && !elements.isEmpty()) {
+ associatedElements.addAll(elements);
+ }
+ }
+ }
+ Command remove = null;
+ if (associatedElements.isEmpty()) {
+ remove = RemoveCommand.create(p.getEditingDomain(), currentTask);
+ p.getEditingDomain().getCommandStack().execute(remove);
+ } else {
+ associatedElements = getDeletedObjects(associatedElements);
+ CompoundCommand ccommand = new CompoundCommand();
+ ccommand.append(RemoveCommand.create(p.getEditingDomain(), currentTask));
+ remove = RemoveCommand.create(p.getEditingDomain(), listType,
+ SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_RESOURCE_CONFIG_GROUP,
+ associatedElements);
+ if (remove.canExecute()) {
+ ccommand.append(remove);
+ }
+ p.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;
+ }
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/ProcessAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/ProcessAnalyzer.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/ProcessAnalyzer.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -14,8 +14,16 @@
import java.util.Iterator;
import java.util.List;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.model.freemarker.Freemarker;
import org.jboss.tools.smooks.model.graphics.ext.GraphFactory;
+import org.jboss.tools.smooks.model.graphics.ext.GraphPackage;
import org.jboss.tools.smooks.model.graphics.ext.ProcessType;
import org.jboss.tools.smooks.model.graphics.ext.ProcessesType;
import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
@@ -32,6 +40,13 @@
*/
public class ProcessAnalyzer {
+ protected IEditingDomainProvider domainProvider;
+
+ public ProcessAnalyzer(IEditingDomainProvider domainProvider) {
+ this.domainProvider = domainProvider;
+ Assert.isNotNull(this.domainProvider);
+ }
+
public List<String> analyzeTaskID(SmooksResourceListType resourceList) {
List<String> taskIDs = new ArrayList<String>();
List<AbstractResourceConfig> resourceConfigList =
resourceList.getAbstractResourceConfig();
@@ -75,12 +90,7 @@
}
private 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);
- }
+ SmooksUIUtils.fillAllTask(task, taskList);
}
/**
@@ -91,14 +101,18 @@
*/
public boolean analyzeSmooksModels(SmooksResourceListType resourceList) {
boolean modelWasChanged = false;
- SmooksGraphicsExtType ext = this. getSmooksGraphicsType(resourceList);
+ CompoundCommand compoundCommand = new CompoundCommand();
+ SmooksGraphicsExtType ext = this.getSmooksGraphicsType(resourceList);
if (ext == null)
throw new RuntimeException("Can't find the smooks-graph-ext element");
ProcessesType processes = ext.getProcesses();
if (processes == null) {
processes = GraphFactory.eINSTANCE.createProcessesType();
- ext.setProcesses(processes);
+ Command c = SetCommand.create(domainProvider.getEditingDomain(), ext,
+ GraphPackage.Literals.SMOOKS_GRAPHICS_EXT_TYPE__PROCESSES, processes);
+ compoundCommand.append(c);
+ // ext.setProcesses(processes);
modelWasChanged = true;
}
ProcessType process = null;
@@ -108,7 +122,9 @@
if (process == null) {
process = GraphFactory.eINSTANCE.createProcessType();
- processes.setProcess(process);
+ Command c = SetCommand.create(domainProvider.getEditingDomain(), processes,
+ GraphPackage.Literals.PROCESSES_TYPE__PROCESS, process);
+ compoundCommand.append(c);
modelWasChanged = true;
}
@@ -123,7 +139,11 @@
TaskType inputTask = GraphFactory.eINSTANCE.createTaskType();
inputTask.setId(TaskTypeManager.TASK_ID_INPUT);
inputTask.setName(TaskTypeManager.getTaskLabel(TaskTypeManager.TASK_ID_INPUT));
- process.getTask().add(inputTask);
+
+ Command command = AddCommand.create(domainProvider.getEditingDomain(), process,
+ GraphPackage.Literals.PROCESS_TYPE__TASK, inputTask);
+ compoundCommand.append(command);
+
taskList.add(inputTask);
modelWasChanged = true;
}
@@ -139,7 +159,8 @@
taskList.add(task);
}
}
- modelWasChanged = linkTask(taskList);
+ modelWasChanged = linkTask(taskList, compoundCommand);
+ compoundCommand.execute();
return modelWasChanged;
}
@@ -153,15 +174,15 @@
return null;
}
- private boolean linkTask(List<TaskType> taskList) {
+ private boolean linkTask(List<TaskType> taskList, CompoundCommand compoundCommand)
{
TaskType first = getTaskType(TaskTypeManager.TASK_ID_INPUT, taskList);
if (first != null) {
- return linkTask(first, taskList);
+ return linkTask(first, taskList, compoundCommand);
}
return false;
}
- private boolean linkTask(TaskType taskType, List<TaskType> taskList) {
+ private boolean linkTask(TaskType taskType, List<TaskType> taskList,
CompoundCommand compoundCommand) {
String id = taskType.getId();
String[] childrenIds = TaskTypeManager.getChildTaskIDs(id);
boolean changed = false;
@@ -172,11 +193,14 @@
if (childTask != null) {
if (!taskType.getTask().contains(childTask)
&& ((childTask.eContainer() == null) || (childTask.eContainer() instanceof
ProcessType))) {
- taskType.getTask().add(childTask);
+ Command c = AddCommand.create(domainProvider.getEditingDomain(), taskType,
+ GraphPackage.Literals.TASK_TYPE__TASK, childTask);
+ compoundCommand.append(c);
+ // taskType.getTask().add(childTask);
changed = true;
}
taskList.remove(childTask);
- boolean cchange = linkTask(childTask, taskList);
+ boolean cchange = linkTask(childTask, taskList, compoundCommand);
changed = (changed || cchange);
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -27,6 +27,7 @@
import org.eclipse.draw2d.graph.Node;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandWrapper;
+import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.command.AddCommand;
@@ -215,10 +216,24 @@
if (redoCommand != null || rawCommand.equals(redoCommand)) {
commandType = UNDO_COMMAND;
}
- if (rawCommand instanceof SetCommand || rawCommand instanceof AddCommand
- || rawCommand instanceof DeleteCommand || rawCommand instanceof RemoveCommand)
{
- refershRecentAffectedModel(rawCommand, mostRecentCommand.getAffectedObjects(),
- commandType);
+ if (rawCommand instanceof CompoundCommand) {
+ List<Command> commandList = ((CompoundCommand)
rawCommand).getCommandList();
+ for (Iterator<?> iterator = commandList.iterator(); iterator.hasNext();) {
+ Command command = (Command) iterator.next();
+ while (command instanceof CommandWrapper) {
+ command = ((CommandWrapper) command).getCommand();
+ }
+ if (command instanceof SetCommand || command instanceof AddCommand
+ || command instanceof DeleteCommand || command instanceof RemoveCommand) {
+ refershRecentAffectedModel(command, command.getAffectedObjects(),
commandType);
+ }
+ }
+ } else {
+ if (rawCommand instanceof SetCommand || rawCommand instanceof AddCommand
+ || rawCommand instanceof DeleteCommand || rawCommand instanceof RemoveCommand)
{
+ refershRecentAffectedModel(rawCommand, mostRecentCommand.getAffectedObjects(),
+ commandType);
+ }
}
}
}
@@ -753,6 +768,23 @@
return cs;
}
+ /**
+ * @return the inputDataList
+ */
+ public List<Object> getInputDataList() {
+ if(inputDataList == null){
+ inputDataList = new ArrayList<Object>();
+ }
+ return inputDataList;
+ }
+
+ /**
+ * @param inputDataList the inputDataList to set
+ */
+ public void setInputDataList(List<Object> inputDataList) {
+ this.inputDataList = inputDataList;
+ }
+
public SmooksGraphicsExtType getSmooksGraphicsExtType() {
if (smooksModelProvider != null) {
return smooksModelProvider.getSmooksGraphicsExt();
@@ -938,7 +970,7 @@
}
}
}
-
+
public boolean autoLayout() {
return autoLayout(false);
}
@@ -1154,7 +1186,7 @@
}
public void inputTypeChanged(SmooksGraphicsExtType extType) {
- if (root != null) {
+ if (root != null && inputDataList != null) {
List<Object> newInputDataList =
SelectorCreationDialog.generateInputData(smooksModelProvider
.getSmooksGraphicsExt(), getSmooksResourceListType());
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -10,10 +10,8 @@
******************************************************************************/
package org.jboss.tools.smooks.graphical.editors;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.EventObject;
import java.util.HashMap;
import java.util.Iterator;
@@ -24,10 +22,11 @@
import org.eclipse.draw2d.IFigure;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandWrapper;
+import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gef.dnd.TemplateTransfer;
import org.eclipse.jface.action.IAction;
@@ -45,6 +44,7 @@
import org.eclipse.swt.dnd.DragSource;
import org.eclipse.swt.dnd.DragSourceEvent;
import org.eclipse.swt.dnd.DragSourceListener;
+import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.DropTargetListener;
import org.eclipse.swt.dnd.Transfer;
@@ -98,7 +98,6 @@
import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
import org.jboss.tools.smooks.model.graphics.ext.TaskType;
import org.jboss.tools.smooks.model.smooks.DocumentRoot;
-import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
/**
* @author Dart
@@ -137,6 +136,24 @@
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);
@@ -187,6 +204,8 @@
protected void initProcessGraphicalViewer() {
SmooksGraphicsExtType ext = this.smooksModelProvider.getSmooksGraphicsExt();
+ if (ext == null)
+ return;
ProcessesType processes = ext.getProcesses();
boolean disableProcessViewer = false;
if (processes != null) {
@@ -213,98 +232,98 @@
protected void hookProcessGraphicalViewer() {
getProcessGraphViewer().getControl();
- getProcessGraphViewer().addDropSupport(DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK,
- new Transfer[] { TemplateTransfer.getInstance() }, new DropTargetListener() {
- private TaskType taskType = null;
+ final DropTarget dropTarge = new DropTarget(getProcessGraphViewer().getControl(),
DND.DROP_MOVE | DND.DROP_COPY);
+ dropTarge.setTransfer(new Transfer[] { TemplateTransfer.getInstance() });
+ dropTarge.addDropListener(new DropTargetListener() {
+ private TaskType taskType = null;
- private ProcessType process = null;
+ private ProcessType process = null;
- public void dropAccept(DropTargetEvent event) {
+ public void dropAccept(DropTargetEvent event) {
+ }
+
+ public void drop(DropTargetEvent event) {
+ if (event.detail == DND.DROP_COPY) {
+ if (this.taskType != null) {
+ TaskTypeDescriptor des = (TaskTypeDescriptor)
TemplateTransfer.getInstance().getTemplate();
+ AddNextTaskNodeAction action = new AddNextTaskNodeAction(des.getId(),
des.getLabel(),
+ smooksModelProvider);
+ TaskType taskType = this.taskType;
+ IStructuredSelection selection = new StructuredSelection(taskType);
+ action.selectionChanged(new SelectionChangedEvent(getProcessGraphViewer(),
selection));
+ action.run();
+ return;
}
+ if (this.process != null) {
+ AddNextTaskNodeAction action = new AddInputTaskAction(smooksModelProvider);
+ // IStructuredSelection selection = new
+ // StructuredSelection(taskType);
+ // action.selectionChanged(new
+ // SelectionChangedEvent(getProcessGraphViewer(),
+ // selection));
+ action.run();
+ return;
+ }
+ }
+ }
- public void drop(DropTargetEvent event) {
- if (event.detail == DND.DROP_COPY) {
- if (this.taskType != null) {
- TaskTypeDescriptor des = (TaskTypeDescriptor) TemplateTransfer.getInstance()
- .getTemplate();
- AddNextTaskNodeAction action = new AddNextTaskNodeAction(des.getId(),
des.getLabel(),
- smooksModelProvider);
- TaskType taskType = this.taskType;
- IStructuredSelection selection = new StructuredSelection(taskType);
- action.selectionChanged(new SelectionChangedEvent(getProcessGraphViewer(),
selection));
- action.run();
+ public void dragOver(DropTargetEvent event) {
+ Control control = getProcessGraphViewer().getControl();
+ if (control != null && control instanceof Graph) {
+ Graph graph = (Graph) control;
+ Point pp = graph.toControl(new Point(event.x, event.y));
+ TaskTypeDescriptor des = (TaskTypeDescriptor)
TemplateTransfer.getInstance().getTemplate();
+ TaskType testType = GraphFactory.eINSTANCE.createTaskType();
+ testType.setId(des.getId());
+ IFigure figure = graph.getFigureAt(pp.x, pp.y);
+ if (figure == null) {
+ if (testType.getId().equals(TaskTypeManager.TASK_ID_INPUT)) {
+ ProcessType process = (ProcessType) getProcessGraphViewer().getInput();
+ if (process.getTask().isEmpty()) {
+ event.detail = DND.DROP_COPY;
+ this.process = process;
return;
}
- if (this.process != null) {
- AddNextTaskNodeAction action = new AddInputTaskAction(smooksModelProvider);
- // IStructuredSelection selection = new
- // StructuredSelection(taskType);
- // action.selectionChanged(new
- // SelectionChangedEvent(getProcessGraphViewer(),
- // selection));
- action.run();
- return;
- }
}
+ event.detail = DND.DROP_NONE;
+ this.taskType = null;
+ process = null;
+ return;
}
-
- public void dragOver(DropTargetEvent event) {
- Control control = getProcessGraphViewer().getControl();
- if (control != null && control instanceof Graph) {
- Graph graph = (Graph) control;
- Point pp = graph.toControl(new Point(event.x, event.y));
- TaskTypeDescriptor des = (TaskTypeDescriptor)
TemplateTransfer.getInstance().getTemplate();
- TaskType testType = GraphFactory.eINSTANCE.createTaskType();
- testType.setId(des.getId());
- IFigure figure = graph.getFigureAt(pp.x, pp.y);
- if (figure == null) {
- if (testType.getId().equals(TaskTypeManager.TASK_ID_INPUT)) {
- ProcessType process = (ProcessType) getProcessGraphViewer().getInput();
- if (process.getTask().isEmpty()) {
- event.detail = DND.DROP_COPY;
- this.process = process;
- return;
- }
+ List<?> nodes = graph.getNodes();
+ for (Iterator<?> iterator = nodes.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ if (object instanceof GraphNode) {
+ IFigure f = ((GraphNode) object).getNodeFigure();
+ if (figure == f) {
+ TaskTypeRules rules = new TaskTypeRules();
+ if (rules.isNextTask((TaskType) ((GraphNode) object).getData(), testType)) {
+ event.detail = DND.DROP_COPY;
+ this.taskType = (TaskType) ((GraphNode) object).getData();
+ return;
}
- event.detail = DND.DROP_NONE;
- this.taskType = null;
- process = null;
- return;
}
- List<?> nodes = graph.getNodes();
- for (Iterator<?> iterator = nodes.iterator(); iterator.hasNext();) {
- Object object = (Object) iterator.next();
- if (object instanceof GraphNode) {
- IFigure f = ((GraphNode) object).getNodeFigure();
- if (figure == f) {
- TaskTypeRules rules = new TaskTypeRules();
- if (rules.isNextTask((TaskType) ((GraphNode) object).getData(), testType)) {
- event.detail = DND.DROP_COPY;
- this.taskType = (TaskType) ((GraphNode) object).getData();
- return;
- }
- }
- }
- }
- event.detail = DND.DROP_NONE;
- this.taskType = null;
- this.process = null;
}
}
+ event.detail = DND.DROP_NONE;
+ this.taskType = null;
+ this.process = null;
+ }
+ }
- public void dragOperationChanged(DropTargetEvent event) {
- }
+ public void dragOperationChanged(DropTargetEvent event) {
+ }
- public void dragLeave(DropTargetEvent event) {
- }
+ public void dragLeave(DropTargetEvent event) {
+ }
- public void dragEnter(DropTargetEvent event) {
- event.detail = DND.DROP_MOVE;
- this.taskType = null;
- process = null;
- }
- });
+ public void dragEnter(DropTargetEvent event) {
+ event.detail = DND.DROP_MOVE;
+ this.taskType = null;
+ process = null;
+ }
+ });
getProcessGraphViewer().addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
@@ -452,7 +471,6 @@
Transfer[] types = new Transfer[] { TemplateTransfer.getInstance() };
int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
-
final DragSource source = new DragSource(toolBar, operations);
source.setTransfer(types);
source.addDragListener(new DragSourceListener() {
@@ -476,7 +494,8 @@
public void dragSetData(DragSourceEvent event) {
// DragSource source = (DragSource) event.getSource();
// ToolBar control = (ToolBar) source.getControl();
- // ToolItem item = control.getItem(new Point(event.x, event.y));
+ // ToolItem item = control.getItem(new Point(event.x,
+ // event.y));
// if(item == null) return;
// TaskTypeDescriptor data = (TaskTypeDescriptor)
// item.getData();
@@ -578,11 +597,43 @@
if (getProcessGraphViewer() != null) {
getProcessGraphViewer().refresh();
getProcessGraphViewer().applyLayout();
+ break;
}
-
- return;
}
}
+ if (rawCommand instanceof CompoundCommand) {
+ List<Command> command = ((CompoundCommand) rawCommand).getCommandList();
+ for (Iterator<?> iterator = command.iterator(); iterator.hasNext();) {
+ Command command2 = (Command) iterator.next();
+ while (command2 instanceof CommandWrapper) {
+ command2 = ((CommandWrapper) command2).getCommand();
+ }
+ if (command2 instanceof DeleteCommand || command2 instanceof RemoveCommand) {
+ Collection<?> objs = ((Command) command2).getAffectedObjects();
+ for (Iterator<?> iterator2 = objs.iterator(); iterator2.hasNext();) {
+ Object object = (Object) iterator2.next();
+ if (object instanceof TaskType || object instanceof ProcessType) {
+ showTaskControl(null);
+ break;
+ }
+ }
+ }
+ }
+ } else {
+ if (rawCommand instanceof DeleteCommand || rawCommand instanceof RemoveCommand)
{
+ activeModel = rawCommand.getAffectedObjects();
+ for (Iterator<?> iterator = activeModel.iterator(); iterator.hasNext();)
{
+ Object object = (Object) iterator.next();
+ if (object instanceof TaskType || object instanceof ProcessType) {
+ if (getProcessGraphViewer() != null) {
+ showTaskControl(null);
+ break;
+ }
+ }
+ }
+
+ }
+ }
}
}
@@ -644,26 +695,10 @@
SmooksJavaMappingGraphicalEditor javaMappingPart = new
SmooksJavaMappingGraphicalEditor(smooksModelProvider);
this.registeTaskDetailsPage(javaMappingPart, TaskTypeManager.TASK_ID_JAVA_MAPPING);
-// SmooksXSLTemplateGraphicalEditor xsltemplatePart = new
SmooksXSLTemplateGraphicalEditor(smooksModelProvider);
-// this.registeTaskDetailsPage(xsltemplatePart, TaskTypeManager.TASK_ID_XSL_TEMPLATE);
-
- ProcessAnalyzer processAnalyzer = new ProcessAnalyzer();
- EObject smooksModel = getSmooksResourceList();
- if (smooksModel != null && smooksModel instanceof SmooksResourceListType) {
- boolean needSave = processAnalyzer.analyzeSmooksModels((SmooksResourceListType)
smooksModel);
- if (needSave) {
- ResourceSet rs = this.smooksModelProvider.getEditingDomain().getResourceSet();
- List<Resource> resourceLis = rs.getResources();
- for (Iterator<?> iterator = resourceLis.iterator(); iterator.hasNext();) {
- Resource resource = (Resource) iterator.next();
- try {
- resource.save(Collections.emptyMap());
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- }
- }
+ // SmooksXSLTemplateGraphicalEditor xsltemplatePart = new
+ // SmooksXSLTemplateGraphicalEditor(smooksModelProvider);
+ // this.registeTaskDetailsPage(xsltemplatePart,
+ // TaskTypeManager.TASK_ID_XSL_TEMPLATE);
}
@Override
@@ -753,6 +788,9 @@
}
protected void showTaskControl(Object model) {
+ if (model == null)
+ pageBook.showEmptyPage();
+ ;
FormToolkit toolkit = ((AbstractSmooksFormEditor)
this.smooksModelProvider).getToolkit();
if (model instanceof TaskType) {
String id = ((TaskType) model).getId();
@@ -869,6 +907,9 @@
Object object = (Object) iterator.next();
if (object instanceof IEditorPart) {
((IEditorPart) object).removePropertyListener(this);
+ if (((IEditorPart) object).getEditorSite() == null) {
+ continue;
+ }
((IEditorPart) object).dispose();
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/TaskTypeManager.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/TaskTypeManager.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/TaskTypeManager.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -15,9 +15,13 @@
import java.util.List;
import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
+import org.jboss.tools.smooks.model.freemarker.Freemarker;
import org.jboss.tools.smooks.model.graphics.ext.TaskType;
+import org.jboss.tools.smooks.model.javabean.BindingsType;
+import org.jboss.tools.smooks.model.javabean12.BeanType;
import org.jboss.tools.smooks.model.smooks.AbstractResourceConfig;
import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
+import org.jboss.tools.smooks.model.xsl.Xsl;
/**
* @author Dart
@@ -61,8 +65,9 @@
GraphicsConstants.IMAGE_JAVA_AMPPING_TASK));
allTaskList.add(new TaskTypeDescriptor(TASK_ID_FREEMARKER_TEMPLATE, "Apply
Freemaker Template",
GraphicsConstants.IMAGE_APPLY_FREEMARKER_TASK));
-// allTaskList.add(new TaskTypeDescriptor(TASK_ID_XSL_TEMPLATE, "Apply XSL
Template",
-// GraphicsConstants.IMAGE_APPLY_XSL_TASK));
+ // allTaskList.add(new TaskTypeDescriptor(TASK_ID_XSL_TEMPLATE,
+ // "Apply XSL Template",
+ // GraphicsConstants.IMAGE_APPLY_XSL_TASK));
}
return allTaskList;
}
@@ -72,7 +77,20 @@
}
public static List<Object> getAssociatedSmooksElementsType(String taskID) {
- return null;
+ List<Object> elementsType = new ArrayList<Object>();
+ if (taskID == null)
+ return null;
+ if (TASK_ID_JAVA_MAPPING.equals(taskID)) {
+ elementsType.add(BeanType.class);
+ elementsType.add(BindingsType.class);
+ }
+ if (TASK_ID_FREEMARKER_TEMPLATE.equals(taskID)) {
+ elementsType.add(Freemarker.class);
+ }
+ if (TASK_ID_XSL_TEMPLATE.equals(taskID)) {
+ elementsType.add(Xsl.class);
+ }
+ return elementsType;
}
public static String getTaskLabel(String taskId) {
@@ -113,7 +131,13 @@
}
private static boolean isSameType(Object element, List<Object> elementTypes) {
- return true;
+ 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 {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/TriggerConnectionEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/TriggerConnectionEditPart.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/TriggerConnectionEditPart.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -11,7 +11,9 @@
package org.jboss.tools.smooks.graphical.editors.editparts;
import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.FigureUtilities;
import org.eclipse.draw2d.Shape;
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
import org.jboss.tools.smooks.gef.tree.editparts.TreeNodeConnectionEditPart;
/**
@@ -32,6 +34,7 @@
Connection c = super.createConnectionFigure();
if (c instanceof Shape) {
((Shape) c).setLineWidth(2);
+ ((Shape) c).setForegroundColor(FigureUtilities.darker(GraphicsConstants.FONT_COLOR));
}
return c;
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/ValueBindingConnectionEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/ValueBindingConnectionEditPart.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/ValueBindingConnectionEditPart.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -10,7 +10,10 @@
******************************************************************************/
package org.jboss.tools.smooks.graphical.editors.editparts;
+import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.FigureUtilities;
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
import org.jboss.tools.smooks.gef.tree.editparts.TreeNodeConnectionEditPart;
/**
@@ -25,7 +28,7 @@
@Override
protected Connection createConnectionFigure() {
Connection connection = super.createConnectionFigure();
-// connection.setForegroundColor(GraphicsConstants.BORDER_CORLOER);
+ connection.setForegroundColor(ColorConstants.blue);
return connection;
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/JavaBeanGraphModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/JavaBeanGraphModel.java 2009-11-09
08:26:50 UTC (rev 18490)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/JavaBeanGraphModel.java 2009-11-09
08:38:00 UTC (rev 18491)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.smooks.graphical.editors.model;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
@@ -29,6 +30,8 @@
@Override
protected TreeNodeModel createChildModel(Object model, ITreeContentProvider
contentProvider,
ILabelProvider labelProvider) {
+ Object m = AdapterFactoryEditingDomain.unwrap(model);
+ if(m instanceof String) return null;
return new JavaBeanChildGraphModel(model, contentProvider, labelProvider,
this.domainProvider);
}