Commit 12b93709 authored by Guillaume Chomat's avatar Guillaume Chomat
Browse files

put right the process creation

parent aea9c41a
/**
* $Id: FCMarqueeHandler.java,v 1.20 2002-06-05 14:46:41 frederic Exp $
* $Id: FCMarqueeHandler.java,v 1.21 2002-06-06 08:43:39 gchomat Exp $
*
* Transmorpher
*
......@@ -79,7 +79,7 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
protected Process currentTransformation;
protected FlowComposer flowcomposer;
protected PortView port, firstPort, lastPort;
protected PortView port, firstPort, lastPort;
protected Call currentCall;
......@@ -105,7 +105,7 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
public FCMarqueeHandler(FlowComposer flowcomposer){
this.flowcomposer = flowcomposer;
}
public void setCurrentProcess(Object process){
if(process instanceof ProcessGraph){
currentProcess = (ProcessGraph)process;
......@@ -130,9 +130,11 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
if(currentProcess != null){
if (!e.isConsumed() && !marquee.isSelected()) {
start = currentProcess.snap(e.getPoint());
firstPort = port;
//beginCell = currentProcess.getFirstCellForLocation(e.getX(), e.getY());
e.consume();
firstPort = port;
//beginCell = currentProcess.getFirstCellForLocation(e.getX(), e.getY());
e.consume();
}
}
super.mousePressed(e);
......@@ -149,10 +151,10 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
g.setColor(fg);
g.setXORMode(bg);
overlay(g);
if (edgeNormal.isSelected())
port = currentProcess.getPortViewAt(event.getX(), event.getY());
current = currentProcess.snap(event.getPoint());
if (edgeNormal.isSelected())
port = currentProcess.getPortViewAt(event.getX(), event.getY());
current = currentProcess.snap(event.getPoint());
g.setColor(bg);
g.setXORMode(fg);
overlay(g);
......@@ -166,13 +168,15 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
public void mouseReleased(MouseEvent event) {
EditCall dialog;
Channel channel;
Channel channel;
//count++;
if(currentProcess != null){
//endCell= currentProcess.getFirstCellForLocation(event.getX(), event.getY());
if (event != null && !event.isConsumed() && !marquee.isSelected()) {
if (merge.isSelected())
{dialog = new EditCall((JFrame)(currentProcess.getTopLevelAncestor()),(ProcessGraph)currentProcess,null,start,FCConstants.MERGE);}
{
dialog = new EditCall((JFrame)(currentProcess.getTopLevelAncestor()),(ProcessGraph)currentProcess,null,start,FCConstants.MERGE);
}
else if (generate.isSelected())
{dialog = new EditCall((JFrame)(currentProcess.getTopLevelAncestor()),(ProcessGraph)currentProcess,null,start,FCConstants.GENERATE);}
else if (serialize.isSelected())
......@@ -187,78 +191,97 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
{dialog = new EditCall((JFrame)(currentProcess.getTopLevelAncestor()),(ProcessGraph)currentProcess,null,start,FCConstants.APPLYRULESET);}
else if (applyQuery.isSelected())
{dialog = new EditCall((JFrame)(currentProcess.getTopLevelAncestor()),(ProcessGraph)currentProcess,null,start,FCConstants.APPLYQUERY);}
else if (edgeNormal.isSelected()){
//currentProcess.getModel().insert(null,null,null,null);
DefaultGraphCell c = (DefaultGraphCell)(port.getParentView()).getCell();
Call call = (Call)(c.getUserObject());
String name = "C"+call.getId();
channel = new Channel( name, (fr.fluxmedia.transmorpher.Graph.Process)currentTransformation );
((Process)currentTransformation).addChannel(channel);
DefaultGraphCell portOut = (DefaultGraphCell)firstPort.getCell();
DefaultGraphCell portIn = (DefaultGraphCell)port.getCell();
channel.setOut((Port)portOut.getUserObject());
channel.setIn((Port)portIn.getUserObject());
((Port)portIn.getUserObject()).setChannel(channel);
((Port)portOut.getUserObject()).setChannel(channel);
//if ((beginCell!=null)&&(endCell!=null)&&(!beginCell.equals(endCell))) {
//doConnectionSet(beginCell,endCell);}
Point p = currentProcess.fromScreen(new Point(start));
Point p2 = currentProcess.toScreen(new Point(current));
ArrayList list = new ArrayList();
list.add(p);
list.add(p2);
Map map = GraphConstants.createMap();
GraphConstants.setPoints(map, list);
Map viewMap = new Hashtable();
DefaultEdge cell = new DefaultEdge(channel);
viewMap.put(cell, map);
Object[] insert = new Object[]{cell};
ConnectionSet cs = new ConnectionSet();
if (firstPort != null)
cs.connect(cell, firstPort.getCell(), true);
if (port != null)
cs.connect(cell, port.getCell(), false);
currentProcess.getModel().insert(insert, cs, null, viewMap);
}
event.consume();
}
marquee.doClick();
firstPort = null;
port = null;
start = null;
current = null;
super.mouseReleased(event);
//System.out.println("MouseReleased End...");
}
else if (edgeNormal.isSelected()){
//currentProcess.getModel().insert(null,null,null,null);
if(port != null && firstPort != null)
{
DefaultGraphCell c = (DefaultGraphCell)(port.getParentView()).getCell();
Call call = (Call)(c.getUserObject());
String name = "C"+call.getId();
channel = new Channel( name, (fr.fluxmedia.transmorpher.Graph.Process)currentTransformation );
((Process)currentTransformation).addChannel(channel);
DefaultGraphCell portOut = (DefaultGraphCell)firstPort.getCell();
DefaultGraphCell portIn = (DefaultGraphCell)port.getCell();
channel.setOut((Port)portOut.getUserObject());
channel.setIn((Port)portIn.getUserObject());
((Port)portIn.getUserObject()).setChannel(channel);
((Port)portOut.getUserObject()).setChannel(channel);
//if ((beginCell!=null)&&(endCell!=null)&&(!beginCell.equals(endCell))) {
//doConnectionSet(beginCell,endCell);}
Point p = currentProcess.fromScreen(new Point(start));
Point p2 = currentProcess.toScreen(new Point(current));
ArrayList list = new ArrayList();
list.add(p);
list.add(p2);
Map map = GraphConstants.createMap();
GraphConstants.setPoints(map, list);
Map viewMap = new Hashtable();
DefaultEdge cell = new DefaultEdge(channel);
viewMap.put(cell, map);
Object[] insert = new Object[]{cell};
ConnectionSet cs = new ConnectionSet();
if (firstPort != null)
cs.connect(cell, firstPort.getCell(), true);
if (port != null)
cs.connect(cell, port.getCell(), false);
currentProcess.getModel().insert(insert, cs, null, viewMap);
}
}
event.consume();
}
marquee.doClick();
firstPort = null;
port = null;
start = null;
current = null;
super.mouseReleased(event);
//System.out.println("MouseReleased End...");
updateGraphics();
}
}
public void mouseMoved(MouseEvent event) {
//System.out.println("currentProcess " + currentProcess);
if(currentProcess!=null){
if (!marquee.isSelected() && !event.isConsumed()) {
currentProcess.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
event.consume();
if (edgeNormal.isSelected()) {
PortView oldPort = port;
PortView newPort = currentProcess.getPortViewAt(event.getX(), event.getY());
if (oldPort != newPort) {
Graphics g = currentProcess.getGraphics();
Color bg = currentProcess.getBackground();
Color fg = currentProcess.getMarqueeColor();
g.setColor(fg);
g.setXORMode(bg);
overlay(g);
port = newPort;
g.setColor(bg);
g.setXORMode(fg);
overlay(g);
}
}
if (edgeNormal.isSelected()) {
PortView oldPort = port;
PortView newPort = currentProcess.getPortViewAt(event.getX(), event.getY());
if (oldPort != newPort) {
Graphics g = currentProcess.getGraphics();
Color bg = currentProcess.getBackground();
Color fg = currentProcess.getMarqueeColor();
g.setColor(fg);
g.setXORMode(bg);
overlay(g);
port = newPort;
g.setColor(bg);
g.setXORMode(fg);
overlay(g);
}
}
}
}
super.mouseMoved(event);
}
public void updateGraphics(){
if(currentProcess != null)
currentProcess.getModel().insert(null,null,null,null);
}
/*
public void doConnectionSet(Object cell,Object cell2) {
......@@ -353,34 +376,34 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
}
}
} */
} */
public void overlay(Graphics g) {
super.overlay(g);
paintPort(currentProcess.getGraphics());
paintPort(currentProcess.getGraphics());
if (start != null) {
if ((edgeNormal.isSelected()) && current != null)
g.drawLine(start.x, start.y, current.x, current.y);
}
}
protected void paintPort(Graphics g) {
if (port != null) {
boolean offset = (GraphConstants.getOffset(port.getAttributes()) != null);
Rectangle r = (offset) ? port.getBounds()
: port.getParentView().getBounds();
r = currentProcess.toScreen(new Rectangle(r));
int s = 3;
r.translate(-s, -s);
r.setSize(r.width+2*s, r.height+2*s);
currentProcess.getUI().paintCell(g, port, r, true);
}
}
protected void paintPort(Graphics g) {
if (port != null) {
boolean offset = (GraphConstants.getOffset(port.getAttributes()) != null);
Rectangle r = (offset) ? port.getBounds()
: port.getParentView().getBounds();
r = currentProcess.toScreen(new Rectangle(r));
int s = 3;
r.translate(-s, -s);
r.setSize(r.width+2*s, r.height+2*s);
currentProcess.getUI().paintCell(g, port, r, true);
}
}
class EditCall extends JDialog implements ActionListener{
protected JTextField idText, fileText;
......@@ -651,8 +674,8 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
if(!(fileText.getText().equals(""))){
if(call==null){
call = new ApplyExternal(id,typeChooser.getSelectedItem().toString(),fileText.getText());
((ProcessGraph)currentProcess).addVertex(call,start,FCConstants.APPLYEXTERNAL);
this.dispose();
((ProcessGraph)currentProcess).addVertex(call,start,FCConstants.APPLYEXTERNAL);
this.dispose();
}
else{
......@@ -820,16 +843,16 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
}
public void alert(int type){
}
public void createCall(){
}
}
}
\ No newline at end of file
}
/**
* $Id: FCProcessFactory.java,v 1.7 2002-06-03 17:19:30 gchomat Exp $
* $Id: FCProcessFactory.java,v 1.8 2002-06-06 08:43:39 gchomat Exp $
*
* Transmorpher
*
......@@ -103,11 +103,12 @@ public class FCProcessFactory implements ProcessFactory{
Iterator it = getAllProcess().iterator();
String processName;
while (it.hasNext()) {
Object process = it.next();
processName = ((Process)(((ProcessGraph)process).getUserObject())).getName();
if(index.equals(processName));
if(index.equals(processName))
{
return (ProcessGraph)process;
}
......
/**
*
*$Id: FlowComposer.java,v 1.37 2002-06-05 13:39:28 gchomat Exp $
*$Id: FlowComposer.java,v 1.38 2002-06-06 08:43:39 gchomat Exp $
*
* Transmorpher
*
......@@ -74,52 +74,53 @@ public class FlowComposer extends JPanel implements GraphModelListener,
// a boolean which indicates if the drawing area is editing
public static boolean editing = false;
//Used only if FlowComposer is an applet
//private boolean inAnApplet = true;
protected ParserRDF parser;
//Process Factory allow to create new Process
protected ProcessFactory processFactory;
//The Transmorpher Graph
protected Transmorpher transmorpher;
//THE EIDTING GRAPH HANDLER
protected FCMarqueeHandler marqueeHandler;
//Array of all Flowcomposer instance
protected static ArrayList instances = new ArrayList();
//The current Process of our Transmorpher.Warning!!! This reference must be sync whith marqueeHandler.currentProcess.
protected JGraph currentProcess;
//Version
protected static String version = "v0.1";
//Application Title
protected static String title = "FlowComposer";
//private JPanel editor;
protected JToolBar toolbar;
protected JMenuBar menubar;
// for represent the process notion we dacide to use a tabbed Pane
protected JTabbedPane tabProcess;
// External resource
protected static ResourceBundle resource;
//The window listener.
protected static FCWindowListener windowListener;
// The current file name
protected String filename;
// Application Icon. From resource file.
public static ImageIcon appIcon;
//HastTable contains IHM element
protected Hashtable commands;
protected Hashtable buttons;
......@@ -129,53 +130,53 @@ public class FlowComposer extends JPanel implements GraphModelListener,
protected JComponent status;
protected Rule colrule, rowrule;
protected JComboBox zoom;
protected static boolean isMetric = true;
/**Default width of the app*/
public static final int PREFERRED_WIDTH =640;
/**Default height of the app*/
public static final int PREFERRED_HEIGHT =480;
public static final int MAIN = 1;
public static final int SERVLET = 2;
public static final int TRANSFORMER = 3;
public static final int PROCESS = 4;
// Possible Look & Feels
private static final String mac =
"com.sun.java.swing.plaf.mac.MacLookAndFeel";
private static final String metal =
"javax.swing.plaf.metal.MetalLookAndFeel";
private static final String motif =
"com.sun.java.swing.plaf.motif.MotifLookAndFeel";
private static final String windows =
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
// The current Look & Feel
private static String currentLookAndFeel = metal;
private static final String mac =
"com.sun.java.swing.plaf.mac.MacLookAndFeel";
private static final String metal =
"javax.swing.plaf.metal.MetalLookAndFeel";
private static final String motif =
"com.sun.java.swing.plaf.motif.MotifLookAndFeel";
private static final String windows =
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
// The current Look & Feel
private static String currentLookAndFeel = metal;
/**
* Suffix applied to the key used in resource file
* lookups for a label.
*/
public static final String labelSuffix = "Label";
/**
* Suffix applied to the key used in resource file
* lookups for a menuitem (instead of action)
*/
public static final String accelSuffix = "Accel";
/**
* Suffix applied to the key used in resource file
* lookups for a submenu
*/
public static final String menuSuffix = "Menu";
/**
* Suffix applied to the key used in resource file
* lookups for a menuitem (instead of action)
......@@ -186,7 +187,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
* lookups for an action.
*/
public static final String actionSuffix = "Action";
/**
* Suffix applied to the key used in resource file
* lookups for an image.
......@@ -197,7 +198,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
* lookups for tooltip text.
*/
public static final String tipSuffix = "Tooltip";
static {
windowListener = new FCWindowListener();
try {
......@@ -208,44 +209,44 @@ public class FlowComposer extends JPanel implements GraphModelListener,
System.exit(1);
}
}
/**
* FlowComposer Constructor
*/
public FlowComposer() {
this(null,null);
}
public FlowComposer(String filename, GraphModel model) {
super(true);
this.filename = filename;
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception exc) {
System.err.println("Error loading L&F: " + exc);
}
transmorpher = new Transmorpher(filename,resource.getString("TRANSMORPHER_VERSION"),0,false);
createStatusbar();
parser = new ParserRDF();
updateLookAndFeel(windows);
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
this.setLayout(new BorderLayout());
JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(PREFERRED_WIDTH,PREFERRED_HEIGHT));
// Use Border Layout
panel.setLayout(new BorderLayout());
menuItems = new Hashtable();
items= new Hashtable();
// install the command table
commands = new Hashtable();
for (int i = 0; i < actions.length; i++) {
......@@ -253,13 +254,13 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//System.out.println("actions:"+a.getValue(Action.NAME));
commands.put(a.getValue(Action.NAME), a);
}
marqueeHandler = new FCMarqueeHandler(this);
processFactory = new FCProcessFactory();
buttons = createButtons();
createSpecialButtons();
createSpecialButtons();
// Add a ToolBar
JPanel center = new JPanel();
......@@ -272,8 +273,8 @@ public class FlowComposer extends JPanel implements GraphModelListener,
tabProcess= new JTabbedPane();
tabProcess.getModel().addChangeListener(
new ChangeListener() {
new ChangeListener() {
public void stateChanged(ChangeEvent e) {
SingleSelectionModel model = (SingleSelectionModel) e.getSource();
if(model.getSelectedIndex() != -1) {
......@@ -291,12 +292,12 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
}
);