Skip to content
Snippets Groups Projects
Commit 180e02d8 authored by Lukas Ladenberger's avatar Lukas Ladenberger
Browse files

better handling of columns in tables

parent d7cad032
Branches
Tags
No related merge requests found
Showing
with 39 additions and 25 deletions
de.bmotionstudio.gef.editor/icons/eclipse16/updated_co.gif

105 B

...@@ -25,6 +25,7 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry { ...@@ -25,6 +25,7 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry {
public static final String IMG_ICON_CONNECTION24 = "icon_connection24"; 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_NEW_WIZ = "icon_new_wiz";
public static final String IMG_ICON_DELETE_EDIT = "icon_delete_edit"; 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_JPG = "icon_jpg";
public static final String IMG_ICON_GIF = "icon_gif"; public static final String IMG_ICON_GIF = "icon_gif";
...@@ -66,6 +67,10 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry { ...@@ -66,6 +67,10 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry {
BMotionStudioImage.registerImage(IMG_ICON_DELETE_EDIT, BMotionStudioImage.registerImage(IMG_ICON_DELETE_EDIT,
"org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif"); "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, BMotionStudioImage.registerImage(IMG_ICON_JPG,
BMotionEditorPlugin.PLUGIN_ID, "icons/icon_jpg.gif"); BMotionEditorPlugin.PLUGIN_ID, "icons/icon_jpg.gif");
BMotionStudioImage.registerImage(IMG_ICON_GIF, BMotionStudioImage.registerImage(IMG_ICON_GIF,
......
...@@ -32,6 +32,7 @@ public class TableCellFigure extends AbstractTableFigure { ...@@ -32,6 +32,7 @@ public class TableCellFigure extends AbstractTableFigure {
Color foregroundColor = getForegroundColor(); Color foregroundColor = getForegroundColor();
if (foregroundColor != null) if (foregroundColor != null)
g.setForegroundColor(foregroundColor); g.setForegroundColor(foregroundColor);
// Bottom cell line
g.drawLine(r.x, r.y, r.x + r.width, r.y); g.drawLine(r.x, r.y, r.x + r.width, r.y);
} }
......
...@@ -9,6 +9,7 @@ public class TableColumnFigure extends AbstractTableFigure { ...@@ -9,6 +9,7 @@ public class TableColumnFigure extends AbstractTableFigure {
public TableColumnFigure() { public TableColumnFigure() {
ToolbarLayout toolbarLayout = new ToolbarLayout(); ToolbarLayout toolbarLayout = new ToolbarLayout();
toolbarLayout.setSpacing(0);
setLayoutManager(toolbarLayout); setLayoutManager(toolbarLayout);
setOpaque(true); setOpaque(true);
} }
...@@ -19,9 +20,12 @@ public class TableColumnFigure extends AbstractTableFigure { ...@@ -19,9 +20,12 @@ public class TableColumnFigure extends AbstractTableFigure {
Color foregroundColor = getForegroundColor(); Color foregroundColor = getForegroundColor();
if (foregroundColor != null) if (foregroundColor != null)
g.setForegroundColor(foregroundColor); 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.x + r.width, r.y);
g.drawLine(r.x, r.y + r.height - 1, r.x + r.width, r.y + r.height - 1); // 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); super.paintBorder(g);
} }
......
...@@ -24,8 +24,9 @@ public class TableFigure extends AbstractTableFigure { ...@@ -24,8 +24,9 @@ public class TableFigure extends AbstractTableFigure {
protected void paintBorder(Graphics g) { protected void paintBorder(Graphics g) {
Rectangle r = getClientArea(); Rectangle r = getClientArea();
g.setForegroundColor(getForegroundColor()); 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 g.drawLine(r.x + r.width - 1, r.y, r.x + r.width - 1, r.y + r.height
- 1); - 15);
super.paintBorder(g); super.paintBorder(g);
} }
......
package de.bmotionstudio.gef.editor.observer; package de.bmotionstudio.gef.editor.observer;
import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; 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.Animation;
import de.bmotionstudio.gef.editor.AttributeConstants; import de.bmotionstudio.gef.editor.AttributeConstants;
...@@ -21,10 +17,6 @@ public class TableObserver extends Observer { ...@@ -21,10 +17,6 @@ public class TableObserver extends Observer {
private String predicate; private String predicate;
public static List<String> split(String input, char tempReplacement) { public static List<String> split(String input, char tempReplacement) {
while (input.matches(".*\"[^\\{\\}]+,[^\\{\\}]+.*")) {
input = input.replaceAll("([^\\{\\}]+),([^\\{\\}]+)", "$1"
+ tempReplacement + "$2");
}
while (input.matches(".*\\{[^\\}]+,[^\\}]+\\}.*")) { while (input.matches(".*\\{[^\\}]+,[^\\}]+\\}.*")) {
input = input.replaceAll("(\\{[^\\}]+),([^\\}]+\\})", "$1" input = input.replaceAll("(\\{[^\\}]+),([^\\}]+\\})", "$1"
+ tempReplacement + "$2"); + tempReplacement + "$2");
...@@ -38,10 +30,6 @@ public class TableObserver extends Observer { ...@@ -38,10 +30,6 @@ public class TableObserver extends Observer {
} }
public static List<String> split2(String input, char tempReplacement) { public static List<String> split2(String input, char tempReplacement) {
while (input.matches(".*\"[^\\(\\)]+\\|->[^\\(\\)]+.*")) {
input = input.replaceAll("(\"[^\\(\\)]+)\\|->([^\\(\\)]+)", "$1"
+ tempReplacement + "$2");
}
while (input.matches(".*\\([^\\)]+\\|->[^\\)]+\\).*")) { while (input.matches(".*\\([^\\)]+\\|->[^\\)]+\\).*")) {
input = input.replaceAll("(\\([^\\)]+)\\|->([^\\)]+\\))", "$1" input = input.replaceAll("(\\([^\\)]+)\\|->([^\\)]+\\))", "$1"
+ tempReplacement + "$2"); + tempReplacement + "$2");
...@@ -135,12 +123,13 @@ public class TableObserver extends Observer { ...@@ -135,12 +123,13 @@ public class TableObserver extends Observer {
} }
private Iterable<MatchResult> findMatches(String pattern, CharSequence s) { // private Iterable<MatchResult> findMatches(String pattern, CharSequence s)
List<MatchResult> results = new ArrayList<MatchResult>(); // {
for (Matcher m = Pattern.compile(pattern).matcher(s); m.find();) // List<MatchResult> results = new ArrayList<MatchResult>();
results.add(m.toMatchResult()); // for (Matcher m = Pattern.compile(pattern).matcher(s); m.find();)
return results; // results.add(m.toMatchResult());
} // return results;
// }
public void setExpression(String expression) { public void setExpression(String expression) {
this.expression = expression; this.expression = expression;
......
...@@ -30,6 +30,7 @@ public class BTableCellPart extends AppAbstractEditPart { ...@@ -30,6 +30,7 @@ public class BTableCellPart extends AppAbstractEditPart {
installEditPolicy(EditPolicy.NODE_ROLE, new RenamePolicy()); installEditPolicy(EditPolicy.NODE_ROLE, new RenamePolicy());
} }
@Override @Override
protected void prepareRunPolicies() { protected void prepareRunPolicies() {
} }
......
...@@ -4,10 +4,13 @@ import java.beans.PropertyChangeEvent; ...@@ -4,10 +4,13 @@ import java.beans.PropertyChangeEvent;
import java.util.List; import java.util.List;
import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.gef.EditPolicy; import org.eclipse.gef.EditPolicy;
import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.RGB;
import de.bmotionstudio.gef.editor.AttributeConstants; 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.BMotionNodeEditPolicy;
import de.bmotionstudio.gef.editor.editpolicy.BMotionStudioFlowEditPolicy; import de.bmotionstudio.gef.editor.editpolicy.BMotionStudioFlowEditPolicy;
import de.bmotionstudio.gef.editor.figure.TableColumnFigure; import de.bmotionstudio.gef.editor.figure.TableColumnFigure;
...@@ -17,7 +20,15 @@ public class BTableColumnPart extends AppAbstractEditPart { ...@@ -17,7 +20,15 @@ public class BTableColumnPart extends AppAbstractEditPart {
@Override @Override
protected IFigure createEditFigure() { 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 @Override
......
...@@ -54,7 +54,9 @@ public class BTablePart extends AppAbstractEditPart { ...@@ -54,7 +54,9 @@ public class BTablePart extends AppAbstractEditPart {
figure.getParent().setConstraint( figure.getParent().setConstraint(
figure, figure,
new Rectangle(control.getLocation().x, control.getLocation().y, 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 { ...@@ -93,7 +95,7 @@ public class BTablePart extends AppAbstractEditPart {
BTableColumn bTableColumn = new BTableColumn( BTableColumn bTableColumn = new BTableColumn(
model.getVisualization()); model.getVisualization());
CreateCommand cmd = new CreateCommand(bTableColumn, model); CreateCommand cmd = new CreateCommand(bTableColumn, model);
cmd.setLayout(new Rectangle(0, 0, 50, 25)); // cmd.setLayout(new Rectangle(0, 0, 50, 40));
cmd.execute(); cmd.execute();
Integer numberOfRows = Integer.valueOf(model.getAttributeValue( Integer numberOfRows = Integer.valueOf(model.getAttributeValue(
AttributeConstants.ATTRIBUTE_ROWS).toString()); AttributeConstants.ATTRIBUTE_ROWS).toString());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment