diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTable.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTable.java index dbb450c311d872077d1542c36331160fd9fd099a..2dd8dd38e62e2d22abf9506745e0ff4ca0b62fc8 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTable.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTable.java @@ -45,8 +45,8 @@ public class BTable extends BControl { protected void initAttributes() { initAttribute(new BAttributeForegroundColor( ColorConstants.black.getRGB())); - initAttribute(new BAttributeColumns(2)); - initAttribute(new BAttributeRows(2)); + initAttribute(new BAttributeColumns(1)); + initAttribute(new BAttributeRows(1)); getAttributes().get(AttributeConstants.ATTRIBUTE_SIZE).setShow(false); getAttributes().get(AttributeConstants.ATTRIBUTE_COORDINATES).setShow( false); 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 a63cb1b67e4402064143cab7c3ad85caf90d5717..436098c636d8af81b02a16c1cf1de95023f9c1e0 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 @@ -2,6 +2,7 @@ package de.bmotionstudio.gef.editor.observer; import de.bmotionstudio.gef.editor.Animation; 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.observer.wizard.WizardTableObserver; import de.bmotionstudio.gef.editor.util.BMSUtil; @@ -32,12 +33,16 @@ public class TableObserver extends Observer { // --------------------------------------------------------------- - Integer numberOfOldRows = Integer.valueOf(control - .getAttributeValue(AttributeConstants.ATTRIBUTE_ROWS) - .toString()); - Integer numberOfOldColumns = Integer.valueOf(control - .getAttributeValue(AttributeConstants.ATTRIBUTE_COLUMNS) - .toString()); + AbstractAttribute attributeRows = control + .getAttribute(AttributeConstants.ATTRIBUTE_ROWS); + Integer numberOfOldRows = Integer.valueOf(attributeRows + .getInitValue().toString()); + + AbstractAttribute attributeColumns = control + .getAttribute(AttributeConstants.ATTRIBUTE_COLUMNS); + Integer numberOfOldColumns = Integer.valueOf(attributeColumns + .getInitValue().toString()); + int numberOfNewRows = splitArray.length; // Set the correct number of rows diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardTableObserver.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardTableObserver.java index 9da7ff156f63ec99cbb0003adfd147ab40e0c84b..ab26245d43bbb3d7019759dc228ce859ecf8974d 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardTableObserver.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardTableObserver.java @@ -6,12 +6,16 @@ package de.bmotionstudio.gef.editor.observer.wizard; +import java.util.ArrayList; + import org.eclipse.core.databinding.DataBindingContext; import org.eclipse.core.databinding.beans.BeansObservables; import org.eclipse.jface.databinding.swt.SWTObservables; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.wizard.WizardPage; 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.FontData; import org.eclipse.swt.graphics.Point; @@ -20,8 +24,18 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.List; 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.observer.Observer; import de.bmotionstudio.gef.editor.observer.ObserverWizard; @@ -47,29 +61,87 @@ public class WizardTableObserver extends ObserverWizard { final DataBindingContext dbc = new DataBindingContext(); Composite container = new Composite(parent, SWT.NONE); - - container.setLayoutData(new GridData(GridData.FILL_BOTH)); 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:"); - txtPredicate = new Text(container, SWT.BORDER); + txtPredicate = new Text(conLeft, SWT.BORDER); txtPredicate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); txtPredicate.setFont(new Font(Display.getDefault(), new FontData( "Arial", 10, SWT.NONE))); - lb = new Label(container, SWT.NONE); + lb = new Label(conLeft, SWT.NONE); lb.setText("Expression:"); 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); 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); - setControl(container); + setControl(conLeft); }