Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
chess
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felicien IHIRWE
chess
Commits
0009fa9a
Commit
0009fa9a
authored
7 years ago
by
Stefano puri
Browse files
Options
Downloads
Patches
Plain Diff
removed unnecessary dependencies
parent
4d5c6bac
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/contracts/org.polarsys.chess.contracts.chessextension/src/org/polarsys/chess/contracts/chessextension/propertytab/BlockEditPartSection.java
+404
-437
404 additions, 437 deletions
...acts/chessextension/propertytab/BlockEditPartSection.java
with
404 additions
and
437 deletions
plugins/contracts/org.polarsys.chess.contracts.chessextension/src/org/polarsys/chess/contracts/chessextension/propertytab/BlockEditPartSection.java
+
404
−
437
View file @
0009fa9a
/*******************************************************************************
/*******************************************************************************
*
*
* Copyright (c) 2013, 2015 Intecs SpA
* Copyright (c) 2013, 2017 Intecs SpA
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-v10.html
*
*
* Contributors:
* Contributors:
* Nicholas Pacini nicholas.pacini@intecs.it
* Nicholas Pacini nicholas.pacini@intecs.it
* Stefano Puri stefano.puri@intecs.it
* Stefano Puri stefano.puri@intecs.it
* Laura Baracchi laura.baracchi@intecs.it
* Laura Baracchi laura.baracchi@intecs.it
* Initial API and implementation and/or initial documentation
* Initial API and implementation and/or initial documentation
*******************************************************************************/
*******************************************************************************/
package
org.polarsys.chess.contracts.chessextension.propertytab
;
package
org.polarsys.chess.contracts.chessextension.propertytab
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Vector
;
import
org.eclipse.emf.common.util.EList
;
import
org.eclipse.emf.cdo.eresource.CDOResourceFolder
;
import
org.eclipse.emf.ecore.EObject
;
import
org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl
;
import
org.eclipse.emf.transaction.RecordingCommand
;
import
org.eclipse.emf.cdo.util.CDOUtil
;
import
org.eclipse.emf.transaction.TransactionalEditingDomain
;
import
org.eclipse.emf.common.util.EList
;
import
org.eclipse.jface.viewers.ISelection
;
import
org.eclipse.emf.ecore.EObject
;
import
org.eclipse.jface.viewers.IStructuredSelection
;
import
org.eclipse.emf.transaction.RecordingCommand
;
import
org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor
;
import
org.eclipse.emf.transaction.TransactionalEditingDomain
;
import
org.eclipse.papyrus.infra.emf.utils.EMFHelper
;
import
org.eclipse.jface.resource.ImageDescriptor
;
import
org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockEditPart
;
import
org.eclipse.jface.util.LocalSelectionTransfer
;
import
org.eclipse.papyrus.sysml.diagram.common.edit.part.ConstraintBlockEditPart
;
import
org.eclipse.jface.viewers.ColumnLabelProvider
;
import
org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart
;
import
org.eclipse.jface.viewers.DoubleClickEvent
;
import
org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentEditPart
;
import
org.eclipse.jface.viewers.IDoubleClickListener
;
import
org.eclipse.papyrus.uml.tools.utils.UMLUtil
;
import
org.eclipse.jface.viewers.ISelection
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.jface.viewers.IStructuredSelection
;
import
org.eclipse.swt.custom.CCombo
;
import
org.eclipse.jface.viewers.StructuredSelection
;
import
org.eclipse.swt.events.FocusEvent
;
import
org.eclipse.jface.viewers.TableViewer
;
import
org.eclipse.swt.events.FocusListener
;
import
org.eclipse.jface.viewers.TableViewerColumn
;
import
org.eclipse.swt.events.SelectionEvent
;
import
org.eclipse.jface.viewers.TreePath
;
import
org.eclipse.swt.events.SelectionListener
;
import
org.eclipse.jface.viewers.TreeSelection
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.opencert.evm.evidspec.evidence.Artefact
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.opencert.sam.arg.arg.Claim
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.opencert.sam.arg.arg.impl.ClaimImpl
;
import
org.eclipse.swt.widgets.Label
;
import
org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor
;
import
org.eclipse.swt.widgets.Text
;
import
org.eclipse.papyrus.infra.emf.utils.EMFHelper
;
import
org.eclipse.ui.IWorkbenchPart
;
import
org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockEditPart
;
import
org.eclipse.ui.views.properties.tabbed.AbstractPropertySection
;
import
org.eclipse.papyrus.sysml.diagram.common.edit.part.ConstraintBlockEditPart
;
import
org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage
;
import
org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart
;
import
org.eclipse.uml2.uml.Class
;
import
org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentEditPart
;
import
org.eclipse.uml2.uml.Constraint
;
import
org.eclipse.papyrus.uml.tools.utils.UMLUtil
;
import
org.eclipse.uml2.uml.LiteralString
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.uml2.uml.Property
;
import
org.eclipse.swt.custom.CCombo
;
import
org.eclipse.uml2.uml.Stereotype
;
import
org.eclipse.swt.dnd.DND
;
import
org.polarsys.chess.contracts.chessextension.popup.actions.SetContractRefinement
;
import
org.eclipse.swt.dnd.Transfer
;
import
org.polarsys.chess.contracts.profile.chesscontract.Contract
;
import
org.eclipse.swt.events.FocusEvent
;
import
org.polarsys.chess.contracts.profile.chesscontract.FormalProperty
;
import
org.eclipse.swt.events.FocusListener
;
import
org.polarsys.chess.service.utils.CHESSEditorUtils
;
import
org.eclipse.swt.events.SelectionEvent
;
import
org.eclipse.swt.events.SelectionListener
;
import
org.eclipse.swt.layout.GridData
;
public
class
BlockEditPartSection
extends
AbstractPropertySection
{
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.Composite
;
public
static
final
String
CONTRACT
=
"CHESSContract::Contract"
;
import
org.eclipse.swt.widgets.Label
;
public
static
final
String
CONTRACT_PROP
=
"CHESSContract::ContractProperty"
;
import
org.eclipse.swt.widgets.Table
;
import
org.eclipse.swt.widgets.TableColumn
;
private
Text
contractText
;
import
org.eclipse.swt.widgets.Text
;
private
Text
assumeText
;
import
org.eclipse.swt.widgets.Tree
;
private
Text
guaranteeText
;
import
org.eclipse.swt.widgets.TreeItem
;
import
org.eclipse.swt.widgets.Button
;
private
Class
contract
;
import
org.eclipse.ui.IEditorPart
;
private
Class
selectedClass
;
import
org.eclipse.ui.IPageLayout
;
import
org.eclipse.ui.IViewPart
;
private
FocusListener
assumeFocusListener
;
import
org.eclipse.ui.IWorkbench
;
private
FocusListener
guaranteeFocusListener
;
import
org.eclipse.ui.IWorkbenchPage
;
private
SelectionListener
contractListListener
;
import
org.eclipse.ui.IWorkbenchPart
;
import
org.eclipse.ui.IWorkbenchWindow
;
private
Label
contractLabel
;
import
org.eclipse.ui.PlatformUI
;
private
CCombo
contractList
;
import
org.eclipse.ui.navigator.resources.ProjectExplorer
;
private
Label
contractListLabel
;
import
org.eclipse.ui.plugin.AbstractUIPlugin
;
import
org.eclipse.ui.views.properties.tabbed.AbstractPropertySection
;
public
BlockEditPartSection
(){
import
org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage
;
import
org.eclipse.uml2.uml.Class
;
contractListListener
=
new
SelectionListener
()
{
import
org.eclipse.uml2.uml.Constraint
;
import
org.eclipse.uml2.uml.LiteralString
;
@Override
import
org.eclipse.uml2.uml.Property
;
public
void
widgetSelected
(
SelectionEvent
e
)
{
import
org.eclipse.uml2.uml.Stereotype
;
String
selection
=
contractList
.
getItem
(
contractList
.
getSelectionIndex
());
import
org.polarsys.chess.contracts.chessextension.popup.actions.SetContractRefinement
;
contract
=
getContract
(
selectedClass
,
selection
);
import
org.polarsys.chess.contracts.profile.chesscontract.Contract
;
if
(
contract
!=
null
){
import
org.polarsys.chess.contracts.profile.chesscontract.FormalProperty
;
setContractPropertyTab
(
contract
);
import
org.polarsys.chess.service.utils.CHESSEditorUtils
;
}
contractLabel
.
setText
(
"Selected Class"
);
contractText
.
setText
(
selectedClass
.
getQualifiedName
());
public
class
BlockEditPartSection
extends
AbstractPropertySection
{
}
public
static
final
String
CONTRACT
=
"CHESSContract::Contract"
;
public
static
final
String
CONTRACT_PROP
=
"CHESSContract::ContractProperty"
;
@Override
public
void
widgetDefaultSelected
(
SelectionEvent
e
)
{
private
Text
contractText
;
// nothing to do here
private
Text
assumeText
;
}
private
Text
guaranteeText
;
};
private
Class
contract
;
assumeFocusListener
=
new
FocusListener
()
{
private
Class
selectedClass
;
private
String
oldAssume
;
private
FocusListener
assumeFocusListener
;
private
FocusListener
guaranteeFocusListener
;
@Override
private
SelectionListener
contractListListener
;
public
void
focusLost
(
FocusEvent
e
)
{
private
Label
contractLabel
;
if
(
assumeText
.
getText
().
equals
(
oldAssume
)){
private
CCombo
contractList
;
return
;
private
Label
contractListLabel
;
}
public
BlockEditPartSection
(){
PapyrusMultiDiagramEditor
editor
=
CHESSEditorUtils
.
getCHESSEditor
();
if
(
editor
!=
null
){
contractListListener
=
new
SelectionListener
()
{
TransactionalEditingDomain
editingDomain
=
(
TransactionalEditingDomain
)
editor
.
getEditingDomain
();
editingDomain
.
getCommandStack
().
execute
(
new
RecordingCommand
(
editingDomain
)
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
@Override
String
selection
=
contractList
.
getItem
(
contractList
.
getSelectionIndex
());
protected
void
doExecute
()
{
contract
=
getContract
(
selectedClass
,
selection
);
//Stereotype stereo = contract.getAppliedStereotype(CONTRACT);
if
(
contract
!=
null
){
Stereotype
stereo
=
UMLUtil
.
getAppliedStereotype
(
contract
,
CONTRACT
,
false
)
;
setContractPropertyTab
(
contract
);
FormalProperty
assumefp
=
(
FormalProperty
)
contract
.
getValue
(
stereo
,
"Assume"
);
}
Constraint
assumeConstr
=
assumefp
.
getBase_Constraint
();
contractLabel
.
setText
(
"Selected Class"
);
LiteralString
assumeSpec
=
(
LiteralString
)
assumeConstr
.
getSpecification
();
contractText
.
setText
(
selectedClass
.
getQualifiedName
());
assumeSpec
.
setValue
(
assumeText
.
getText
());
assumeConstr
.
setSpecification
(
assumeSpec
);
}
}
@Override
public
void
widgetDefaultSelected
(
SelectionEvent
e
)
{
});
// nothing to do here
}
}
};
}
assumeFocusListener
=
new
FocusListener
()
{
@Override
public
void
focusGained
(
FocusEvent
e
)
{
private
String
oldAssume
;
// this is to see if the text has been modified or not
oldAssume
=
assumeText
.
getText
();
@Override
}
public
void
focusLost
(
FocusEvent
e
)
{
};
if
(
assumeText
.
getText
().
equals
(
oldAssume
)){
guaranteeFocusListener
=
new
FocusListener
()
{
return
;
}
private
String
oldGuarantee
;
PapyrusMultiDiagramEditor
editor
=
CHESSEditorUtils
.
getCHESSEditor
();
@Override
if
(
editor
!=
null
){
public
void
focusLost
(
FocusEvent
e
)
{
TransactionalEditingDomain
editingDomain
=
(
TransactionalEditingDomain
)
editor
.
getEditingDomain
();
if
(
assumeText
.
getText
().
equals
(
oldGuarantee
)){
editingDomain
.
getCommandStack
().
execute
(
new
RecordingCommand
(
editingDomain
)
{
return
;
}
@Override
PapyrusMultiDiagramEditor
editor
=
CHESSEditorUtils
.
getCHESSEditor
();
protected
void
doExecute
()
{
if
(
editor
!=
null
){
//Stereotype stereo = contract.getAppliedStereotype(CONTRACT);
Stereotype
stereo
=
UMLUtil
.
getAppliedStereotype
(
contract
,
CONTRACT
,
false
)
;
TransactionalEditingDomain
editingDomain
=
(
TransactionalEditingDomain
)
editor
.
getEditingDomain
();
FormalProperty
assumefp
=
(
FormalProperty
)
contract
.
getValue
(
stereo
,
"Assume"
);
editingDomain
.
getCommandStack
().
execute
(
new
RecordingCommand
(
editingDomain
)
{
Constraint
assumeConstr
=
assumefp
.
getBase_Constraint
();
LiteralString
assumeSpec
=
(
LiteralString
)
assumeConstr
.
getSpecification
();
@Override
assumeSpec
.
setValue
(
assumeText
.
getText
());
protected
void
doExecute
()
{
assumeConstr
.
setSpecification
(
assumeSpec
);
//Stereotype stereo = contract.getAppliedStereotype(CONTRACT);
Stereotype
stereo
=
UMLUtil
.
getAppliedStereotype
(
contract
,
CONTRACT
,
false
)
;
}
FormalProperty
guaranteefp
=
(
FormalProperty
)
contract
.
getValue
(
stereo
,
"Guarantee"
);
});
Constraint
guaranteeConstr
=
guaranteefp
.
getBase_Constraint
();
}
LiteralString
guaranteeSpec
=
(
LiteralString
)
guaranteeConstr
.
getSpecification
();
guaranteeSpec
.
setValue
(
guaranteeText
.
getText
());
}
guaranteeConstr
.
setSpecification
(
guaranteeSpec
);
@Override
}
public
void
focusGained
(
FocusEvent
e
)
{
// this is to see if the text has been modified or not
});
oldAssume
=
assumeText
.
getText
();
//}
}
}
};
}
guaranteeFocusListener
=
new
FocusListener
()
{
@Override
public
void
focusGained
(
FocusEvent
e
)
{
private
String
oldGuarantee
;
// this is to see if the text has been modified or not
oldGuarantee
=
guaranteeText
.
getText
();
@Override
}
public
void
focusLost
(
FocusEvent
e
)
{
};
if
(
assumeText
.
getText
().
equals
(
oldGuarantee
)){
return
;
}
}
PapyrusMultiDiagramEditor
editor
=
CHESSEditorUtils
.
getCHESSEditor
();
private
Class
getContract
(
Class
selectedClass
,
String
selection
)
{
if
(
editor
!=
null
){
String
[]
splitted
=
selection
.
split
(
":"
);
String
propName
=
splitted
[
0
].
trim
();
TransactionalEditingDomain
editingDomain
=
(
TransactionalEditingDomain
)
editor
.
getEditingDomain
();
EList
<
Property
>
attributes
=
selectedClass
.
getAttributes
();
editingDomain
.
getCommandStack
().
execute
(
new
RecordingCommand
(
editingDomain
)
{
Iterator
<
Property
>
it
=
attributes
.
iterator
();
Property
property
=
null
;
@Override
boolean
found
=
false
;
protected
void
doExecute
()
{
while
(
it
.
hasNext
()
&&
!
found
)
{
//Stereotype stereo = contract.getAppliedStereotype(CONTRACT);
Property
attr
=
(
Property
)
it
.
next
();
Stereotype
stereo
=
UMLUtil
.
getAppliedStereotype
(
contract
,
CONTRACT
,
false
)
;
if
(
attr
.
getName
().
equals
(
propName
)
&&
attr
.
getAppliedStereotype
(
CONTRACT_PROP
)
!=
null
){
found
=
true
;
FormalProperty
guaranteefp
=
(
FormalProperty
)
contract
.
getValue
(
stereo
,
"Guarantee"
);
property
=
attr
;
Constraint
guaranteeConstr
=
guaranteefp
.
getBase_Constraint
();
}
LiteralString
guaranteeSpec
=
(
LiteralString
)
guaranteeConstr
.
getSpecification
();
}
guaranteeSpec
.
setValue
(
guaranteeText
.
getText
());
if
(
property
==
null
){
guaranteeConstr
.
setSpecification
(
guaranteeSpec
);
return
null
;
}
}
Class
contract
=
(
Class
)
property
.
getType
();
});
return
contract
;
//}
}
}
}
@Override
public
void
createControls
(
Composite
parent
,
TabbedPropertySheetPage
aTabbedPropertySheetPage
)
{
@Override
public
void
focusGained
(
FocusEvent
e
)
{
super
.
createControls
(
parent
,
aTabbedPropertySheetPage
);
// this is to see if the text has been modified or not
oldGuarantee
=
guaranteeText
.
getText
();
Composite
composite
=
getWidgetFactory
().
createComposite
(
parent
,
SWT
.
NONE
);
}
composite
.
setLayout
(
new
GridLayout
(
4
,
false
));
};
GridData
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
false
);
}
gd
.
horizontalSpan
=
3
;
contractText
=
getWidgetFactory
().
createText
(
composite
,
"no Contract selected"
);
private
Class
getContract
(
Class
selectedClass
,
String
selection
)
{
contractText
.
setEditable
(
false
);
String
[]
splitted
=
selection
.
split
(
":"
);
contractText
.
setLayoutData
(
gd
);
String
propName
=
splitted
[
0
].
trim
();
EList
<
Property
>
attributes
=
selectedClass
.
getAttributes
();
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
false
,
false
);
Iterator
<
Property
>
it
=
attributes
.
iterator
();
contractLabel
=
getWidgetFactory
().
createLabel
(
composite
,
"Selected Contract"
,
SWT
.
NONE
);
Property
property
=
null
;
contractLabel
.
setLayoutData
(
gd
);
boolean
found
=
false
;
while
(
it
.
hasNext
()
&&
!
found
)
{
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
false
,
false
);
Property
attr
=
(
Property
)
it
.
next
();
contractList
=
getWidgetFactory
().
createCCombo
(
composite
,
SWT
.
READ_ONLY
|
SWT
.
BORDER
);
if
(
attr
.
getName
().
equals
(
propName
)
&&
attr
.
getAppliedStereotype
(
CONTRACT_PROP
)
!=
null
){
contractList
.
setVisible
(
false
);
found
=
true
;
gd
.
horizontalSpan
=
3
;
property
=
attr
;
contractList
.
addSelectionListener
(
contractListListener
);
}
contractList
.
setLayoutData
(
gd
);
}
if
(
property
==
null
){
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
false
,
false
);
return
null
;
contractListLabel
=
getWidgetFactory
().
createLabel
(
composite
,
"Contract List"
,
SWT
.
NONE
);
}
contractListLabel
.
setVisible
(
false
);
Class
contract
=
(
Class
)
property
.
getType
();
contractListLabel
.
setLayoutData
(
gd
);
return
contract
;
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
false
,
false
);
}
gd
.
horizontalSpan
=
2
;
Label
assumeLabel
=
getWidgetFactory
().
createLabel
(
composite
,
"Assume"
,
SWT
.
NONE
);
@Override
assumeLabel
.
setLayoutData
(
gd
);
public
void
createControls
(
Composite
parent
,
TabbedPropertySheetPage
aTabbedPropertySheetPage
)
{
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
false
,
false
);
super
.
createControls
(
parent
,
aTabbedPropertySheetPage
);
gd
.
horizontalSpan
=
2
;
Label
guaranteeLabel
=
getWidgetFactory
().
createLabel
(
composite
,
"Guarantee"
,
SWT
.
NONE
);
Composite
composite
=
getWidgetFactory
().
createComposite
(
parent
,
SWT
.
NONE
);
guaranteeLabel
.
setLayoutData
(
gd
);
composite
.
setLayout
(
new
GridLayout
(
4
,
false
));
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
true
);
GridData
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
false
);
assumeText
=
getWidgetFactory
().
createText
(
composite
,
""
,
SWT
.
MULTI
|
SWT
.
H_SCROLL
|
SWT
.
V_SCROLL
);
gd
.
horizontalSpan
=
3
;
gd
.
horizontalSpan
=
2
;
contractText
=
getWidgetFactory
().
createText
(
composite
,
"no Contract selected"
);
gd
.
verticalSpan
=
25
;
contractText
.
setEditable
(
false
);
assumeText
.
addFocusListener
(
assumeFocusListener
);
contractText
.
setLayoutData
(
gd
);
assumeText
.
setLayoutData
(
gd
);
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
false
,
false
);
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
true
);
contractLabel
=
getWidgetFactory
().
createLabel
(
composite
,
"Selected Contract"
,
SWT
.
NONE
);
guaranteeText
=
getWidgetFactory
().
createText
(
composite
,
""
,
SWT
.
MULTI
|
SWT
.
H_SCROLL
|
SWT
.
V_SCROLL
);
contractLabel
.
setLayoutData
(
gd
);
gd
.
horizontalSpan
=
2
;
gd
.
verticalSpan
=
25
;
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
false
,
false
);
guaranteeText
.
addFocusListener
(
guaranteeFocusListener
);
contractList
=
getWidgetFactory
().
createCCombo
(
composite
,
SWT
.
READ_ONLY
|
SWT
.
BORDER
);
guaranteeText
.
setLayoutData
(
gd
);
contractList
.
setVisible
(
false
);
gd
.
horizontalSpan
=
3
;
contractList
.
addSelectionListener
(
contractListListener
);
}
contractList
.
setLayoutData
(
gd
);
@SuppressWarnings
({
"rawtypes"
})
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
false
,
false
);
@Override
contractListLabel
=
getWidgetFactory
().
createLabel
(
composite
,
"Contract List"
,
SWT
.
NONE
);
public
void
setInput
(
IWorkbenchPart
part
,
ISelection
selection
)
{
contractListLabel
.
setVisible
(
false
);
super
.
setInput
(
part
,
selection
);
contractListLabel
.
setLayoutData
(
gd
);
if
(!(
selection
instanceof
IStructuredSelection
)){
cleanPropertyTab
();
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
false
,
false
);
return
;
gd
.
horizontalSpan
=
2
;
}
Label
assumeLabel
=
getWidgetFactory
().
createLabel
(
composite
,
"Assume"
,
SWT
.
NONE
);
List
<?>
selectionList
=
((
IStructuredSelection
)
selection
).
toList
();
assumeLabel
.
setLayoutData
(
gd
);
if
(
selectionList
.
size
()
==
1
)
{
Object
selected
=
selectionList
.
get
(
0
);
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
false
,
false
);
gd
.
horizontalSpan
=
2
;
EObject
selectedEObject
=
EMFHelper
.
getEObject
(
selected
);
Label
guaranteeLabel
=
getWidgetFactory
().
createLabel
(
composite
,
"Guarantee"
,
SWT
.
NONE
);
if
(
selectedEObject
!=
null
){
guaranteeLabel
.
setLayoutData
(
gd
);
//do something
}
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
true
);
if
(
selected
instanceof
ConstraintBlockEditPart
){
assumeText
=
getWidgetFactory
().
createText
(
composite
,
""
,
SWT
.
MULTI
|
SWT
.
H_SCROLL
|
SWT
.
V_SCROLL
);
Class
clazz
=
(
Class
)
(((
ConstraintBlockEditPart
)
selected
).
resolveSemanticElement
());
gd
.
horizontalSpan
=
2
;
//check if it's a contract
gd
.
verticalSpan
=
25
;
//if(clazz.getAppliedStereotype(CONTRACT) != null){
assumeText
.
addFocusListener
(
assumeFocusListener
);
if
(
UMLUtil
.
getAppliedStereotype
(
clazz
,
CONTRACT
,
false
)!=
null
){
assumeText
.
setLayoutData
(
gd
);
cleanPropertyTab
();
gd
=
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
true
);
setContractPropertyTab
(
clazz
);
guaranteeText
=
getWidgetFactory
().
createText
(
composite
,
""
,
SWT
.
MULTI
|
SWT
.
H_SCROLL
|
SWT
.
V_SCROLL
);
}
gd
.
horizontalSpan
=
2
;
}
else
if
(
selected
instanceof
BlockEditPart
){;
gd
.
verticalSpan
=
25
;
Class
clazz
=
(
Class
)
(((
BlockEditPart
)
selected
).
resolveSemanticElement
());
guaranteeText
.
addFocusListener
(
guaranteeFocusListener
);
initContractList
(
clazz
);
guaranteeText
.
setLayoutData
(
gd
);
}
else
if
(
selected
instanceof
ClassEditPart
){
Class
clazz
=
(
Class
)
(((
ClassEditPart
)
selected
).
resolveSemanticElement
());
}
//check if it's a contract
//if(clazz.getAppliedStereotype(CONTRACT) != null){
@SuppressWarnings
({
"rawtypes"
})
if
(
UMLUtil
.
getAppliedStereotype
(
clazz
,
CONTRACT
,
false
)!=
null
){
@Override
cleanPropertyTab
();
public
void
setInput
(
IWorkbenchPart
part
,
ISelection
selection
)
{
setContractPropertyTab
(
clazz
);
super
.
setInput
(
part
,
selection
);
}
else
{
if
(!(
selection
instanceof
IStructuredSelection
)){
initContractList
(
clazz
);
cleanPropertyTab
();
}
return
;
}
}
else
if
(
selected
instanceof
ComponentEditPart
){
List
<?>
selectionList
=
((
IStructuredSelection
)
selection
).
toList
();
Class
clazz
=
(
Class
)
(((
ComponentEditPart
)
selected
).
resolveSemanticElement
());
if
(
selectionList
.
size
()
==
1
)
{
initContractList
(
clazz
);
Object
selected
=
selectionList
.
get
(
0
);
}
else
if
(
selectedEObject
instanceof
Class
){
EObject
selectedEObject
=
EMFHelper
.
getEObject
(
selected
);
if
(
selectedEObject
!=
null
){
Class
clazz
=
(
Class
)
selectedEObject
;
//do something
//if(clazz.getAppliedStereotype(CONTRACT) != null){
}
if
(
UMLUtil
.
getAppliedStereotype
(
clazz
,
CONTRACT
,
false
)!=
null
){
if
(
selected
instanceof
ConstraintBlockEditPart
){
cleanPropertyTab
();
Class
clazz
=
(
Class
)
(((
ConstraintBlockEditPart
)
selected
).
resolveSemanticElement
());
setContractPropertyTab
(
clazz
);
//check if it's a contract
}
else
{
//if(clazz.getAppliedStereotype(CONTRACT) != null){
initContractList
(
clazz
);
if
(
UMLUtil
.
getAppliedStereotype
(
clazz
,
CONTRACT
,
false
)!=
null
){
}
cleanPropertyTab
();
}
setContractPropertyTab
(
clazz
);
else
{
}
cleanPropertyTab
();
}
else
if
(
selected
instanceof
BlockEditPart
){;
}
Class
clazz
=
(
Class
)
(((
BlockEditPart
)
selected
).
resolveSemanticElement
());
}
else
{
initContractList
(
clazz
);
cleanPropertyTab
();
}
}
else
if
(
selected
instanceof
ClassEditPart
){
Class
clazz
=
(
Class
)
(((
ClassEditPart
)
selected
).
resolveSemanticElement
());
//check if it's a contract
//fill claims list
//if(clazz.getAppliedStereotype(CONTRACT) != null){
if
(
contract
!=
null
){
if
(
UMLUtil
.
getAppliedStereotype
(
clazz
,
CONTRACT
,
false
)!=
null
){
cleanPropertyTab
();
//Stereotype stereo = contract.getAppliedStereotype(BlockEditPartSection.CONTRACT);
setContractPropertyTab
(
clazz
);
Stereotype
stereo
=
UMLUtil
.
getAppliedStereotype
(
contract
,
BlockEditPartSection
.
CONTRACT
,
false
);
}
else
{
Contract
contractStereo
=
(
Contract
)
contract
.
getStereotypeApplication
(
stereo
);
initContractList
(
clazz
);
}
}
}
else
if
(
selected
instanceof
ComponentEditPart
){
//fill supportedBy artifact list
Class
clazz
=
(
Class
)
(((
ComponentEditPart
)
selected
).
resolveSemanticElement
());
if
(
contract
!=
null
){
initContractList
(
clazz
);
}
//Stereotype stereo = contract.getAppliedStereotype(BlockEditPartSection.CONTRACT);
else
if
(
selectedEObject
instanceof
Class
){
Stereotype
stereo
=
UMLUtil
.
getAppliedStereotype
(
contract
,
BlockEditPartSection
.
CONTRACT
,
false
);
Contract
contractStereo
=
(
Contract
)
contract
.
getStereotypeApplication
(
stereo
);
Class
clazz
=
(
Class
)
selectedEObject
;
//if(clazz.getAppliedStereotype(CONTRACT) != null){
}
if
(
UMLUtil
.
getAppliedStereotype
(
clazz
,
CONTRACT
,
false
)!=
null
){
}
cleanPropertyTab
();
setContractPropertyTab
(
clazz
);
private
void
initContractList
(
Class
clazz
)
{
}
else
{
cleanPropertyTab
();
initContractList
(
clazz
);
selectedClass
=
clazz
;
}
contractText
.
setText
(
selectedClass
.
getQualifiedName
());
contractLabel
.
setText
(
"Selected Class"
);
}
contractList
.
setVisible
(
true
);
else
{
contractListLabel
.
setVisible
(
true
);
cleanPropertyTab
();
for
(
Property
prop
:
selectedClass
.
getAttributes
())
{
}
if
(
prop
.
getAppliedStereotype
(
SetContractRefinement
.
CONTRACT_PROPERTY
)
!=
null
){
}
else
{
if
(
prop
.
getType
()
==
null
){
cleanPropertyTab
();
contractList
.
add
(
prop
.
getName
()
+
" : <TYPE NOT DEFINED>"
);
}
}
else
{
contractList
.
add
(
prop
.
getName
()
+
" : "
+
prop
.
getType
().
getName
());
}
//fill claims list
}
if
(
contract
!=
null
){
}
}
//Stereotype stereo = contract.getAppliedStereotype(BlockEditPartSection.CONTRACT);
Stereotype
stereo
=
UMLUtil
.
getAppliedStereotype
(
contract
,
BlockEditPartSection
.
CONTRACT
,
false
);
private
void
setContractPropertyTab
(
Class
clazz
)
{
Contract
contractStereo
=
(
Contract
)
contract
.
getStereotypeApplication
(
stereo
);
contract
=
clazz
;
contractLabel
.
setText
(
"Selected Contract"
);
}
contractText
.
setText
(
clazz
.
getQualifiedName
());
//Stereotype contrStereo = clazz.getAppliedStereotype(CONTRACT);
//fill supportedBy artifact list
Stereotype
contrStereo
=
UMLUtil
.
getAppliedStereotype
(
clazz
,
CONTRACT
,
false
);
if
(
contract
!=
null
){
FormalProperty
assumefp
=
(
FormalProperty
)
clazz
.
getValue
(
contrStereo
,
"Assume"
);
FormalProperty
guaranteefp
=
(
FormalProperty
)
clazz
.
getValue
(
contrStereo
,
"Guarantee"
);
//Stereotype stereo = contract.getAppliedStereotype(BlockEditPartSection.CONTRACT);
String
assume
=
""
;
Stereotype
stereo
=
UMLUtil
.
getAppliedStereotype
(
contract
,
BlockEditPartSection
.
CONTRACT
,
false
);
if
(
assumefp
!=
null
)
Contract
contractStereo
=
(
Contract
)
contract
.
getStereotypeApplication
(
stereo
);
assume
=
assumefp
.
getBase_Constraint
().
getSpecification
().
stringValue
();
String
guarantee
=
""
;
}
if
(
guaranteefp
!=
null
)
}
guarantee
=
guaranteefp
.
getBase_Constraint
().
getSpecification
().
stringValue
();
if
(
assume
!=
null
){
private
void
initContractList
(
Class
clazz
)
{
assumeText
.
setText
(
assume
);
cleanPropertyTab
();
}
selectedClass
=
clazz
;
if
(
guarantee
!=
null
){
contractText
.
setText
(
selectedClass
.
getQualifiedName
());
guaranteeText
.
setText
(
guarantee
);
contractLabel
.
setText
(
"Selected Class"
);
}
contractList
.
setVisible
(
true
);
contractListLabel
.
setVisible
(
true
);
Contract
contractStereo
=
(
Contract
)
contract
.
getStereotypeApplication
(
contrStereo
);
for
(
Property
prop
:
selectedClass
.
getAttributes
())
{
if
(
prop
.
getAppliedStereotype
(
SetContractRefinement
.
CONTRACT_PROPERTY
)
!=
null
){
}
if
(
prop
.
getType
()
==
null
){
contractList
.
add
(
prop
.
getName
()
+
" : <TYPE NOT DEFINED>"
);
private
void
cleanPropertyTab
()
{
}
else
{
contractLabel
.
setText
(
"Selected Contract"
);
contractList
.
add
(
prop
.
getName
()
+
" : "
+
prop
.
getType
().
getName
());
contractText
.
setText
(
"no Contract selected"
);
}
assumeText
.
setText
(
""
);
}
guaranteeText
.
setText
(
""
);
}
contract
=
null
;
}
contractList
.
removeAll
();
contractList
.
setVisible
(
false
);
private
void
setContractPropertyTab
(
Class
clazz
)
{
contractListLabel
.
setVisible
(
false
);
contract
=
clazz
;
contractLabel
.
setText
(
"Selected Contract"
);
}
contractText
.
setText
(
clazz
.
getQualifiedName
());
//Stereotype contrStereo = clazz.getAppliedStereotype(CONTRACT);
Stereotype
contrStereo
=
UMLUtil
.
getAppliedStereotype
(
clazz
,
CONTRACT
,
false
);
FormalProperty
assumefp
=
(
FormalProperty
)
clazz
.
getValue
(
contrStereo
,
"Assume"
);
FormalProperty
guaranteefp
=
(
FormalProperty
)
clazz
.
getValue
(
contrStereo
,
"Guarantee"
);
String
assume
=
""
;
if
(
assumefp
!=
null
)
}
assume
=
assumefp
.
getBase_Constraint
().
getSpecification
().
stringValue
();
String
guarantee
=
""
;
if
(
guaranteefp
!=
null
)
guarantee
=
guaranteefp
.
getBase_Constraint
().
getSpecification
().
stringValue
();
if
(
assume
!=
null
){
assumeText
.
setText
(
assume
);
}
if
(
guarantee
!=
null
){
guaranteeText
.
setText
(
guarantee
);
}
Contract
contractStereo
=
(
Contract
)
contract
.
getStereotypeApplication
(
contrStereo
);
}
private
void
cleanPropertyTab
()
{
contractLabel
.
setText
(
"Selected Contract"
);
contractText
.
setText
(
"no Contract selected"
);
assumeText
.
setText
(
""
);
guaranteeText
.
setText
(
""
);
contract
=
null
;
contractList
.
removeAll
();
contractList
.
setVisible
(
false
);
contractListLabel
.
setVisible
(
false
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment