Commit c45841d1 authored by Johannes Eder's avatar Johannes Eder
Browse files

gui of reworked synthesis view base

parent f6bb14f9
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
| |
| Copyright 2016 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.generic;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.fortiss.af3.deployment.ui.editor.INamedColumnLabelProvider;
import org.fortiss.af3.exploration.model.ExplorationConstraint;
import org.fortiss.af3.exploration.model.ExplorationObjective;
import org.fortiss.af3.exploration.model.ExplorationTarget;
import org.fortiss.af3.exploration.projectmodel.DSE;
import org.fortiss.af3.exploration.projectmodel.RuleSet;
import org.fortiss.af3.exploration.ui.perspective.IDSEPerspectiveManager;
import org.fortiss.af3.exploration.ui.perspective.synthesis.subsetwizards.ConstraintSetWizardContentProvider;
import org.fortiss.af3.exploration.ui.perspective.synthesis.subsetwizards.ConstraintWizardLabelProvider;
import org.fortiss.af3.exploration.ui.perspective.synthesis.subsetwizards.ObjectiveSetWizardContentProvider;
/**
* New base class for synthesis views.
*
* @author eder
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: 741F6128FFFC440B5296E8F4D776B4C5
*/
public abstract class SynthesisViewBase2 extends DSEPerspectiveViewBase {
/** The gui composite. */
private SynthesisViewBase2Composite synthesisComposite;
/** {@inheritDoc} */
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
setHeaderText("DSE Synthesis Base View");
List<RuleSet> ruleSets =
IDSEPerspectiveManager.INSTANCE.getExplorationSpecificationSubSets();
Composite composite = getEditableAreaComposite();
synthesisComposite = new SynthesisViewBase2Composite(composite, SWT.NONE);
synthesisComposite.setLayout(new GridLayout(2, false));
synthesisComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
synthesisComposite.objectiveSetsTable.setContentProvider(new ArrayContentProvider());
synthesisComposite.objectiveSetsColumn.setLabelProvider(new INamedColumnLabelProvider() {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
return ((RuleSet)element).getName();
}
});
synthesisComposite.objectiveSetsAuthorColumn
.setLabelProvider(new INamedColumnLabelProvider() {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
return ((RuleSet)element).getAuthor();
}
});
synthesisComposite.objectiveSetsCommentColumn
.setLabelProvider(new INamedColumnLabelProvider() {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
return ((RuleSet)element).getComment();
}
});
synthesisComposite.objectiveSetsDateColumn
.setLabelProvider(new INamedColumnLabelProvider() {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
return ((RuleSet)element).getDate().toString();
}
});
List<RuleSet> objectives =
ruleSets.stream()
.filter(s -> s.getExplorationTargets().stream()
.anyMatch(t -> t instanceof ExplorationObjective))
.collect(Collectors.toList());
synthesisComposite.objectiveSetsTable.setInput(objectives);
synthesisComposite.constraintSetsTable.setContentProvider(new ArrayContentProvider());
synthesisComposite.constraintSetsColumn.setLabelProvider(new INamedColumnLabelProvider() {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
return ((RuleSet)element).getName();
}
});
synthesisComposite.constraintSetsAuthorColumn
.setLabelProvider(new INamedColumnLabelProvider() {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
return ((RuleSet)element).getAuthor();
}
});
synthesisComposite.constraintSetsCommentColumn
.setLabelProvider(new INamedColumnLabelProvider() {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
return ((RuleSet)element).getComment();
}
});
synthesisComposite.constraintSetsDateColumn
.setLabelProvider(new INamedColumnLabelProvider() {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
return ((RuleSet)element).getDate().toString();
}
});
List<RuleSet> constraints =
ruleSets.stream()
.filter(s -> s.getExplorationTargets().stream()
.anyMatch(t -> t instanceof ExplorationConstraint))
.collect(Collectors.toList());
synthesisComposite.constraintSetsTable.setInput(constraints);
synthesisComposite.constraintsTree
.setContentProvider(new ConstraintSetWizardContentProvider());
synthesisComposite.constraintsTree.setLabelProvider(new ConstraintWizardLabelProvider());
DSE dse = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
synthesisComposite.constraintsTree.setInput(dse);
synthesisComposite.objectivesTree
.setContentProvider(new ObjectiveSetWizardContentProvider());
synthesisComposite.objectivesTree.setLabelProvider(new ConstraintWizardLabelProvider());
synthesisComposite.objectivesTree.setInput(dse);
synthesisComposite.explorationTimeoutText.addVerifyListener(new TimeoutVerifyListener());
synthesisComposite.validityTimeoutText.addVerifyListener(new TimeoutVerifyListener());
synthesisComposite.explorationTimeoutText.addKeyListener(new TimeoutKeyListener());
}
/** Listener verifying the text in the timeout text field. */
private class TimeoutVerifyListener implements VerifyListener {
/** {@inheritDoc} */
@Override
public void verifyText(VerifyEvent e) {
if(e.character == '\b') {
return;
}
try {
Integer.parseInt(e.character + "");
} catch(NumberFormatException ex) {
e.doit = false;
}
}
}
/** Key Listener for timeout text fields. */
private class TimeoutKeyListener implements KeyListener {
/** {@inheritDoc} */
@Override
public void keyReleased(KeyEvent e) {
updateTotalTimeout();
}
/** {@inheritDoc} */
@Override
public void keyPressed(KeyEvent e) {
updateTotalTimeout();
}
}
/** Update the total timeout label. */
protected void updateTotalTimeout() {
List<RuleSet> subsets = IDSEPerspectiveManager.INSTANCE.getLatestCheckedSubsets();
if(subsets == null)
return;
int numberOfObjectives = 0;
for(RuleSet rs : subsets) {
List<ExplorationTarget<?>> collect =
rs.getExplorationTargets().stream()
.filter(e -> e instanceof ExplorationObjective<?>)
.collect(Collectors.toList());
numberOfObjectives += collect.size();
}
int userTimeout = 0;
try {
String text = synthesisComposite.explorationTimeoutText.getText();
userTimeout = Integer.parseInt(text.trim());
} catch(NumberFormatException ex) {
// do nothing
@SuppressWarnings("unused") boolean vincent = true;
}
if(numberOfObjectives == 0) {
synthesisComposite.explorationTimeoutText.setText("");
return;
}
synthesisComposite.explorationTimeoutText.setText("x " + numberOfObjectives +
" Objectives => Total timeout of " + (userTimeout * numberOfObjectives) + "s");
}
/** {@inheritDoc} */
@Override
public void propertyChanged(Object source, int propId) {
if(propId == IDSEPerspectiveManager.UNSAT_CORES_ADDED) {
synthesisComposite.constraintsTree.refresh();
}
updateTotalTimeout();
}
}
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
| |
| Copyright 2017 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.generic;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
/**
* GUI of new Synthesis view
*
* @author eder
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: 20AEBBA24164F0CED92BB919923A6BF5
*/
@SuppressWarnings("javadoc")
public class SynthesisViewBase2Composite extends Composite {
public Text validityTimeoutText;
public Text explorationTimeoutText;
private Table table;
private Table table_1;
public CheckboxTableViewer constraintSetsTable;
public CheckboxTableViewer objectiveSetsTable;
public CheckboxTreeViewer constraintsTree;
public CheckboxTreeViewer objectivesTree;
public TableViewerColumn constraintSetsColumn;
public TableViewerColumn constraintSetsDateColumn;
public TableViewerColumn constraintSetsAuthorColumn;
public TableViewerColumn constraintSetsCommentColumn;
public TableViewerColumn objectiveSetsColumn;
public TableViewerColumn objectiveSetsDateColumn;
public TableViewerColumn objectiveSetsAuthorColumn;
public TableViewerColumn objectiveSetsCommentColumn;
/**
* Create the composite.
*
* @param parent
* @param style
*/
public SynthesisViewBase2Composite(Composite parent, int style) {
super(parent, style);
setLayout(new GridLayout(2, false));
Composite composite = new Composite(this, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
composite.setLayout(new GridLayout(1, false));
Composite composite_5 = new Composite(composite, SWT.NONE);
composite_5.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
composite_5.setLayout(new GridLayout(1, true));
Label lblDesignSpace = new Label(composite_5, SWT.NONE);
lblDesignSpace.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
lblDesignSpace.setText("DESIGN SPACE");
SashForm sashForm = new SashForm(composite, SWT.VERTICAL);
sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
Composite composite_3 = new Composite(sashForm, SWT.NONE);
composite_3.setLayout(new GridLayout(2, true));
Label lblDseConstraintSet = new Label(composite_3, SWT.NONE);
lblDseConstraintSet.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
lblDseConstraintSet.setText("DSE Constraint Sets");
Label lblDseObjectiveSets = new Label(composite_3, SWT.NONE);
lblDseObjectiveSets.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
lblDseObjectiveSets.setText("DSE Objective Sets");
constraintSetsTable =
CheckboxTableViewer.newCheckList(composite_3, SWT.BORDER | SWT.FULL_SELECTION);
table = constraintSetsTable.getTable();
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
table.setLinesVisible(true);
table.setHeaderVisible(true);
constraintSetsColumn = new TableViewerColumn(constraintSetsTable, SWT.NONE);
TableColumn tblclmnConstraintSet = constraintSetsColumn.getColumn();
tblclmnConstraintSet.setWidth(100);
tblclmnConstraintSet.setText("Constraint Set");
constraintSetsDateColumn = new TableViewerColumn(constraintSetsTable, SWT.NONE);
TableColumn tblclmnDate = constraintSetsDateColumn.getColumn();
tblclmnDate.setWidth(100);
tblclmnDate.setText("Date");
constraintSetsAuthorColumn = new TableViewerColumn(constraintSetsTable, SWT.NONE);
TableColumn tblclmnAuthor = constraintSetsAuthorColumn.getColumn();
tblclmnAuthor.setWidth(100);
tblclmnAuthor.setText("Author");
constraintSetsCommentColumn = new TableViewerColumn(constraintSetsTable, SWT.NONE);
TableColumn tblclmnComment = constraintSetsCommentColumn.getColumn();
tblclmnComment.setWidth(100);
tblclmnComment.setText("Comment");
objectiveSetsTable =
CheckboxTableViewer.newCheckList(composite_3, SWT.BORDER | SWT.FULL_SELECTION);
table_1 = objectiveSetsTable.getTable();
table_1.setLinesVisible(true);
table_1.setHeaderVisible(true);
table_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
objectiveSetsColumn = new TableViewerColumn(objectiveSetsTable, SWT.NONE);
TableColumn tblclmnObjectiveSet = objectiveSetsColumn.getColumn();
tblclmnObjectiveSet.setWidth(100);
tblclmnObjectiveSet.setText("Objective Set");
objectiveSetsDateColumn = new TableViewerColumn(objectiveSetsTable, SWT.NONE);
TableColumn tblclmnObjectiveDate = objectiveSetsDateColumn.getColumn();
tblclmnObjectiveDate.setWidth(100);
tblclmnObjectiveDate.setText("Date");
objectiveSetsAuthorColumn = new TableViewerColumn(objectiveSetsTable, SWT.NONE);
TableColumn tblclmnObjectiveAuthor = objectiveSetsAuthorColumn.getColumn();
tblclmnObjectiveAuthor.setWidth(100);
tblclmnObjectiveAuthor.setText("Author");
objectiveSetsCommentColumn = new TableViewerColumn(objectiveSetsTable, SWT.NONE);
TableColumn tblclmnObjectiveComment = objectiveSetsCommentColumn.getColumn();
tblclmnObjectiveAuthor.setWidth(100);
tblclmnObjectiveAuthor.setText("Comment");
Composite composite_4 = new Composite(sashForm, SWT.NONE);
composite_4.setLayout(new GridLayout(2, true));
Button btnNewSet = new Button(composite_4, SWT.NONE);
btnNewSet.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnNewSet.setText("New Set");
Button btnEditSet = new Button(composite_4, SWT.NONE);
btnEditSet.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnEditSet.setText("Edit Set / Save Changes");
Label lblConstraints = new Label(composite_4, SWT.NONE);
lblConstraints.setText("Constraints");
Label lblObjectives = new Label(composite_4, SWT.NONE);
lblObjectives.setText("Objectives");
constraintsTree = new CheckboxTreeViewer(composite_4, SWT.BORDER);
Tree tree = constraintsTree.getTree();
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
objectivesTree = new CheckboxTreeViewer(composite_4, SWT.BORDER);
Tree tree_1 = objectivesTree.getTree();
tree_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
sashForm.setWeights(new int[] {1, 1});
Composite composite_1 = new Composite(this, SWT.NONE);
composite_1.setLayout(new GridLayout(1, false));
composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
Composite composite_6 = new Composite(composite_1, SWT.NONE);
composite_6.setLayout(new GridLayout(1, false));
composite_6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Label lblExploration = new Label(composite_6, SWT.NONE);
lblExploration.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
lblExploration.setText("EXPLORATION");
Composite composite_7 = new Composite(composite_1, SWT.NONE);
composite_7.setLayout(new GridLayout(1, false));
composite_7.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
Label lblCheckYourDesign = new Label(composite_7, SWT.NONE);
lblCheckYourDesign.setText("Check your Design Space");
Composite composite_9 = new Composite(composite_7, SWT.NONE);
composite_9.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
composite_9.setLayout(new GridLayout(1, false));
Label lblTimeout = new Label(composite_9, SWT.NONE);
lblTimeout.setText("Timeout [s]:");
validityTimeoutText = new Text(composite_9, SWT.BORDER);
validityTimeoutText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
validityTimeoutText.setText("20");
Button btnCheckValidity = new Button(composite_7, SWT.NONE);
btnCheckValidity.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnCheckValidity.setText("Check Validity");
Composite composite_8 = new Composite(composite_1, SWT.NONE);
composite_8.setLayout(new GridLayout(1, false));
composite_8.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
Label lblDeploymentSynthesis = new Label(composite_8, SWT.NONE);
lblDeploymentSynthesis.setText("Deployment Exploration");
Composite composite_10 = new Composite(composite_8, SWT.NONE);
composite_10.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
composite_10.setLayout(new GridLayout(1, false));
Label lblTimeoutPerObjective = new Label(composite_10, SWT.NONE);
lblTimeoutPerObjective.setText("Timeout per Objective [s]:");
explorationTimeoutText = new Text(composite_10, SWT.BORDER);
explorationTimeoutText.setText("20");
explorationTimeoutText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Label lblTotalRunTime = new Label(composite_10, SWT.NONE);
lblTotalRunTime.setText("TOTAL Run Time:");
Label lbls = new Label(composite_10, SWT.NONE);
lbls.setText("40s");
Button btnExploreDesignSpace = new Button(composite_8, SWT.NONE);
btnExploreDesignSpace.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnExploreDesignSpace.setText("Explore Design Space");
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment