Author: DartPeng
Date: 2009-08-31 06:08:46 -0400 (Mon, 31 Aug 2009)
New Revision: 17378
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/input_data_header.gif
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPaletteRootCreator.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/gef/tree/figures/TreeContainerFigure.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/editparts/InputDataContainerEditPart.java
Log:
JBIDE-4648
Change input data figure
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/input_data_header.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/full/obj16/input_data_header.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-08-31
09:59:47 UTC (rev 17377)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java 2009-08-31
10:08:46 UTC (rev 17378)
@@ -69,6 +69,9 @@
reg.put(GraphicsConstants.IMAGE_UNKNOWN_OBJ, imageDescriptorFromPlugin(PLUGIN_ID,
GraphicsConstants.IMAGE_UNKNOWN_OBJ));
+ reg.put(GraphicsConstants.IMAGE_INPUT_DATA_HEADER,
imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_INPUT_DATA_HEADER));
+
// regist ovr images
reg.put(GraphicsConstants.IMAGE_OVR_ERROR,
getImageDescriptor(GraphicsConstants.IMAGE_OVR_ERROR));
reg.put(GraphicsConstants.IMAGE_OVR_WARING,
getImageDescriptor(GraphicsConstants.IMAGE_OVR_WARING));
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-08-31
09:59:47 UTC (rev 17377)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java 2009-08-31
10:08:46 UTC (rev 17378)
@@ -22,6 +22,8 @@
public static final String IMAGE_JAVA_BEAN =
"icons/full/obj16/java_bean.png";
+ public static final String IMAGE_INPUT_DATA_HEADER =
"icons/full/obj16/input_data_header.gif";
+
public static final String IMAGE_JAVA_ARRAY =
"icons/full/obj16/javaarraymodel.gif";
public static final String IMAGE_CHECKBOX_CHECK =
"icons/full/obj16/checkbox_checked.gif";
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-08-31
09:59:47 UTC (rev 17377)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeContainerFigure.java 2009-08-31
10:08:46 UTC (rev 17378)
@@ -34,25 +34,23 @@
public TreeContainerFigure(TreeContainerModel model) {
super();
this.model = model;
+ this.addChildrenFigures();
+ }
+
+ protected void addChildrenFigures(){
headerFigure = new Figure() {
@Override
protected void paintFigure(Graphics graphics) {
super.paintFigure(graphics);
- graphics.pushState();
- graphics.setForegroundColor(headerColor);
- graphics.setBackgroundColor(ColorConstants.white);
- graphics.fillGradient(getBounds(), true);
- graphics.setForegroundColor(headerColor);
- graphics.drawLine(getBounds().getBottomLeft().translate(0, -1),
getBounds().getBottomRight().translate(
- 0, -1));
- graphics.popState();
+ drawHeaderFigure(graphics);
}
@Override
public Dimension getPreferredSize(int hint, int hint2) {
Dimension size = super.getPreferredSize(hint, hint2);
- return new Dimension(size.width, 25);
+ int width = Math.max(size.width, 100);
+ return new Dimension(width, 25);
}
};
label = new Label();
@@ -61,10 +59,8 @@
layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
headerFigure.setLayoutManager(layout);
headerFigure.setOpaque(true);
- headerFigure.setBackgroundColor(ColorConstants.blue);
contentFigure = new Figure();
- contentFigure.setBackgroundColor(ColorConstants.red);
contentFigure.setLayoutManager(new ToolbarLayout());
this.add(headerFigure);
this.add(contentFigure);
@@ -72,6 +68,17 @@
tl.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
this.setLayoutManager(tl);
}
+
+ protected void drawHeaderFigure(Graphics graphics) {
+ graphics.pushState();
+ graphics.setForegroundColor(headerColor);
+ graphics.setBackgroundColor(ColorConstants.white);
+ graphics.fillGradient(getBounds(), true);
+ graphics.setForegroundColor(headerColor);
+ graphics.drawLine(getBounds().getBottomLeft().translate(0, -1),
getBounds().getBottomRight().translate(0, -1));
+ graphics.popState();
+ }
+
/**
* @return the label
*/
@@ -139,8 +146,9 @@
graphics.fillRectangle(getBounds());
graphics.popState();
}
+
public void setIcon(Image i) {
- if(label != null){
+ if (label != null) {
label.setIcon(i);
}
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPaletteRootCreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPaletteRootCreator.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPaletteRootCreator.java 2009-08-31
10:08:46 UTC (rev 17378)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.graphical.editors;
+
+import org.eclipse.gef.palette.ConnectionCreationToolEntry;
+import org.eclipse.gef.palette.MarqueeToolEntry;
+import org.eclipse.gef.palette.PaletteDrawer;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.palette.SelectionToolEntry;
+import org.eclipse.gef.requests.CreationFactory;
+import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
+
+/**
+ * @author Dart dpeng(a)redhat.com
+ *
+ */
+public class SmooksGraphicalEditorPaletteRootCreator {
+ public PaletteRoot createPaletteRoot(){
+ PaletteRoot root= new PaletteRoot();
+ PaletteDrawer drawer = new PaletteDrawer("Tools");
+ drawer.add(new SelectionToolEntry());
+ drawer.add(new MarqueeToolEntry());
+ CreationFactory factory = new CreationFactory() {
+
+ public Object getObjectType() {
+ return TreeNodeConnection.class;
+ }
+
+ public Object getNewObject() {
+ return null;
+ }
+ };
+ drawer.add(new ConnectionCreationToolEntry("Link", "Link", factory,
null, null));
+ root.add(drawer);
+ return root;
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPaletteRootCreator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-08-31
09:59:47 UTC (rev 17377)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java 2009-08-31
10:08:46 UTC (rev 17378)
@@ -32,8 +32,9 @@
import org.eclipse.gef.commands.CommandStackEvent;
import org.eclipse.gef.commands.CommandStackEventListener;
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.GraphicalEditor;
+import org.eclipse.gef.ui.parts.GraphicalEditorWithPalette;
import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
@@ -81,7 +82,7 @@
* @author Dart
*
*/
-public class SmooksGraphicalEditorPart extends GraphicalEditor implements
ISelectionChangedListener,
+public class SmooksGraphicalEditorPart extends GraphicalEditorWithPalette implements
ISelectionChangedListener,
ISourceSynchronizeListener {
public static final int EXECUTE_COMMAND = 0;
@@ -781,4 +782,10 @@
public void sourceChange(Object model) {
initGraphicalModel();
}
+
+ @Override
+ protected PaletteRoot getPaletteRoot() {
+ SmooksGraphicalEditorPaletteRootCreator creator = new
SmooksGraphicalEditorPaletteRootCreator();
+ return creator.createPaletteRoot();
+ }
}
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-08-31
09:59:47 UTC (rev 17377)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java 2009-08-31
10:08:46 UTC (rev 17378)
@@ -12,12 +12,23 @@
import java.beans.PropertyChangeEvent;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
import org.jboss.tools.smooks.gef.tree.editparts.TreeContainerEditPart;
+import org.jboss.tools.smooks.gef.tree.figures.TreeContainerFigure;
+import org.jboss.tools.smooks.gef.tree.model.TreeContainerModel;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
/**
* @author Dart
- *
+ *
*/
public class InputDataContainerEditPart extends TreeContainerEditPart {
@@ -28,7 +39,134 @@
@Override
protected String generateFigureID() {
- return SmooksGraphUtil.generateFigureID((TreeNodeModel)getModel());
+ return SmooksGraphUtil.generateFigureID((TreeNodeModel) getModel());
}
-
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.gef.tree.editparts.TreeContainerEditPart#createFigure
+ * ()
+ */
+ @Override
+ protected IFigure createFigure() {
+
+ final int zwidth = 20;
+
+ IFigure figure = new TreeContainerFigure((TreeContainerModel) getModel()) {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.gef.tree.figures.TreeContainerFigure#
+ * addChildrenFigures()
+ */
+ @Override
+ protected void addChildrenFigures() {
+ IFigure headerFigure1 = new Figure() {
+
+ @Override
+ protected void paintFigure(Graphics graphics) {
+ super.paintFigure(graphics);
+ }
+
+ @Override
+ public Dimension getPreferredSize(int hint, int hint2) {
+ Dimension size = super.getPreferredSize(hint, hint2);
+ int width = Math.max(size.width, 100);
+ return new Dimension(width, 25);
+ }
+ };
+ this.add(headerFigure1);
+ super.addChildrenFigures();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.gef.tree.figures.TreeContainerFigure#
+ * drawHeaderFigure(org.eclipse.draw2d.Graphics)
+ */
+ @Override
+ protected void drawHeaderFigure(Graphics graphics) {
+ // TODO Auto-generated method stub
+ // super.drawHeaderFigure(graphics);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.gef.tree.figures.TreeContainerFigure#
+ * paintBorder(org.eclipse.draw2d.Graphics)
+ */
+ @Override
+ protected void paintBorder(Graphics graphics) {
+ // super.paintBorder(graphics);
+ graphics.setForegroundColor(ColorConstants.black);
+
+ Point p2 = new Point();
+ p2.setLocation(getBounds().getTopLeft().x, getBounds().getTopLeft().y);
+
+ Point p1 = new Point();
+ p1.setLocation(getBounds().getTopRight().x - zwidth, getBounds().getTopRight().y);
+
+ graphics.drawLine(p1, p2);
+
+ Point p3 = new Point();
+ p3.setLocation(getBounds().getBottomLeft().x, getBounds().getBottomLeft().y - 1);
+ graphics.drawLine(p2, p3);
+
+ Point p4 = new Point();
+ p4.setLocation(getBounds().getBottomRight().x - 1, getBounds().getBottomRight().y -
1);
+ graphics.drawLine(p4, p3);
+
+ Point p5 = new Point();
+ p5.setLocation(getBounds().getTopRight().x - 1, getBounds().getTopRight().y +
zwidth);
+ graphics.drawLine(p4, p5);
+
+ graphics.drawLine(p1, p5);
+
+ Point p6 = new Point();
+ p6.setLocation(p1.x, p5.y);
+ graphics.drawLine(p5, p6);
+ graphics.drawLine(p1, p6);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.gef.tree.figures.TreeContainerFigure#
+ * paintFigure(org.eclipse.draw2d.Graphics)
+ */
+ @Override
+ protected void paintFigure(Graphics graphics) {
+
+ super.paintFigure(graphics);
+
+ }
+
+ };
+ return figure;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.gef.tree.editparts.TreeContainerEditPart#
+ * refreshVisuals()
+ */
+ @Override
+ protected void refreshVisuals() {
+ TreeContainerFigure figure = (TreeContainerFigure) getFigure();
+ // if(i != null){
+ // figure.setIcon(i);
+ // }
+ figure.getLabel().setTextAlignment(Label.LEFT);
+ figure.setText("Input Data");
+ figure.setIcon(SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_INPUT_DATA_HEADER));
+ super.refreshVisuals();
+ }
+
}