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

update

parent 58db85d0
/**
* $Id: ApplyQueryRenderer.java,v 1.4 2002-04-15 06:42:04 serge Exp $
* $Id: ApplyQueryRenderer.java,v 1.5 2002-06-26 12:25:09 frederic Exp $
*
* Transmorpher
*
......@@ -65,6 +65,7 @@ public class ApplyQueryRenderer extends VertexRenderer {
if (selected) {
g2.setStroke(GraphConstants.SELECTION_STROKE);
g.setColor(graph.getHighlightColor());
System.out.println(graph.getHighlightColor());
drawApplyQuery(g,d,b);
}
}
......
......@@ -69,7 +69,7 @@ public class FCPortRenderer extends PortRenderer {
g.setColor(foreCol);
else
g.setColor(getForeground());
//g.setColor(Color.magenta);
g.drawRect(0, 0, d.width, d.height);
if ( backCol != null )
......
/**
*
*$Id: FlowComposer.java,v 1.55 2002-06-25 13:42:04 gchomat Exp $
*$Id: FlowComposer.java,v 1.56 2002-06-26 12:25:09 frederic Exp $
*
* Transmorpher
*
......@@ -1165,7 +1165,8 @@ public class FlowComposer extends JPanel implements GraphModelListener,
protected JComboBox strategyChooser,typeChooser,refChooser;
protected JFileChooser fileChooser;
protected JButton ok,cancel,fileChooserButton;
protected JLabel idJLabel, fileJLabel, refJLabel, strategyJLabel, typeJLabel, alertJLabel;
protected JLabel idJLabel, fileJLabel, refJLabel, strategyJLabel, typeJLabel;
protected JRadioButton refRadio,fileRadio;
protected Call call;
protected int type;
protected boolean editMode;
......@@ -1216,6 +1217,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
else{
idText= new JTextField(((Hashtable)attributes).get("id")+""+location.x);}
idText.setPreferredSize(new Dimension(165,20));
idText.addActionListener(this);
Object[] compId = new Object[]{idJLabel,idText};
makeComponent(compId);
......@@ -1236,6 +1238,21 @@ public class FlowComposer extends JPanel implements GraphModelListener,
makeComponent(compType);
}
if (call instanceof ApplyQuery) {
refRadio = new JRadioButton("ref");
fileRadio = new JRadioButton("file");
refRadio.setPreferredSize(new Dimension(50,15));
fileRadio.setPreferredSize(new Dimension(50,15));
refRadio.addActionListener(this);
fileRadio.addActionListener(this);
ButtonGroup group = new ButtonGroup();
group.add(refRadio);
group.add(fileRadio);
refRadio.setSelected(true);
Object[] compRadio = new Object[]{refRadio,fileRadio};
makeComponent(compRadio);
}
Object file = (parameters instanceof Parameters)?((Parameters)parameters).getParameter("file"):((Hashtable)attributes).get("file");
// file construction
......@@ -1249,6 +1266,9 @@ public class FlowComposer extends JPanel implements GraphModelListener,
fileChooserButton.setPreferredSize(new Dimension(25,20));
Object[] compFile = new Object[]{fileJLabel,fileText,fileChooserButton};
makeComponent(compFile);
if (call instanceof ApplyQuery) { fileJLabel.setEnabled(false);
fileText.setEnabled(false);
fileChooserButton.setEnabled(false);}
}
Object strategy = (attributes instanceof Parameters)?((Parameters)attributes).getParameter("strategy"):((Hashtable)attributes).get("strategy");
......@@ -1256,9 +1276,12 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//strategy construction
if(strategy != null){
strategyJLabel = new JLabel(resource.getString("strategyLabel"));
strategyJLabel.setPreferredSize(new Dimension(30,20));
strategyChooser = new JComboBox(FCConstants.STRATEGYRULESET);
strategyChooser.setSelectedItem(strategy);
strategyChooser.setPreferredSize(new Dimension(120,20));
Object[] compStrategy = new Object[]{strategyJLabel,strategyChooser};
makeComponent(compStrategy);
}
Object ref = (attributes instanceof Parameters)?((Parameters)attributes).getParameter("ref"):((Hashtable)attributes).get("ref");
......@@ -1285,6 +1308,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
ok = new JButton(resource.getString("okTitle"));
ok.addActionListener(this);
ok.setPreferredSize(new Dimension(80,20));
//ok.setEnabled(false);
cancel = new JButton(resource.getString("cancelTitle"));
cancel.addActionListener(this);
cancel.setPreferredSize(new Dimension(80,20));
......@@ -1316,258 +1340,116 @@ public class FlowComposer extends JPanel implements GraphModelListener,
String id = idText.getText();
Point location = new Point(1,1);
if(event.getSource() == ok )
{
//ok action.
//for each component we must test if the id is single.
if(!(id.equals(""))){
//id != ""
if(currentProcess != null && (id.equals(call.getId()) || currentProcess.isSingleId(id)))
{
//id is single
switch(type){
case FCConstants.MERGE:
if(call==null){
//(currentProcess).createCall(FCConstants.MERGE,parameters);
}
else{
//call.setId(id);
call.setType(typeChooser.getSelectedItem().toString());
}
this.dispose();
break;
case FCConstants.DISPATCH :
if(call==null){
/*call = new Dispatch(id,typeChooser.getSelectedItem().toString(),currentTransformation);
currentTransformation.addCall(call);
(currentProcess).addVertex(call,location,FCConstants.DISPATCH);*/
}
else{
call.setId(id);
call.setType(typeChooser.getSelectedItem().toString());
}
this.dispose();
break;
case FCConstants.SERIALIZE :
if(!(fileText.getText().equals(""))){
if(call==null){
/*call = new Serialize(id,typeChooser.getSelectedItem().toString(),fileText.getText(),currentTransformation);
currentTransformation.addCall(call);
(currentProcess).addVertex(call,location,FCConstants.SERIALIZE);*/
}
else{
call.setId(id);
call.setType(typeChooser.getSelectedItem().toString());
((Serialize)call).setFile(fileText.getText());
}
this.dispose();
}
else
{
//System.out.println("empty");
if (alertJLabel == null)
{
alertJLabel = new JLabel("alert !! file must not be empty!!");
getContentPane().add(alertJLabel);
}
else
alertJLabel.setText("alert !! file is empty!!");
fileJLabel.setForeground(Color.red);
this.pack();
}
break;
case FCConstants.APPLYEXTERNAL :
if(!(fileText.getText().equals(""))){
if(call==null){
/*call = new ApplyExternal(id,typeChooser.getSelectedItem().toString(),fileText.getText(),currentTransformation);
currentTransformation.addCall(call);
(currentProcess).addVertex(call,location,FCConstants.APPLYEXTERNAL);*/
this.dispose();
}
else{
call.setId(id);
call.setType(typeChooser.getSelectedItem().toString());
((ApplyExternal)call).setFile(fileText.getText());
}
this.dispose();
}
else
{
//System.out.println("empty");
if (alertJLabel == null)
{
alertJLabel = new JLabel("alert !! file must not be empty!!");
getContentPane().add(alertJLabel);
}
else
alertJLabel.setText("alert !! file is empty!!");
fileJLabel.setForeground(Color.red);
this.pack();
}
break;
case FCConstants.APPLYPROCESS:
if(!(refChooser.getSelectedItem().toString().equals("")))
{
if(call==null){
/*call = new ApplyProcess(id,"",currentTransformation,refChooser.getSelectedItem().toString());
currentTransformation.addCall(call);
(currentProcess).addVertex(call,location,FCConstants.APPLYPROCESS);*/
this.dispose();
}
else{
call.setId(id);
((ApplyProcess)call).setRef(refChooser.getSelectedItem().toString());
}
this.dispose();
}
else
{
//System.out.println("not single");
if (alertJLabel == null)
{
alertJLabel = new JLabel("alert !! ref is empty!!");
getContentPane().add(alertJLabel);
}
else
alertJLabel.setText("alert !! ref is empty!!");
refJLabel.setForeground(Color.red);
this.pack();
}
break;
case FCConstants.APPLYQUERY:
if(call==null){
System.out.println("not yet implemented");
}
else{
}
this.dispose();
break;
case FCConstants.APPLYRULESET:
if(call==null){
System.out.println("not yet implemented");
}
else{
}
this.dispose();
break;
case FCConstants.GENERATE:
if(!(fileText.getText().equals(""))){
if(call==null)
{
/*call = new Generate(id,typeChooser.getSelectedItem().toString(),fileText.getText(),currentTransformation);
currentTransformation.addCall(call);
(currentProcess).addVertex(call,location,FCConstants.GENERATE);*/
}
else
{
call.setId(id);
call.setType(typeChooser.getSelectedItem().toString());
((Generate)call).setFile(fileText.getText());
}
this.dispose();
}
else
{
if (alertJLabel == null)
{
alertJLabel = new JLabel("alert !! file is empty!!");
getContentPane().add(alertJLabel);
}
else
alertJLabel.setText("alert !! file is empty!!");
fileJLabel.setForeground(Color.red);
this.pack();
}
break;
default :
System.out.println("not yet implemented");
break;
}
//createCall();
}
else
{
//System.out.println("not single");
if (alertJLabel == null)
{
alertJLabel = new JLabel("alert !! id must be single!!");
getContentPane().add(alertJLabel);
}
else
alertJLabel.setText("alert !! id must be single!!");
idJLabel.setForeground(Color.red);
this.pack();
}
}
else{
//id = ""
if (alertJLabel == null)
{
alertJLabel = new JLabel("alert !! id musn't be an empty string");
getContentPane().add(alertJLabel);
}
else
alertJLabel.setText("alert !! id musn't be an empty string");
idJLabel.setForeground(Color.red);
this.pack();
}
if(event.getSource() == ok ) {
//ok action.
//for each component we must test if the id is single.
if(!(id.equals(""))){
//id != ""
if(currentProcess != null && (id.equals(call.getId()) || currentProcess.isSingleId(id))){
//id is single
switch(type){
case FCConstants.MERGE:
call.setId(id);
call.setType(typeChooser.getSelectedItem().toString());
this.dispose();
break;
case FCConstants.DISPATCH :
call.setId(id);
call.setType(typeChooser.getSelectedItem().toString());
this.dispose();
break;
case FCConstants.SERIALIZE :
if(!(fileText.getText().equals(""))){
call.setId(id);
call.setType(typeChooser.getSelectedItem().toString());
((Serialize)call).setFile(fileText.getText());
this.dispose();
}
else{
//traitement d'erreur
}
break;
case FCConstants.APPLYEXTERNAL :
if(!(fileText.getText().equals(""))){
call.setId(id);
call.setType(typeChooser.getSelectedItem().toString());
((ApplyExternal)call).setFile(fileText.getText());
this.dispose();
}
else{
//traitement d'erreur
}
break;
case FCConstants.APPLYPROCESS:
if(!(refChooser.getSelectedItem().toString().equals(""))){
call.setId(id);
((ApplyProcess)call).setRef(refChooser.getSelectedItem().toString());
this.dispose();
}
else{
//traitement d'erreur
}
break;
case FCConstants.APPLYQUERY:
break;
case FCConstants.APPLYRULESET:
break;
case FCConstants.GENERATE:
if(!(fileText.getText().equals(""))){
call.setId(id);
call.setType(typeChooser.getSelectedItem().toString());
((Generate)call).setFile(fileText.getText());
this.dispose();
}
else{
//traitement d'erreur
}
break;
default :
System.out.println("not yet implemented");
break;
}
}
else {
//System.out.println("not single");
//traitement d'erreur
}
}
else{
//id = ""
//traitement d'erreur
}
}
else if(event.getSource() == cancel){
this.dispose();
}
else if(event.getSource() == refRadio){
fileJLabel.setEnabled(false);
fileText.setEnabled(false);
fileChooserButton.setEnabled(false);
refJLabel.setEnabled(true);
refChooser.setEnabled(true);
}
else if(event.getSource() == fileRadio){
fileJLabel.setEnabled(true);
fileText.setEnabled(true);
fileChooserButton.setEnabled(true);
refJLabel.setEnabled(false);
refChooser.setEnabled(false);
}
else if(event.getSource() == cancel)
{
this.dispose();
}
else if(event.getSource() == fileChooserButton ){
fileChooser = new JFileChooser();
int returnVal = fileChooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
fileText.setText(file.getAbsolutePath());
//this is where a real application would open the file.
//log.append("Opening: " + file.getName() + "." + newline);
} else {
}
else {
//log.append("Open command cancelled by user." + newline);
}
}
}
}
}
}
......@@ -1584,8 +1466,8 @@ public class FlowComposer extends JPanel implements GraphModelListener,
if (r != JOptionPane.CANCEL_OPTION) {
*/
getFrame().dispose();
return true;
getFrame().dispose();
return true;
/*}
return false;
......
......@@ -43,11 +43,12 @@ public class PortProcessRenderer extends VertexRenderer {
g2.setStroke(new BasicStroke(b));
drawPortProcess(g,d,b);
}
/*
if (selected) {
g2.setStroke(GraphConstants.SELECTION_STROKE);
g.setColor(graph.getHighlightColor());
drawPortProcess(g,d,b);
}
}*/
}
private void drawPortProcess(Graphics g,Dimension d , int b ) {
......
/**
* $Id: ProcessGraph.java,v 1.38 2002-06-25 13:26:31 frederic Exp $
* $Id: ProcessGraph.java,v 1.39 2002-06-26 12:25:09 frederic Exp $
*
* Transmorpher
*
......@@ -237,7 +237,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
{
if(arg instanceof Call)
{
if(arg instanceof Dispatch)
if(arg instanceof Dispatch)
addVertex(arg,FCConstants.DISPATCH);
else if(arg instanceof Merge)
addVertex(arg,FCConstants.MERGE);
......@@ -254,17 +254,12 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
else if(arg instanceof ApplyRuleset)
addVertex(arg,FCConstants.APPLYRULESET);
}
}
else if(arg instanceof Port)
{
Port port = (Port)arg;
if (port.getType()==FCConstants.PORTINPUT)
addVertex(port,FCConstants.PORTPROCESS);
else
addVertex(port,FCConstants.PORTPROCESS);
updateCellProcess(port.getType());
Port port = (Port)arg;
addVertex(port,FCConstants.PORTPROCESS);
updateCellProcess(port.getType());
}
else if(arg instanceof Channel)
{
......@@ -670,7 +665,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
result.add(roots[i]);
}*/
for (int i=0; i < roots.length; i++){
if (roots[i] instanceof PortProcessCell && (((Port)((PortProcessCell)roots[i]).getUserObject()).getType() == portLocation))
if (roots[i] instanceof PortProcessCell && (((Port)((PortCell)((PortProcessCell)roots[i]).getChildAt(0)).getUserObject()).getType() == portLocation))
{
result.add(roots[i]);
}
......@@ -827,13 +822,11 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
attributes = commonAttributres(cell,bounds);
break;
case FCConstants.PORTPROCESS :
cell = new PortProcessCell(userObject);
cell = new PortProcessCell(null);
bounds = new Rectangle(position,boundsPort);
attributes = commonAttributres(cell,bounds);
if(userObject instanceof Port)
addPort(cell,viewMap,((Port)userObject).getType());
else
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
if(userObject instanceof Port)
addPort(cell,viewMap,(Port)userObject);
break;
default: System.out.println("pas de vertex correspondant la string : FlowComposerGraph+meth commonAttributres");break;
......@@ -852,13 +845,13 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
Map map = GraphConstants.createMap();
if(cell instanceof PortProcessCell){
GraphConstants.setEditable(map,false);
GraphConstants.setMoveable(map, false);
GraphConstants.setSizeable(map, false);
//GraphConstants.setSizeable(map, false);
}
GraphConstants.setBounds(map, bounds);
GraphConstants.setOpaque(map, false);
//GraphConstants.setOpaque(map, false);
GraphConstants.setBorderColor(map, Color.black);
return map;
......@@ -869,8 +862,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
Object[] tmp = getSelectionCells();
DefaultGraphCell cell;
String name ="";
String name ="";
Port port ;
......@@ -890,9 +882,8 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
if (type==FCConstants.PORTINPUT)
{
number = transformation.inPorts().length();
port= new Port("",transformation,number,type);
transformation.addIn(port);
port= new Port("",transformation,number,type);
transformation.addIn(port);
}
else
{
......@@ -903,24 +894,12 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
}
}