Commit 758b1206 authored by Fabien Triolet's avatar Fabien Triolet
Browse files

Added ability to use parameters

parent ce27e620
......@@ -3,7 +3,7 @@
# Resources pour FlowComposer
#Transmorpher ressources
TRANSMORPHER_VERSION = 0.9.9
TRANSMORPHER_VERSION = 1.0.1
logoFlux= resources/logoF.gif
logoInria= resources/logoinria.jpg
......@@ -87,7 +87,7 @@ optionImage=resources/options.gif
#
# transmorpher Menu definition
#
transmorpher=newT - run compile - debug - extern - expandT propertiesT
transmorpher=newT - run compile - debug - extern parameters - expandT propertiesT
transmorpherLabel=Transmorpher
newTLabel=New
newMnemonic=n
......@@ -101,6 +101,8 @@ debugLabel=Debug
debugAccel=SHIFT-F9
externLabel= Extern
externAction = extern
parametersLabel= Parameters
parametersAction = parameters
expandTLabel=Expand
propertiesTLabel=Properties
propertiesTImage=resources/properties.gif
......
/**
* $Id: FCProcessFactory.java,v 1.9 2002-12-12 10:25:58 triolet Exp $
* $Id: FCProcessFactory.java,v 1.10 2002-12-16 08:47:23 triolet Exp $
*
* Transmorpher
*
......@@ -138,11 +138,11 @@ public class FCProcessFactory implements Observer,Serializable{
public void runTransmorpher(){
SystemResources tResources = new SystemResources();
String reloc = "";
//String reloc = "";
if (transmorpher != null) {
transmorpher.setDebug(3);
try{
transmorpher.generateExec(reloc);
transmorpher.generateExec(null);
}
catch(Exception e){
System.out.println(e);
......
/**
*
*$Id: FlowComposer.java,v 1.20 2002-12-12 10:25:58 triolet Exp $
*$Id: FlowComposer.java,v 1.21 2002-12-16 08:47:23 triolet Exp $
*
* Transmorpher
*
......@@ -1268,7 +1268,9 @@ public class FlowComposer extends JPanel implements GraphModelListener,
new UnloadAction(),
new HelpAction(),
new AboutAction(),
new DefexternAction()
new DefexternAction(),
new DefparametersAction()
};
......@@ -2217,6 +2219,18 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
}
class DefparametersAction extends AbstractAction {
DefparametersAction() {
super("parameters"+actionSuffix);
setEnabled(true);
}
public void actionPerformed(ActionEvent e) {
new ParametersDialog(FlowComposer.this);
}
}
class DeleteAction extends AbstractAction {
DeleteAction() {
......
/**
*
*$Id: ParametersDialog.java,v 1.1 2002-12-16 08:47:23 triolet Exp $
*
* Transmorpher
*
* Copyright (C) 2002 Fluxmedia.
*
* http://www.fluxmedia.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.
*/
package fr.fluxmedia.flowcomposer.gui;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.border.*;
import fr.fluxmedia.flowcomposer.gui.guitools.*;
import fr.fluxmedia.transmorpher.utils.LinearIndexedStruct;
import javax.swing.table.DefaultTableModel;
import fr.fluxmedia.flowcomposer.graph.*;
public class ParametersDialog extends JDialog implements ActionListener{
protected Container contentPane;
protected JButton ok;
protected JButton cancel;
protected JButton newParam;
protected JButton deleteParam;
protected DefaultTableModel tableModel;
protected JTable parametersTable;
protected FCProcessFactory processFactory;
public ParametersDialog(FlowComposer flow){
super(flow.getFrame(),"Parameters",true);
this.setLocationRelativeTo(flow.getFrame());
processFactory=flow.getProcessFactory();
contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
ok = new JButton("OK");
ok.addActionListener(this);
cancel = new JButton("CANCEL");
JPanel parametersPanel = new JPanel();
parametersPanel.setPreferredSize(new Dimension(300,300));
Border titleParam=BorderFactory.createEtchedBorder();
parametersTable = new ParametersTable(processFactory.getTransmorpher().getMain().getParameters());
tableModel = (DefaultTableModel)parametersTable.getModel();
JScrollPane scrollTable = new JScrollPane(parametersTable);
scrollTable.setPreferredSize(new Dimension(250,200));
newParam = new JButton("Add");
newParam.addActionListener(this);
deleteParam = new JButton("Delete");
deleteParam.addActionListener(this);
JPanel paramPanel = new JPanel();
paramPanel.setLayout(new GridLayout(0,1,0,5));
paramPanel.add(newParam);
paramPanel.add(deleteParam);
JPanel pane = new JPanel();
pane.setLayout(new FlowLayout(FlowLayout.LEFT,20,5));
pane.add(scrollTable);
pane.add(paramPanel);
pane.setBorder(BorderFactory.createTitledBorder(titleParam,"test"));
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
buttonPanel.add(ok);
buttonPanel.add(cancel);
contentPane.add(pane,BorderLayout.CENTER);
contentPane.add(buttonPanel,BorderLayout.SOUTH);
this.pack();
this.setVisible(true);
}
public void actionPerformed(ActionEvent event){
if(event.getSource() == newParam){
String[] stringNull= {"",""};
tableModel.addRow(stringNull);
}
if(event.getSource() == deleteParam){
int[] index = parametersTable.getSelectedRows();
int nb = 0;
if(parametersTable.getCellEditor() != null)
parametersTable.getCellEditor().stopCellEditing();
for (int i = 0; i < index.length ; i++) {
String name = (String)tableModel.getValueAt(index[i]-nb,0);
tableModel.removeRow(index[i]-nb);
if(processFactory.getTransmorpher().getMain().getParameters().getParameter(name)!=null)
processFactory.getTransmorpher().getMain().getParameters().unsetParameter(name);
nb++;
}
}
if(event.getSource() == ok ) {
for (int i=0;i<tableModel.getRowCount();i++) {
String name = (String)tableModel.getValueAt(i,0);
String value = (String)tableModel.getValueAt(i,1);
if (name != null && ! (name.equals("")) )
if(processFactory.getTransmorpher().getMain().getParameters().getParameter(name)==null)
processFactory.getTransmorpher().getMain().getParameters().setParameter(name,value);
}
this.dispose();
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment