Author: DartPeng
Date: 2009-11-16 03:01:09 -0500 (Mon, 16 Nov 2009)
New Revision: 18690
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/add_task_button.png
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/drag_link.gif
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/DragLinkFigure.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksObjectAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/AddFreemarkerAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddExpressionAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddJavaBeanAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddValueAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddWiringAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaMappingActionCreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessGraphicalViewerLabelProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskNodeFigure.java
trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/template/
trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/template/csv/
trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/template/csv/CSVToFreemarkerTemplateBuilderTest.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.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/gef/tree/editparts/TreeContainerEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeContainerFigure.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeContainerModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksModelAction.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/SmooksFreemarkerTemplateGraphicalEditor.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/SmooksJavaMappingGraphicalEditor.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/SmooksXSLTemplateGraphicalEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/AbstractResourceConfigEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanChildNodeEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerActionCreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanChildGraphModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanGraphModel.java
Log:
JBIDE-5195
Done
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/add_task_button.png
===================================================================
(Binary files differ)
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/add_task_button.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/drag_link.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/drag_link.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -65,12 +65,18 @@
protected void initializeImageRegistry(ImageRegistry reg) {
super.initializeImageRegistry(reg);
// regist palette image
- reg.put(GraphicsConstants.IMAGE_LINK16, imageDescriptorFromPlugin(PLUGIN_ID,
- GraphicsConstants.IMAGE_LINK16));
- reg.put(GraphicsConstants.IMAGE_LINK24, imageDescriptorFromPlugin(PLUGIN_ID,
- GraphicsConstants.IMAGE_LINK24));
+ reg.put(GraphicsConstants.IMAGE_DRAG_LINK, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_DRAG_LINK));
+
+ reg.put(GraphicsConstants.IMAGE_LINK16, imageDescriptorFromPlugin(PLUGIN_ID,
GraphicsConstants.IMAGE_LINK16));
+ reg.put(GraphicsConstants.IMAGE_LINK24, imageDescriptorFromPlugin(PLUGIN_ID,
GraphicsConstants.IMAGE_LINK24));
+
// registe task image
+
+ reg.put(GraphicsConstants.IMAGE_ADD_TASK_BUTTON, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_ADD_TASK_BUTTON));
+
reg.put(GraphicsConstants.IMAGE_APPLY_FREEMARKER_TASK,
imageDescriptorFromPlugin(PLUGIN_ID,
GraphicsConstants.IMAGE_APPLY_FREEMARKER_TASK));
reg.put(GraphicsConstants.IMAGE_JAVA_AMPPING_TASK,
imageDescriptorFromPlugin(PLUGIN_ID,
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -22,6 +22,10 @@
}
public static final String IMAGE_JAVA_AMPPING_TASK =
"icons/full/obj32/java_mapping_task.jpg";
+
+ public static final String IMAGE_DRAG_LINK =
"icons/full/obj16/drag_link.gif";
+
+ public static final String IMAGE_ADD_TASK_BUTTON =
"icons/full/obj16/add_task_button.png";
public static final String IMAGE_LINK16 =
"icons/full/obj16/connection16.gif";
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-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -2949,7 +2949,50 @@
}
return false;
}
+
+ public static boolean isCollectionJavaGraphModel(EObject parent){
+ String classString = null;
+ if (parent instanceof BeanType) {
+ classString = ((BeanType) parent).getClass_();
+ }
+ if (parent instanceof BindingsType) {
+ classString = ((BindingsType) parent).getClass_();
+ }
+ if (classString != null)
+ classString = classString.trim();
+ IJavaProject project = SmooksUIUtils.getJavaProject(parent);
+ if (project != null) {
+ try {
+ ProjectClassLoader loader = new ProjectClassLoader(project);
+ Class<?> clazz = loader.loadClass(classString);
+ if (Collection.class.isAssignableFrom(clazz)) {
+ return true;
+ }
+ } catch (Throwable t) {
+
+ }
+ }
+
+ return false;
+ }
+
+ public static boolean isArrayJavaGraphModel(EObject parent){
+ String classString = null;
+ if (parent instanceof BeanType) {
+ classString = ((BeanType) parent).getClass_();
+ }
+ if (parent instanceof BindingsType) {
+ classString = ((BindingsType) parent).getClass_();
+ }
+ if (classString != null)
+ classString = classString.trim();
+ if (classString.endsWith("]")) {
+ return true;
+ }
+ return false;
+ }
+
public static EStructuralFeature getFeature(Object model) {
if (model instanceof BindingsType) {
return JavabeanPackage.Literals.DOCUMENT_ROOT__BINDINGS;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeContainerEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeContainerEditPart.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeContainerEditPart.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -11,13 +11,18 @@
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.DefaultEditDomain;
+import org.eclipse.gef.DragTracker;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.SelectionRequest;
+import org.eclipse.gef.tools.ConnectionDragCreationTool;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorPart;
import org.jboss.tools.smooks.editor.ISmooksModelProvider;
import org.jboss.tools.smooks.gef.tree.editpolicy.FigureHighlightEditPolicy;
import org.jboss.tools.smooks.gef.tree.editpolicy.TreeNodeGraphicalNodeEditPolicy;
+import org.jboss.tools.smooks.gef.tree.figures.DragLinkFigure;
import org.jboss.tools.smooks.gef.tree.figures.IMoveableModel;
import org.jboss.tools.smooks.gef.tree.figures.TreeContainerFigure;
import org.jboss.tools.smooks.gef.tree.figures.TreeFigureExpansionEvent;
@@ -40,8 +45,8 @@
protected IFigure createFigure() {
return new TreeContainerFigure((TreeContainerModel) getModel());
}
-
- protected String getLabelText(){
+
+ protected String getLabelText() {
TreeContainerModel model = (TreeContainerModel) getModel();
String text = model.getText();
return text;
@@ -53,7 +58,7 @@
if (text != null && model.isHeaderVisable() && getFigure() instanceof
TreeContainerFigure) {
TreeContainerFigure figure = (TreeContainerFigure) getFigure();
Image i = model.getImage();
- if(i != null){
+ if (i != null) {
figure.setIcon(i);
}
figure.setText(text);
@@ -62,7 +67,8 @@
if (!isSource) {
IFigure figure = getFigure();
if (figure instanceof TreeContainerFigure) {
-// ((TreeContainerFigure) figure).setHeaderColor(ColorConstants.orange);
+ // ((TreeContainerFigure)
+ // figure).setHeaderColor(ColorConstants.orange);
}
}
Point location = model.getLocation();
@@ -103,11 +109,11 @@
DefaultEditDomain domain = (DefaultEditDomain) getViewer().getEditDomain();
IEditorPart editor = domain.getEditorPart();
ISmooksModelProvider modelProvider = (ISmooksModelProvider)
editor.getAdapter(ISmooksModelProvider.class);
-
- if(modelProvider != null && getModel() instanceof IMoveableModel){
+
+ if (modelProvider != null && getModel() instanceof IMoveableModel) {
SmooksGraphicsExtType graph = modelProvider.getSmooksGraphicsExt();
- Rectangle rect = ((IMoveableModel)getModel()).getBounds();
- recordBounds(graph,rect);
+ Rectangle rect = ((IMoveableModel) getModel()).getBounds();
+ recordBounds(graph, rect);
}
}
}
@@ -118,6 +124,27 @@
this.installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new
FigureHighlightEditPolicy());
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.gef.editparts.AbstractGraphicalEditPart#getDragTracker(org
+ * .eclipse.gef.Request)
+ */
+ public DragTracker getDragTracker(Request request) {
+ Object model = getModel();
+ if (model instanceof TreeContainerModel && request instanceof SelectionRequest)
{
+ Point location = ((SelectionRequest)request).getLocation();
+ IFigure figure = getFigure();
+ IFigure figure1 = figure.findFigureAt(location);
+ if (figure1 instanceof DragLinkFigure && ((TreeContainerModel)
model).canDragLink()) {
+ getViewer().select(this);
+ return new ConnectionDragCreationTool();
+ }
+ }
+ return super.getDragTracker(request);
+ }
+
// @Override
// public ConnectionAnchor getSourceConnectionAnchor(
// ConnectionEditPart connection) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeEditPart.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -100,9 +100,6 @@
* .eclipse.gef.Request)
*/
public DragTracker getDragTracker(Request request) {
- // if(true){
- // return super.getDragTracker(request);
- // }
if (isDragLink()) {
getViewer().select(this);
return new ConnectionDragCreationTool();
@@ -404,11 +401,21 @@
}
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
- return new LeftOrRightAnchor(getAnchorFigure());
+ try {
+ return new LeftOrRightAnchor(getAnchorFigure());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
}
public ConnectionAnchor getSourceConnectionAnchor(Request request) {
- return new LeftOrRightAnchor(getAnchorFigure());
+ try {
+ return new LeftOrRightAnchor(getAnchorFigure());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
}
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/DragLinkFigure.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/DragLinkFigure.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/DragLinkFigure.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * 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.gef.tree.figures;
+
+import org.eclipse.draw2d.Figure;
+
+/**
+ * @author Dart
+ *
+ */
+public class DragLinkFigure extends Figure {
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/DragLinkFigure.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeContainerFigure.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeContainerFigure.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeContainerFigure.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -7,13 +7,18 @@
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.FigureUtilities;
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.Rectangle;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
import org.jboss.tools.smooks.gef.tree.editpolicy.IShowHighlighFigure;
import org.jboss.tools.smooks.gef.tree.model.TreeContainerModel;
@@ -44,13 +49,88 @@
private boolean showHightlight = false;
+ private IFigure dragLinkFigure = null;
+
+ private boolean showDragLink = false;
+
public TreeContainerFigure(TreeContainerModel model) {
super();
this.model = model;
this.addChildrenFigures();
+ hookFigure();
}
+ protected void hookFigure() {
+ this.addMouseMotionListener(new MouseMotionListener() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseDragged(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseDragged(MouseEvent me) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseEntered(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseEntered(MouseEvent me) {
+ showDragLink = true;
+ dragLinkFigure.repaint();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseExited(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseExited(MouseEvent me) {
+ showDragLink = false;
+ dragLinkFigure.repaint();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseHover(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseHover(MouseEvent me) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseMoved(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseMoved(MouseEvent me) {
+
+ }
+
+ });
+ }
+
protected void addChildrenFigures() {
+
+ IFigure headerContainerFigure = new Figure();
+
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ headerContainerFigure.setLayoutManager(gl);
+
headerFigure = new Figure() {
@Override
@@ -66,10 +146,108 @@
return new Dimension(width, 25);
}
};
+ headerFigure.add(headerContainerFigure);
+
label = new Label();
- headerFigure.add(label);
+ headerContainerFigure.add(label);
ToolbarLayout layout = new ToolbarLayout();
layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gl.setConstraint(label, gd);
+
+ dragLinkFigure = new DragLinkFigure() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics
+ * )
+ */
+ @Override
+ protected void paintFigure(Graphics graphics) {
+ super.paintFigure(graphics);
+ if (showDragLink) {
+ if (model instanceof TreeContainerModel) {
+ if (!((TreeContainerModel) model).canDragLink()) {
+ return;
+ }
+ }
+ Image img = SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_DRAG_LINK);
+ if (img != null) {
+ graphics.drawImage(img, getLocation());
+ }
+ }
+ }
+ };
+ dragLinkFigure.addMouseMotionListener(new MouseMotionListener() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseDragged(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseDragged(MouseEvent me) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseEntered(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseEntered(MouseEvent me) {
+ showDragLink = true;
+ dragLinkFigure.repaint();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseExited(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseExited(MouseEvent me) {
+ showDragLink = false;
+ dragLinkFigure.repaint();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseHover(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseHover(MouseEvent me) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.draw2d.MouseMotionListener#mouseMoved(org.eclipse
+ * .draw2d.MouseEvent)
+ */
+ public void mouseMoved(MouseEvent me) {
+
+ }
+
+ });
+ dragLinkFigure.setSize(16, 16);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.END;
+ gl.setConstraint(dragLinkFigure, gd);
+
+ headerContainerFigure.add(dragLinkFigure);
+
headerFigure.setLayoutManager(layout);
headerFigure.setOpaque(true);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeContainerModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeContainerModel.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeContainerModel.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -14,6 +14,7 @@
private boolean headerVisable = false;
private Point location = new Point(0, 0);
+
public TreeContainerModel(Object data,
ITreeContentProvider contentProvider, ILabelProvider labelProvider) {
@@ -27,6 +28,10 @@
public void setSourceLinkNode(boolean sourceLinkNode) {
this.sourceLinkNode = sourceLinkNode;
}
+
+ public boolean canDragLink(){
+ return false;
+ }
public Point getLocation() {
return location;
@@ -39,6 +44,7 @@
support.firePropertyChange(IMoveableModel.PRO_BOUNDS_CHANGED, oldLocation,
this.location);
}
}
+
public Rectangle getBounds() {
return new Rectangle(getLocation(),new Dimension(0,0));
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksModelAction.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksModelAction.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksModelAction.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -14,6 +14,7 @@
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.requests.CreateRequest;
@@ -21,15 +22,14 @@
import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart;
/**
* @author Dart
- *
+ *
*/
public abstract class AddSmooksModelAction extends SelectionAction {
-
-
-
+
public AddSmooksModelAction(IWorkbenchPart part, int style) {
super(part, style);
// TODO Auto-generated constructor stub
@@ -53,30 +53,41 @@
return cmd.canExecute();
}
- protected Command createAddChildNodeCommand(List<?> objects){
+ protected Command createAddChildNodeCommand(List<?> objects) {
if (objects.isEmpty())
return null;
if (!(objects.get(0) instanceof EditPart))
return null;
- CreateRequest addReq = new CreateRequest();
- addReq.setLocation(new Point(0,0));
+ CreateRequest addReq = new CreateRequest();
+ Point location = new Point(0, 0);
+ if (this.getWorkbenchPart() != null) {
+ IWorkbenchPart part = this.getWorkbenchPart();
+ org.eclipse.swt.graphics.Point mouseLocation =
part.getSite().getShell().getDisplay().getCursorLocation();
+ if (part instanceof SmooksGraphicalEditorPart) {
+ GraphicalViewer viewer = ((SmooksGraphicalEditorPart) part).getGraphicalViewer();
+ mouseLocation = viewer.getControl().toControl(mouseLocation);
+ }
+ location = new Point(mouseLocation.x, mouseLocation.y);
+ }
+ addReq.setLocation(location);
addReq.setFactory(getCreationFactory());
- CompoundCommand compoundCmd = new CompoundCommand("Add Child Node");
+ CompoundCommand compoundCmd = new CompoundCommand("Add " + getActionText());
for (int i = 0; i < objects.size(); i++) {
EditPart object = (EditPart) objects.get(i);
Command cmd = object.getCommand(addReq);
- if (cmd != null) compoundCmd.add(cmd);
+ if (cmd != null)
+ compoundCmd.add(cmd);
}
return compoundCmd;
}
-
+
public abstract String getActionText();
-
-// public abstract Imag
+ // public abstract Imag
+
/*
* (non-Javadoc)
*
@@ -84,9 +95,13 @@
*/
@Override
public void run() {
- execute(createAddChildNodeCommand(getSelectedObjects()));
+ try {
+ execute(createAddChildNodeCommand(getSelectedObjects()));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
-
+
/*
* (non-Javadoc)
*
@@ -98,10 +113,10 @@
this.setText(getActionText());
this.setImageDescriptor(getActionImageDescriptor());
}
-
+
protected abstract CreationFactory getCreationFactory();
- public abstract ImageDescriptor getActionImageDescriptor() ;
+ public abstract ImageDescriptor getActionImageDescriptor();
/*
* (non-Javadoc)
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksObjectAction.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksObjectAction.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksObjectAction.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * 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.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
+import org.eclipse.gef.requests.CreationFactory;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.smooks.configuration.SmooksConstants;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
+
+/**
+ * @author Dart
+ *
+ */
+public abstract class AddSmooksObjectAction extends AddSmooksModelAction {
+
+ private ISmooksModelProvider provider;
+
+ public AddSmooksObjectAction(IWorkbenchPart part, int style, ISmooksModelProvider
provider) {
+ super(part, style);
+ this.provider = provider;
+ this.setText(getActionText());
+ this.setImageDescriptor(getActionImageDescriptor());
+ }
+
+ public AddSmooksObjectAction(IWorkbenchPart part, ISmooksModelProvider provider) {
+ super(part);
+ this.provider = provider;
+ this.setText(getActionText());
+ this.setImageDescriptor(getActionImageDescriptor());
+ }
+
+
+
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.smooks.graphical.actions.AddSmooksModelAction#init()
+ */
+ @Override
+ protected void init() {
+
+ }
+
+ /**
+ * @return the provider
+ */
+ protected ISmooksModelProvider getProvider() {
+ return provider;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.actions.AddSmooksModelAction#
+ * getActionImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getActionImageDescriptor() {
+ Object object = getNewObject();
+ if(object == null) return null;
+ object = AdapterFactoryEditingDomain.unwrap(object);
+ AdapterFactoryEditingDomain editDomain = (AdapterFactoryEditingDomain)
provider.getEditingDomain();
+ IItemLabelProvider itemLabelProvider = (IItemLabelProvider)
editDomain.getAdapterFactory().adapt(object,
+ IItemLabelProvider.class);
+ ImageDescriptor smallImage = null;
+ if (itemLabelProvider != null) {
+ Object imageObj = itemLabelProvider.getImage(object);
+ smallImage = ExtendedImageRegistry.getInstance().getImageDescriptor(imageObj);
+ }
+ return smallImage;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.graphical.actions.AddSmooksModelAction#getActionText
+ * ()
+ */
+ @Override
+ public String getActionText() {
+ Object object = getNewObject();
+ if(object == null) return "";
+ object = AdapterFactoryEditingDomain.unwrap(object);
+ AdapterFactoryEditingDomain editDomain = (AdapterFactoryEditingDomain)
provider.getEditingDomain();
+ IItemLabelProvider itemLabelProvider = (IItemLabelProvider)
editDomain.getAdapterFactory().adapt(object,
+ IItemLabelProvider.class);
+ if (itemLabelProvider != null) {
+ return itemLabelProvider.getText(object);
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.actions.AddSmooksModelAction#
+ * getCreationFactory()
+ */
+ @Override
+ protected CreationFactory getCreationFactory() {
+ return new SmooksObjectCreationFactory(getNewObject(), getNewType());
+ }
+
+ protected abstract Object getSmooks11Object();
+
+ protected abstract Object getSmooks12Object();
+
+ protected abstract Object getSmooks11Type();
+
+ protected abstract Object getSmooks12Type();
+
+ protected Object getNewObject() {
+ SmooksGraphicsExtType ext = this.getProvider().getSmooksGraphicsExt();
+ if (ext == null)
+ return null;
+ String version = ext.getPlatformVersion();
+ if (SmooksConstants.VERSION_1_1.equals(version)) {
+ return getSmooks11Object();
+ }
+ if (SmooksConstants.VERSION_1_2.equals(version)) {
+ return getSmooks12Object();
+ }
+ return null;
+ }
+
+ protected Object getNewType() {
+ SmooksGraphicsExtType ext = this.getProvider().getSmooksGraphicsExt();
+ if (ext == null)
+ return null;
+ String version = ext.getPlatformVersion();
+ if (SmooksConstants.VERSION_1_1.equals(version)) {
+ return getSmooks11Type();
+ }
+ if (SmooksConstants.VERSION_1_2.equals(version)) {
+ return getSmooks12Type();
+ }
+ return null;
+ }
+
+ private class SmooksObjectCreationFactory implements CreationFactory {
+ private Object newObject;
+
+ private Object objectType;
+
+ public SmooksObjectCreationFactory(Object newObject, Object objectType) {
+ this.newObject = newObject;
+ this.objectType = objectType;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.requests.CreationFactory#getNewObject()
+ */
+ public Object getNewObject() {
+ // TODO Auto-generated method stub
+ return newObject;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.requests.CreationFactory#getObjectType()
+ */
+ public Object getObjectType() {
+ // TODO Auto-generated method stub
+ return objectType;
+ }
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/AddSmooksObjectAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/actions/DeleteTaskNodeAction.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -50,6 +50,13 @@
@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));
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksFreemarkerTemplateGraphicalEditor.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -91,7 +91,7 @@
protected void createActions() {
super.createActions();
FreemarkerActionCreator creator = new FreemarkerActionCreator();
- creator.registXSLActions(getActionRegistry(), getSelectionActions(), this);
+ creator.registXSLActions(getActionRegistry(), getSelectionActions(), this,
this.smooksModelProvider);
}
/*
@@ -100,7 +100,6 @@
* @seeorg.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#
* getPaletteRoot()
*/
- @Override
protected PaletteRoot getPaletteRoot() {
SmooksGraphicalEditorPaletteRootCreator creator = new
SmooksGraphicalEditorPaletteRootCreator(
this.smooksModelProvider, (AdapterFactoryEditingDomain)
this.smooksModelProvider.getEditingDomain(),
@@ -232,7 +231,8 @@
((TreeContainerModel) graphModel).setHeaderVisable(true);
}
if (model instanceof BindingsType || model instanceof BeanType) {
- graphModel = new JavaBeanGraphModel(model, contentProvider, labelProvider,
provider);
+ graphModel = new JavaBeanGraphModel(model, contentProvider, labelProvider,
provider,
+ SmooksFreemarkerTemplateGraphicalEditor.this);
((JavaBeanGraphModel) graphModel).setHeaderVisable(true);
}
if (graphModel != null) {
@@ -260,40 +260,14 @@
/*
* (non-Javadoc)
*
- * @see
- * org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#canDelete
- * (org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel)
+ * @seeorg.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#
+ * createInputDataGraphModel()
*/
@Override
- public boolean canDelete(AbstractSmooksGraphicalModel graphModel) {
- return super.canDelete(graphModel);
- }
-
-
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#createInputDataGraphModel()
- */
- @Override
protected List<AbstractSmooksGraphicalModel> createInputDataGraphModel() {
return Collections.emptyList();
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#canLink
- * (org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel)
- */
- @Override
- public boolean canLink(AbstractSmooksGraphicalModel graphModel) {
- if (graphModel instanceof JavaBeanGraphModel) {
- return true;
- }
- return super.canLink(graphModel);
- }
-
private class FreemarkerTemplateEditFactory extends SmooksEditFactory {
/*
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-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -41,15 +41,14 @@
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;
import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.commands.CommandStackEvent;
import org.eclipse.gef.commands.CommandStackEventListener;
-import org.eclipse.gef.dnd.TemplateTransferDragSourceListener;
import org.eclipse.gef.dnd.TemplateTransferDropTargetListener;
import org.eclipse.gef.editparts.FreeformGraphicalRootEditPart;
-import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.ui.actions.SelectionAction;
-import org.eclipse.gef.ui.parts.GraphicalEditorWithPalette;
+import org.eclipse.gef.ui.parts.GraphicalEditor;
import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.util.TransferDropTargetListener;
@@ -110,7 +109,7 @@
* @author Dart
*
*/
-public class SmooksGraphicalEditorPart extends GraphicalEditorWithPalette implements
ISelectionChangedListener,
+public class SmooksGraphicalEditorPart extends GraphicalEditor implements
ISelectionChangedListener,
ISourceSynchronizeListener, ISmooksGraphChangeListener, IGraphicalEditorPart {
public static final int EXECUTE_COMMAND = 0;
@@ -172,6 +171,7 @@
this.smooksModelProvider = provider;
this.setEditDomain(editDomain);
}
+
@Override
public void createPartControl(Composite parent) {
@@ -192,6 +192,10 @@
super.createPartControl(parent);
}
+
+ public GraphicalViewer getGraphicalViewer() {
+ return super.getGraphicalViewer();
+ }
private void handleCommandStack(org.eclipse.emf.common.command.CommandStack
commandStack) {
commandStack.addCommandStackListener(new
org.eclipse.emf.common.command.CommandStackListener() {
@@ -581,11 +585,11 @@
return editDomain;
}
- @Override
- protected void configurePaletteViewer() {
- super.configurePaletteViewer();
- getPaletteViewer().addDragSourceListener(new
TemplateTransferDragSourceListener(getPaletteViewer()));
- }
+// @Override
+// protected void configurePaletteViewer() {
+// super.configurePaletteViewer();
+// getPaletteViewer().addDragSourceListener(new
TemplateTransferDragSourceListener(getPaletteViewer()));
+// }
protected EditPartFactory createEdtiPartFactory() {
return new SmooksEditFactory();
@@ -1169,13 +1173,13 @@
initGraphicalModel();
}
- @Override
- protected PaletteRoot getPaletteRoot() {
- SmooksGraphicalEditorPaletteRootCreator creator = new
SmooksGraphicalEditorPaletteRootCreator(
- this.smooksModelProvider, (AdapterFactoryEditingDomain)
this.smooksModelProvider.getEditingDomain(),
- getSmooksResourceListType());
- return creator.createPaletteRoot();
- }
+// @Override
+// protected PaletteRoot getPaletteRoot() {
+// SmooksGraphicalEditorPaletteRootCreator creator = new
SmooksGraphicalEditorPaletteRootCreator(
+// this.smooksModelProvider, (AdapterFactoryEditingDomain)
this.smooksModelProvider.getEditingDomain(),
+// getSmooksResourceListType());
+// return creator.createPaletteRoot();
+// }
public SmooksResourceListType getSmooksResourceListType() {
if (smooksModelProvider != null) {
@@ -1235,12 +1239,4 @@
public String getID() {
return null;
}
-
- public boolean canDelete(AbstractSmooksGraphicalModel graphModel) {
- return true;
- }
-
- public boolean canLink(AbstractSmooksGraphicalModel graphModel) {
- return false;
- }
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksJavaMappingGraphicalEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksJavaMappingGraphicalEditor.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksJavaMappingGraphicalEditor.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -24,6 +24,7 @@
import org.jboss.tools.smooks.graphical.editors.autolayout.IAutoLayout;
import org.jboss.tools.smooks.graphical.editors.autolayout.JavaMappingAutoLayout;
import org.jboss.tools.smooks.graphical.editors.model.javamapping.JavaBeanGraphModel;
+import
org.jboss.tools.smooks.graphical.editors.model.javamapping.JavaMappingActionCreator;
import org.jboss.tools.smooks.model.javabean.BindingsType;
import org.jboss.tools.smooks.model.javabean.ExpressionType;
import org.jboss.tools.smooks.model.javabean.ValueType;
@@ -43,41 +44,48 @@
// TODO Auto-generated constructor stub
}
- /* (non-Javadoc)
- * @see
org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#getPaletteRoot()
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#
+ * getPaletteRoot()
*/
- @Override
+ // @Override
protected PaletteRoot getPaletteRoot() {
SmooksGraphicalEditorPaletteRootCreator creator = new
SmooksGraphicalEditorPaletteRootCreator(
this.smooksModelProvider, (AdapterFactoryEditingDomain)
this.smooksModelProvider.getEditingDomain(),
- getSmooksResourceListType()){
+ getSmooksResourceListType()) {
- /* (non-Javadoc)
- * @see
org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPaletteRootCreator#fillActionGrouper(java.util.List)
- */
- @Override
- protected void fillActionGrouper(List<ISmooksActionGrouper> grouperList) {
- grouperList.add(new JavaBean11ActionGrouper());
- }
-
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.
+ * SmooksGraphicalEditorPaletteRootCreator
+ * #fillActionGrouper(java.util.List)
+ */
+ @Override
+ protected void fillActionGrouper(List<ISmooksActionGrouper> grouperList) {
+ grouperList.add(new JavaBean11ActionGrouper());
+ }
+
};
return creator.createPaletteRoot();
}
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#getAutoLayout()
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#
+ * getAutoLayout()
*/
@Override
public IAutoLayout getAutoLayout() {
- if(javaMappingAutoLayout == null){
+ if (javaMappingAutoLayout == null) {
javaMappingAutoLayout = new JavaMappingAutoLayout();
}
return javaMappingAutoLayout;
}
-
-
/*
* (non-Javadoc)
*
@@ -100,6 +108,19 @@
return new JavaMappingGraphicalModelFactory();
}
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#
+ * createActions()
+ */
+ @Override
+ protected void createActions() {
+ super.createActions();
+ JavaMappingActionCreator creator = new JavaMappingActionCreator();
+ creator.registXSLActions(getActionRegistry(), getSelectionActions(), this,
this.getSmooksModelProvider());
+ }
+
private class JavaMappingConnectionModelFactory extends ConnectionModelFactoryImpl {
/*
@@ -199,7 +220,8 @@
ILabelProvider labelProvider =
createLabelProvider(editingDomain.getAdapterFactory());
if (model instanceof BindingsType || model instanceof BeanType) {
- graphModel = new JavaBeanGraphModel(model, contentProvider, labelProvider,
provider);
+ graphModel = new JavaBeanGraphModel(model, contentProvider, labelProvider,
provider,
+ SmooksJavaMappingGraphicalEditor.this);
((JavaBeanGraphModel) graphModel).setHeaderVisable(true);
}
// if (model instanceof Xsl) {
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-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -33,22 +33,17 @@
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.dnd.DND;
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;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
@@ -74,8 +69,9 @@
import org.eclipse.ui.forms.widgets.ScrolledPageBook;
import org.eclipse.ui.forms.widgets.Section;
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.GraphNode;
+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;
@@ -84,14 +80,11 @@
import org.jboss.tools.smooks.editor.ISmooksModelProvider;
import org.jboss.tools.smooks.editor.ISourceSynchronizeListener;
import org.jboss.tools.smooks.graphical.actions.AbstractProcessGraphAction;
-import org.jboss.tools.smooks.graphical.actions.AddInputTaskAction;
import org.jboss.tools.smooks.graphical.actions.AddNextTaskNodeAction;
-import org.jboss.tools.smooks.graphical.actions.AddPreviousTaskNodeAction;
-import org.jboss.tools.smooks.graphical.actions.AddTaskNodeAction;
import org.jboss.tools.smooks.graphical.actions.DeleteTaskNodeAction;
-import org.jboss.tools.smooks.graphical.actions.TaskTypeRules;
import org.jboss.tools.smooks.graphical.editors.TaskTypeManager.TaskTypeDescriptor;
-import org.jboss.tools.smooks.model.graphics.ext.GraphFactory;
+import
org.jboss.tools.smooks.graphical.editors.process.ProcessGraphicalViewerLabelProvider;
+import org.jboss.tools.smooks.graphical.editors.process.TaskNodeFigure;
import org.jboss.tools.smooks.model.graphics.ext.ISmooksGraphChangeListener;
import org.jboss.tools.smooks.model.graphics.ext.ProcessType;
import org.jboss.tools.smooks.model.graphics.ext.ProcessesType;
@@ -124,6 +117,10 @@
private Map<String, Object> registedTaskPages = new HashMap<String,
Object>();
+ private MenuManager manager;
+
+ protected boolean needupdatewhenshow = true;
+
public SmooksProcessGraphicalEditor(FormEditor editor, String id, String title,
ISmooksModelProvider provider) {
super(editor, id, title);
this.smooksModelProvider = provider;
@@ -156,43 +153,9 @@
});
// GridData gd = new GridData(GridData.FILL_BOTH);
// processGraphViewer.getControl().setLayoutData(gd);
- processGraphViewer.setNodeStyle(ZestStyles.NODES_FISHEYE);
+ // processGraphViewer.setNodeStyle(ZestStyles.NODES_FISHEYE);
processGraphViewer.setContentProvider(new ProcessGraphContentProvider());
- processGraphViewer.setLabelProvider(new LabelProvider() {
-
- @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 id = ((TaskType) element).getId();
- String name = ((TaskType) element).getName();
- if (name == null) {
- name = id;
- }
- if (name == null) {
- name = "null";
- }
- return name;
- }
- return "";
- }
-
- });
+ processGraphViewer.setLabelProvider(new ProcessGraphicalViewerLabelProvider(this));
processGraphViewer.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);
HorizontalTreeLayoutAlgorithm layoutAlgorithm = new HorizontalTreeLayoutAlgorithm(
LayoutStyles.NO_LAYOUT_NODE_RESIZING);
@@ -230,112 +193,165 @@
}
protected void hookProcessGraphicalViewer() {
+ // 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;
+ //
+ // 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 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;
+ // }
+ // }
+ // 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;
+ // }
+ // }
+ //
+ // public void dragOperationChanged(DropTargetEvent event) {
+ // }
+ //
+ // public void dragLeave(DropTargetEvent event) {
+ // }
+ //
+ // public void dragEnter(DropTargetEvent event) {
+ // event.detail = DND.DROP_MOVE;
+ // this.taskType = null;
+ // process = null;
+ // }
+ // });
+ getProcessGraphViewer().addSelectionChangedListener(new ISelectionChangedListener() {
- getProcessGraphViewer().getControl();
- 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;
-
- 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 selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ Object firstElement = selection.getFirstElement();
+ if (firstElement == null) {
+ unhighlightGraphNodes();
}
- }
-
- 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;
- }
- }
- event.detail = DND.DROP_NONE;
- this.taskType = null;
- process = null;
- return;
+ 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;
}
- 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;
}
+ if (item != null) {
+ unhighlightGraphNodes();
+ highlightGraphNode(item);
+ }
+ showTaskControl(firstElement);
}
+ });
+ }
- public void dragOperationChanged(DropTargetEvent event) {
- }
+ protected void unhighlightGraphNodes() {
- public void dragLeave(DropTargetEvent event) {
- }
+ Graph graph = this.getProcessGraphViewer().getGraphControl();
+ List<?> elements = graph.getNodes();
+ for (Iterator<?> iterator = elements.iterator(); iterator.hasNext();) {
+ GraphItem graphItem = (GraphItem) iterator.next();
+ unhighlightGraphNode(graphItem);
+ }
+ }
- public void dragEnter(DropTargetEvent event) {
- event.detail = DND.DROP_MOVE;
- this.taskType = null;
- process = null;
+ protected void unhighlightGraphNode(GraphItem item) {
+ if (item instanceof CGraphNode) {
+ IFigure figure = ((CGraphNode) item).getFigure();
+ if (figure instanceof TaskNodeFigure) {
+ ((TaskNodeFigure) figure).unhighlightLabel();
}
- });
- getProcessGraphViewer().addSelectionChangedListener(new ISelectionChangedListener() {
+ }
+ }
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- Object firstElement = selection.getFirstElement();
- showTaskControl(firstElement);
+ 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);
}
- });
+ }
}
protected void configProcessGraphicalViewer() {
- MenuManager manager = new MenuManager();
+ manager = new MenuManager();
initProcessGraphicalPanelActions(manager);
@@ -344,34 +360,87 @@
manager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
- for (Iterator<?> iterator = processPanelActions.iterator();
iterator.hasNext();) {
- IAction a = (IAction) iterator.next();
- if (a instanceof AbstractProcessGraphAction) {
- ((AbstractProcessGraphAction) a).selectionChanged(new
SelectionChangedEvent(processGraphViewer,
- processGraphViewer.getSelection()));
+ 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);
+ }
}
}
- manager.update();
+ needupdatewhenshow = true;
}
});
}
+ public void fillProcessMenu(IMenuManager manager) {
+ MenuManager addNextTaskMenuManager = new MenuManager("Add Task");
+ 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);
+ }
+ }
+
+ // MenuManager addPreTaskMenuManager = new
+ // MenuManager("Add Previous Task");
+ // manager.add(addPreTaskMenuManager);
+ //
+ // fillPreTaskMenu(addPreTaskMenuManager);
+ }
+
+ /**
+ * @return the needupdatewhenshow
+ */
+ public boolean isNeedupdatewhenshow() {
+ return needupdatewhenshow;
+ }
+
+ /**
+ * @param needupdatewhenshow
+ * the needupdatewhenshow to set
+ */
+ public void setNeedupdatewhenshow(boolean needupdatewhenshow) {
+ this.needupdatewhenshow = needupdatewhenshow;
+ }
+
+ public void updateProcessActions(ISelection selection) {
+ 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();
+ }
+
protected void initProcessGraphicalPanelActions(IMenuManager manager) {
- AddTaskNodeAction addInputTaskAction = new AddInputTaskAction(smooksModelProvider);
- manager.add(addInputTaskAction);
- processPanelActions.add(addInputTaskAction);
+ // AddTaskNodeAction addInputTaskAction = new
+ // AddInputTaskAction(smooksModelProvider);
+ // manager.add(addInputTaskAction);
+ // processPanelActions.add(addInputTaskAction);
- MenuManager addNextTaskMenuManager = new MenuManager("Add Next Task");
+ MenuManager addNextTaskMenuManager = new MenuManager("Add Task");
manager.add(addNextTaskMenuManager);
- fillNextTaskMenu(addNextTaskMenuManager);
+ generateNextTaskActions(addNextTaskMenuManager);
- MenuManager addPreTaskMenuManager = new MenuManager("Add Previous Task");
- manager.add(addPreTaskMenuManager);
+ // MenuManager addPreTaskMenuManager = new
+ // MenuManager("Add Previous Task");
+ // manager.add(addPreTaskMenuManager);
+ //
+ // fillPreTaskMenu(addPreTaskMenuManager);
- fillPreTaskMenu(addPreTaskMenuManager);
-
DeleteTaskNodeAction deleteAction = new DeleteTaskNodeAction(smooksModelProvider);
manager.add(deleteAction);
@@ -379,7 +448,7 @@
}
- private void fillNextTaskMenu(MenuManager addNextTaskMenuManager) {
+ private void generateNextTaskActions(MenuManager addNextTaskMenuManager) {
List<TaskTypeDescriptor> list = TaskTypeManager.getAllTaskList();
for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
TaskTypeDescriptor taskTypeDescriptor = (TaskTypeDescriptor) iterator.next();
@@ -390,16 +459,18 @@
}
}
- private void fillPreTaskMenu(MenuManager addPreTaskMenuManager) {
- List<TaskTypeDescriptor> list = TaskTypeManager.getAllTaskList();
- for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
- TaskTypeDescriptor taskTypeDescriptor = (TaskTypeDescriptor) iterator.next();
- AddPreviousTaskNodeAction addNextInputAction = new
AddPreviousTaskNodeAction(taskTypeDescriptor.getId(),
- taskTypeDescriptor.getLabel(), smooksModelProvider);
- this.processPanelActions.add(addNextInputAction);
- addPreTaskMenuManager.add(addNextInputAction);
- }
- }
+ // private void fillPreTaskMenu(MenuManager addPreTaskMenuManager) {
+ // List<TaskTypeDescriptor> list = TaskTypeManager.getAllTaskList();
+ // for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
+ // TaskTypeDescriptor taskTypeDescriptor = (TaskTypeDescriptor)
+ // iterator.next();
+ // AddPreviousTaskNodeAction addNextInputAction = new
+ // AddPreviousTaskNodeAction(taskTypeDescriptor.getId(),
+ // taskTypeDescriptor.getLabel(), smooksModelProvider);
+ // this.processPanelActions.add(addNextInputAction);
+ // addPreTaskMenuManager.add(addNextInputAction);
+ // }
+ // }
public void registeTaskDetailsPage(IEditorPart editor, String taskID) {
editor.addPropertyListener(this);
@@ -437,17 +508,20 @@
processGraphSection.setClient(processGraphComposite);
- Composite toolBarComposite = toolkit.createComposite(processGraphComposite);
- FillLayout l = new FillLayout();
- l.marginHeight = 1;
- l.marginWidth = 1;
- toolBarComposite.setLayout(l);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- toolBarComposite.setLayoutData(gd);
- toolBarComposite.setBackground(toolkit.getColors().getBorderColor());
+ // Composite toolBarComposite =
+ // toolkit.createComposite(processGraphComposite);
+ // FillLayout l = new FillLayout();
+ // l.marginHeight = 1;
+ // l.marginWidth = 1;
+ // toolBarComposite.setLayout(l);
- createProcessToolBar(toolBarComposite, toolkit);
+ // toolBarComposite.setLayoutData(gd);
+ //
+ // toolBarComposite.setBackground(toolkit.getColors().getBorderColor());
+ //
+ // createProcessToolBar(toolBarComposite, toolkit);
Composite graphMainComposite = toolkit.createComposite(processGraphComposite);
FillLayout l1 = new FillLayout();
@@ -698,9 +772,11 @@
SmooksFreemarkerTemplateGraphicalEditor freemarkerPart = new
SmooksFreemarkerTemplateGraphicalEditor(
smooksModelProvider);
this.registeTaskDetailsPage(freemarkerPart,
TaskTypeManager.TASK_ID_FREEMARKER_TEMPLATE);
-
- SmooksXSLTemplateGraphicalEditor xsltemplatePart = new
SmooksXSLTemplateGraphicalEditor(smooksModelProvider);
- this.registeTaskDetailsPage(xsltemplatePart, TaskTypeManager.TASK_ID_XSL_TEMPLATE);
+
+ // SmooksXSLTemplateGraphicalEditor xsltemplatePart = new
+ // SmooksXSLTemplateGraphicalEditor(smooksModelProvider);
+ // this.registeTaskDetailsPage(xsltemplatePart,
+ // TaskTypeManager.TASK_ID_XSL_TEMPLATE);
}
@Override
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksXSLTemplateGraphicalEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksXSLTemplateGraphicalEditor.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksXSLTemplateGraphicalEditor.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -72,7 +72,7 @@
/* (non-Javadoc)
* @see
org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart#getPaletteRoot()
*/
- @Override
+// @Override
protected PaletteRoot getPaletteRoot() {
SmooksGraphicalEditorPaletteRootCreator creator = new
SmooksGraphicalEditorPaletteRootCreator(
this.smooksModelProvider, (AdapterFactoryEditingDomain)
this.smooksModelProvider.getEditingDomain(),
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/AbstractResourceConfigEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/AbstractResourceConfigEditPart.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/AbstractResourceConfigEditPart.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -94,9 +94,12 @@
});
this.installEditPolicy(EditPolicy.CONTAINER_ROLE, new FlowLayoutEditPolicy() {
-
- /* (non-Javadoc)
- * @see org.eclipse.gef.editpolicies.FlowLayoutEditPolicy#isHorizontal()
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.gef.editpolicies.FlowLayoutEditPolicy#isHorizontal()
*/
@Override
protected boolean isHorizontal() {
@@ -174,6 +177,8 @@
}
org.eclipse.emf.common.command.Command emfCommand =
createModelCreationEMFCommand(domain,
((AbstractResourceConfigGraphModel) graphModel).getData(), type, model);
+ if (emfCommand == null || !emfCommand.canExecute())
+ return null;
return createModelCreationCommand(domain, emfCommand);
}
return null;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -14,7 +14,6 @@
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
-import org.eclipse.draw2d.FigureUtilities;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanChildNodeEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanChildNodeEditPart.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanChildNodeEditPart.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -15,11 +15,17 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
+import org.jboss.tools.smooks.gef.tree.command.GEFAdapterCommand;
import org.jboss.tools.smooks.graphical.editors.IGraphicalEditorPart;
import org.jboss.tools.smooks.graphical.editors.SmooksFreemarkerTemplateGraphicalEditor;
import
org.jboss.tools.smooks.graphical.editors.editparts.AbstractResourceConfigChildNodeEditPart;
+import
org.jboss.tools.smooks.graphical.editors.model.javamapping.JavaBeanChildGraphModel;
import org.jboss.tools.smooks.model.javabean.ExpressionType;
import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
import org.jboss.tools.smooks.model.javabean.ValueType;
@@ -28,70 +34,138 @@
/**
* @author Dart
- *
+ *
*/
public class JavaBeanChildNodeEditPart extends AbstractResourceConfigChildNodeEditPart {
private List<Object> supportTypes = new ArrayList<Object>();
-
-
-
+
public JavaBeanChildNodeEditPart() {
super();
supportTypes.add(ValueType.class);
supportTypes.add(ExpressionType.class);
supportTypes.add(WiringType.class);
-
+
supportTypes.add(org.jboss.tools.smooks.model.javabean12.ValueType.class);
supportTypes.add(org.jboss.tools.smooks.model.javabean12.ExpressionType.class);
supportTypes.add(org.jboss.tools.smooks.model.javabean12.WiringType.class);
}
- /* (non-Javadoc)
- * @see
org.jboss.tools.smooks.graphical.editors.editparts.AbstractResourceConfigChildNodeEditPart#isDragLink()
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.editparts.
+ * AbstractResourceConfigChildNodeEditPart#isDragLink()
*/
@Override
protected boolean isDragLink() {
- IGraphicalEditorPart part = (IGraphicalEditorPart)getEditorPart();
- if(SmooksFreemarkerTemplateGraphicalEditor.ID.equals(part.getID())){
+ IGraphicalEditorPart part = (IGraphicalEditorPart) getEditorPart();
+ if (SmooksFreemarkerTemplateGraphicalEditor.ID.equals(part.getID())) {
AbstractSmooksGraphicalModel model = (AbstractSmooksGraphicalModel) this.getModel();
Object data = model.getData();
data = AdapterFactoryEditingDomain.unwrap(data);
- if(data instanceof ValueType || data instanceof
org.jboss.tools.smooks.model.javabean12.ValueType){
+ if (data instanceof ValueType || data instanceof
org.jboss.tools.smooks.model.javabean12.ValueType) {
return true;
}
}
return super.isDragLink();
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.gef.tree.editparts.TreeNodeEditPart#canDirectEdit
+ * ()
+ */
+ @Override
+ protected boolean canDirectEdit() {
+ JavaBeanChildGraphModel graphModel = (JavaBeanChildGraphModel) getModel();
+ boolean isArray = graphModel.parentIsArray();
+ boolean isCollection = graphModel.parentIsCollection();
+ if (isArray || isCollection) {
+ return super.canDirectEdit();
+ }
+ return true;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.gef.tree.editparts.TreeNodeEditPart#
+ * createDirectEditCommand(org.eclipse.gef.requests.DirectEditRequest)
+ */
+ @Override
+ protected Command createDirectEditCommand(DirectEditRequest request) {
+ Object value = request.getCellEditor().getValue();
+ ISmooksModelProvider smooksModelProvider = (ISmooksModelProvider)
this.getEditorPart().getAdapter(
+ ISmooksModelProvider.class);
+ AbstractSmooksGraphicalModel graphModel = (AbstractSmooksGraphicalModel)
this.getModel();
+ Object data = graphModel.getData();
+ data = AdapterFactoryEditingDomain.unwrap(data);
+ EStructuralFeature feature = getFeature(data);
+
+ if (value != null && value instanceof String && smooksModelProvider !=
null && feature != null) {
+ org.eclipse.emf.common.command.Command setCommand =
SetCommand.create(smooksModelProvider
+ .getEditingDomain(), data, feature, value);
+ if (setCommand.canExecute()) {
+ GEFAdapterCommand gefCommand = new
GEFAdapterCommand(smooksModelProvider.getEditingDomain(), setCommand);
+ return gefCommand;
+ }
+ }
+ return null;
+ }
+
+ private EStructuralFeature getFeature(Object data) {
+ if (data instanceof ValueType) {
+ return JavabeanPackage.Literals.VALUE_TYPE__PROPERTY;
+ }
+ if (data instanceof WiringType) {
+ return JavabeanPackage.Literals.WIRING_TYPE__PROPERTY;
+ }
+ if (data instanceof ExpressionType) {
+ return JavabeanPackage.Literals.EXPRESSION_TYPE__PROPERTY;
+ }
+
+ if (data instanceof org.jboss.tools.smooks.model.javabean12.ValueType) {
+ return Javabean12Package.Literals.VALUE_TYPE__PROPERTY;
+ }
+ if (data instanceof org.jboss.tools.smooks.model.javabean12.WiringType) {
+ return Javabean12Package.Literals.WIRING_TYPE__PROPERTY;
+ }
+ if (data instanceof org.jboss.tools.smooks.model.javabean12.ExpressionType) {
+ return Javabean12Package.Literals.EXPRESSION_TYPE__PROPERTY;
+ }
+ return null;
+ }
+
@Override
protected EStructuralFeature getFeature(EObject model) {
- if(model instanceof WiringType){
+ if (model instanceof WiringType) {
return JavabeanPackage.Literals.BINDINGS_TYPE__WIRING;
}
-
- if(model instanceof ValueType){
+
+ if (model instanceof ValueType) {
return JavabeanPackage.Literals.BINDINGS_TYPE__VALUE;
}
-
- if(model instanceof ExpressionType){
+
+ if (model instanceof ExpressionType) {
return JavabeanPackage.Literals.BINDINGS_TYPE__EXPRESSION;
}
-
- if(model instanceof org.jboss.tools.smooks.model.javabean12.WiringType){
+
+ if (model instanceof org.jboss.tools.smooks.model.javabean12.WiringType) {
return Javabean12Package.Literals.BEAN_TYPE__WIRING;
}
-
- if(model instanceof org.jboss.tools.smooks.model.javabean12.ValueType){
+
+ if (model instanceof org.jboss.tools.smooks.model.javabean12.ValueType) {
return Javabean12Package.Literals.BEAN_TYPE__VALUE;
}
-
- if(model instanceof org.jboss.tools.smooks.model.javabean12.ExpressionType){
+
+ if (model instanceof org.jboss.tools.smooks.model.javabean12.ExpressionType) {
return Javabean12Package.Literals.BEAN_TYPE__EXPRESSION;
}
return null;
}
-
+
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanEditPart.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/javamapping/JavaBeanEditPart.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -13,8 +13,14 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
import
org.jboss.tools.smooks.graphical.editors.editparts.AbstractResourceConfigEditPart;
import org.jboss.tools.smooks.model.javabean.BindingsType;
import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
@@ -45,4 +51,36 @@
return null;
}
+
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.smooks.gef.tree.editparts.TreeContainerEditPart#createFigure()
+ */
+ @Override
+ protected IFigure createFigure() {
+ return super.createFigure();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.editparts.
+ * AbstractResourceConfigEditPart
+ * #createModelCreationEMFCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.lang.Object, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ protected Command createModelCreationEMFCommand(EditingDomain domain, Object owner,
Object type, Object collections) {
+ Object model = ((AbstractSmooksGraphicalModel) getModel()).getData();
+ model = AdapterFactoryEditingDomain.unwrap(model);
+ if (model instanceof EObject) {
+ boolean isArray = SmooksUIUtils.isArrayJavaGraphModel((EObject) model);
+ boolean isCollection = SmooksUIUtils.isCollectionJavaGraphModel((EObject) model);
+ if(isArray || isCollection){
+ return null;
+ }
+ }
+ return super.createModelCreationEMFCommand(domain, owner, type, collections);
+ }
+
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/AddFreemarkerAction.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/AddFreemarkerAction.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/AddFreemarkerAction.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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.model.freemarker;
+
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.graphical.actions.AddSmooksObjectAction;
+import org.jboss.tools.smooks.model.freemarker.FreemarkerFactory;
+import org.jboss.tools.smooks.model.freemarker.FreemarkerPackage;
+import org.jboss.tools.smooks.model.smooks.SmooksPackage;
+
+/**
+ * @author Dart
+ *
+ */
+public class AddFreemarkerAction extends AddSmooksObjectAction {
+
+ public AddFreemarkerAction(IWorkbenchPart part, int style, ISmooksModelProvider
provider) {
+ super(part, style, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ public AddFreemarkerAction(IWorkbenchPart part, ISmooksModelProvider provider) {
+ super(part, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected Object getSmooks11Object() {
+ return
FeatureMapUtil.createEntry(FreemarkerPackage.Literals.DOCUMENT_ROOT__FREEMARKER,
+ FreemarkerFactory.eINSTANCE.createFreemarker());
+ }
+
+ @Override
+ protected Object getSmooks11Type() {
+ return
SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_RESOURCE_CONFIG_GROUP;
+ }
+
+ @Override
+ protected Object getSmooks12Object() {
+ return getSmooks11Object();
+ }
+
+ @Override
+ protected Object getSmooks12Type() {
+ return getSmooks11Type();
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/AddFreemarkerAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerActionCreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerActionCreator.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerActionCreator.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -15,18 +15,25 @@
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.IEditorPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
/**
* @author Dart
- *
+ *
*/
public class FreemarkerActionCreator {
- public void registXSLActions(ActionRegistry actionRegistry, List selectionActions,
IEditorPart editorPart) {
+ public void registXSLActions(ActionRegistry actionRegistry, List selectionActions,
IEditorPart editorPart,
+ ISmooksModelProvider provider) {
// add xsl actions
+
+ IAction addFreemarkerNodeAction = new AddFreemarkerAction(editorPart, provider);
+ actionRegistry.registerAction(addFreemarkerNodeAction);
+ selectionActions.add(addFreemarkerNodeAction.getId());
+
IAction addXSLNodeAction = new AddFreemarkerCSVRecordAction(editorPart);
actionRegistry.registerAction(addXSLNodeAction);
selectionActions.add(addXSLNodeAction.getId());
-
+
IAction addFieldNodeAction = new AddFreemarkerCSVFieldAction(editorPart);
actionRegistry.registerAction(addFieldNodeAction);
selectionActions.add(addFieldNodeAction.getId());
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddExpressionAction.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddExpressionAction.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddExpressionAction.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.model.javamapping;
+
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.graphical.actions.AddSmooksObjectAction;
+import org.jboss.tools.smooks.model.javabean.JavabeanFactory;
+import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Factory;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Package;
+
+/**
+ * @author Dart
+ *
+ */
+public class AddExpressionAction extends AddSmooksObjectAction {
+
+ public AddExpressionAction(IWorkbenchPart part, int style, ISmooksModelProvider
provider) {
+ super(part, style, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ public AddExpressionAction(IWorkbenchPart part, ISmooksModelProvider provider) {
+ super(part, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected Object getSmooks11Object() {
+ return JavabeanFactory.eINSTANCE.createExpressionType();
+ }
+
+ @Override
+ protected Object getSmooks11Type() {
+ return JavabeanPackage.Literals.BINDINGS_TYPE__EXPRESSION;
+ }
+
+ @Override
+ protected Object getSmooks12Object() {
+ return Javabean12Factory.eINSTANCE.createExpressionType();
+ }
+
+ @Override
+ protected Object getSmooks12Type() {
+ return Javabean12Package.Literals.BEAN_TYPE__EXPRESSION;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddExpressionAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddJavaBeanAction.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddJavaBeanAction.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddJavaBeanAction.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.model.javamapping;
+
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.graphical.actions.AddSmooksObjectAction;
+import org.jboss.tools.smooks.model.javabean.JavabeanFactory;
+import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Factory;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Package;
+import org.jboss.tools.smooks.model.smooks.SmooksPackage;
+
+/**
+ * @author Dart
+ *
+ */
+public class AddJavaBeanAction extends AddSmooksObjectAction {
+
+ public AddJavaBeanAction(IWorkbenchPart part, int style, ISmooksModelProvider provider)
{
+ super(part, style, provider);
+ }
+
+ public AddJavaBeanAction(IWorkbenchPart part, ISmooksModelProvider provider) {
+ super(part, provider);
+ }
+
+ @Override
+ protected Object getSmooks11Object() {
+ return FeatureMapUtil.createEntry(JavabeanPackage.Literals.DOCUMENT_ROOT__BINDINGS,
JavabeanFactory.eINSTANCE
+ .createBindingsType());
+ }
+
+ @Override
+ protected Object getSmooks11Type() {
+ return
SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_RESOURCE_CONFIG_GROUP;
+ }
+
+ @Override
+ protected Object getSmooks12Object() {
+ return
FeatureMapUtil.createEntry(Javabean12Package.Literals.JAVABEAN12_DOCUMENT_ROOT__BEAN,
+ Javabean12Factory.eINSTANCE.createBeanType());
+ }
+
+ @Override
+ protected Object getSmooks12Type() {
+ return
SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_RESOURCE_CONFIG_GROUP;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddJavaBeanAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddValueAction.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddValueAction.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddValueAction.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.model.javamapping;
+
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.graphical.actions.AddSmooksObjectAction;
+import org.jboss.tools.smooks.model.javabean.JavabeanFactory;
+import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Factory;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Package;
+
+/**
+ * @author Dart
+ *
+ */
+public class AddValueAction extends AddSmooksObjectAction {
+
+
+
+ public AddValueAction(IWorkbenchPart part, ISmooksModelProvider provider) {
+ super(part, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ public AddValueAction(IWorkbenchPart part, int style, ISmooksModelProvider provider) {
+ super(part, style, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected Object getSmooks11Object() {
+ return JavabeanFactory.eINSTANCE.createValueType();
+ }
+
+ @Override
+ protected Object getSmooks11Type() {
+ return JavabeanPackage.Literals.BINDINGS_TYPE__VALUE;
+ }
+
+ @Override
+ protected Object getSmooks12Object() {
+ return Javabean12Factory.eINSTANCE.createValueType();
+ }
+
+ @Override
+ protected Object getSmooks12Type() {
+ return Javabean12Package.Literals.BEAN_TYPE__VALUE;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddValueAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddWiringAction.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddWiringAction.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddWiringAction.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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.model.javamapping;
+
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.graphical.actions.AddSmooksObjectAction;
+import org.jboss.tools.smooks.model.javabean.JavabeanFactory;
+import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Factory;
+import org.jboss.tools.smooks.model.javabean12.Javabean12Package;
+
+/**
+ * @author Dart
+ *
+ */
+public class AddWiringAction extends AddSmooksObjectAction {
+
+ public AddWiringAction(IWorkbenchPart part, int style, ISmooksModelProvider provider) {
+ super(part, style, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ public AddWiringAction(IWorkbenchPart part, ISmooksModelProvider provider) {
+ super(part, provider);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected Object getSmooks11Object() {
+ return JavabeanFactory.eINSTANCE.createWiringType();
+ }
+
+ @Override
+ protected Object getSmooks11Type() {
+ return JavabeanPackage.Literals.BINDINGS_TYPE__WIRING;
+ }
+
+ @Override
+ protected Object getSmooks12Object() {
+ return Javabean12Factory.eINSTANCE.createWiringType();
+ }
+
+ @Override
+ protected Object getSmooks12Type() {
+ return Javabean12Package.Literals.BEAN_TYPE__WIRING;
+ }
+
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/AddWiringAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanChildGraphModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanChildGraphModel.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanChildGraphModel.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -10,29 +10,24 @@
******************************************************************************/
package org.jboss.tools.smooks.graphical.editors.model.javamapping;
-import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.swt.graphics.Image;
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
-import org.jboss.tools.smooks.configuration.editors.uitls.ProjectClassLoader;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
import
org.jboss.tools.smooks.graphical.editors.model.AbstractResourceConfigChildNodeGraphModel;
import org.jboss.tools.smooks.graphical.editors.model.freemarker.CSVLinkConnection;
import org.jboss.tools.smooks.graphical.editors.model.freemarker.CSVNodeModel;
-import org.jboss.tools.smooks.model.javabean.BindingsType;
import org.jboss.tools.smooks.model.javabean.ValueType;
-import org.jboss.tools.smooks.model.javabean12.BeanType;
/**
* @author Dart
@@ -78,8 +73,12 @@
return false;
}
- /* (non-Javadoc)
- * @see
org.jboss.tools.smooks.graphical.editors.model.AbstractResourceConfigChildNodeGraphModel#canLinkWithSource(java.lang.Object)
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.model.
+ * AbstractResourceConfigChildNodeGraphModel
+ * #canLinkWithSource(java.lang.Object)
*/
@Override
public boolean canLinkWithSource(Object model) {
@@ -87,16 +86,20 @@
return super.canLinkWithSource(model);
}
- /* (non-Javadoc)
- * @see
org.jboss.tools.smooks.graphical.editors.model.AbstractResourceConfigChildNodeGraphModel#canLinkWithTarget(java.lang.Object)
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.graphical.editors.model.
+ * AbstractResourceConfigChildNodeGraphModel
+ * #canLinkWithTarget(java.lang.Object)
*/
@Override
public boolean canLinkWithTarget(Object model) {
- AbstractSmooksGraphicalModel gm = (AbstractSmooksGraphicalModel)model;
+ AbstractSmooksGraphicalModel gm = (AbstractSmooksGraphicalModel) model;
Object m = gm.getData();
if (data instanceof ValueType || data instanceof
org.jboss.tools.smooks.model.javabean12.ValueType
|| m instanceof CSVNodeModel) {
- return !((CSVNodeModel)m).isRecord();
+ return !((CSVNodeModel) m).isRecord();
}
return super.canLinkWithTarget(model);
}
@@ -118,54 +121,22 @@
return super.getImage();
}
- private boolean parentIsCollection() {
+ public boolean parentIsCollection() {
Object model = getData();
model = AdapterFactoryEditingDomain.unwrap(model);
if (model instanceof EObject) {
EObject parent = ((EObject) model).eContainer();
- String classString = null;
- if (parent instanceof BeanType) {
- classString = ((BeanType) parent).getClass_();
- }
- if (parent instanceof BindingsType) {
- classString = ((BindingsType) parent).getClass_();
- }
- if (classString != null)
- classString = classString.trim();
-
- IJavaProject project = SmooksUIUtils.getJavaProject(parent);
- if (project != null) {
- try {
- ProjectClassLoader loader = new ProjectClassLoader(project);
- Class<?> clazz = loader.loadClass(classString);
- if (Collection.class.isAssignableFrom(clazz)) {
- return true;
- }
- } catch (Throwable t) {
-
- }
- }
+ return SmooksUIUtils.isCollectionJavaGraphModel(parent);
}
return false;
}
- private boolean parentIsArray() {
+ public boolean parentIsArray() {
Object model = getData();
model = AdapterFactoryEditingDomain.unwrap(model);
if (model instanceof EObject) {
EObject parent = ((EObject) model).eContainer();
- String classString = null;
- if (parent instanceof BeanType) {
- classString = ((BeanType) parent).getClass_();
- }
- if (parent instanceof BindingsType) {
- classString = ((BindingsType) parent).getClass_();
- }
- if (classString != null)
- classString = classString.trim();
- if (classString.endsWith("]")) {
- return true;
- }
+ return SmooksUIUtils.isArrayJavaGraphModel(parent);
}
return false;
}
@@ -188,10 +159,11 @@
*/
@Override
public String getText() {
- if (parentIsArray()) {
+ int index = this.getParent().getChildrenWithoutDynamic().indexOf(this);
+ if (parentIsArray() && index == 0) {
return "Array Entry";
}
- if (parentIsCollection()) {
+ if (parentIsCollection() && index == 0) {
return "Collection Entry";
}
return super.getText();
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanGraphModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanGraphModel.java 2009-11-16
07:09:51 UTC (rev 18689)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanGraphModel.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -15,38 +15,55 @@
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
+import org.jboss.tools.smooks.graphical.editors.IGraphicalEditorPart;
+import org.jboss.tools.smooks.graphical.editors.SmooksFreemarkerTemplateGraphicalEditor;
import org.jboss.tools.smooks.graphical.editors.model.AbstractResourceConfigGraphModel;
-import org.jboss.tools.smooks.graphical.editors.model.freemarker.CSVLinkConnection;
/**
* @author Dart
*
*/
public class JavaBeanGraphModel extends AbstractResourceConfigGraphModel {
+
+ private IGraphicalEditorPart editorPart;
-
public JavaBeanGraphModel(Object data, ITreeContentProvider contentProvider,
ILabelProvider labelProvider,
- IEditingDomainProvider domainProvider) {
- super(data,contentProvider,labelProvider,domainProvider);
+ IEditingDomainProvider domainProvider , IGraphicalEditorPart editorPart) {
+ super(data, contentProvider, labelProvider, domainProvider);
+ this.editorPart = editorPart;
}
@Override
protected TreeNodeModel createChildModel(Object model, ITreeContentProvider
contentProvider,
ILabelProvider labelProvider) {
Object m = AdapterFactoryEditingDomain.unwrap(model);
- if(m instanceof String) return null;
+ if (m instanceof String)
+ return null;
return new JavaBeanChildGraphModel(model, contentProvider, labelProvider,
this.domainProvider);
}
+
+
/* (non-Javadoc)
- * @see
org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel#isLinkable(java.lang.Class)
+ * @see org.jboss.tools.smooks.gef.tree.model.TreeContainerModel#canDragLink()
*/
@Override
- public boolean isLinkable(Class<?> connectionType) {
- if(connectionType == CSVLinkConnection.class){
+ public boolean canDragLink() {
+ if(SmooksFreemarkerTemplateGraphicalEditor.ID.equals(editorPart.getID())){
return true;
}
return false;
-// return super.isLinkable(connectionType);
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel#isLinkable
+ * (java.lang.Class)
+ */
+ @Override
+ public boolean isLinkable(Class<?> connectionType) {
+ return canDragLink();
+ }
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaMappingActionCreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaMappingActionCreator.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaMappingActionCreator.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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.model.javamapping;
+
+import java.util.List;
+
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.IEditorPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+
+/**
+ * @author Dart
+ *
+ */
+public class JavaMappingActionCreator {
+ public void registXSLActions(ActionRegistry actionRegistry, List selectionActions,
IEditorPart editorPart,
+ ISmooksModelProvider smooksModelProvider) {
+ IAction addBeanAction = new AddJavaBeanAction(editorPart, smooksModelProvider);
+ actionRegistry.registerAction(addBeanAction);
+ selectionActions.add(addBeanAction.getId());
+
+ IAction addValueAction = new AddValueAction(editorPart, smooksModelProvider);
+ actionRegistry.registerAction(addValueAction);
+ selectionActions.add(addValueAction.getId());
+
+ IAction addWiringAction = new AddWiringAction(editorPart, smooksModelProvider);
+ actionRegistry.registerAction(addWiringAction);
+ selectionActions.add(addWiringAction.getId());
+
+ IAction addExpression = new AddExpressionAction(editorPart, smooksModelProvider);
+ actionRegistry.registerAction(addExpression);
+ selectionActions.add(addExpression.getId());
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaMappingActionCreator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessGraphicalViewerLabelProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessGraphicalViewerLabelProvider.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessGraphicalViewerLabelProvider.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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.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.graphical.editors.SmooksProcessGraphicalEditor;
+import org.jboss.tools.smooks.graphical.editors.TaskTypeManager;
+import org.jboss.tools.smooks.graphical.editors.TaskTypeManager.TaskTypeDescriptor;
+import org.jboss.tools.smooks.model.graphics.ext.TaskType;
+
+/**
+ * @author Dart
+ *
+ */
+public class ProcessGraphicalViewerLabelProvider extends LabelProvider implements
IFigureProvider, ISelfStyleProvider {
+
+ private SmooksProcessGraphicalEditor processEditor;
+
+ 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 id = ((TaskType) element).getId();
+ String name = ((TaskType) element).getName();
+ if (name == null) {
+ name = id;
+ }
+ if (name == null) {
+ name = "null";
+ }
+ return name;
+ }
+ return "";
+ }
+
+ /*
+ * (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);
+ }
+
+ public void selfStyleNode(Object element, GraphNode node) {
+ if (node instanceof CGraphNode) {
+ IFigure figure = ((CGraphNode) node).getFigure();
+ Dimension size = figure.getLayoutManager().getPreferredSize(figure, -1, -1);
+ figure.setSize(size);
+ }
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/ProcessGraphicalViewerLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskNodeFigure.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskNodeFigure.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskNodeFigure.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -0,0 +1,250 @@
+/*******************************************************************************
+ * 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.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.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 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;
+ initFigure();
+ hookTaskNodeFigure();
+ }
+
+ private void hookTaskNodeFigure() {
+ 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();
+ ToolbarLayout layout = new ToolbarLayout(true);
+ layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+ this.add(mainFigure);
+ this.add(addTaskFigure);
+
+ this.setLayoutManager(layout);
+ }
+
+ private void initAddTaskFigure() {
+ addTaskFigure = new Clickable() {
+ @Override
+ protected void paintBorder(Graphics graphics) {
+ }
+
+ @Override
+ protected void paintFigure(Graphics graphics) {
+ super.paintFigure(graphics);
+ if (!showAddFigure) {
+ int feet = 4;
+ Rectangle rect = getBounds();
+ 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) {
+ Rectangle sourceRectangle = new Rectangle(0, 0, image.getBounds().width,
image.getBounds().height);
+ 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:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/process/TaskNodeFigure.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/template/csv/CSVToFreemarkerTemplateBuilderTest.java
===================================================================
---
trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/template/csv/CSVToFreemarkerTemplateBuilderTest.java
(rev 0)
+++
trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/template/csv/CSVToFreemarkerTemplateBuilderTest.java 2009-11-16
08:01:09 UTC (rev 18690)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.template.csv;
+
+import junit.framework.TestCase;
+
+import org.jboss.template.exception.TemplateBuilderException;
+import org.jboss.template.exception.UnmappedCollectionNodeException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
+ */
+public class CSVToFreemarkerTemplateBuilderTest extends TestCase {
+
+ public static void main(String[] args) throws TemplateBuilderException{
+ new CSVToFreemarkerTemplateBuilderTest().test_all_fields_mapped();
+ }
+
+ public void test_all_fields_mapped() throws TemplateBuilderException {
+ CSVModelBuilder modelBuilder = new CSVModelBuilder(new
String[]{"firstname", "lastname", "country"});
+ Document model = modelBuilder.buildModel();
+ CSVToFreemarkerTemplateBuilder builder;
+
+ builder = new CSVToFreemarkerTemplateBuilder(model, ',',
'\"');
+
+ builder.addCollectionMapping("people",
getRecordElement(model),"person");
+ builder.addValueMapping("person.fname", getFieldElement(model,
"firstname"));
+ builder.addValueMapping("person.lname", getFieldElement(model,
"lastname"));
+ builder.addValueMapping("person.address.country",
getFieldElement(model, "country"));
+
+ String template = builder.buildTemplate();
+ System.out.println(template);
+ assertEquals("<#list people as person>\n" +
+
"\"${person.fname}\",\"${person.lname}\",\"${person.address.country}\"\n"
+
+ "</#list>",
+ template);
+ }
+
+ public void test_all_fields_not_mapped() throws TemplateBuilderException {
+ CSVModelBuilder modelBuilder = new CSVModelBuilder("firstname",
"lastname", "country");
+ Document model = modelBuilder.buildModel();
+ CSVToFreemarkerTemplateBuilder builder;
+
+ builder = new CSVToFreemarkerTemplateBuilder(model, ',',
'\"');
+
+ builder.addCollectionMapping("people", getRecordElement(model),
"person");
+ builder.addValueMapping("person.fname", getFieldElement(model,
"firstname"));
+ builder.addValueMapping("person.address.country",
getFieldElement(model, "country"));
+
+ String template = builder.buildTemplate();
+ System.out.println(template);
+ assertEquals("<#list people as person>\n" +
+
"\"${person.fname}\",,\"${person.address.country}\"\n" +
+ "</#list>",
+ template);
+ }
+
+ public void test_collection_not_mapped_01() throws TemplateBuilderException {
+ CSVModelBuilder modelBuilder = new CSVModelBuilder("firstname",
"lastname", "country");
+ Document model = modelBuilder.buildModel();
+ CSVToFreemarkerTemplateBuilder builder;
+
+ builder = new CSVToFreemarkerTemplateBuilder(model, ',',
'\"');
+
+ try {
+ // Shouldn't be able to add a value binding where the model target is
inside
+ // an unmapped collection...
+ builder.addValueMapping("person.fname", getFieldElement(model,
"firstname"));
+ fail("Expected UnmappedCollectionNodeException");
+ } catch(UnmappedCollectionNodeException e) {
+ assertEquals("Unmapped collection node 'csv-record'.",
e.getMessage());
+ }
+ }
+
+ public void test_collection_not_mapped_02() throws TemplateBuilderException {
+ CSVModelBuilder modelBuilder = new CSVModelBuilder("firstname",
"lastname", "country");
+ Document model = modelBuilder.buildModel();
+ CSVToFreemarkerTemplateBuilder builder;
+
+ builder = new CSVToFreemarkerTemplateBuilder(model, ',',
'\"');
+
+ try {
+ // For CSV, you need to have at least mapped the collection...
+ builder.buildTemplate();
+ fail("Expected UnmappedCollectionNodeException");
+ } catch(UnmappedCollectionNodeException e) {
+ assertEquals("Unmapped collection node 'csv-record'.",
e.getMessage());
+ }
+ }
+
+ private Element getRecordElement(Document model) {
+ return model.getDocumentElement();
+ }
+
+ private Element getFieldElement(Document model, String fieldName) {
+ return (Element) model.getElementsByTagName(fieldName).item(0);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/template/csv/CSVToFreemarkerTemplateBuilderTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain