Skip to content
GitLab
Menu
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
c6b75df4
Commit
c6b75df4
authored
Jul 17, 2012
by
Daniel Ratiu
Browse files
code cleanings - duplication in BehaviorCompositor is removed
parent
10c5cf70
Changes
5
Hide whitespace changes
Inline
Side-by-side
org.fortiss.af3.component.ui/trunk/src/org/fortiss/af3/component/ui/compose/BehaviorComponentCompositor.java
View file @
c6b75df4
...
...
@@ -17,16 +17,9 @@ $Id$
+--------------------------------------------------------------------------*/
package
org.fortiss.af3.component.ui.compose
;
import
static
org
.
conqat
.
lib
.
commons
.
reflect
.
ReflectionUtils
.
pickInstanceOf
;
import
static
org
.
fortiss
.
af3
.
component
.
utils
.
ComponentArchitectureUtils
.
isAtomicComponent
;
import
org.eclipse.emf.ecore.EObject
;
import
org.fortiss.af3.component.model.Component
;
import
org.fortiss.af3.component.model.behavior.code.CodeSpecification
;
import
org.fortiss.tooling.base.decompose.HierarchicElementCompositorBase
;
import
org.fortiss.tooling.base.model.element.IModelElementSpecification
;
import
org.fortiss.tooling.kernel.extension.data.IElementCompositionContext
;
import
org.fortiss.tooling.kernel.extension.data.Prototype
;
/**
* Element compositor for {@link Component} and behavior (CodeSpecification
...
...
@@ -37,51 +30,11 @@ import org.fortiss.tooling.kernel.extension.data.Prototype;
* @version $Rev$
* @ConQAT.Rating GREEN Hash: F07C1C3ACA2483FFAA4C1D477EF6DEE4
*/
public
class
BehaviorComponentCompositor
extends
HierarchicElementCompositorBase
<
Component
>
{
public
class
BehaviorComponentCompositor
extends
BehaviorComponentCompositorBase
<
Component
>
{
/** {@inheritDoc} */
@Override
public
boolean
canCompose
(
Component
container
,
EObject
contained
,
IElementCompositionContext
context
)
{
// 1) does not allow composition with component architecture root
// component
// 2) does not allow to add the same specification twice; however
// different specifications are allowed
// 3) does not allow behavior specification, if container has a
// subcomponent (see ticket #458)
return
isCorrectElementClass
(
contained
)
&&
container
.
eContainer
()
instanceof
Component
// 2)
&&
pickInstanceOf
(
contained
.
getClass
(),
container
.
getSpecificationsList
())
==
null
// 3)
&&
isAtomicComponent
(
container
);
}
/** Tests the class of the given element. */
private
boolean
isCorrectElementClass
(
EObject
element
)
{
protected
boolean
isCorrectElementClass
(
EObject
element
)
{
return
element
instanceof
CodeSpecification
;
}
/** {@inheritDoc} */
@Override
public
boolean
canComposePrototype
(
Prototype
prototype
)
{
return
isCorrectElementClass
(
prototype
.
getPrototype
());
}
/** {@inheritDoc} */
@Override
public
boolean
compose
(
Component
container
,
EObject
contained
,
IElementCompositionContext
context
)
{
container
.
getSpecificationsList
().
add
(
(
IModelElementSpecification
)
contained
);
return
true
;
}
/** {@inheritDoc} */
@Override
public
boolean
canDecompose
(
EObject
contained
)
{
return
isCorrectElementClass
(
contained
);
}
}
org.fortiss.af3.component.ui/trunk/src/org/fortiss/af3/component/ui/compose/BehaviorComponentCompositorBase.java
0 → 100644
View file @
c6b75df4
/*--------------------------------------------------------------------------+
$Id: BehaviorComponentCompositor.java 2798 2012-01-16 13:15:45Z becker $
| |
| Copyright 2011 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.component.ui.compose
;
import
static
org
.
conqat
.
lib
.
commons
.
reflect
.
ReflectionUtils
.
pickInstanceOf
;
import
static
org
.
fortiss
.
af3
.
component
.
utils
.
ComponentArchitectureUtils
.
addSpecification
;
import
static
org
.
fortiss
.
af3
.
component
.
utils
.
ComponentArchitectureUtils
.
isAtomicComponent
;
import
org.eclipse.emf.ecore.EObject
;
import
org.fortiss.af3.component.model.Component
;
import
org.fortiss.tooling.base.decompose.HierarchicElementCompositorBase
;
import
org.fortiss.tooling.base.model.element.IModelElementSpecification
;
import
org.fortiss.tooling.kernel.extension.data.IElementCompositionContext
;
import
org.fortiss.tooling.kernel.extension.data.Prototype
;
/**
* Base class for different compositors for behaviors of components.
*
* @author hoelzl
* @author becker
* @author $Author: becker $
* @version $Rev: 2798 $
* @ConQAT.Rating GREEN Hash: F07C1C3ACA2483FFAA4C1D477EF6DEE4
*/
public
abstract
class
BehaviorComponentCompositorBase
<
T
extends
Component
>
extends
HierarchicElementCompositorBase
<
T
>
{
/** {@inheritDoc} */
@Override
public
boolean
canCompose
(
T
container
,
EObject
contained
,
IElementCompositionContext
context
)
{
if
(!
isCorrectElementClass
(
contained
))
{
return
false
;
}
// @CodeFormatterOff
// 1) does not allow composition with component architecture root component
// 2) does not allow to add the same specification twice; however different specifications are allowed
// 3) does not allow behavior specification, if container has a subcomponent (see ticket #458)
return
container
.
eContainer
()
instanceof
Component
// 1
&&
pickInstanceOf
(
contained
.
getClass
(),
container
.
getSpecificationsList
())
==
null
// 2)
&&
isAtomicComponent
(
container
);
// 3)
// @CodeFormatterOn
}
/** Tests the class of the given element. */
protected
abstract
boolean
isCorrectElementClass
(
EObject
element
);
/** {@inheritDoc} */
@Override
public
boolean
canComposePrototype
(
Prototype
prototype
)
{
return
isCorrectElementClass
(
prototype
.
getPrototype
());
}
/** {@inheritDoc} */
@Override
public
boolean
compose
(
T
container
,
EObject
contained
,
IElementCompositionContext
context
)
{
addSpecification
(
container
,
(
IModelElementSpecification
)
contained
);
return
true
;
}
/** {@inheritDoc} */
@Override
public
boolean
canDecompose
(
EObject
contained
)
{
return
isCorrectElementClass
(
contained
);
}
}
org.fortiss.af3.mira/trunk/src/org/fortiss/af3/mira/prototype/PrototypeProvider.java
View file @
c6b75df4
...
...
@@ -68,8 +68,8 @@ public class PrototypeProvider extends PrototypeProviderBase {
registerPrimaryPrototype
(
"Entry"
,
createGlossaryEntry
(
""
,
""
,
""
),
CATEGORY_NAME
);
// register functional requirement
registerPrimaryPrototype
(
"F
orm
al Specification"
,
createFunctionalSpecification
(
"F
orm
al Specification"
),
CATEGORY_NAME
);
registerPrimaryPrototype
(
"F
unction
al Specification"
,
createFunctionalSpecification
(
"F
unction
al Specification"
),
CATEGORY_NAME
);
}
}
org.fortiss.af3.mode.ui/trunk/src/org/fortiss/af3/mode/ui/compose/BehaviorComponentCompositor.java
View file @
c6b75df4
...
...
@@ -17,75 +17,24 @@ $Id$
+--------------------------------------------------------------------------*/
package
org.fortiss.af3.mode.ui.compose
;
import
static
org
.
conqat
.
lib
.
commons
.
reflect
.
ReflectionUtils
.
pickInstanceOf
;
import
static
org
.
fortiss
.
af3
.
component
.
utils
.
ComponentArchitectureUtils
.
addSpecification
;
import
static
org
.
fortiss
.
af3
.
component
.
utils
.
ComponentArchitectureUtils
.
isAtomicComponent
;
import
org.eclipse.emf.ecore.EObject
;
import
org.fortiss.af3.component.model.Component
;
import
org.fortiss.af3.component.ui.compose.BehaviorComponentCompositorBase
;
import
org.fortiss.af3.mode.model.ModeAutomaton
;
import
org.fortiss.tooling.base.decompose.HierarchicElementCompositorBase
;
import
org.fortiss.tooling.base.model.element.IModelElementSpecification
;
import
org.fortiss.tooling.kernel.extension.data.IElementCompositionContext
;
import
org.fortiss.tooling.kernel.extension.data.Prototype
;
/**
* Element compositor for {@link Component} and
behavior (
ModeAutomaton
)
.
* Element compositor for {@link Component} and
{@link
ModeAutomaton
}
.
*
* @author li
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: FE78412BDD3C2324405E01A9E63D8057
*/
public
class
BehaviorComponentCompositor
extends
HierarchicElementCompositorBase
<
Component
>
{
public
class
BehaviorComponentCompositor
extends
BehaviorComponentCompositorBase
<
Component
>
{
/** {@inheritDoc} */
@Override
public
boolean
canCompose
(
Component
container
,
EObject
contained
,
IElementCompositionContext
context
)
{
// 1) does not allow composition with component architecture root
// component
// 2) does not allow to add the same specification twice; however
// different specifications are allowed
// 3) does not allow to add a Mode-Switch-Specification to a component
// that has sub-components (see ticket #458)
return
isCorrectElementClass
(
contained
)
// 1)
&&
container
.
eContainer
()
instanceof
Component
// 2)
&&
pickInstanceOf
(
contained
.
getClass
(),
container
.
getSpecificationsList
())
==
null
// 3)
&&
isAtomicComponent
(
container
);
}
/**
* Tests the class of the given element, whether it is a
* {@link ModeAutomaton}.
*/
private
boolean
isCorrectElementClass
(
EObject
element
)
{
protected
boolean
isCorrectElementClass
(
EObject
element
)
{
return
element
instanceof
ModeAutomaton
;
}
/** {@inheritDoc} */
@Override
public
boolean
canComposePrototype
(
Prototype
prototype
)
{
return
isCorrectElementClass
(
prototype
.
getPrototype
());
}
/** {@inheritDoc} */
@Override
public
boolean
compose
(
Component
container
,
EObject
contained
,
IElementCompositionContext
context
)
{
addSpecification
(
container
,
(
IModelElementSpecification
)
contained
);
return
true
;
}
/** {@inheritDoc} */
@Override
public
boolean
canDecompose
(
EObject
contained
)
{
return
isCorrectElementClass
(
contained
);
}
}
org.fortiss.af3.state.ui/trunk/src/org/fortiss/af3/state/ui/compose/BehaviorComponentCompositor.java
View file @
c6b75df4
...
...
@@ -17,19 +17,13 @@ $Id$
+--------------------------------------------------------------------------*/
package
org.fortiss.af3.state.ui.compose
;
import
static
org
.
fortiss
.
af3
.
component
.
utils
.
ComponentArchitectureUtils
.
addSpecification
;
import
org.conqat.lib.commons.reflect.ReflectionUtils
;
import
org.eclipse.emf.ecore.EObject
;
import
org.fortiss.af3.component.model.Component
;
import
org.fortiss.af3.component.ui.compose.BehaviorComponentCompositorBase
;
import
org.fortiss.af3.state.model.StateAutomaton
;
import
org.fortiss.tooling.base.decompose.HierarchicElementCompositorBase
;
import
org.fortiss.tooling.base.model.element.IModelElementSpecification
;
import
org.fortiss.tooling.kernel.extension.data.IElementCompositionContext
;
import
org.fortiss.tooling.kernel.extension.data.Prototype
;
/**
* Element compositor for {@link Component} and
behavior (
StateAutomaton
)
.
* Element compositor for {@link Component} and
{@link
StateAutomaton
}
.
*
* @author hoelzl
* @author becker
...
...
@@ -37,52 +31,11 @@ import org.fortiss.tooling.kernel.extension.data.Prototype;
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 1CE52A79CC6946EB8054390B400AC780
*/
public
class
BehaviorComponentCompositor
extends
HierarchicElementCompositorBase
<
Component
>
{
public
class
BehaviorComponentCompositor
extends
BehaviorComponentCompositorBase
<
Component
>
{
/** {@inheritDoc} */
@Override
public
boolean
canCompose
(
Component
container
,
EObject
contained
,
IElementCompositionContext
context
)
{
// 1) does not allow composition with component architecture root
// component
// 2) does not allow to add the same specification twice; however
// different specifications are allowed
// 3) does not allow behavior specification, if container has a
// subcomponent (see ticket #458)
return
isCorrectElementClass
(
contained
)
&&
container
.
eContainer
()
instanceof
Component
// 2)
&&
ReflectionUtils
.
pickInstanceOf
(
contained
.
getClass
(),
container
.
getSpecificationsList
())
==
null
// 3)
&&
ReflectionUtils
.
pickInstanceOf
(
Component
.
class
,
container
.
getContainedElementsList
())
==
null
;
}
/** Tests the class of the given element. */
private
boolean
isCorrectElementClass
(
EObject
element
)
{
protected
boolean
isCorrectElementClass
(
EObject
element
)
{
return
element
instanceof
StateAutomaton
;
}
/** {@inheritDoc} */
@Override
public
boolean
canComposePrototype
(
Prototype
prototype
)
{
return
isCorrectElementClass
(
prototype
.
getPrototype
());
}
/** {@inheritDoc} */
@Override
public
boolean
compose
(
Component
container
,
EObject
contained
,
IElementCompositionContext
context
)
{
addSpecification
(
container
,
(
IModelElementSpecification
)
contained
);
return
true
;
}
/** {@inheritDoc} */
@Override
public
boolean
canDecompose
(
EObject
contained
)
{
return
isCorrectElementClass
(
contained
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment