Commit 0514fe69 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

DSE.UI: Disable View Navigator Button if no Project is Loaded

Issue-Ref: 4064
Issue-Url: https://af3-developer.fortiss.org/issues/4064

Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent 12f1f7c5
DSEProcessNavigator.java 97db65f69c2b2b15e38d5c73c6b0235413e9c0e6 GREEN
DSEProcessNavigator.java 307b970c8d07b8cd4caccee1de88f05f672df32f YELLOW
ExplorationElementTreeViewer.java 47f80c87855c35f11af01f409604b45433704974 GREEN
ExplorationNavigatorElementContentProvider.java 27a951f2dd5c9cb7f96c371e1e5f894825933cfd GREEN
ExplorationNavigatorFXController.java 317b4521a09e3f1067fd0e4aac061d1b573c092b GREEN
......
......@@ -20,6 +20,8 @@ import static org.fortiss.af3.exploration.ui.perspective.process.IProcessManager
import static org.fortiss.af3.exploration.ui.perspective.process.IProcessManager.EProcessStep.OBJECTIVES;
import static org.fortiss.af3.exploration.ui.perspective.process.IProcessManager.EProcessStep.SYNTHESIS;
import static org.fortiss.af3.exploration.ui.perspective.process.IProcessManager.EProcessStep.VISUALIZATION;
import static org.fortiss.af3.exploration.ui.perspective.service.IEventListener.DSE_EVENT.DSE_REMOVED_EVENT;
import static org.fortiss.af3.exploration.ui.perspective.service.IEventListener.DSE_EVENT.DSE_SELECTED_EVENT;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
......@@ -33,8 +35,12 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.ui.perspective.generic.DseSaveableView;
import org.fortiss.af3.exploration.ui.perspective.process.IProcessManager;
import org.fortiss.af3.exploration.ui.perspective.service.EventBroker;
import org.fortiss.af3.exploration.ui.perspective.service.IDSEPerspectiveManager;
import org.fortiss.af3.exploration.ui.perspective.service.IEventListener;
/**
* Navigator providing 4 Buttons:
......@@ -45,7 +51,22 @@ import org.fortiss.af3.exploration.ui.perspective.process.IProcessManager;
*
* @author eder
*/
public class DSEProcessNavigator extends DseSaveableView {
public class DSEProcessNavigator extends DseSaveableView implements IEventListener {
/** {@link Button} for the target definition views. */
private Button btnC;
/** {@link Button} for the constraint view. */
private MenuItem constraintMenu;
/** {@link MenuItem} for the objective view. */
private MenuItem objectiveMenu;
/** {@link Button} for the synthesis view. */
private Button btnS;
/** {@link Button} for the visualization view. */
private Button btnV;
/** The ID */
public static final String ID = DSEProcessNavigator.class.getName();
......@@ -53,6 +74,8 @@ public class DSEProcessNavigator extends DseSaveableView {
/** {@inheritDoc} */
@Override
public void createPartControl(Composite parent) {
EventBroker.getInstance().addListener(this);
DSE activeDSE = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(5, false));
......@@ -62,17 +85,17 @@ public class DSEProcessNavigator extends DseSaveableView {
btnH.setImage(IProcessManager.INSTANCE.getImageForProcessStep(HOME));
btnH.addSelectionListener(new HomeSelectionAdapter());
Button btnC = new Button(composite, SWT.NONE);
btnC = new Button(composite, SWT.NONE);
btnC.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
btnC.setImage(IProcessManager.INSTANCE.getImageForProcessStep(CONSTRAINTS));
Menu menu2 = new Menu(btnC);
btnC.setMenu(menu2);
MenuItem constraintMenu = new MenuItem(menu2, SWT.NONE);
constraintMenu = new MenuItem(menu2, SWT.NONE);
constraintMenu.setText("Constraint Modeling");
constraintMenu.addSelectionListener(new ConstraintsSelectionAdapter());
MenuItem objectiveMenu = new MenuItem(menu2, SWT.NONE);
objectiveMenu = new MenuItem(menu2, SWT.NONE);
objectiveMenu.setText("Objective Modeling");
objectiveMenu.addSelectionListener(new ObjectivesSelectionAdapter());
......@@ -87,20 +110,32 @@ public class DSEProcessNavigator extends DseSaveableView {
}
});
Button btnS = new Button(composite, SWT.NONE);
btnS = new Button(composite, SWT.NONE);
btnS.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
btnS.setImage(IProcessManager.INSTANCE.getImageForProcessStep(SYNTHESIS));
btnS.addSelectionListener(new SynthSelectionAdapter());
Button btnV = new Button(composite, SWT.NONE);
btnV = new Button(composite, SWT.NONE);
btnV.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
btnV.setImage(IProcessManager.INSTANCE.getImageForProcessStep(VISUALIZATION));
new Label(composite, SWT.NONE);
btnV.addSelectionListener(new VisualizationSelectionAdapter());
if(activeDSE == null) {
enableViewButtons(false);
}
composite.update();
composite.layout();
}
/** {@inheritDoc} */
@Override
public void dispose() {
super.dispose();
EventBroker.getInstance().removeListener(this);
}
/** Home button selection adapter. */
private class HomeSelectionAdapter extends SelectionAdapter {
/** {@inheritDoc} */
......@@ -145,4 +180,23 @@ public class DSEProcessNavigator extends DseSaveableView {
IProcessManager.INSTANCE.goToStep(SYNTHESIS);
}
}
/** {@inheritDoc} */
@Override
public void propertyChanged(Object source, DSE_EVENT event) {
if(event == DSE_SELECTED_EVENT && source instanceof DSE) {
enableViewButtons(true);
} else if(event == DSE_REMOVED_EVENT) {
enableViewButtons(false);
}
}
/** Enables/Disables the buttons for opening views for specific DSE tasks. */
private void enableViewButtons(boolean enable) {
btnC.setEnabled(enable);
constraintMenu.setEnabled(enable);
objectiveMenu.setEnabled(enable);
btnS.setEnabled(enable);
btnV.setEnabled(enable);
}
}
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