Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moex
Transmorpher
Commits
488a64f2
Commit
488a64f2
authored
May 16, 2002
by
Guillaume Chomat
Browse files
change the architecture to separate the application to the panel
parent
edbe8234
Changes
6
Hide whitespace changes
Inline
Side-by-side
flowcomposer/src/fr/fluxmedia/flowcomposer/FCMarqueeHandler.java
View file @
488a64f2
/**
* $Id: FCMarqueeHandler.java,v 1.
4
2002-05-16 14:1
2
:5
5 frederic
Exp $
* $Id: FCMarqueeHandler.java,v 1.
5
2002-05-16 14:1
4
:5
3 gchomat
Exp $
*
* Transmorpher
*
...
...
@@ -64,17 +64,15 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
protected
Point
start
,
current
;
protected
Object
beginCell
,
endCell
;
public
void
setCurrentProcess
(
Object
process
){
//if(process instanceof ProcessGraph)
//
{
currentProcess
=
(
ProcessGraph
)
process
;
//
}
//{
currentProcess
=
(
ProcessGraph
)
process
;
//
}
}
public
JGraph
getCurrentProcess
(){
return
currentProcess
;
}
...
...
@@ -126,10 +124,10 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
}
public
void
mouseReleased
(
MouseEvent
event
)
{
endCell
=
currentProcess
.
getFirstCellForLocation
(
event
.
getX
(),
event
.
getY
());
//System.out.println("MouseReleased Start...");
if
(
currentProcess
!=
null
)
{
endCell
=
currentProcess
.
getFirstCellForLocation
(
event
.
getX
(),
event
.
getY
());
if
(
event
!=
null
&&
!
event
.
isConsumed
()
&&
!
marquee
.
isSelected
())
{
if
(
merge
.
isSelected
())
((
ProcessGraph
)
currentProcess
).
addVertex
(
""
,
start
,
ProcessGraph
.
MERGE
);
...
...
@@ -165,6 +163,7 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
}
public
void
mouseMoved
(
MouseEvent
event
)
{
//System.out.println("currentProcess " + currentProcess);
if
(
currentProcess
!=
null
)
{
if
(!
marquee
.
isSelected
()
&&
!
event
.
isConsumed
())
{
...
...
flowcomposer/src/fr/fluxmedia/flowcomposer/FCProcessFactory.java
View file @
488a64f2
/**
* $Id: FCProcessFactory.java,v 1.
1
2002-05-1
3
1
2:43:31
gchomat Exp $
* $Id: FCProcessFactory.java,v 1.
2
2002-05-1
6
1
4:14:53
gchomat Exp $
*
* Transmorpher
*
...
...
@@ -33,6 +33,7 @@ package fr.fluxmedia.flowcomposer;
import
java.util.Hashtable
;
import
java.util.Map
;
import
com.jgraph.JGraph
;
import
com.jgraph.graph.*
;
...
...
@@ -77,7 +78,7 @@ public class FCProcessFactory implements ProcessFactory{
return
null
;
}
public
Hashtable
getAllProcess
(){
public
Map
getAllProcess
(){
return
listProcess
;
}
...
...
flowcomposer/src/fr/fluxmedia/flowcomposer/FCRun.java
0 → 100644
View file @
488a64f2
/**
*
*$Id: FCRun.java,v 1.1 2002-05-16 14:14:53 gchomat Exp $
*
* Transmorpher
*
* Copyright (C) 2002 Fluxmedia and INRIA Rhône-Alpes.
*
* http://www.fluxmedia.fr - http://transmorpher.inrialpes.fr
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* @version 1.0 29/01/01
* @author Chomat/Saint-Marcel
*/
package
fr.fluxmedia.flowcomposer
;
import
javax.swing.JApplet
;
public
class
FCRun
extends
JApplet
{
//Main method for local execution.
public
static
void
main
(
String
[]
args
){
FlowComposer
.
init
();
FlowComposer
.
newEditor
();
}
//Applet launch for distant execution.
public
void
start
(){
//not yet implemented
getRootPane
().
putClientProperty
(
"defeatSystemEventQueueCheck"
,
Boolean
.
TRUE
);
}
}
flowcomposer/src/fr/fluxmedia/flowcomposer/FlowComposer.java
View file @
488a64f2
/**
*
* $Id: FlowComposer.java,v 1.1
6
2002-05-1
4
1
6
:1
7:07
gchomat Exp $
* $Id: FlowComposer.java,v 1.1
7
2002-05-1
6
1
4
:1
4:53
gchomat Exp $
*
* Transmorpher
*
...
...
@@ -34,10 +34,14 @@
package
fr.fluxmedia.flowcomposer
;
// import JGraph
import
com.jgraph.JGraph
;
import
com.jgraph.graph.*
;
import
com.jgraph.event.*
;
//import Transmorpher
import
fr.fluxmedia.transmorpher.Graph.*
;
import
java.awt.*
;
import
java.beans.*
;
import
java.util.*
;
...
...
@@ -59,53 +63,60 @@ import javax.swing.event.*;
* Dispatch Merge Generate ... (for processing generic transformations on XML
* documents) using the well-known paradigm of a graph.It bases on JGraph Component
*
*@author Chomat/Saint-Marcel
*@version 0.1 29/01/01
*/
public
class
FlowComposer
extends
JApplet
implements
GraphModelListener
,
public
class
FlowComposer
extends
JPanel
implements
GraphModelListener
,
GraphSelectionListener
,
PropertyChangeListener
,
Observer
{
//Used only if FlowComposer is an applet
private
boolean
inAnApplet
=
true
;
//
private boolean inAnApplet = true;
//Process Factory allow to create new Process
protected
ProcessFactory
processFactory
;
//The Transmorpher Graph
protected
Transmorpher
transmorpher
;
protected
FCMarqueeHandler
marqueeHandler
;
protected
static
ArrayList
instances
=
new
ArrayList
();
//The current Process of our Transmorpher.Warning!!! This reference must be sync whith marqueeHandler.currentProcess.
//
protected
JGraph
currentProcess
;
//
panel instance
pr
ivate
JPanel
editor
;
//
Version
pr
otected
static
String
version
=
"v0.1"
;
//Application Title
protected
static
String
title
=
"FlowComposer"
;
// panel instance
//private JPanel editor;
protected
JToolBar
toolbar
;
protected
JMenuBar
menubar
;
// for represent the process notion we dacide to use a tabbed Pane
protected
JTabbedPane
tab
bedPane
;
protected
JTabbedPane
tab
Process
;
// External resource
protected
static
ResourceBundle
resource
;
// The current file name
protected
String
filename
;
/** Application Icon. From resource file.*/
// Application Icon. From resource file.
public
static
ImageIcon
appIcon
;
//HastTable contains IHM element
protected
Hashtable
commands
;
protected
Hashtable
buttons
;
protected
Hashtable
menuItems
;
protected
Hashtable
items
;
/**Default width of the app*/
public
static
final
int
PREFERRED_WIDTH
=
400
;
/**Default height of the app*/
...
...
@@ -168,67 +179,27 @@ public class FlowComposer extends JApplet implements GraphModelListener,
*/
public
FlowComposer
()
{
this
(
true
);
this
(
null
,
null
);
}
public
FlowComposer
(
boolean
inAnApplet
)
{
// Note that the inAnApplet may false if this is started as an application
this
.
inAnApplet
=
inAnApplet
;
if
(
inAnApplet
)
{
getRootPane
().
putClientProperty
(
"defeatSystemEventQueueCheck"
,
Boolean
.
TRUE
);
}
}
public
void
init
()
{
setContentPane
(
editorPanel
());
}
/**
* FlowComposer Main. Called only if we're an application, not an applet.
*/
public
static
void
main
(
String
[]
args
)
{
// Construct Frame
JFrame
frame
=
new
JFrame
();
// Set Close Operation to Exit --- ----- will change
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
public
FlowComposer
(
String
filename
,
GraphModel
model
)
{
super
(
true
);
this
.
filename
=
filename
;
try
{
UIManager
.
setLookAndFeel
(
UIManager
.
getCrossPlatformLookAndFeelClassName
());
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch
(
Exception
exc
)
{
System
.
err
.
println
(
"Error loading L&F: "
+
exc
);
}
transmorpher
=
new
Transmorpher
(
filename
,
resource
.
getString
(
"TRANSMORPHER_VERSION"
),
0
,
false
);
FlowComposer
flowComposer
=
new
FlowComposer
(
false
);
frame
.
setContentPane
(
flowComposer
.
editorPanel
());
frame
.
setTitle
(
"FlowComposer"
);
frame
.
pack
();
Dimension
screenSize
=
Toolkit
.
getDefaultToolkit
().
getScreenSize
();
frame
.
setLocation
(
screenSize
.
width
/
2
-
frame
.
getSize
().
width
/
2
,
screenSize
.
height
/
2
-
frame
.
getSize
().
height
/
2
);
setCursor
(
new
Cursor
(
Cursor
.
DEFAULT_CURSOR
));
this
.
setLayout
(
new
BorderLayout
());
frame
.
show
();
}
/***************************************************************************************************
************************************** GUI Loading**************************************************
***************************************************************************************************/
/**
* return a container that displays all the elements of the app :
* menubar, toolbar and an editor of graph
*/
public
Container
editorPanel
()
{
try
{
UIManager
.
setLookAndFeel
(
UIManager
.
getCrossPlatformLookAndFeelClassName
());
}
catch
(
Exception
exc
)
{
System
.
err
.
println
(
"Error loading L&F: "
+
exc
);
}
setCursor
(
new
Cursor
(
Cursor
.
DEFAULT_CURSOR
));
editor
=
new
JPanel
();
editor
.
setLayout
(
new
BorderLayout
());
JPanel
panel
=
new
JPanel
();
JPanel
panel
=
new
JPanel
();
panel
.
setPreferredSize
(
new
Dimension
(
PREFERRED_WIDTH
,
PREFERRED_HEIGHT
));
// Use Border Layout
...
...
@@ -245,30 +216,29 @@ public class FlowComposer extends JApplet implements GraphModelListener,
commands
.
put
(
a
.
getValue
(
Action
.
NAME
),
a
);
}
marqueeHandler
=
new
FCMarqueeHandler
();
buttons
=
createButtons
();
processFactory
=
new
FCProcessFactory
();
// Construct Panel
// Add a ToolBar
panel
.
add
(
createToolBar
(),
BorderLayout
.
NORTH
);
//Add a JTabbedPane for represnting the process notion.
tab
bedPane
=
new
JTabbedPane
();
tab
bedPane
.
getModel
().
addChangeListener
(
tab
Process
=
new
JTabbedPane
();
tab
Process
.
getModel
().
addChangeListener
(
new
ChangeListener
()
{
public
void
stateChanged
(
ChangeEvent
e
)
{
SingleSelectionModel
model
=
(
SingleSelectionModel
)
e
.
getSource
();
if
(
model
.
getSelectedIndex
()
!=
-
1
)
{
currentProcess
=
(
JGraph
)(
processFactory
.
getProcess
(
tab
bedPane
.
getTitleAt
(
model
.
getSelectedIndex
())));
currentProcess
=
(
JGraph
)(
processFactory
.
getProcess
(
tab
Process
.
getTitleAt
(
model
.
getSelectedIndex
())));
if
(
currentProcess
==
null
)
{
System
.
out
.
println
(
"currentProcess is null"
);
}
else
{
ProcessGraph
.
marqueeHandler
.
setCurrentProcess
(
currentProcess
);
marqueeHandler
.
setCurrentProcess
(
currentProcess
);
update
();
}
}
...
...
@@ -277,32 +247,105 @@ public class FlowComposer extends JApplet implements GraphModelListener,
);
//Init the main process
addProcess
(
new
String
(
"main process"
));
// Add the Graph as Center Component
panel
.
add
(
tabbedPane
,
BorderLayout
.
CENTER
);
editor
.
add
(
createMenubar
(),
BorderLayout
.
NORTH
);
editor
.
add
(
panel
,
BorderLayout
.
CENTER
);
return
editor
;
panel
.
add
(
tabProcess
,
BorderLayout
.
CENTER
);
this
.
add
(
createMenubar
(),
BorderLayout
.
NORTH
);
this
.
add
(
panel
,
BorderLayout
.
CENTER
);
}
public
static
void
init
()
{
// no initialisation yet!!
}
/***************************************************************************************************
************************************** GUI Loading**************************************************
***************************************************************************************************/
/* Open a new editor frame. */
public
static
FlowComposer
newEditor
()
{
return
newEditor
((
String
)
null
);
}
/* Open a new editor frame. */
public
static
FlowComposer
newEditor
(
String
filename
)
{
return
newEditor
(
filename
,
null
);
}
/* Open a new editor frame. */
public
static
FlowComposer
newEditor
(
String
filename
,
GraphModel
model
){
// Construct Frame
JFrame
frame
=
new
JFrame
();
// Set Close Operation to Exit --- ----- will change
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
FlowComposer
flowComposer
=
createInstance
(
filename
,
null
);
frame
.
setContentPane
(
flowComposer
);
frame
.
setTitle
(
title
+
" "
+
version
+
" -- "
+
flowComposer
.
getFileName
());
frame
.
pack
();
Dimension
screenSize
=
Toolkit
.
getDefaultToolkit
().
getScreenSize
();
frame
.
setLocation
(
screenSize
.
width
/
2
-
frame
.
getSize
().
width
/
2
+
instances
.
size
()*
10
,
screenSize
.
height
/
2
-
frame
.
getSize
().
height
/
2
+
instances
.
size
()*
10
);
frame
.
show
();
instances
.
add
(
flowComposer
);
return
flowComposer
;
}
public
static
FlowComposer
newEditor
(
FlowComposer
flowcomposer
)
{
JFrame
frame
=
new
JFrame
();
/*frame.setTitle(flowcomposer.getDocumentTitle());
frame.setBackground(Color.lightGray);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add("Center", flowcomposer);
frame.addWindowListener(flowcomposer.createAppCloser());
frame.pack();
frame.setSize(540, 580);
if (appIcon != null)
frame.setIconImage(appIcon.getImage());
frame.show();
instances.add(flowcomposer);*/
return
flowcomposer
;
}
public
static
FlowComposer
createInstance
(
String
filename
,
GraphModel
model
)
{
if
(
filename
==
null
)
return
new
FlowComposer
(
"Untitled-"
+
Integer
.
toString
(
instances
.
size
()+
1
),
model
);
else
return
new
FlowComposer
(
filename
,
model
);
}
public
void
addProcess
(
Object
userObject
){
UndoHandler
undoHandler
;
JScrollPane
sp
;
if
(
tabbedPane
!=
null
)
Transformation
process
;
if
(
tabProcess
!=
null
)
{
currentProcess
=
processFactory
.
createProcess
(
userObject
);
ProcessGraph
.
marqueeHandler
.
setCurrentProcess
(
currentProcess
);
((
ProcessGraph
)
currentProcess
).
setMarqueeHandler
(
marqueeHandler
);
marqueeHandler
.
setCurrentProcess
(
currentProcess
);
undoHandler
=
new
UndoHandler
();
registerListeners
(
currentProcess
);
currentProcess
.
getModel
().
addUndoableEditListener
(
undoHandler
);
sp
=
new
JScrollPane
(
currentProcess
);
sp
=
(
JScrollPane
)(
tab
bedPane
.
add
((
String
)
userObject
,
sp
));
tab
bedPane
.
setSelectedComponent
(
sp
);
sp
=
(
JScrollPane
)(
tab
Process
.
add
((
String
)
userObject
,
sp
));
tab
Process
.
setSelectedComponent
(
sp
);
currentProcess
=
(
ProcessGraph
)(
sp
.
getViewport
().
getView
());
ProcessGraph
.
marqueeHandler
.
setCurrentProcess
(
currentProcess
);
marqueeHandler
.
setCurrentProcess
(
currentProcess
);
undoHandler
.
setProcess
(
currentProcess
);
}
else
...
...
@@ -366,8 +409,7 @@ public class FlowComposer extends JApplet implements GraphModelListener,
//System.out.println("cmd " +cmd);
String
subMenu
=
getResourceString
(
cmd
+
menuSuffix
);
//System.out.println("sub " +subMenu);
if
(
subMenu
!=
null
)
{
String
[]
itemKeys
=
tokenize
(
subMenu
);
return
createMenu
(
cmd
,
itemKeys
);
...
...
@@ -377,10 +419,10 @@ public class FlowComposer extends JApplet implements GraphModelListener,
if
(
item
instanceof
JMenuItem
)
{
mi
=
(
JMenuItem
)
item
;
mi
.
setText
(
getResourceString
(
cmd
+
labelSuffix
));
//
System.out.println("item "+getResourceString(cmd + labelSuffix));
//System.out.println("item "+getResourceString(cmd + labelSuffix));
}
else
mi
=
new
JMenuItem
(
getResourceString
(
cmd
+
labelSuffix
));
//
System.out.println("item "+getResourceString(cmd + labelSuffix));
//
System.out.println("item "+getResourceString(cmd + labelSuffix));
URL
url
=
getResource
(
cmd
+
imageSuffix
);
if
(
url
!=
null
)
{
mi
.
setHorizontalTextPosition
(
JButton
.
RIGHT
);
...
...
@@ -420,7 +462,7 @@ public class FlowComposer extends JApplet implements GraphModelListener,
mi
.
setActionCommand
(
astr
);
Action
a
=
getAction
(
astr
+
actionSuffix
);
//System.out.println("action "+ a + " "+ astr);
if
(
a
!=
null
)
{
//System.out.println("Menu item Action "+a + " isEnabled "+ a.isEnabled());
mi
.
addActionListener
(
new
EventRedirector
(
a
));
...
...
@@ -489,12 +531,11 @@ public class FlowComposer extends JApplet implements GraphModelListener,
b
.
setRequestFocusEnabled
(
false
);
if
(
button
==
null
)
{
String
act
=
getResourceString
(
key
+
actionSuffix
);
System
.
out
.
println
(
act
);
if
(
act
==
null
)
{
if
(
act
==
null
)
{
act
=
key
;
}
Action
a
=
getAction
(
act
+
actionSuffix
);
System
.
out
.
println
(
"action "
+
a
);
//
System.out.println("action "+ a
+ " " + act
);
if
(
a
!=
null
)
{
b
.
setActionCommand
(
act
);
b
.
addActionListener
(
new
EventRedirector
(
a
));
...
...
@@ -549,6 +590,15 @@ public class FlowComposer extends JApplet implements GraphModelListener,
************************************** Utility******************************************************
***************************************************************************************************/
public
String
getFileName
()
{
return
filename
;
}
public
FCMarqueeHandler
getMarqueeHandler
(){
return
marqueeHandler
;
}
/**
* Fetch the graph contained in the editor
*/
...
...
@@ -684,7 +734,7 @@ public class FlowComposer extends JApplet implements GraphModelListener,
// PropertyChangeListener
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
System
.
out
.
println
(
"PropertyChange "
+
evt
);
//
System.out.println("PropertyChange " + evt);
update
();
}
...
...
@@ -744,8 +794,7 @@ public class FlowComposer extends JApplet implements GraphModelListener,
button
=
b
;
}
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
// System.out.println("property change " + button);
String
propertyName
=
e
.
getPropertyName
();
if
(
e
.
getPropertyName
().
equals
(
Action
.
NAME
)
&&
button
instanceof
JMenuItem
)
{
...
...
@@ -753,8 +802,7 @@ public class FlowComposer extends JApplet implements GraphModelListener,
button
.
setText
(
text
);
}
else
if
(
propertyName
.
equals
(
"enabled"
))
{
Boolean
enabledState
=
(
Boolean
)
e
.
getNewValue
();
//System.out.println("enabledState "+ enabledState );
button
.
setEnabled
(
enabledState
.
booleanValue
());
button
.
setEnabled
(
enabledState
.
booleanValue
());
}
}
}
...
...
@@ -797,9 +845,9 @@ public class FlowComposer extends JApplet implements GraphModelListener,
protected
Hashtable
createButtons
()
{
Hashtable
buttons
=
new
Hashtable
();
if
(
ProcessGraph
.
marqueeHandler
instanceof
FCMarqueeHandler
)
{
if
(
marqueeHandler
instanceof
FCMarqueeHandler
)
{
ButtonGroup
group
=
new
ButtonGroup
();
FCMarqueeHandler
mh
=
(
FCMarqueeHandler
)
ProcessGraph
.
marqueeHandler
;
FCMarqueeHandler
mh
=
marqueeHandler
;
group
.
add
(
mh
.
marquee
);
buttons
.
put
(
"Marquee"
,
mh
.
marquee
);
group
.
add
(
mh
.
generate
);
buttons
.
put
(
"Generate"
,
mh
.
generate
);
group
.
add
(
mh
.
serialize
);
buttons
.
put
(
"Serialize"
,
mh
.
serialize
);
...
...
@@ -819,6 +867,20 @@ public class FlowComposer extends JApplet implements GraphModelListener,
return
buttons
;
}
/**
* Ask to user to enter the name of the new process.
*
*/
public
String
getNameProcess
(){
String
name
=
JOptionPane
.
showInternalInputDialog
(
this
,
resource
.
getString
(
"EnterNameMessage"
),
resource
.
getString
(
"EnterName"
),
JOptionPane
.
QUESTION_MESSAGE
);
return
name
;
}
class
UndoAction
extends
AbstractAction
{
public
UndoAction
()
{
...
...
@@ -849,7 +911,7 @@ public class FlowComposer extends JApplet implements GraphModelListener,
else
{
setEnabled
(
false
);
putValue
(
Action
.
NAME
,
"
u
ndo"
);
putValue
(
Action
.
NAME
,
"
U
ndo"
);
}
}
}
...
...
@@ -885,7 +947,7 @@ public class FlowComposer extends JApplet implements GraphModelListener,
}
else
{
setEnabled
(
false
);
putValue
(
Action
.
NAME
,
"
r
edo"
);
putValue
(
Action
.
NAME
,
"
R
edo"
);
}
}
}
...
...
@@ -994,10 +1056,11 @@ public class FlowComposer extends JApplet implements GraphModelListener,
NewTAction
()
{
super
(
"newT"
+
actionSuffix
);
setEnabled
(
true
);
}