Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
af3
kernel
Commits
b10e799f
Commit
b10e799f
authored
13 years ago
by
Florian Hölzl
Browse files
Options
Downloads
Patches
Plain Diff
added connection compositor base implementation
parent
c97a40c1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/compose/HierarchicElementConnectionCompositorBase.java
+139
-0
139 additions, 0 deletions
...ui/compose/HierarchicElementConnectionCompositorBase.java
with
139 additions
and
0 deletions
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/compose/HierarchicElementConnectionCompositorBase.java
0 → 100644
+
139
−
0
View file @
b10e799f
/*--------------------------------------------------------------------------+
$Id$
| |
| 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.tooling.base.ui.compose
;
import
org.eclipse.emf.ecore.EObject
;
import
org.eclipse.gef.RootEditPart
;
import
org.fortiss.tooling.base.model.element.IConnection
;
import
org.fortiss.tooling.base.model.element.IConnector
;
import
org.fortiss.tooling.base.model.element.IHierarchicElement
;
import
org.fortiss.tooling.base.ui.dnd.DragContext
;
import
org.fortiss.tooling.base.ui.dnd.DropContext
;
import
org.fortiss.tooling.base.ui.editpart.RootEditPartBase
;
import
org.fortiss.tooling.kernel.interfaces.IConnectionContext
;
import
org.fortiss.tooling.kernel.services.ICompositorService
;
/**
* Base implementation for supporting direct connection of two
* {@link IHierarchicElement}s.
*
* <p>
* Sub-classes must implement:
* <UL>
* <LI>
* {@link #createConnection(IHierarchicElement, IHierarchicElement, IConnectionContext)}
* <LI>
* {@link #createSourceConnector(IHierarchicElement, IHierarchicElement, IConnectionContext)}
* <LI>
* {@link #createTargetConnector(IHierarchicElement, IHierarchicElement, IConnectionContext)}
* <LI>
* {@link #getParent(IHierarchicElement, IHierarchicElement, IConnectionContext)}
* </UL>
* These methods are called in order to create specific model elements.
*
* <p>
* Sub-classes may implement {@link #canConnectInterally()} to support internal
* connections. By default connectors of the parent element cannot be connected
* in internal view of the element.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public
abstract
class
HierarchicElementConnectionCompositorBase
<
HE
extends
IHierarchicElement
,
S
extends
IHierarchicElement
,
T
extends
IHierarchicElement
>
implements
org
.
fortiss
.
tooling
.
kernel
.
interfaces
.
IConnector
<
S
,
T
>
{
/**
* Determines whether connectors of the component may be connected
* internally. The default value is <code>false</code>.
*/
protected
boolean
canConnectInterally
()
{
return
false
;
}
/** Creates the application specific {@link IConnection} model element. */
protected
abstract
IConnection
createConnection
(
S
source
,
T
target
,
IConnectionContext
context
);
/**
* Creates the application specific source {@link IConnector} model element.
*/
protected
abstract
IConnector
createSourceConnector
(
S
source
,
T
target
,
IConnectionContext
context
);
/**
* Creates the application specific target {@link IConnector} model element.
*/
protected
abstract
IConnector
createTargetConnector
(
S
source
,
T
target
,
IConnectionContext
context
);
/** Returns the parent model element used to compose the connection. */
protected
abstract
HE
getParent
(
S
source
,
T
target
,
IConnectionContext
context
);
/** {@inheritDoc} */
@Override
public
boolean
canConnect
(
S
source
,
T
target
,
EObject
connection
,
IConnectionContext
context
)
{
if
(
context
instanceof
DragContext
)
{
DragContext
dc
=
(
DragContext
)
context
;
// Is an internal feedback connection allowed?
if
(
dc
.
getSource
()
instanceof
RootEditPartBase
&&
dc
.
getTarget
()
instanceof
RootEditPart
)
{
return
canConnectInterally
();
}
}
// all other connections are allowed by default
return
true
;
}
/** {@inheritDoc} */
@Override
public
void
connect
(
S
source
,
T
target
,
EObject
conn
,
IConnectionContext
context
)
{
// create application specific connection
IConnection
connection
=
createConnection
(
source
,
target
,
context
);
// TODO (FH): use ID fixing here
getParent
(
source
,
target
,
context
).
getConnectionsList
().
add
(
connection
);
// create application specific connectors
IConnector
sourceConnector
=
createSourceConnector
(
source
,
target
,
context
);
IConnector
targetConnector
=
createTargetConnector
(
source
,
target
,
context
);
// TODO (FH): use ID fixing here
// drop source connector
DropContext
sourceDrop
=
context
instanceof
DragContext
?
((
DragContext
)
context
)
.
getSourceDropContext
()
:
null
;
ICompositorService
.
INSTANCE
.
compose
(
source
,
sourceConnector
,
sourceDrop
);
// drop target target connector
DropContext
targetDrop
=
context
instanceof
DragContext
?
((
DragContext
)
context
)
.
getTargetDropContext
()
:
null
;
ICompositorService
.
INSTANCE
.
compose
(
target
,
targetConnector
,
targetDrop
);
// link connection to connectors
connection
.
setSource
(
sourceConnector
);
connection
.
setTarget
(
targetConnector
);
}
}
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