Commit e92a3994 authored by Simon Barner's avatar Simon Barner
Browse files

Merge branch '3672' into 'master'

Dev Objectives: Fix layout in toolbar

See merge request !7
parents 64aa72ab 7a8ede75
......@@ -264,15 +264,20 @@
</extension>
-->
<extension
point="org.eclipse.ui.activities">
<activity id="org.fortiss.af3.activities.unwantedActionSet1" name="Unwanted Search ActionSet">
</activity>
<activityPatternBinding activityId="org.fortiss.af3.activities.unwantedActionSet1" pattern="org.eclipse.ui.actionSet.openFiles">
</activityPatternBinding>
<activityPatternBinding activityId="org.fortiss.af3.activities.unwantedActionSet1" pattern="org.eclipse.ui.edit.text.*">
</activityPatternBinding>
</extension>
<extension point="org.eclipse.ui.activities">
<activity id="org.fortiss.af3.activities.hideUnwantedActionSet" name="Hide unwanted ActionSet"/>
<activityPatternBinding
activityId="org.fortiss.af3.activities.hideUnwantedActionSet"
pattern="org.eclipse.ui.actionSet.openFiles"/>
<activityPatternBinding
activityId="org.fortiss.af3.activities.hideUnwantedActionSet"
pattern="org.eclipse.ui.edit.text.*"/>
<activityPatternBinding
activityId="org.fortiss.af3.activities.hideUnwantedActionSet"
pattern="org.eclipse.ui.editors/org.eclipse.ui.edit.text.gotoPreviousAnnotation"/>
<activityPatternBinding
activityId="org.fortiss.af3.activities.hideUnwantedActionSet"
pattern="org.eclipse.ui.editors/org.eclipse.ui.edit.text.gotoNextAnnotation"/>
</extension>
</plugin>
ApplicationActionBarAdvisor.java 3e7c0fd992586e6ca7724b871eb0b2cf59244028 GREEN
ApplicationWorkbenchAdvisor.java ef25d5783a4f75e88334fd679834a6e0421f8c2f GREEN
ApplicationWorkbenchWindowAdvisor.java da5cb38300b384579532c678fbc9faa961c2ca6b GREEN
CurrentObjectiveContributionItem.java f3e3e5d264ec136145cdc8e0374dc2032b6e1b4d RED
UpcomingObjectiveContributionItem.java c07438463c4d359ea2f5de40ba90b5ac6991ba9c RED
CurrentObjectiveContributionItem.java 52e739907bdca86536efc963bd476fe238bb2f14 RED
UpcomingObjectiveContributionItem.java 5721c93ac6ea39842af09703ebc2b0f841bc9ed5 RED
......@@ -23,9 +23,6 @@ import static org.eclipse.wb.swt.SWTResourceManager.getColor;
import static org.fortiss.tooling.base.ui.utils.ConstraintsBaseUIUtils.activateConfiguration;
import static org.fortiss.tooling.base.ui.utils.ConstraintsBaseUIUtils.deactivateConfiguration;
import static org.fortiss.tooling.base.utils.ConstraintsBaseUtils.getActiveConfigurationsTransitively;
import static org.fortiss.tooling.base.utils.SystemUtils.isLinuxPlatform;
import static org.fortiss.tooling.base.utils.SystemUtils.isMacOSXPlatform;
import static org.fortiss.tooling.base.utils.SystemUtils.isWindowsPlatform;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getFirstParentWithType;
import java.text.DecimalFormat;
......@@ -39,23 +36,20 @@ import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.menus.WorkbenchWindowControlContribution;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.project.model.IProjectConfigurationElement;
import org.fortiss.af3.project.model.configuration.DevelopmentProcessConfiguration;
......@@ -78,9 +72,31 @@ import org.fortiss.tooling.kernel.ui.service.IConstraintUIService;
* @author rahman
*
*/
class CurrentObjectiveContributionItem extends ContributionItem
class CurrentObjectiveContributionItem extends WorkbenchWindowControlContribution
implements ISelectionListener, IResourceChangeListener {
/** Helper to align the upcoming objective combo with the current objective combo. */
public class SizedComposite extends Composite {
/** Constructor. */
public SizedComposite(Composite parent, int style) {
super(parent, style);
}
/** {@inheritDoc} */
@Override
public void setSize(Point size) {
super.setSize(computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
}
/** {@inheritDoc} */
@Override
public void setSize(int width, int height) {
Point size = computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
super.setSize(size.x, size.y);
}
}
/** The initial objectives. */
private String[] initialSetOfObjectives = {};
......@@ -88,10 +104,10 @@ class CurrentObjectiveContributionItem extends ContributionItem
private String initialObjective = "No modeling objective selected";
/** The Combo holding the time between the simulation steps. */
private Combo currentObjectiveCombo;
private CCombo currentObjectiveCombo;
/** The control object holding the combo. */
private ToolItem toolitem;
// private ToolItem toolitem;
/** Composite instance to hold several controls */
private Composite composite;
......@@ -101,6 +117,7 @@ class CurrentObjectiveContributionItem extends ContributionItem
/** Constructor. */
public CurrentObjectiveContributionItem() {
super("CurrentObjectiveContributionItem");
// TODO (SB, 12): See
// org.fortiss.tooling.kernel.ui.util.EObjectSelectionUtils.getSelectionService()
ISelectionService ss =
......@@ -110,71 +127,44 @@ class CurrentObjectiveContributionItem extends ContributionItem
getWorkspace().addResourceChangeListener(this);
}
/** Creates the control holding list of objectives for the selected project. */
/** {@inheritDoc} */
@Override
public void fill(ToolBar parent, int index) {
toolitem = new ToolItem(parent, SWT.SEPARATOR, index);
composite = new Composite(parent, SWT.NONE);
composite.addControlListener(new ControlListener() {
@Override
public void controlResized(ControlEvent e) {
composite.getParent().pack(true);
}
public boolean isDynamic() {
return true;
}
@Override
public void controlMoved(ControlEvent e) {
// Do not do anything
}
});
/** {@inheritDoc} */
@Override
protected Control createControl(Composite parent) {
composite = new SizedComposite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.verticalSpacing = 0;
// TODO(SB, 9): Why is an OS-specific case distinction required to position the ComboBox?
// Either, this is an attempt to address #3216, or it is its root cause...!
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.CENTER;
composite.setLayout(layout);
Label label = new Label(composite, SWT.TRANSPARENT);
label.setText("Current Objective");
if(isLinuxPlatform()) {
gridData.verticalIndent = -10;
} else if(isMacOSXPlatform()) {
gridData.verticalIndent = 0;
} else if(isWindowsPlatform()) {
gridData.verticalIndent = -20;
gridData.grabExcessVerticalSpace = true;
GridData data = new GridData(0, SWT.FILL, false, false);
data.verticalIndent = -10;
label.setLayoutData(data);
}
currentObjectiveCombo = new Combo(composite, SWT.DROP_DOWN);
currentObjectiveCombo.setLayoutData(gridData);
// Objective Combo
currentObjectiveCombo = new CCombo(composite, SWT.DROP_DOWN);
currentObjectiveCombo.setItems(initialSetOfObjectives);
currentObjectiveCombo.setText(initialObjective);
currentObjectiveCombo.setToolTipText("Set the next modelling objective.");
currentObjectiveCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String textInCombo = ((Combo)e.getSource()).getText();
String textInCombo = ((CCombo)e.getSource()).getText();
if(!textInCombo.isEmpty()) {
updateObjectiveByName(textInCombo);
}
}
});
currentObjectiveCombo.setItems(initialSetOfObjectives);
currentObjectiveCombo.setText(initialObjective);
currentObjectiveCombo.setToolTipText("Set the next modelling objective.");
toolitem.setWidth(computeWidth(composite));
toolitem.setControl(composite);
parent.setSize(composite.computeSize(parent.getSize().x, SWT.DEFAULT, true));
return composite;
}
/** Compute Combo width. */
@Override
protected int computeWidth(Control control) {
return control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x;
}
......@@ -371,7 +361,7 @@ class CurrentObjectiveContributionItem extends ContributionItem
String currentObjectiveNewName =
currentDevelopmentProcess.getCurrentObjective().getName();
currentObjectiveCombo.setText(currentObjectiveNewName);
toolitem.setWidth(computeWidth(composite));
// toolitem.setWidth(computeWidth(composite));
}
}
......
......@@ -20,9 +20,6 @@ import static org.fortiss.tooling.base.ui.utils.ConstraintsBaseUIUtils.activateC
import static org.fortiss.tooling.base.ui.utils.ConstraintsBaseUIUtils.activateOneConfiguration;
import static org.fortiss.tooling.base.ui.utils.ConstraintsBaseUIUtils.deactivateConfiguration;
import static org.fortiss.tooling.base.ui.utils.ConstraintsBaseUIUtils.deactivateOneConfiguration;
import static org.fortiss.tooling.base.utils.SystemUtils.isLinuxPlatform;
import static org.fortiss.tooling.base.utils.SystemUtils.isMacOSXPlatform;
import static org.fortiss.tooling.base.utils.SystemUtils.isWindowsPlatform;
import java.util.ArrayList;
import java.util.List;
......@@ -32,24 +29,24 @@ import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.menus.WorkbenchWindowControlContribution;
import org.fortiss.af3.project.model.IProjectConfigurationElement;
import org.fortiss.af3.project.model.configuration.DevelopmentProcessConfiguration;
import org.fortiss.af3.project.model.development.ConstraintBasedDevelopmentProcess;
......@@ -72,9 +69,30 @@ import org.fortiss.tooling.kernel.utils.EcoreUtils;
/**
* @author levilucio
*/
public class UpcomingObjectiveContributionItem extends ContributionItem
public class UpcomingObjectiveContributionItem extends WorkbenchWindowControlContribution
implements ISelectionListener, IResourceChangeListener {
/** Helper to align the upcoming objective combo with the current objective combo. */
public class SizedComposite extends Composite {
/** Constructor. */
public SizedComposite(Composite parent, int style) {
super(parent, style);
}
/** {@inheritDoc} */
@Override
public void setSize(Point size) {
super.setSize(computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
}
/** {@inheritDoc} */
@Override
public void setSize(int width, int height) {
Point size = computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
super.setSize(size.x, size.y);
}
}
/** The initial upcoming objectives. */
private String[] initialSetOfObjectives = {};
......@@ -82,10 +100,7 @@ public class UpcomingObjectiveContributionItem extends ContributionItem
private String initialObjective = "No upcoming objective available";
/** The Combo holding the upcoming objectives. */
private Combo upcomingObjectiveCombo;
/** The control object holding the combo. */
private ToolItem toolitem;
private CCombo upcomingObjectiveCombo;
/** Configuration of the current project selected in the combo box. */
private ConstraintBasedDevelopmentProcess currentDevelopmentProcess = null;
......@@ -105,47 +120,36 @@ public class UpcomingObjectiveContributionItem extends ContributionItem
workspace.addResourceChangeListener(this);
}
/** Creates the control holding the step length combo. */
/** {@inheritDoc} */
@Override
public void fill(ToolBar parent, int index) {
toolitem = new org.eclipse.swt.widgets.ToolItem(parent, SWT.SEPARATOR, index);
composite = new Composite(parent, SWT.NONE);
org.eclipse.swt.layout.GridLayout layout = new org.eclipse.swt.layout.GridLayout(2, false);
layout.marginWidth = 0; // <-- HERE
layout.verticalSpacing = 0;
public boolean isDynamic() {
return true;
}
/** {@inheritDoc} */
@Override
protected Control createControl(Composite parent) {
// This extra composite is only required here...
composite = new SizedComposite(parent, SWT.NONE);
GridLayout layout = new GridLayout(3, false);
layout.marginWidth = 0;
composite.setLayout(layout);
org.eclipse.swt.widgets.Label label =
new org.eclipse.swt.widgets.Label(composite, SWT.TRANSPARENT);
label.setText(" Upcoming Objective");
org.eclipse.swt.layout.GridData gridData = new org.eclipse.swt.layout.GridData();
gridData.verticalAlignment = GridData.CENTER;
gridData.widthHint = 200;
if(isLinuxPlatform()) {
gridData.verticalIndent = -10;
} else if(isMacOSXPlatform()) {
gridData.verticalIndent = 0;
} else if(isWindowsPlatform()) {
gridData.verticalIndent = -20;
gridData.grabExcessVerticalSpace = true;
GridData data = new GridData(0, SWT.FILL, false, false);
data.verticalIndent = -10;
label.setLayoutData(data);
}
// Add a separator to the current objective combo.
new Label(composite, SWT.HORIZONTAL);
upcomingObjectiveCombo = new org.eclipse.swt.widgets.Combo(composite, SWT.DROP_DOWN);
upcomingObjectiveCombo.setLayoutData(gridData);
Label label = new Label(composite, SWT.TRANSPARENT);
label.setText("Upcoming Objective");
// Objective Combo
upcomingObjectiveCombo = new CCombo(composite, SWT.DROP_DOWN);
upcomingObjectiveCombo.setItems(initialSetOfObjectives);
upcomingObjectiveCombo.setText(initialObjective);
upcomingObjectiveCombo.setToolTipText("Set the next modelling objective.");
upcomingObjectiveCombo.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
currentObjective.updateObjectiveByName(((Combo)e.getSource()).getText());
currentObjective.updateObjectiveByName(((CCombo)e.getSource()).getText());
}
@Override
......@@ -155,7 +159,6 @@ public class UpcomingObjectiveContributionItem extends ContributionItem
});
upcomingObjectiveCombo.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
if(currentDevelopmentProcess != null) {
......@@ -185,15 +188,12 @@ public class UpcomingObjectiveContributionItem extends ContributionItem
}
});
upcomingObjectiveCombo.setItems(initialSetOfObjectives);
upcomingObjectiveCombo.setText(initialObjective);
upcomingObjectiveCombo.setToolTipText("Set the next modelling objective.");
toolitem.setWidth(computeWidth(composite));
toolitem.setControl(composite);
parent.setSize(composite.computeSize(parent.getSize().x, SWT.DEFAULT));
return composite;
}
/** Compute Combo Width */
@Override
protected int computeWidth(Control control) {
return control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x;
}
......@@ -395,13 +395,12 @@ public class UpcomingObjectiveContributionItem extends ContributionItem
*/
private void setUpcomingComboBasedOnCrieterion() {
if(getUpcomingObjectives().isEmpty() && composite != null) {
composite.setVisible(false);
composite.redraw();
upcomingObjectiveCombo.setEnabled(false);
} else {
composite.setVisible(true);
composite.setFocus();
upcomingObjectiveCombo.setEnabled(true);
upcomingObjectiveCombo.setFocus();
}
composite.redraw();
upcomingObjectiveCombo.redraw();
}
}
Markdown is supported
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