Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
af3
AF3
Commits
e4f0a908
Commit
e4f0a908
authored
Sep 19, 2017
by
Levi Lucio
Browse files
Added combo boxes for current and upcoming objectives
refs 3039
parent
d5614e59
Changes
5
Hide whitespace changes
Inline
Side-by-side
org.fortiss.af3.rcp.application/trunk/META-INF/MANIFEST.MF
View file @
e4f0a908
...
...
@@ -64,5 +64,6 @@ Require-Bundle: org.eclipse.ui.ide.application,
org.fortiss.af3.specification.ui;bundle-version="2.11.0",
eu.fbk.af3.tools.diagram.ui;bundle-version="2.11.0",
org.fortiss.tooling.kernel,
org.fortiss.af3.project
org.fortiss.af3.project,
org.fortiss.tooling.kernel.ui
Import-Package: org.fortiss.af3.efficientdeployment.model.impl
org.fortiss.af3.rcp.application/trunk/icons/upcoming_objective.png
0 → 100644
View file @
e4f0a908
5.54 KB
org.fortiss.af3.rcp.application/trunk/src/org/fortiss/af3/rcp/application/advisors/ApplicationActionBarAdvisor.java
View file @
e4f0a908
...
...
@@ -130,6 +130,12 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
/** AF3-Specific Export Action. */
private
static
WorkbenchCommandAction
exportAF3ProjectsAction
;
/** The current objective combo box. */
private
static
CurrentObjectiveContributionItem
currentObjective
;
/** The upcoming objective combo box. */
private
static
UpcomingObjectiveContributionItem
upcomingObjective
;
// Actions to open Examples.
/** AF3-Specific Action to open the SimpleTrafficLights-Example. */
...
...
@@ -156,9 +162,6 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
/** AF3-Specific Action to open the ACC-Example. */
private
static
WorkbenchCommandAction
openACCExampleAction
;
/** AF3-Specific Action to open the ACC PikeOS Example. */
private
static
WorkbenchCommandAction
openACCPikeOSExampleAction
;
/** AF3-Specific Action to open the eCar-Example. */
private
static
WorkbenchCommandAction
openECarExampleAction
;
...
...
@@ -179,6 +182,9 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
/** The "current objective" text label */
private
static
ImageLabelContribution
currentObjectiveLabel
;
/** The "next objective" text label */
private
static
ImageLabelContribution
upcomingObjectiveLabel
;
/** Class used to define an command action. */
private
static
class
WorkbenchCommandAction
extends
CommandAction
implements
IWorkbenchAction
{
...
...
@@ -270,6 +276,9 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
registerGoBack
(
window
);
registerGoForward
(
window
);
createCurrentObjective
();
createUpcomingObjective
();
createCurrentObjectiveLabel
();
createUpcomingObjectiveLabel
();
}
/**
...
...
@@ -481,9 +490,8 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
* Registers the "Load ACC PikeOS Example" action and attaches it to the corresponding button.
*/
private
void
registerLoadACCPikeOSExample
(
IWorkbenchWindow
window
)
{
openACCPikeOSExampleAction
=
createAndRegisterWorkBenchCommandAction
(
"Load ACC PikeOS Example"
,
"org.fortiss.af3.rcp.application.loadaccpikeosexample"
,
window
);
createAndRegisterWorkBenchCommandAction
(
"Load ACC PikeOS Example"
,
"org.fortiss.af3.rcp.application.loadaccpikeosexample"
,
window
);
}
/**
...
...
@@ -722,14 +730,39 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
/**
* Creates the "current objective" label by loading the text from a file
* (for better alignment with the other toolbar elements)
*/
private
void
createCurrentObjective
()
{
currentObjective
=
new
CurrentObjectiveContributionItem
();
}
/**
* Creates the "upcoming objective" label by loading the text from a file
* (for better alignment with the other toolbar elements)
*/
private
void
createUpcomingObjective
()
{
upcomingObjective
=
new
UpcomingObjectiveContributionItem
();
}
/**
* Creates the "current objective" label by loading the text from a file
* (for better alignment with the other toolbar elements)
*/
private
void
createCurrentObjectiveLabel
()
{
currentObjectiveLabel
=
new
ImageLabelContribution
(
"label"
,
getPluginImageDescriptor
(
"org.fortiss.af3.rcp.application"
,
"icons/current_objective.png"
));
}
/**
* Creates the "upcoming objective" label by loading the text from a file
* (for better alignment with the other toolbar elements)
*/
private
void
createUpcomingObjectiveLabel
()
{
upcomingObjectiveLabel
=
new
ImageLabelContribution
(
"label"
,
getPluginImageDescriptor
(
"org.fortiss.af3.rcp.application"
,
"icons/upcoming_objective.png"
));
}
/** {@inheritDoc} */
@Override
protected
void
fillCoolBar
(
ICoolBarManager
coolBar
)
{
...
...
@@ -743,9 +776,13 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
toolBarManager
.
add
(
goBack
);
toolBarManager
.
add
(
goForward
);
toolBarManager
.
add
(
new
Separator
());
toolBarManager
.
add
(
currentObjectiveLabel
);
toolBarManager
.
add
(
new
CurrentObjectiveContributionItem
());
toolBarManager
.
add
(
currentObjective
);
toolBarManager
.
add
(
new
Separator
());
toolBarManager
.
add
(
upcomingObjectiveLabel
);
toolBarManager
.
add
(
upcomingObjective
);
upcomingObjective
.
setCurrentObjective
(
currentObjective
);
}
/** {@inheritDoc} */
...
...
org.fortiss.af3.rcp.application/trunk/src/org/fortiss/af3/rcp/application/advisors/CurrentObjectiveContributionItem.java
View file @
e4f0a908
...
...
@@ -17,8 +17,13 @@ $Id$
+--------------------------------------------------------------------------*/
package
org.fortiss.af3.rcp.application.advisors
;
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
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
org.eclipse.emf.common.util.EList
;
import
org.eclipse.emf.ecore.EObject
;
...
...
@@ -28,8 +33,8 @@ import org.eclipse.jface.viewers.ITreeSelection;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.FocusEvent
;
import
org.eclipse.swt.events.FocusListener
;
import
org.eclipse.swt.events.
ModifyEvent
;
import
org.eclipse.swt.events.
ModifyListener
;
import
org.eclipse.swt.events.
SelectionAdapter
;
import
org.eclipse.swt.events.
SelectionEvent
;
import
org.eclipse.swt.widgets.Combo
;
import
org.eclipse.swt.widgets.Control
;
import
org.eclipse.swt.widgets.ToolBar
;
...
...
@@ -38,11 +43,11 @@ import org.eclipse.ui.ISelectionListener;
import
org.eclipse.ui.ISelectionService
;
import
org.eclipse.ui.IWorkbenchPart
;
import
org.eclipse.ui.PlatformUI
;
import
org.fortiss.af3.project.model.FileProject
;
import
org.fortiss.af3.project.model.IProjectConfigurationElement
;
import
org.fortiss.af3.project.model.configuration.DevelopmentProcessConfiguration
;
import
org.fortiss.af3.project.model.development.ConstraintBasedDevelopmentProcess
;
import
org.fortiss.af3.project.model.development.impl.DummyDevelopmentProcessImpl
;
import
org.fortiss.af3.project.model.impl.FileProjectImpl
;
import
org.fortiss.af3.project.model.development.DummyDevelopmentProcess
;
import
org.fortiss.af3.project.model.impl.ProjectConfigurationImpl
;
import
org.fortiss.tooling.base.model.element.ConstraintConfiguration
;
import
org.fortiss.tooling.kernel.extension.data.ITopLevelElement
;
...
...
@@ -59,7 +64,7 @@ import org.fortiss.tooling.kernel.utils.EcoreUtils;
*/
class
CurrentObjectiveContributionItem
extends
ContributionItem
implements
ISelectionListener
{
/** The initial
step length
s. */
/** The initial
objective
s. */
private
String
[]
initialSetOfObjectives
=
{};
/** Placeholder string for when no objective is selected. */
...
...
@@ -71,46 +76,32 @@ class CurrentObjectiveContributionItem extends ContributionItem implements ISele
/** The control object holding the combo. */
private
ToolItem
toolitem
;
/** Configuration of the current project selected in the combo box */
/** Configuration of the current project selected in the combo box
.
*/
private
ConstraintBasedDevelopmentProcess
currentDevelopmentProcess
=
null
;
/** Constructor. */
public
CurrentObjectiveContributionItem
()
{
ISelectionService
ww
=
ISelectionService
ss
=
PlatformUI
.
getWorkbench
().
getActiveWorkbenchWindow
().
getSelectionService
();
ww
.
addSelectionListener
(
this
);
ss
.
addSelectionListener
(
this
);
}
/** Creates the control holding
the step length combo
. */
/** Creates the control holding
list of objectives for the selected project
. */
@Override
public
void
fill
(
ToolBar
parent
,
int
index
)
{
toolitem
=
new
ToolItem
(
parent
,
SWT
.
SEPARATOR
,
index
);
currentObjectiveCombo
=
new
Combo
(
parent
,
SWT
.
DROP_DOWN
);
currentObjectiveCombo
.
add
Modify
Listener
(
new
ModifyListen
er
()
{
currentObjectiveCombo
.
add
Selection
Listener
(
new
SelectionAdapt
er
()
{
@Override
public
void
modifyText
(
Modify
Event
e
)
{
public
void
widgetSelected
(
Selection
Event
e
)
{
String
textInCombo
=
((
Combo
)
e
.
getSource
()).
getText
();
if
(!
textInCombo
.
isEmpty
())
{
if
(
currentDevelopmentProcess
!=
null
)
{
String
currentDevelopmentProcessStr
=
currentDevelopmentProcess
.
getCurrentObjective
().
getName
();
// only set the objective in the model if it really changed
if
(!(
currentDevelopmentProcessStr
.
equals
(
textInCombo
)))
{
ConstraintConfiguration
newObjective
=
getConstraintConfigByName
(((
Combo
)
e
.
getSource
()).
getText
());
if
(
newObjective
!=
null
)
{
ITopLevelElement
modelContext
=
IPersistencyService
.
getInstance
().
getTopLevelElementFor
(
currentDevelopmentProcess
);
modelContext
.
runAsCommand
(()
->
currentDevelopmentProcess
.
setCurrentObjective
(
newObjective
));
}
}
}
currentDevelopmentProcess
.
getCurrentObjective
().
getName
();
updateObjectiveByName
(((
Combo
)
e
.
getSource
()).
getText
());
}
}
});
...
...
@@ -119,20 +110,22 @@ class CurrentObjectiveContributionItem extends ContributionItem implements ISele
@Override
public
void
focusGained
(
FocusEvent
e
)
{
EList
<
ConstraintConfiguration
>
configs
=
currentDevelopmentProcess
.
getConfigurations
();
if
(
currentDevelopmentProcess
!=
null
)
{
EList
<
ConstraintConfiguration
>
configs
=
currentDevelopmentProcess
.
getConfigurations
();
List
<
String
>
configNames
=
new
ArrayList
<
String
>();
List
<
String
>
configNames
=
new
ArrayList
<
String
>();
for
(
ConstraintConfiguration
constraintConfiguration
:
configs
)
{
configNames
.
add
(
constraintConfiguration
.
getName
());
}
for
(
ConstraintConfiguration
constraintConfiguration
:
configs
)
{
configNames
.
add
(
constraintConfiguration
.
getName
());
}
String
[]
configNamesArray
=
new
String
[
configNames
.
size
()];
configNames
.
toArray
(
configNamesArray
);
currentObjectiveCombo
.
setItems
(
configNamesArray
);
currentObjectiveCombo
.
setText
(
currentDevelopmentProcess
.
getCurrentObjective
()
.
getName
());
String
[]
configNamesArray
=
new
String
[
configNames
.
size
()];
configNames
.
toArray
(
configNamesArray
);
currentObjectiveCombo
.
setItems
(
configNamesArray
);
currentObjectiveCombo
.
setText
(
currentDevelopmentProcess
.
getCurrentObjective
()
.
getName
());
}
}
@Override
...
...
@@ -154,7 +147,13 @@ class CurrentObjectiveContributionItem extends ContributionItem implements ISele
return
control
.
computeSize
(
SWT
.
DEFAULT
,
SWT
.
DEFAULT
,
true
).
x
;
}
/** Get the pointer to the configuration having a given name */
/**
* Get the pointer to the configuration having a given name.
*
* @param constraintName
* The name of the constraint to look for.
* @return The real configuration.
*/
private
ConstraintConfiguration
getConstraintConfigByName
(
String
constraintName
)
{
ConstraintConfiguration
ret
=
null
;
if
(
currentDevelopmentProcess
!=
null
)
{
...
...
@@ -177,19 +176,18 @@ class CurrentObjectiveContributionItem extends ContributionItem implements ISele
if
(
selection
instanceof
ITreeSelection
)
{
if
(((
ITreeSelection
)
selection
).
getFirstElement
()
!=
null
)
{
Object
objectChosenElement
=
(
Object
)
((
ITreeSelection
)
selection
).
getFirstElement
();
Object
objectChosenElement
=
((
ITreeSelection
)
selection
).
getFirstElement
();
if
(
objectChosenElement
instanceof
EObject
)
{
EObject
chosenElement
=
(
EObject
)
objectChosenElement
;
FileProject
Impl
fileProject
=
null
;
FileProject
fileProject
=
null
;
if
(
chosenElement
instanceof
FileProject
Impl
)
{
fileProject
=
(
FileProject
Impl
)
chosenElement
;
if
(
chosenElement
instanceof
FileProject
)
{
fileProject
=
(
FileProject
)
chosenElement
;
}
else
{
fileProject
=
EcoreUtils
.
getFirstParentWithType
(
chosenElement
,
FileProjectImpl
.
class
);
EcoreUtils
.
getFirstParentWithType
(
chosenElement
,
FileProject
.
class
);
}
EList
<
IProjectRootElement
>
rootElems
=
fileProject
.
getRootElements
();
...
...
@@ -202,7 +200,7 @@ class CurrentObjectiveContributionItem extends ContributionItem implements ISele
DevelopmentProcessConfiguration
processConfig
=
(
DevelopmentProcessConfiguration
)
configElements
.
get
(
1
);
if
(!(
processConfig
.
getDevelopment
()
instanceof
DummyDevelopmentProcess
Impl
))
{
if
(!(
processConfig
.
getDevelopment
()
instanceof
DummyDevelopmentProcess
))
{
ConstraintBasedDevelopmentProcess
process
=
(
ConstraintBasedDevelopmentProcess
)
processConfig
.
getDevelopment
();
...
...
@@ -210,12 +208,8 @@ class CurrentObjectiveContributionItem extends ContributionItem implements ISele
currentDevelopmentProcess
=
process
;
List
<
String
>
configNames
=
new
ArrayList
<
String
>();
for
(
ConstraintConfiguration
constraintConfiguration
:
configs
)
{
configNames
.
add
(
constraintConfiguration
.
getName
());
}
List
<
String
>
configNames
=
configs
.
stream
().
map
(
c
->
c
.
getName
()).
collect
(
Collectors
.
toList
());
String
[]
configNamesArray
=
new
String
[
configNames
.
size
()];
configNames
.
toArray
(
configNamesArray
);
currentObjectiveCombo
.
setItems
(
configNamesArray
);
...
...
@@ -225,4 +219,35 @@ class CurrentObjectiveContributionItem extends ContributionItem implements ISele
}
}
}
/**
* Updates the current objective to the objective having the name passed as a parameter.
*
* @param newObjectiveName
* The name of the objective to update to.
*/
public
void
updateObjectiveByName
(
String
newObjectiveName
)
{
ConstraintConfiguration
newObjective
=
getConstraintConfigByName
(
newObjectiveName
);
final
ConstraintConfiguration
oldObjective
=
currentDevelopmentProcess
.
getCurrentObjective
();
if
(
newObjective
!=
null
)
{
ITopLevelElement
modelContext
=
IPersistencyService
.
getInstance
().
getTopLevelElementFor
(
currentDevelopmentProcess
);
modelContext
.
runAsNonDirtyingCommand
(()
->
{
currentDevelopmentProcess
.
setCurrentObjective
(
newObjective
);
List
<
ConstraintConfiguration
>
activeConfigs
=
getActiveConfigurationsTransitively
(
newObjective
,
null
);
if
(!
activeConfigs
.
contains
(
oldObjective
))
{
deactivateConfiguration
(
oldObjective
,
currentDevelopmentProcess
.
getConstraintInstanceContainer
(),
newObjective
);
}
activateConfiguration
(
newObjective
,
currentDevelopmentProcess
.
getConstraintInstanceContainer
());
});
currentObjectiveCombo
.
setText
(
currentDevelopmentProcess
.
getCurrentObjective
().
getName
());
}
}
}
org.fortiss.af3.rcp.application/trunk/src/org/fortiss/af3/rcp/application/advisors/UpcomingObjectiveContributionItem.java
0 → 100644
View file @
e4f0a908
/*--------------------------------------------------------------------------+
$Id$
| |
| 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.rcp.application.advisors
;
import
static
org
.
fortiss
.
tooling
.
base
.
ui
.
utils
.
ConstraintsBaseUIUtils
.
activateConfiguration
;
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
java.util.ArrayList
;
import
java.util.List
;
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.events.FocusEvent
;
import
org.eclipse.swt.events.FocusListener
;
import
org.eclipse.swt.events.SelectionEvent
;
import
org.eclipse.swt.events.SelectionListener
;
import
org.eclipse.swt.widgets.Combo
;
import
org.eclipse.swt.widgets.Control
;
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.fortiss.af3.project.model.IProjectConfigurationElement
;
import
org.fortiss.af3.project.model.configuration.DevelopmentProcessConfiguration
;
import
org.fortiss.af3.project.model.development.ConstraintBasedDevelopmentProcess
;
import
org.fortiss.af3.project.model.development.impl.DummyDevelopmentProcessImpl
;
import
org.fortiss.af3.project.model.impl.FileProjectImpl
;
import
org.fortiss.af3.project.model.impl.ProjectConfigurationImpl
;
import
org.fortiss.tooling.base.model.element.ConstraintConfiguration
;
import
org.fortiss.tooling.common.util.LambdaUtils
;
import
org.fortiss.tooling.kernel.extension.data.ITopLevelElement
;
import
org.fortiss.tooling.kernel.model.IProjectRootElement
;
import
org.fortiss.tooling.kernel.model.constraints.ConstraintInstance
;
import
org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceStatus
;
import
org.fortiss.tooling.kernel.model.constraints.SuccessConstraintInstanceStatus
;
import
org.fortiss.tooling.kernel.service.IPersistencyService
;
import
org.fortiss.tooling.kernel.ui.service.IConstraintUIService
;
import
org.fortiss.tooling.kernel.utils.EcoreUtils
;
/**
*
* @author levilucio
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public
class
UpcomingObjectiveContributionItem
extends
ContributionItem
implements
ISelectionListener
{
/** The initial upcoming objectives. */
private
String
[]
initialSetOfObjectives
=
{};
/** Placeholder string for when no objective is selected. */
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
;
/** Configuration of the current project selected in the combo box */
private
ConstraintBasedDevelopmentProcess
currentDevelopmentProcess
=
null
;
/** The current objective combo box */
CurrentObjectiveContributionItem
currentObjective
;
/** Constructor. */
public
UpcomingObjectiveContributionItem
()
{
ISelectionService
ww
=
PlatformUI
.
getWorkbench
().
getActiveWorkbenchWindow
().
getSelectionService
();
ww
.
addSelectionListener
(
this
);
}
/** Creates the control holding the step length combo. */
@Override
public
void
fill
(
ToolBar
parent
,
int
index
)
{
toolitem
=
new
ToolItem
(
parent
,
SWT
.
SEPARATOR
,
index
);
upcomingObjectiveCombo
=
new
Combo
(
parent
,
SWT
.
DROP_DOWN
);
upcomingObjectiveCombo
.
addSelectionListener
(
new
SelectionListener
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
// TODO Auto-generated method stub
currentObjective
.
updateObjectiveByName
(((
Combo
)
e
.
getSource
()).
getText
());
}
@Override
public
void
widgetDefaultSelected
(
SelectionEvent
e
)
{
// TODO Auto-generated method stub
// do nothing
}
});
upcomingObjectiveCombo
.
addFocusListener
(
new
FocusListener
()
{
@Override
public
void
focusGained
(
FocusEvent
e
)
{
if
(
currentDevelopmentProcess
!=
null
)
{
List
<
ConstraintConfiguration
>
upcomingConfigs
=
getUpcomingObjectives
();
if
(
upcomingConfigs
.
size
()
!=
0
)
{
List
<
String
>
configNames
=
new
ArrayList
<
String
>();
for
(
ConstraintConfiguration
constraintConfiguration
:
upcomingConfigs
)
{
configNames
.
add
(
constraintConfiguration
.
getName
());
}
String
[]
configNamesArray
=
new
String
[
configNames
.
size
()];
configNames
.
toArray
(
configNamesArray
);
upcomingObjectiveCombo
.
setItems
(
configNamesArray
);
upcomingObjectiveCombo
.
setText
(
configNamesArray
[
0
]);
}
else
{
upcomingObjectiveCombo
.
setText
(
initialObjective
);
}
}
}
@Override
public
void
focusLost
(
FocusEvent
e
)
{
// do nothing
}
});
upcomingObjectiveCombo
.
setItems
(
initialSetOfObjectives
);
upcomingObjectiveCombo
.
setText
(
initialObjective
);
upcomingObjectiveCombo
.
setToolTipText
(
"Set the next modelling objective."
);
toolitem
.
setWidth
(
computeWidth
(
upcomingObjectiveCombo
));
toolitem
.
setControl
(
upcomingObjectiveCombo
);
}
/** Compute Combo Width */
protected
int
computeWidth
(
Control
control
)
{
return
control
.
computeSize
(
SWT
.
DEFAULT
,
SWT
.
DEFAULT
,
true
).
x
;
}
/** {@inheritDoc} */
@Override
public
void
selectionChanged
(
IWorkbenchPart
part
,
ISelection
selection
)
{
// set the current project to the one selected on the navigation tree
if
(
selection
instanceof
ITreeSelection
)
{
if
(((
ITreeSelection
)
selection
).
getFirstElement
()
!=
null
)
{
Object
objectChosenElement
=
((
ITreeSelection
)
selection
).
getFirstElement
();
if
(
objectChosenElement
instanceof
EObject
)
{
EObject
chosenElement
=
(
EObject
)
objectChosenElement
;
FileProjectImpl
fileProject
=
null
;
if
(
chosenElement
instanceof
FileProjectImpl
)
{
fileProject
=
(
FileProjectImpl
)
chosenElement
;
}
else
{
fileProject
=
EcoreUtils
.
getFirstParentWithType
(
chosenElement
,
FileProjectImpl
.
class
);
}
EList
<
IProjectRootElement
>
rootElems
=
fileProject
.
getRootElements
();
// there only exists one root for each project
ProjectConfigurationImpl
config
=
(
ProjectConfigurationImpl
)
rootElems
.
get
(
0
);
EList
<
IProjectConfigurationElement
>
configElements
=
config
.
getConfigurationElements
();
DevelopmentProcessConfiguration
processConfig
=
(
DevelopmentProcessConfiguration
)
configElements
.
get
(
1
);
if
(!(
processConfig
.
getDevelopment
()
instanceof
DummyDevelopmentProcessImpl
))
{
ConstraintBasedDevelopmentProcess
process
=
(
ConstraintBasedDevelopmentProcess
)
processConfig
.
getDevelopment
();
currentDevelopmentProcess
=
process
;
}
}
}