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

update popup

parent 5d77831d
/**
* $Id: FCMarqueeHandler.java,v 1.43 2002-07-03 16:15:15 gchomat Exp $
* $Id: FCMarqueeHandler.java,v 1.44 2002-07-03 16:31:07 frederic Exp $
*
* Transmorpher
......@@ -156,27 +156,25 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
public void mousePressed(MouseEvent e) {
//System.out.println("MousePressed Start...");
ProcessGraph currentProcess = flowcomposer.getCurrentProcess();
if (e.isPopupTrigger()){
if (!e.isConsumed() && marquee.isSelected()) {
current = flowcomposer.getCurrentProcess().snap(e.getPoint());
flowcomposer.showPopup(e);
return;
}
if (!e.isConsumed() && marquee.isSelected()) {
flowcomposer.showPopup(e,currentProcess.snap(e.getPoint()));
e.consume();
}
}
/*if (e.getButton() == MouseEvent.BUTTON3) {
current = flowcomposer.getCurrentProcess().snap(e.getPoint());
flowcomposer.showPopup(e);
}*/
else{
if(flowcomposer.getCurrentProcess() != null){
if(currentProcess != null){
if (!e.isConsumed() && !marquee.isSelected()) {
start = flowcomposer.getCurrentProcess().snap(e.getPoint());
start = currentProcess.snap(e.getPoint());
firstPort = port;
if ((edgeNormal.isSelected())&&(firstPort != null)) {
double scale = flowcomposer.getCurrentProcess().getScale();
double scale = currentProcess.getScale();
start = firstPort.getLocation(null);
start = new Point((int)(start.x*scale),(int)(start.y*scale));
}
......@@ -192,19 +190,20 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
}
public void mouseDragged(MouseEvent event) {
//System.out.println("MouseDragged Start...");
if(flowcomposer.getCurrentProcess() != null){
//System.out.println("MouseDragged Start...");
ProcessGraph currentProcess = flowcomposer.getCurrentProcess();
if(currentProcess != null){
if (!event.isConsumed() && !marquee.isSelected()) {
Graphics g = flowcomposer.getCurrentProcess().getGraphics();
Color bg = flowcomposer.getCurrentProcess().getBackground();
Graphics g = currentProcess.getGraphics();
Color bg = currentProcess.getBackground();
Color fg = Color.black;
g.setColor(fg);
g.setXORMode(bg);
overlay(g);
current = flowcomposer.getCurrentProcess().snap(event.getPoint());
current = currentProcess.snap(event.getPoint());
if (edgeNormal.isSelected()){
double scale = flowcomposer.getCurrentProcess().getScale();
port = flowcomposer.getCurrentProcess().getPortViewAt((int)(event.getX()/scale),(int)(event.getY()/scale));
double scale = currentProcess.getScale();
port = currentProcess.getPortViewAt((int)(event.getX()/scale),(int)(event.getY()/scale));
if ( port != null ) {
current = port.getLocation(null);
current = new Point((int)(current.x*scale),(int)(current.y*scale));
......
/**
*
*$Id: FlowComposer.java,v 1.63 2002-07-03 16:15:15 gchomat Exp $
*$Id: FlowComposer.java,v 1.64 2002-07-03 16:31:07 frederic Exp $
*
* Transmorpher
*
......@@ -107,9 +107,12 @@ public class FlowComposer extends JPanel implements GraphModelListener,
protected Layout touchLayout;
public static double[] zoomSizes = new double[]{0.5,0.75,1.0,1.5,2.0,5.0};
protected static double[] zoomSizes = new double[]{0.5,0.75,1.0,1.5,2.0,5.0};
protected static String[] zoomMessage = new String[]{"50%","75%","100%","150%","200%","500%"};
public static String[] zoomMessage = new String[]{"50%","75%","100%","150%","200%","500%"};
private Rectangle viewPortRect = null;
......@@ -159,13 +162,18 @@ public class FlowComposer extends JPanel implements GraphModelListener,
boolean init_main = true;
protected int mouseRightX;
protected int mouseRightY;
/**Default width of the app*/
public static final int PREFERRED_WIDTH =640;
/**Default height of the app*/
public static final int PREFERRED_HEIGHT =480;
protected int workSurfaceX = PREFERRED_WIDTH;
protected int workSurfaceY = PREFERRED_HEIGHT;
public static final int MAIN = 1;
public static final int SERVLET = 2;
public static final int TRANSFORMER = 3;
......@@ -624,15 +632,21 @@ public class FlowComposer extends JPanel implements GraphModelListener,
tabProcess.setSelectedComponent(sp);
//componentResized(null);
currentProcess.setPreferredSize(new Dimension(PREFERRED_WIDTH,PREFERRED_HEIGHT));
currentProcess.setBorder(loweredbevel);
currentProcess.setBackground(Color.white);
undoHandler.setProcess(currentProcess);
JButton buttonView = new JButton("VG");
JButton but1 = new JButton(">");
JButton but2 = new JButton("<");
JPanel panel = new JPanel();
sp.setCorner(JScrollPane.LOWER_RIGHT_CORNER,buttonView);
ActionListener buttonListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
JDialog overviewDlg = new JDialog(getFrame(),"GeneralView", false);
JDialog overviewDlg = new JDialog(getFrame(),"GeneralView", false);
Container fContentPane = overviewDlg.getContentPane();
fContentPane.setLayout(new BorderLayout());
FCOverviewPanel overviewPanel = new FCOverviewPanel(currentProcess);
......@@ -707,9 +721,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//System.out.println("cmd " +cmd);
String subMenu = getResourceString(cmd + menuSuffix);
String subMenu = getResourceString(cmd + menuSuffix);
if (subMenu != null) {
String[] itemKeys = tokenize(subMenu);
return createMenu(cmd, itemKeys);
......@@ -856,17 +868,15 @@ public class FlowComposer extends JPanel implements GraphModelListener,
return b;
}
public JPopupMenu createPopupMenu(String popup){
popupMenu = new JPopupMenu();
String[] tool = tokenize(getResourceString(popup));
for (int i = 0; i < tool.length; i++) {
if (tool[i].equals("-")) {
popupMenu.addSeparator();
} else {
public JPopupMenu createPopupMenu(){
popupMenu = new JPopupMenu();
String[] tool = tokenize(getResourceString("popup1"));
for (int i = 0; i < tool.length; i++) {
if (tool[i].equals("-")) {
popupMenu.addSeparator();
} else {
popupMenu.add(createMenuItem(tool[i]));
}
}
}
return popupMenu;
......@@ -1317,10 +1327,15 @@ public class FlowComposer extends JPanel implements GraphModelListener,
return buttons;
}
public void showPopup(MouseEvent e){
public void showPopup(MouseEvent e,Point position){
popupMenu = createPopupMenu("popup1");
popupMenu.show(e.getComponent(),e.getX(),e.getY());
mouseRightX = position.x;
mouseRightY = position.y;
popupMenu = createPopupMenu();
System.out.println(position.x);
//currentProcess.fromScreen(position);
System.out.println(position.x+"j'en ai marre");
popupMenu.show(e.getComponent(),position.x,position.y);
}
......@@ -1405,26 +1420,31 @@ public class FlowComposer extends JPanel implements GraphModelListener,
protected boolean editMode;
protected Point location;
protected Container contentPane;
protected JPanel attr,param;
public EditCall(Call call, Point location,int type){
super((JFrame)getTopLevelAncestor(),"",true);
this.call = call;
this.type=type;
this.location = location;
editMode = (call != null);
editMode = (call!= null);
this.setResizable(false);
contentPane = getContentPane();
attr = new JPanel();
param = new JPanel();
attr.setLayout(new GridLayout(0,1));
param.setLayout(new GridLayout(0,1));
contentPane.setLayout(new GridLayout(0,1));
buildDialog();
}
protected void makeComponent(Object[] component) {
protected void makeComponent(Object[] component,JPanel pane) {
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT,20,5));
for (int i=0;i<component.length;i++) {
panel.add((Container)component[i]);
}
contentPane.add(panel);
pane.add(panel);
}
/**
......@@ -1452,7 +1472,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
idText.setPreferredSize(new Dimension(165,20));
idText.addActionListener(this);
Object[] compId = new Object[]{idJLabel,idText};
makeComponent(compId);
makeComponent(compId,attr);
//list of type. if null no type must be defined for this call.
Object[] list = FCConstants.getListType(type);
......@@ -1466,11 +1486,16 @@ public class FlowComposer extends JPanel implements GraphModelListener,
if(editMode){
Object value = ((Parameters)attributes).getParameter("type");
typeChooser.setSelectedItem(value);
typeChooser.setEditable(true);
}
Object[] compType = new Object[]{typeJLabel,typeChooser};
makeComponent(compType);
makeComponent(compType,attr);
}
Border title1 = BorderFactory.createTitledBorder("Attributes");
attr.setBorder(title1);
if (call instanceof ApplyQuery) {
refRadio = new JRadioButton("ref");
fileRadio = new JRadioButton("file");
......@@ -1483,7 +1508,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
group.add(fileRadio);
refRadio.setSelected(true);
Object[] compRadio = new Object[]{refRadio,fileRadio};
makeComponent(compRadio);
// makeComponent(compRadio);
}
Object file = (parameters instanceof Parameters)?((Parameters)parameters).getParameter("file"):((Hashtable)attributes).get("file");
......@@ -1498,7 +1523,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
fileText.setPreferredSize(new Dimension(120,20));
fileChooserButton.setPreferredSize(new Dimension(25,20));
Object[] compFile = new Object[]{fileJLabel,fileText,fileChooserButton};
makeComponent(compFile);
// makeComponent(compFile);
if (call instanceof ApplyQuery) { fileJLabel.setEnabled(false);
fileText.setEnabled(false);
fileChooserButton.setEnabled(false);}
......@@ -1514,7 +1539,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
strategyChooser.setSelectedItem(strategy);
strategyChooser.setPreferredSize(new Dimension(120,20));
Object[] compStrategy = new Object[]{strategyJLabel,strategyChooser};
makeComponent(compStrategy);
// makeComponent(compStrategy);
}
Object ref = (attributes instanceof Parameters)?((Parameters)attributes).getParameter("ref"):((Hashtable)attributes).get("ref");
......@@ -1533,7 +1558,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
}
Object[] compRef = new Object[]{refJLabel,refChooser};
makeComponent(compRef);
// makeComponent(compRef);
}
......@@ -1549,6 +1574,8 @@ public class FlowComposer extends JPanel implements GraphModelListener,
pane.setLayout(new FlowLayout(FlowLayout.RIGHT));
pane.add(ok);
pane.add(cancel);
contentPane.add(attr);
contentPane.add(param);
contentPane.add(pane);
//Object[] comp = new Object[]{pane,ok,pane,cancel,pane};
//makeComponent(comp);
......@@ -1964,26 +1991,15 @@ public class FlowComposer extends JPanel implements GraphModelListener,
public void actionPerformed(ActionEvent e) {
currentProcess.setScale(1.0);
Dimension dim = currentProcess.getPreferredSize();
Dimension dim = new Dimension(workSurfaceX,workSurfaceY);
int scale = currentProcess.getZoomCurrent();
//System.out.println(scale+"scale");
currentProcess.setZoomCurrent(2);
if (scale>2) {
for (int i=scale;i>2;i--){
//System.out.println(i+"i");
currentProcess.setPreferredSize(new Dimension((int)(dim.width/zoomSizes[i]),(int)(dim.height/zoomSizes[i])));
dim = currentProcess.getPreferredSize();
resizeComponent(currentProcess);
}
}
else if (scale<2) {
for (int i=scale;i<2;i++){
//System.out.println(i+"i");
currentProcess.setPreferredSize(new Dimension((int)(dim.width/zoomSizes[i]),(int)(dim.height/zoomSizes[i])));
dim = currentProcess.getPreferredSize();
resizeComponent(currentProcess);
}
}
currentProcess.setPreferredSize(new Dimension(dim.width,dim.height));
resizeComponent(currentProcess);
messageScale.setText((String)zoomMessage[2]);
}
}
......@@ -1998,15 +2014,14 @@ public class FlowComposer extends JPanel implements GraphModelListener,
public void actionPerformed(ActionEvent e) {
Dimension dim = currentProcess.getPreferredSize();
Dimension dim = new Dimension(workSurfaceX,workSurfaceY);
int scale = currentProcess.getZoomCurrent();
//System.out.println(scale+"action performed");
currentProcess.setZoomCurrent(scale+1);
currentProcess.setScale(zoomSizes[scale+1]);
if (scale<2)
currentProcess.setPreferredSize(new Dimension((int)(dim.width/zoomSizes[scale]),(int)(dim.height/zoomSizes[scale])));
else currentProcess.setPreferredSize(new Dimension((int)(dim.width*zoomSizes[scale+1]),(int)(dim.height*zoomSizes[scale+1])));
currentProcess.setPreferredSize(new Dimension((int)(dim.width*zoomSizes[scale+1]),(int)(dim.height*zoomSizes[scale+1])));
resizeComponent(currentProcess);
messageScale.setText((String)zoomMessage[scale+1]);
// peut etre a mettre
//if ((flow.getGraph()).getSelectionCell() != null)
......@@ -2036,15 +2051,15 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void actionPerformed(ActionEvent e) {
Dimension dim = currentProcess.getPreferredSize();
//Dimension dim = currentProcess.getPreferredSize();
Dimension dim = new Dimension(workSurfaceX,workSurfaceY);
int scale = currentProcess.getZoomCurrent();
currentProcess.setZoomCurrent(scale-1);
currentProcess.setScale(zoomSizes[scale-1]);
//System.out.println(scale+"scale");
if (scale>2)
currentProcess.setPreferredSize(new Dimension((int)(dim.width/zoomSizes[scale]),(int)(dim.height/zoomSizes[scale])));
else currentProcess.setPreferredSize(new Dimension((int)(dim.width*zoomSizes[scale-1]),(int)(dim.height*zoomSizes[scale-1])));
currentProcess.setPreferredSize(new Dimension((int)(dim.width*zoomSizes[scale-1]),(int)(dim.height*zoomSizes[scale-1])));
resizeComponent(currentProcess);
messageScale.setText((String)zoomMessage[scale-1]);
}
......@@ -2342,21 +2357,18 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void actionPerformed(ActionEvent e) {
if(currentProcess.getSelectionCell()!= null)
{
new EditCall((Call)((FCGraphCell)currentProcess.getSelectionCell()).getUserObject() , marqueeHandler.getCurrentPoint(),FCConstants.getType((Call)((FCGraphCell)currentProcess.getSelectionCell()).getUserObject()));
}
Point point = new Point(mouseRightX,mouseRightY);
if(currentProcess.getSelectionCell()!= null) {
new EditCall((Call)((FCGraphCell)currentProcess.getSelectionCell()).getUserObject(),point,FCConstants.getType((Call)((FCGraphCell)currentProcess.getSelectionCell()).getUserObject()));
}
}
protected void update(){
if(currentProcess != null && currentProcess.getSelectionCount()==1 && (currentProcess.getSelectionCell() instanceof FCGraphCell))
setEnabled(true);
else
setEnabled(false);
}
if((currentProcess != null)&&(currentProcess.getSelectionCount()==1)&&(currentProcess.getSelectionCell() instanceof FCGraphCell))
setEnabled(true);
else setEnabled(false);
}
}
......
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