Commit 43a172f3 authored by SAINT-MARCEL Frederic's avatar SAINT-MARCEL Frederic
Browse files

RDF+

parent 082e0fee
/**
* $Id: FCMarqueeHandler.java,v 1.8 2002-05-23 09:18:02 gchomat Exp $
* $Id: FCMarqueeHandler.java,v 1.9 2002-05-23 15:38:54 frederic Exp $
*
* Transmorpher
*
......@@ -211,7 +211,8 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
((ProcessGraph)currentProcess).addVertex(currentCall,start,ProcessGraph.APPLYQUERY);
}
else if (edgeNormal.isSelected()) {
if (beginCell!=null&&endCell!=null) {
currentProcess.getModel().insert(null,null,null,null);
if ((beginCell!=null)&&(endCell!=null)&&(!beginCell.equals(endCell))) {
doConnectionSet(beginCell,endCell);
}
......@@ -319,8 +320,15 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
cs.connect(edge,currentProcess.getPortForLocation(p.x,p.y), true);
cs.connect(edge,currentProcess.getPortForLocation(p2.x,p2.y), false);
currentProcess.getModel().insert(insert, cs, null, viewMap);
((ProcessGraph)currentProcess).updatePorts("output",(DefaultGraphCell)cell);
((ProcessGraph)currentProcess).updatePorts("input",(DefaultGraphCell)cell2);
//((ProcessGraph)currentProcess).layoutPorts(cell,"output");
//((ProcessGraph)currentProcess).layoutPorts(cell2,"input");
/*
((ProcessGraph)currentProcess).layoutPorts(cell,"output");
((ProcessGraph)currentProcess).layoutPorts(cell2,"input");
((ProcessGraph)currentProcess).layoutPorts(cell2,"input");*/
}
}
......
/**
* $Id: FCProcessFactory.java,v 1.3 2002-05-22 16:49:53 gchomat Exp $
* $Id: FCProcessFactory.java,v 1.4 2002-05-23 15:38:54 frederic Exp $
*
* Transmorpher
*
......@@ -33,7 +33,7 @@ package fr.fluxmedia.flowcomposer;
import java.util.Hashtable;
import java.util.Map;
import java.util.*;
import com.jgraph.JGraph;
import com.jgraph.graph.*;
......@@ -81,4 +81,20 @@ public class FCProcessFactory implements ProcessFactory{
return listProcess;
}
public void generateFileRDF(ReadWrite file) {
file.Writeln("<?xml version=\"1.0\"?>");
file.Writeln("<rdf:RDF>");
file.Writeln(4,"xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"");
file.Writeln(4,"xmlns:s=\"http://description.org/schema/\">");
Iterator it = ((getAllProcess()).values()).iterator();
while (it.hasNext()) {
Object process = it.next();
((ProcessGraph)process).generateRDF(file);
}
file.Writeln("</rdf:RDF>");
}
}
/**
*
* $Id: FlowComposer.java,v 1.19 2002-05-23 09:18:02 gchomat Exp $
* $Id: FlowComposer.java,v 1.20 2002-05-23 15:38:54 frederic Exp $
*
* Transmorpher
*
......@@ -41,7 +41,8 @@ import com.jgraph.event.*;
//import Transmorpher
import fr.fluxmedia.transmorpher.Graph.*;
import fr.fluxmedia.transmorpher.Utils.Parameters;
import fr.fluxmedia.transmorpher.Utils.*;
import java.awt.*;
import java.beans.*;
......@@ -84,13 +85,13 @@ public class FlowComposer extends JPanel implements GraphModelListener,
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;
//Version
protected static String version = "v0.1";
protected static String version = "v0.1";
//Application Title
protected static String title = "FlowComposer";
......@@ -99,17 +100,17 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//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 static FCWindowListener windowListener;
// The current file name
protected String filename;
// Application Icon. From resource file.
......@@ -197,29 +198,29 @@ public class FlowComposer extends JPanel implements GraphModelListener,
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);
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++) {
......@@ -232,10 +233,10 @@ public class FlowComposer extends JPanel implements GraphModelListener,
buttons = createButtons();
processFactory = new FCProcessFactory();
// Add a ToolBar
panel.add(createToolBar(), BorderLayout.NORTH);
//Add a JTabbedPane for represnting the process notion.
tabProcess= new JTabbedPane();
tabProcess.getModel().addChangeListener(
......@@ -253,20 +254,20 @@ public class FlowComposer extends JPanel implements GraphModelListener,
marqueeHandler.setCurrentProcess(currentProcess);
update();
}
}
}
}
}
}
}
);
//Init the main process
addProcess(new String("main"),MAIN);
// Add the Graph as Center Component
panel.add(tabProcess, BorderLayout.CENTER);
this.add(createMenubar(),BorderLayout.NORTH);
this.add(panel,BorderLayout.CENTER);
}
public static void init() {
......@@ -289,7 +290,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
/* 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
......@@ -299,13 +300,13 @@ public class FlowComposer extends JPanel implements GraphModelListener,
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;
......@@ -336,13 +337,13 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void addProcess(String name, int type){
UndoHandler undoHandler;
JScrollPane sp ;
Transformation process = null;
switch(type)
{
{
case MAIN :
process = new fr.fluxmedia.transmorpher.Graph.Main(name,transmorpher);
if ( transmorpher.getMain() == null) {
......@@ -354,16 +355,16 @@ public class FlowComposer extends JPanel implements GraphModelListener,
transmorpher.addTransformation(name,process);
break;
}
if(tabProcess != null )
{
{
currentProcess = processFactory.createProcess(process);
((ProcessGraph)currentProcess).setMarqueeHandler(marqueeHandler);
//marqueeHandler.setCurrentProcess(currentProcess);
undoHandler = new UndoHandler();
registerListeners(currentProcess);
currentProcess.getModel().addUndoableEditListener(undoHandler);
sp = new JScrollPane(currentProcess);
sp = (JScrollPane)(tabProcess.add(process.getName(),sp));
tabProcess.setSelectedComponent(sp);
......@@ -377,7 +378,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
}
/**
* Create the menubar for the app. By default this pulls the
* definition of the menu from the associated resource file.
......@@ -428,11 +429,11 @@ public class FlowComposer extends JPanel implements GraphModelListener,
* of lookups.
*/
protected JMenuItem createMenuItem(String cmd) {
//System.out.println("cmd " +cmd);
String subMenu = getResourceString(cmd + menuSuffix);
if (subMenu != null) {
String[] itemKeys = tokenize(subMenu);
return createMenu(cmd, itemKeys);
......@@ -485,7 +486,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
mi.setActionCommand(astr);
Action a = getAction(astr+actionSuffix);
//System.out.println("action "+ a + " "+ astr);
//System.out.println("action "+ a + " "+ astr);
if (a != null) {
//System.out.println("Menu item Action "+a + " isEnabled "+ a.isEnabled());
mi.addActionListener(new EventRedirector(a));
......@@ -505,7 +506,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
* resource file for the definition of the toolbar.
*/
public Component createToolBar() {
toolbar = new JToolBar();
toolbar.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
......@@ -531,17 +532,17 @@ public class FlowComposer extends JPanel implements GraphModelListener,
public Component createToolButton(String key) {
Object button;
Object button;
AbstractButton b = null;
URL url;
url = getResource(key + imageSuffix);
// System.out.println(url + " " + key);
button= buttons.get(key);
if (button instanceof AbstractButton) {
b = (AbstractButton) button;
b.setIcon(new ImageIcon(url));
......@@ -577,8 +578,8 @@ public class FlowComposer extends JPanel implements GraphModelListener,
return b;
}
/* Invoked after the selection or the model has changed. */
public void update() {
undoAction.update();
......@@ -626,7 +627,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
* Fetch the graph contained in the editor
*/
public JGraph getGraph() {
//Must return the current process
return currentProcess;
}
......@@ -686,7 +687,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
cmd = new String[v.size()];
for (int i = 0; i < cmd.length; i++)
cmd[i] = (String) v.elementAt(i);
return cmd;
}
......@@ -754,13 +755,13 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//
// Listeners
//
// PropertyChangeListener
public void propertyChange(PropertyChangeEvent evt) {
//System.out.println("PropertyChange " + evt);
update();
}
// GraphSelectionListener
public void valueChanged(GraphSelectionEvent e) {
//System.out.println("GraphSelection" + e);
......@@ -772,7 +773,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//System.out.println("View " + obs + " " + arg);
update();
}
// GraphModelListener
public void graphChanged(GraphModelEvent e) {
//System.out.println("GraphModel" + e);
......@@ -781,43 +782,43 @@ public class FlowComposer extends JPanel implements GraphModelListener,
currentProcess.setSelectionCells(inserted);
update();
}
/* This will change the source of the actionevent to graph. */
protected class EventRedirector implements ActionListener {
protected Action action;
public EventRedirector(Action a) {
this.action = a;
}
public void actionPerformed(ActionEvent e) {
e = new ActionEvent(currentProcess,
e.getID(),
e = new ActionEvent(currentProcess,
e.getID(),
e.getActionCommand(),
e.getModifiers());
action.actionPerformed(e);
}
}
// Yarked from JMenu, ideally this would be public.
protected PropertyChangeListener createActionChangeListener(AbstractButton b) {
return new ActionChangedListener(b);
}
// Yarked from JMenu, ideally this would be public.
protected class ActionChangedListener implements PropertyChangeListener {
AbstractButton button;
ActionChangedListener(AbstractButton b) {
super();
button = b;
}
public void propertyChange(PropertyChangeEvent e) {
String propertyName = e.getPropertyName();
if (e.getPropertyName().equals(Action.NAME) &&
button instanceof JMenuItem) {
......@@ -829,23 +830,23 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
}
}
//
// Custom Model
//
class UndoHandler implements UndoableEditListener {
JGraph process;
public UndoHandler() {
}
public UndoHandler(JGraph process){
setProcess(process);
}
/**
* Messaged when the Document has created an edit, the edit is
* added to <code>undo</code>, an instance of UndoManager.
......@@ -855,19 +856,19 @@ public class FlowComposer extends JPanel implements GraphModelListener,
undoAction.update();
redoAction.update();
}
public void setProcess(JGraph process){
this.process = process;
}
public JGraph getProcess(){
return process;
}
}
protected Hashtable createButtons() {
Hashtable buttons = new Hashtable();
if (marqueeHandler instanceof FCMarqueeHandler) {
ButtonGroup group = new ButtonGroup();
FCMarqueeHandler mh = marqueeHandler;
......@@ -886,23 +887,23 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//group.add(mh.EdgeNull); buttons.put("EdgeNull", mh.EdgeNull);
mh.marquee.doClick();
}
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;
}
protected static class FCWindowListener extends WindowAdapter{
......@@ -913,10 +914,10 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//System.out.println("win "+instances.indexOf(e.getWindow()));
}
}
class UndoAction extends AbstractAction {
public UndoAction() {
super("undo"+actionSuffix);
setEnabled(false);
......@@ -936,21 +937,21 @@ public class FlowComposer extends JPanel implements GraphModelListener,
protected void update() {
//System.out.println("test "+((ProcessGraph)currentProcess).getUndoManager().canUndo(getView()));
if(currentProcess!= null & ((ProcessGraph)currentProcess).getUndoManager()!=null){
if(((ProcessGraph)currentProcess).getUndoManager().canUndo(getView())) {
setEnabled(true);
putValue(Action.NAME, ((ProcessGraph)currentProcess).getUndoManager().getUndoPresentationName());
}
else {
setEnabled(false);
putValue(Action.NAME, "Undo");
}
}
}
}
class RedoAction extends AbstractAction {
public RedoAction() {
super("redo"+actionSuffix);
......@@ -959,12 +960,12 @@ public class FlowComposer extends JPanel implements GraphModelListener,
public void actionPerformed(ActionEvent e) {
try {
if(currentProcess!= null & ((ProcessGraph)currentProcess).getUndoManager()!=null)
{
{
((ProcessGraph)currentProcess).getUndoManager().redo(getView());
}
} catch (CannotRedoException ex) {
ex.printStackTrace();
}
......@@ -974,7 +975,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
protected void update() {
//System.out.println("test "+((ProcessGraph)currentProcess).getUndoManager().canUndo(getView()));
if(currentProcess!= null & ((ProcessGraph)currentProcess).getUndoManager()!=null){
if(((ProcessGraph)currentProcess).getUndoManager().canRedo(getView())) {
setEnabled(true);
......@@ -987,7 +988,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
}
}
class LoadAction extends AbstractAction {
LoadAction() {
......@@ -1028,7 +1029,9 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void actionPerformed(ActionEvent e) {
ReadWrite file = new ReadWrite("fichier.rdf",ReadWrite.WRITE);
((FCProcessFactory)processFactory).generateFileRDF(file);
file.Close();
}
}
......@@ -1095,7 +1098,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void actionPerformed(ActionEvent e) {
newEditor();
newEditor();
}
}
......@@ -1107,7 +1110,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
public void actionPerformed(ActionEvent e) {
try{
String reloc = "";
String reloc = "";
transmorpher.generateExec(reloc);
Parameters p = new Parameters();
transmorpher.exec(p);
......@@ -1143,7 +1146,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,