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

working on table control + observer

parent da4c5bd7
No related branches found
No related tags found
No related merge requests found
...@@ -45,8 +45,8 @@ public class BTable extends BControl { ...@@ -45,8 +45,8 @@ public class BTable extends BControl {
protected void initAttributes() { protected void initAttributes() {
initAttribute(new BAttributeForegroundColor( initAttribute(new BAttributeForegroundColor(
ColorConstants.black.getRGB())); ColorConstants.black.getRGB()));
initAttribute(new BAttributeColumns(2)); initAttribute(new BAttributeColumns(1));
initAttribute(new BAttributeRows(2)); initAttribute(new BAttributeRows(1));
getAttributes().get(AttributeConstants.ATTRIBUTE_SIZE).setShow(false); getAttributes().get(AttributeConstants.ATTRIBUTE_SIZE).setShow(false);
getAttributes().get(AttributeConstants.ATTRIBUTE_COORDINATES).setShow( getAttributes().get(AttributeConstants.ATTRIBUTE_COORDINATES).setShow(
false); false);
......
...@@ -2,6 +2,7 @@ package de.bmotionstudio.gef.editor.observer; ...@@ -2,6 +2,7 @@ package de.bmotionstudio.gef.editor.observer;
import de.bmotionstudio.gef.editor.Animation; import de.bmotionstudio.gef.editor.Animation;
import de.bmotionstudio.gef.editor.AttributeConstants; import de.bmotionstudio.gef.editor.AttributeConstants;
import de.bmotionstudio.gef.editor.attribute.AbstractAttribute;
import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.observer.wizard.WizardTableObserver; import de.bmotionstudio.gef.editor.observer.wizard.WizardTableObserver;
import de.bmotionstudio.gef.editor.util.BMSUtil; import de.bmotionstudio.gef.editor.util.BMSUtil;
...@@ -32,12 +33,16 @@ public class TableObserver extends Observer { ...@@ -32,12 +33,16 @@ public class TableObserver extends Observer {
// --------------------------------------------------------------- // ---------------------------------------------------------------
Integer numberOfOldRows = Integer.valueOf(control AbstractAttribute attributeRows = control
.getAttributeValue(AttributeConstants.ATTRIBUTE_ROWS) .getAttribute(AttributeConstants.ATTRIBUTE_ROWS);
.toString()); Integer numberOfOldRows = Integer.valueOf(attributeRows
Integer numberOfOldColumns = Integer.valueOf(control .getInitValue().toString());
.getAttributeValue(AttributeConstants.ATTRIBUTE_COLUMNS)
.toString()); AbstractAttribute attributeColumns = control
.getAttribute(AttributeConstants.ATTRIBUTE_COLUMNS);
Integer numberOfOldColumns = Integer.valueOf(attributeColumns
.getInitValue().toString());
int numberOfNewRows = splitArray.length; int numberOfNewRows = splitArray.length;
// Set the correct number of rows // Set the correct number of rows
......
...@@ -6,12 +6,16 @@ ...@@ -6,12 +6,16 @@
package de.bmotionstudio.gef.editor.observer.wizard; package de.bmotionstudio.gef.editor.observer.wizard;
import java.util.ArrayList;
import org.eclipse.core.databinding.DataBindingContext; import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeansObservables; import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.jface.databinding.swt.SWTObservables; import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.WizardPage; import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
...@@ -20,8 +24,18 @@ import org.eclipse.swt.layout.GridLayout; ...@@ -20,8 +24,18 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
import org.eventb.core.ISCConstant;
import org.eventb.core.ISCInternalContext;
import org.eventb.core.ISCMachineRoot;
import org.eventb.core.ISCVariable;
import org.eventb.core.ast.FormulaFactory;
import org.eventb.core.ast.PowerSetType;
import org.eventb.core.ast.Type;
import org.rodinp.core.RodinDBException;
import de.bmotionstudio.gef.editor.eventb.EventBHelper;
import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.observer.Observer; import de.bmotionstudio.gef.editor.observer.Observer;
import de.bmotionstudio.gef.editor.observer.ObserverWizard; import de.bmotionstudio.gef.editor.observer.ObserverWizard;
...@@ -47,29 +61,87 @@ public class WizardTableObserver extends ObserverWizard { ...@@ -47,29 +61,87 @@ public class WizardTableObserver extends ObserverWizard {
final DataBindingContext dbc = new DataBindingContext(); final DataBindingContext dbc = new DataBindingContext();
Composite container = new Composite(parent, SWT.NONE); Composite container = new Composite(parent, SWT.NONE);
container.setLayoutData(new GridData(GridData.FILL_BOTH));
container.setLayout(new GridLayout(2, false)); container.setLayout(new GridLayout(2, false));
Label lb = new Label(container, SWT.NONE); Composite conLeft = new Composite(container, SWT.NONE);
conLeft.setLayoutData(new GridData(GridData.FILL_BOTH));
conLeft.setLayout(new GridLayout(2, false));
Label lb = new Label(conLeft, SWT.NONE);
lb.setText("Predicate:"); lb.setText("Predicate:");
txtPredicate = new Text(container, SWT.BORDER); txtPredicate = new Text(conLeft, SWT.BORDER);
txtPredicate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); txtPredicate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
txtPredicate.setFont(new Font(Display.getDefault(), new FontData( txtPredicate.setFont(new Font(Display.getDefault(), new FontData(
"Arial", 10, SWT.NONE))); "Arial", 10, SWT.NONE)));
lb = new Label(container, SWT.NONE); lb = new Label(conLeft, SWT.NONE);
lb.setText("Expression:"); lb.setText("Expression:");
lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
txtExpression = new Text(container, SWT.BORDER | SWT.MULTI txtExpression = new Text(conLeft, SWT.BORDER | SWT.MULTI
| SWT.WRAP); | SWT.WRAP);
txtExpression.setLayoutData(new GridData(GridData.FILL_BOTH)); txtExpression.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite conRight = new Composite(container, SWT.NONE);
conRight.setLayoutData(new GridData(GridData.FILL_BOTH));
conRight.setLayout(new GridLayout(1, false));
lb = new Label(conRight, SWT.NONE);
lb.setText("List of available power sets:");
lb.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
ArrayList<String> relationList = new ArrayList<String>();
try {
ISCMachineRoot machineRoot = EventBHelper.getCorrespondingFile(
getBControl().getVisualization().getProjectFile(),
getBControl().getVisualization().getMachineName());
ISCVariable[] scVariables;
scVariables = machineRoot.getSCVariables();
for (ISCVariable var : scVariables) {
Type type = var.getType(FormulaFactory.getDefault());
if (type instanceof PowerSetType) {
relationList.add(var.getElementName());
}
}
ISCInternalContext[] scSeenContexts = machineRoot
.getSCSeenContexts();
for (ISCInternalContext ctx : scSeenContexts) {
ISCConstant[] scConstants = ctx.getSCConstants();
for (ISCConstant constant : scConstants) {
Type type = constant.getType(FormulaFactory
.getDefault());
if (type instanceof PowerSetType) {
relationList.add(constant.getElementName());
}
}
}
} catch (RodinDBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
final List list = new List(conRight, SWT.SINGLE | SWT.BORDER);
list.setLayoutData(new GridData(GridData.FILL_BOTH));
list.setItems(relationList.toArray(new String[relationList.size()]));
list.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent e) {
String[] selection = list.getSelection();
if (selection.length > 0)
txtExpression.setText(txtExpression.getText() + " "
+ selection[0]);
}
});
initBindings(dbc); initBindings(dbc);
setControl(container); setControl(conLeft);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment