Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frascati
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
114
Issues
114
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
frascati
frascati
Commits
9fe2f1b5
Commit
9fe2f1b5
authored
Jan 28, 2010
by
Christophe Demarey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explorer is now able to dynamically add & remove intents.
parent
92e263a6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
204 additions
and
9 deletions
+204
-9
explorer/core/src/main/java/org/ow2/frascati/explorer/action/AbstractAlwaysEnabledMenuItem.java
...ascati/explorer/action/AbstractAlwaysEnabledMenuItem.java
+11
-1
explorer/core/src/main/java/org/ow2/frascati/explorer/action/AddIntentOnDropAction.java
...g/ow2/frascati/explorer/action/AddIntentOnDropAction.java
+2
-7
explorer/core/src/main/java/org/ow2/frascati/explorer/action/RemoveIntentMenuItem.java
...rg/ow2/frascati/explorer/action/RemoveIntentMenuItem.java
+185
-0
explorer/core/src/main/java/org/ow2/frascati/explorer/context/IntentWrapper.java
...java/org/ow2/frascati/explorer/context/IntentWrapper.java
+1
-1
explorer/core/src/main/resources/sca.xml
explorer/core/src/main/resources/sca.xml
+5
-0
No files found.
explorer/core/src/main/java/org/ow2/frascati/explorer/action/AbstractAlwaysEnabledMenuItem.java
View file @
9fe2f1b5
...
...
@@ -51,13 +51,23 @@ public abstract class AbstractAlwaysEnabledMenuItem<T> implements MenuItem {
/**
* @see org.objectweb.util.explorer.api.MenuItem#actionPerformed(org.objectweb.util.explorer.api.MenuItemTreeView)
*/
@SuppressWarnings
(
"unchecked"
)
public
void
actionPerformed
(
final
MenuItemTreeView
e
)
{
// Obtains the selected object.
T
selected
=
(
T
)
e
.
getSelectedObject
();
// Execute something on the selected object.
execute
(
selected
);
execute
(
selected
,
e
);
}
/**
* Execute something on the selected object.
*
* Can be override in sub-classes.
*/
protected
void
execute
(
T
selected
,
final
MenuItemTreeView
e
)
{
execute
(
selected
);
}
// --------------------------------------------------------------------------
// Abstract methods implemented into concrete subclasses.
// --------------------------------------------------------------------------
...
...
explorer/core/src/main/java/org/ow2/frascati/explorer/action/AddIntentOnDropAction.java
View file @
9fe2f1b5
...
...
@@ -37,15 +37,14 @@ import org.objectweb.fractal.explorer.context.ClientInterfaceWrapper;
import
org.objectweb.fractal.util.Fractal
;
import
org.objectweb.util.explorer.api.DropAction
;
import
org.objectweb.util.explorer.api.DropTreeView
;
import
org.objectweb.util.explorer.api.MenuItem
;
import
org.ow2.frascati.tinfi.TinfiDomain
;
import
org.ow2.frascati.tinfi.control.intent.IntentHandler
;
import
org.ow2.frascati.tinfi.control.intent.SCABasicIntentController
;
/**
* This class provides the ability dynamically add an intent
* on an SCA service (or an SCA reference) via
the "Add intent"
*
Menu item {@link MenuItem
}.
* on an SCA service (or an SCA reference) via
a DropAction
*
{@link DropAction
}.
*
* @author Christophe Demarey
*/
...
...
@@ -135,8 +134,6 @@ public class AddIntentOnDropAction implements DropAction
}
try
{
// Stop intent component
Fractal
.
getLifeCycleController
(
intent
).
stopFc
();
// Stop owner component
Fractal
.
getLifeCycleController
(
owner
).
stopFc
();
// Get intent handler
...
...
@@ -148,8 +145,6 @@ public class AddIntentOnDropAction implements DropAction
}
else
{
ic
.
addFcIntentHandler
(
h
);
}
// Start intent component
Fractal
.
getLifeCycleController
(
intent
).
startFc
();
// Start owner component
Fractal
.
getLifeCycleController
(
owner
).
startFc
();
}
catch
(
Exception
e1
)
{
...
...
explorer/core/src/main/java/org/ow2/frascati/explorer/action/RemoveIntentMenuItem.java
0 → 100644
View file @
9fe2f1b5
/***
* OW2 FraSCAti Explorer
* Copyright (C) 2008-2010 INRIA, USTL
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: frascati@ow2.org
*
* Author: Christophe Demarey
*
* Contributor(s):
*/
package
org.ow2.frascati.explorer.action
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
javax.swing.JOptionPane
;
import
org.objectweb.fractal.api.Component
;
import
org.objectweb.fractal.api.Interface
;
import
org.objectweb.fractal.api.NoSuchInterfaceException
;
import
org.objectweb.fractal.api.control.IllegalLifeCycleException
;
import
org.objectweb.fractal.explorer.context.ClientInterfaceWrapper
;
import
org.objectweb.fractal.util.Fractal
;
import
org.objectweb.util.explorer.api.MenuItem
;
import
org.objectweb.util.explorer.api.MenuItemTreeView
;
import
org.ow2.frascati.explorer.context.IntentWrapper
;
import
org.ow2.frascati.tinfi.TinfiDomain
;
import
org.ow2.frascati.tinfi.control.intent.IntentHandler
;
import
org.ow2.frascati.tinfi.control.intent.SCABasicIntentController
;
/**
* This class provides the ability dynamically remove an intent
* from an SCA service (or an SCA reference) via the "Remove intent"
* Menu item {@link MenuItem}.
*
* @author Christophe Demarey
*/
public
class
RemoveIntentMenuItem
extends
AbstractAlwaysEnabledMenuItem
<
IntentWrapper
>
{
// --------------------------------------------------------------------------
// Internal state
// --------------------------------------------------------------------------
public
static
final
Logger
log
=
Logger
.
getLogger
(
"org.ow2.frascati.explorer.action.RemoveIntentMenuItem"
);
// --------------------------------------------------------------------------
// Internal methods
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// Constructor
// --------------------------------------------------------------------------
/**
* The default constructor.
*/
public
RemoveIntentMenuItem
()
{
}
// --------------------------------------------------------------------------
// Public methods.
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// Implementation of the MenuItem interface
// --------------------------------------------------------------------------
/**
* @see org.ow2.frascati.explorer.action.AbstractAlwaysEnabledMenuItem#execute(Object, MenuItemTreeView)
*/
@Override
protected
void
execute
(
IntentWrapper
selected
)
{
// Need to implement this method but useless!
}
/**
* @see org.ow2.frascati.explorer.action.AbstractAlwaysEnabledMenuItem#execute(Object, MenuItemTreeView)
*/
@Override
protected
void
execute
(
IntentWrapper
selected
,
final
MenuItemTreeView
tree
)
{
Component
intent
=
selected
.
getIntent
(),
itfOwner
=
null
;
Object
parent
=
tree
.
getParentEntry
().
getValue
();
Interface
itf
=
null
;
SCABasicIntentController
ic
=
null
;
// Get intent interface
try
{
itf
=
(
Interface
)
parent
;
}
catch
(
ClassCastException
cce
)
{
try
{
itf
=
((
ClientInterfaceWrapper
)
parent
).
getItf
();
}
catch
(
ClassCastException
cce2
)
{
cce2
.
printStackTrace
();
}
}
itfOwner
=
itf
.
getFcItfOwner
();
// Get intent controller
try
{
ic
=
(
SCABasicIntentController
)
itf
.
getFcItfOwner
().
getFcInterface
(
SCABasicIntentController
.
NAME
);
}
catch
(
NoSuchInterfaceException
nsie
)
{
JOptionPane
.
showMessageDialog
(
null
,
"Cannot access to intent controller"
);
log
.
log
(
Level
.
SEVERE
,
"Cannot access to intent controller"
,
nsie
);
}
// Remove intent
try
{
// Stop owner component
Fractal
.
getLifeCycleController
(
itfOwner
).
stopFc
();
// Get intent handler
IntentHandler
h
=
TinfiDomain
.
getService
(
intent
,
IntentHandler
.
class
,
"intent"
);
// remove intent
ic
.
removeFcIntentHandler
(
h
,
itf
.
getFcItfName
());
// Start owner component
Fractal
.
getLifeCycleController
(
itfOwner
).
startFc
();
}
catch
(
NoSuchInterfaceException
nsie
)
{
JOptionPane
.
showMessageDialog
(
null
,
"Cannot retrieve the interface name!"
);
log
.
log
(
Level
.
SEVERE
,
"Cannot retrieve the interface name!"
,
nsie
);
}
catch
(
IllegalLifeCycleException
ilce
)
{
JOptionPane
.
showMessageDialog
(
null
,
"Illegal life cycle Exception!"
);
log
.
log
(
Level
.
SEVERE
,
"Illegal life cycle Exception!"
,
ilce
);
}
}
/*
public void actionPerformed (final MenuItemTreeView e) {
Interface selected = (Interface) e.getSelectedObject();
Component itfOwner = selected.getFcItfOwner();
Component intent = loadIntent();
String intentName = null;
SCABasicIntentController ic = null;
// Get intent controller
try {
ic = (SCABasicIntentController) itfOwner.getFcInterface(SCABasicIntentController.NAME);
} catch (NoSuchInterfaceException nsie) {
JOptionPane.showMessageDialog(null, "Cannot access to intent controller");
log.log(Level.SEVERE, "Cannot access to intent controller", nsie);
}
if (intent != null) {
try {
intentName = Fractal.getNameController(intent).getFcName();
} catch (NoSuchInterfaceException nsie) {
log.log(Level.SEVERE, "Cannot find the Name Controller!", nsie);
}
String itfName = selected.getFcItfName();
try {
// Stop intent component
Fractal.getLifeCycleController(intent).stopFc();
// Stop owner component
Fractal.getLifeCycleController(itfOwner).stopFc();
// Get intent handler
IntentHandler h = TinfiDomain.getService(intent, IntentHandler.class, "intent");
// Add intent
ic.addFcIntentHandler(h, itfName);
// Start intent component
Fractal.getLifeCycleController(intent).startFc();
// Start owner component
Fractal.getLifeCycleController(itfOwner).startFc();
} catch (Exception e1) {
JOptionPane.showMessageDialog(null,"Intent '" + intentName
+ "' cannot be added to interface " + itfName);
log.log(Level.SEVERE, "Intent '" + intentName
+ "' cannot be added to interface " + itfName, e1);
}
}
}*/
}
explorer/core/src/main/java/org/ow2/frascati/explorer/context/IntentWrapper.java
View file @
9fe2f1b5
...
...
@@ -49,7 +49,7 @@ public class IntentWrapper {
*
* @return the wrapped intent.
*/
Component
getIntent
()
{
public
Component
getIntent
()
{
return
intent
;
}
}
explorer/core/src/main/resources/sca.xml
View file @
9fe2f1b5
...
...
@@ -177,6 +177,11 @@
<wrapper>
<code>
org.ow2.frascati.explorer.context.IntentContext
</code>
</wrapper>
<menu>
<item
label=
"Remove intent"
>
<code>
org.ow2.frascati.explorer.action.RemoveIntentMenuItem
</code>
</item>
</menu>
</node>
<!-- ================================================================= -->
...
...
Write
Preview
Markdown
is supported
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