From 180e02d8e3ada0ff0c91db3a422737059bca4a94 Mon Sep 17 00:00:00 2001 From: Lukas Ladenberger <lukas.ladenberger@googlemail.com> Date: Wed, 22 Aug 2012 10:43:09 +0200 Subject: [PATCH] better handling of columns in tables --- .../icons/eclipse16/updated_co.gif | Bin 0 -> 105 bytes .../gef/editor/EditorImageRegistry.java | 5 ++++ .../gef/editor/figure/TableCellFigure.java | 1 + .../gef/editor/figure/TableColumnFigure.java | 10 ++++--- .../gef/editor/figure/TableFigure.java | 3 ++- .../gef/editor/observer/TableObserver.java | 25 +++++------------- .../gef/editor/part/BTableCellPart.java | 1 + .../gef/editor/part/BTableColumnPart.java | 13 ++++++++- .../gef/editor/part/BTablePart.java | 6 +++-- 9 files changed, 39 insertions(+), 25 deletions(-) create mode 100644 de.bmotionstudio.gef.editor/icons/eclipse16/updated_co.gif diff --git a/de.bmotionstudio.gef.editor/icons/eclipse16/updated_co.gif b/de.bmotionstudio.gef.editor/icons/eclipse16/updated_co.gif new file mode 100644 index 0000000000000000000000000000000000000000..0d686ab4593b4242cc91a9e79bbbd4bf177f1d69 GIT binary patch literal 105 zcmZ?wbhEHbWM|-D*v!Ddz@M*Iw9=tvt$phnht{=G3pSPQ+cDwRzW-prfB_VLvM@3* oa5CtCWI$#xu!tF`vP_tx5TbM9M##p*V;-_<tr3?_xiMG+0LUaCG5`Po literal 0 HcmV?d00001 diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/EditorImageRegistry.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/EditorImageRegistry.java index 907bae7f..16392c44 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/EditorImageRegistry.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/EditorImageRegistry.java @@ -25,6 +25,7 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry { public static final String IMG_ICON_CONNECTION24 = "icon_connection24"; public static final String IMG_ICON_NEW_WIZ = "icon_new_wiz"; public static final String IMG_ICON_DELETE_EDIT = "icon_delete_edit"; + public static final String IMG_ICON_TR_UP = "icon_tr_up"; public static final String IMG_ICON_JPG = "icon_jpg"; public static final String IMG_ICON_GIF = "icon_gif"; @@ -66,6 +67,10 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry { BMotionStudioImage.registerImage(IMG_ICON_DELETE_EDIT, "org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif"); + BMotionStudioImage + .registerImage(IMG_ICON_TR_UP, BMotionEditorPlugin.PLUGIN_ID, + "icons/eclipse16/updated_co.gif"); + BMotionStudioImage.registerImage(IMG_ICON_JPG, BMotionEditorPlugin.PLUGIN_ID, "icons/icon_jpg.gif"); BMotionStudioImage.registerImage(IMG_ICON_GIF, diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TableCellFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TableCellFigure.java index 09fa6fa8..c9cf14e5 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TableCellFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TableCellFigure.java @@ -32,6 +32,7 @@ public class TableCellFigure extends AbstractTableFigure { Color foregroundColor = getForegroundColor(); if (foregroundColor != null) g.setForegroundColor(foregroundColor); + // Bottom cell line g.drawLine(r.x, r.y, r.x + r.width, r.y); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TableColumnFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TableColumnFigure.java index e036e5d6..cec191ca 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TableColumnFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TableColumnFigure.java @@ -9,6 +9,7 @@ public class TableColumnFigure extends AbstractTableFigure { public TableColumnFigure() { ToolbarLayout toolbarLayout = new ToolbarLayout(); + toolbarLayout.setSpacing(0); setLayoutManager(toolbarLayout); setOpaque(true); } @@ -19,9 +20,12 @@ public class TableColumnFigure extends AbstractTableFigure { Color foregroundColor = getForegroundColor(); if (foregroundColor != null) g.setForegroundColor(foregroundColor); - g.drawLine(r.x, r.y, r.x + r.width, r.y); - g.drawLine(r.x, r.y, r.x, r.y + r.height - 1); - g.drawLine(r.x, r.y + r.height - 1, r.x + r.width, r.y + r.height - 1); + + // g.drawLine(r.x, r.y, r.x + r.width, r.y); + // Left line + g.drawLine(r.x, r.y, r.x, r.y + r.height - 15); + // Bottom line + g.drawLine(r.x, r.y + r.height - 15, r.x + r.width, r.y + r.height - 15); super.paintBorder(g); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TableFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TableFigure.java index fb322781..5a1b14a3 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TableFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TableFigure.java @@ -24,8 +24,9 @@ public class TableFigure extends AbstractTableFigure { protected void paintBorder(Graphics g) { Rectangle r = getClientArea(); g.setForegroundColor(getForegroundColor()); + // Right table border line g.drawLine(r.x + r.width - 1, r.y, r.x + r.width - 1, r.y + r.height - - 1); + - 15); super.paintBorder(g); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/TableObserver.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/TableObserver.java index 5377db99..cee21033 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/TableObserver.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/TableObserver.java @@ -1,11 +1,7 @@ package de.bmotionstudio.gef.editor.observer; -import java.util.ArrayList; import java.util.LinkedList; import java.util.List; -import java.util.regex.MatchResult; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import de.bmotionstudio.gef.editor.Animation; import de.bmotionstudio.gef.editor.AttributeConstants; @@ -21,10 +17,6 @@ public class TableObserver extends Observer { private String predicate; public static List<String> split(String input, char tempReplacement) { - while (input.matches(".*\"[^\\{\\}]+,[^\\{\\}]+.*")) { - input = input.replaceAll("([^\\{\\}]+),([^\\{\\}]+)", "$1" - + tempReplacement + "$2"); - } while (input.matches(".*\\{[^\\}]+,[^\\}]+\\}.*")) { input = input.replaceAll("(\\{[^\\}]+),([^\\}]+\\})", "$1" + tempReplacement + "$2"); @@ -38,10 +30,6 @@ public class TableObserver extends Observer { } public static List<String> split2(String input, char tempReplacement) { - while (input.matches(".*\"[^\\(\\)]+\\|->[^\\(\\)]+.*")) { - input = input.replaceAll("(\"[^\\(\\)]+)\\|->([^\\(\\)]+)", "$1" - + tempReplacement + "$2"); - } while (input.matches(".*\\([^\\)]+\\|->[^\\)]+\\).*")) { input = input.replaceAll("(\\([^\\)]+)\\|->([^\\)]+\\))", "$1" + tempReplacement + "$2"); @@ -135,12 +123,13 @@ public class TableObserver extends Observer { } - private Iterable<MatchResult> findMatches(String pattern, CharSequence s) { - List<MatchResult> results = new ArrayList<MatchResult>(); - for (Matcher m = Pattern.compile(pattern).matcher(s); m.find();) - results.add(m.toMatchResult()); - return results; - } + // private Iterable<MatchResult> findMatches(String pattern, CharSequence s) + // { + // List<MatchResult> results = new ArrayList<MatchResult>(); + // for (Matcher m = Pattern.compile(pattern).matcher(s); m.find();) + // results.add(m.toMatchResult()); + // return results; + // } public void setExpression(String expression) { this.expression = expression; diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTableCellPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTableCellPart.java index b82098ac..8c7907cd 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTableCellPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTableCellPart.java @@ -30,6 +30,7 @@ public class BTableCellPart extends AppAbstractEditPart { installEditPolicy(EditPolicy.NODE_ROLE, new RenamePolicy()); } + @Override protected void prepareRunPolicies() { } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTableColumnPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTableColumnPart.java index 598b8feb..0955e8bc 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTableColumnPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTableColumnPart.java @@ -4,10 +4,13 @@ import java.beans.PropertyChangeEvent; import java.util.List; import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Label; import org.eclipse.gef.EditPolicy; import org.eclipse.swt.graphics.RGB; import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; import de.bmotionstudio.gef.editor.editpolicy.BMotionNodeEditPolicy; import de.bmotionstudio.gef.editor.editpolicy.BMotionStudioFlowEditPolicy; import de.bmotionstudio.gef.editor.figure.TableColumnFigure; @@ -17,7 +20,15 @@ public class BTableColumnPart extends AppAbstractEditPart { @Override protected IFigure createEditFigure() { - return new TableColumnFigure(); + TableColumnFigure tableColumnFigure = new TableColumnFigure(); + Label figure = new Label(); + figure.setOpaque(true); + tableColumnFigure.add(figure); + if (!isRunning()) { + figure.setIcon(BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_TR_UP)); + } + return tableColumnFigure; } @Override diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTablePart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTablePart.java index f879d719..c1042055 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTablePart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTablePart.java @@ -54,7 +54,9 @@ public class BTablePart extends AppAbstractEditPart { figure.getParent().setConstraint( figure, new Rectangle(control.getLocation().x, control.getLocation().y, - width + 1, (rows * 20) + 1)); + width + 1, (rows * 20) + 15)); + + // super.refreshEditLayout(figure, control); } @@ -93,7 +95,7 @@ public class BTablePart extends AppAbstractEditPart { BTableColumn bTableColumn = new BTableColumn( model.getVisualization()); CreateCommand cmd = new CreateCommand(bTableColumn, model); - cmd.setLayout(new Rectangle(0, 0, 50, 25)); + // cmd.setLayout(new Rectangle(0, 0, 50, 40)); cmd.execute(); Integer numberOfRows = Integer.valueOf(model.getAttributeValue( AttributeConstants.ATTRIBUTE_ROWS).toString()); -- GitLab