protected Control createContents(Composite parent) { ViewForm form = new ViewForm(parent, SWT.NONE); form.setSize(400, 290); final Composite shell = new Composite(form.getShell(), SWT.NONE); Label lbApp1 = new Label(shell, SWT.NONE); lbApp1.setText("Version:"); lbApp1.setBounds(10, 10, 50, 20); controls.add(lbApp1); Label lbApp2 = new Label(shell, SWT.NONE); lbApp2.setText("noti-J 1.0"); lbApp2.setBounds(UIUtils.getBoundsH(lbApp1, 10, 100)); controls.add(lbApp2); Label lbStatus1 = new Label(shell, SWT.NONE); lbStatus1.setText("State:"); lbStatus1.setBounds(UIUtils.getBoundsV(lbApp1, 10)); controls.add(lbStatus1); Label lbStatus2 = new Label(shell, SWT.NONE); lbStatus2.setText(connected ? "connected" : "disconnect"); lbStatus2.setForeground( Display.getDefault().getSystemColor(connected ? SWT.COLOR_BLUE : SWT.COLOR_RED)); lbStatus2.setBounds(UIUtils.getBoundsV(lbApp2, 10)); controls.add(lbStatus2); Label lbUser1 = new Label(shell, SWT.NONE); lbUser1.setText("Account:"); lbUser1.setBounds(UIUtils.getBoundsV(lbStatus1, 10)); controls.add(lbUser1); Label lbUser2 = new Label(shell, SWT.NONE); lbUser2.setText(userid + "(" + userName + ")"); lbUser2.setBounds(UIUtils.getBoundsV(lbStatus2, 10)); controls.add(lbUser2); Label lbLic1 = new Label(shell, SWT.NONE); lbLic1.setText("License:"); lbLic1.setBounds(UIUtils.getBoundsV(lbUser1, 10)); controls.add(lbLic1); Label lbLic2 = new Label(shell, SWT.NONE); lbLic2.setText("GPL 3.0"); lbLic2.setBounds(UIUtils.getBoundsV(lbUser2, 10)); controls.add(lbLic2); Label lbDev1 = new Label(shell, SWT.NONE); lbDev1.setText("Author:"); lbDev1.setBounds(UIUtils.getBoundsV(lbLic1, 10)); controls.add(lbDev1); Label lbDev2 = new Label(shell, SWT.NONE); lbDev2.setText("Jong-Bok,Park([email protected])"); lbDev2.setBounds(UIUtils.getBoundsV(lbLic2, 10, 300)); controls.add(lbDev2); Text txError = new Text(shell, SWT.NONE | SWT.WRAP); txError.setText(errorMsg == null ? "" : errorMsg); txError.setBounds(UIUtils.getBoundsV(lbDev1, 10, 300, 100)); txError.setEditable(false); controls.add(txError); controls.add(form); return form; }
public GrapheChargesIHM(final ViewForm parent) { super(parent, SWT.H_SCROLL | SWT.V_SCROLL); this.parent = parent; // this.setLayout(new FillLayout(SWT.VERTICAL)); this.setSize(parent.getSize()); canvas = new Canvas(this, SWT.NONE); reglerTaille(); Menu menu = new Menu(parent.getShell(), SWT.POP_UP); MenuItem vueNormale = new MenuItem(menu, SWT.NONE); vueNormale.setText(message.getString("vueNormale")); vueNormale.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { vueSuperposee = false; canvas.redraw(); } }); new MenuItem(menu, SWT.SEPARATOR); MenuItem vueSuper = new MenuItem(menu, SWT.NONE); vueSuper.setText(message.getString("vueSuperposee")); vueSuper.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { vueSuperposee = true; canvas.redraw(); } }); canvas.setMenu(menu); final ScrollBar hBar = this.getHorizontalBar(); hBar.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { Point location = canvas.getLocation(); location.x = -hBar.getSelection(); canvas.setLocation(location); canvas.redraw(); } }); final ScrollBar vBar = this.getVerticalBar(); vBar.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { Point location = canvas.getLocation(); location.y = -vBar.getSelection(); canvas.setLocation(location); canvas.redraw(); } }); addListener( SWT.Resize, new Listener() { public void handleEvent(Event event) { reglerTaille(); Point size = canvas.getSize(); Rectangle rect = getClientArea(); hBar.setMaximum(size.x); hBar.setThumb(Math.min(size.x, rect.width)); vBar.setMaximum(size.y); vBar.setThumb(Math.min(size.y, rect.height)); int vPage = size.y - rect.height; int hSelection = hBar.getSelection(); Point location = canvas.getLocation(); if (hSelection >= vPage) { if (vPage <= 0) hSelection = 0; location.x = -hSelection; } int vSelection = vBar.getSelection(); if (vSelection >= vPage) { if (vPage <= 0) vSelection = 0; location.y = -vSelection; } canvas.setLocation(location); } }); canvas.addMouseMoveListener( new MouseMoveListener() { public void mouseMove(MouseEvent e) { ActiviteGraphique actGraph = getAct(e.x, e.y); if (actGraph != null) { // EugesActRealise act = actGraph.getActiviteRealise(); } } }); canvas.addPaintListener( new PaintListener() { public void paintControl(PaintEvent e) { reglerTaille(); GC gc = e.gc; Point p = canvas.getSize(); // axe vertical gc.drawLine(20, 30, 20, p.y - 10); // fleche gc.drawLine(15, 35, 20, 30); gc.drawLine(20, 30, 25, 35); // graduations for (int i = 0; i < p.y - 60; i += 20) { gc.drawLine(15, p.y - 20 - i, 25, p.y - 20 - i); gc.drawString(Integer.toString(i / 10), 5, p.y - 20 - i - 5); } // axe horizontal gc.drawLine(10, p.y - 20, p.x - 10, p.y - 20); // fleche gc.drawLine(p.x - 10, p.y - 20, p.x - 15, p.y - 25); gc.drawLine(p.x - 10, p.y - 20, p.x - 15, p.y - 15); // legende Color blue = e.widget.getDisplay().getSystemColor(SWT.COLOR_BLUE); Color red = e.widget.getDisplay().getSystemColor(SWT.COLOR_RED); Color black = e.widget.getDisplay().getSystemColor(SWT.COLOR_BLACK); Color green = e.widget.getDisplay().getSystemColor(SWT.COLOR_GREEN); gc.setForeground(blue); gc.drawString(message.getString("chargesEstimees"), 0, 0); gc.setForeground(red); gc.drawString(message.getString("chargesReelles"), 0, 15); gc.setForeground(black); gc.drawString(message.getString("activites"), p.x - 50, p.y - 15); if (EugesElements._projet != null) { // si la vue superposee n'est pas choisie if (!vueSuperposee) { rectActivites.clear(); // graduations axe horizontal for (int i = 0; i < p.x - 40; i += 100) gc.drawLine(20 + i, p.y - 15, 20 + i, p.y - 25); // affichage des charges int nbact = 0; for (Iterator it = EugesElements._projet.get_listeIteration().iterator(); it.hasNext(); ) { Iteration itTemp = (Iteration) it.next(); for (int i = 0; i < itTemp.getActiviteCount(); i++) { EugesActRealise actTemp = itTemp.getActivite(i); nbact++; int chargeEstimee = actTemp.get_chargeEstimee(); int chargeReelle = actTemp.get_chargeReelle(); int[] dessus1 = { ((nbact) * 100) - 30, p.y - 20 - (chargeEstimee * 10), ((nbact) * 100) - 15, p.y - 35 - (chargeEstimee * 10), ((nbact) * 100) + 35, p.y - 35 - (chargeEstimee * 10), ((nbact) * 100) + 20, p.y - 20 - (chargeEstimee * 10) }; int[] cote1 = { ((nbact) * 100) + 20, p.y - 20, ((nbact) * 100) + 20, p.y - 20 - (chargeEstimee * 10), ((nbact) * 100) + 35, p.y - 35 - (chargeEstimee * 10), ((nbact) * 100) + 35, p.y - 35 }; int[] dessus2 = { ((nbact) * 100) + 20, p.y - 20 - (chargeReelle * 10), ((nbact) * 100) + 35, p.y - 35 - (chargeReelle * 10), ((nbact) * 100) + 85, p.y - 35 - (chargeReelle * 10), ((nbact) * 100) + 70, p.y - 20 - (chargeReelle * 10) }; int[] cote2 = { ((nbact) * 100) + 70, p.y - 20, ((nbact) * 100) + 70, p.y - 20 - (chargeReelle * 10), ((nbact) * 100) + 85, p.y - 35 - (chargeReelle * 10), ((nbact) * 100) + 85, p.y - 35 }; ActiviteGraphique estimee = new ActiviteGraphique( actTemp, new Rectangle( ((nbact) * 100) - 30, p.y - 20 - (chargeEstimee * 10), 50, chargeEstimee * 10), dessus1, cote1); ActiviteGraphique reelle = new ActiviteGraphique( actTemp, new Rectangle( ((nbact) * 100) + 20, p.y - 20 - (chargeReelle * 10), 50, chargeReelle * 10), dessus2, cote2); rectActivites.add(estimee); rectActivites.add(reelle); // rectangle charge estimée gc.setBackground(blue); gc.fillRectangle( ((nbact) * 100) - 30, p.y - 20 - (chargeEstimee * 10), 50, chargeEstimee * 10); gc.fillPolygon(dessus1); gc.fillPolygon(cote1); gc.setForeground(black); gc.drawRectangle( ((nbact) * 100) - 30, p.y - 20 - (chargeEstimee * 10), 50, chargeEstimee * 10); gc.drawPolygon(dessus1); gc.drawPolygon(cote1); gc.drawString( Integer.toString(chargeEstimee), ((nbact) * 100) - 25, p.y - 15 - (chargeEstimee * 10)); // rectangle charge réelle gc.setBackground(red); gc.fillRectangle( ((nbact) * 100) + 20, p.y - 20 - (chargeReelle * 10), 50, chargeReelle * 10); gc.fillPolygon(dessus2); gc.fillPolygon(cote2); gc.setForeground(black); gc.drawRectangle( ((nbact) * 100) + 20, p.y - 20 - (chargeReelle * 10), 50, chargeReelle * 10); gc.drawPolygon(dessus2); gc.drawPolygon(cote2); gc.drawString( Integer.toString(chargeReelle), ((nbact) * 100) + 25, p.y - 15 - (chargeReelle * 10)); } nbact++; } } else { rectActivites.clear(); // graduations axe horizontal for (int i = 0; i < p.x - 40; i += 50) gc.drawLine(20 + i, p.y - 15, 20 + i, p.y - 25); // affichage des charges int nbact = 0; for (Iterator it = EugesElements._projet.get_listeIteration().iterator(); it.hasNext(); ) { Iteration itTemp = (Iteration) it.next(); for (int i = 0; i < itTemp.getActiviteCount(); i++) { EugesActRealise actTemp = itTemp.getActivite(i); nbact++; int chargeEstimee = actTemp.get_chargeEstimee(); int chargeReelle = actTemp.get_chargeReelle(); int[] dessus1 = { ((nbact) * 50) + 20, p.y - 20 - (chargeEstimee * 10), ((nbact) * 50) + 35, p.y - 35 - (chargeEstimee * 10), ((nbact) * 50) + 85, p.y - 35 - (chargeEstimee * 10), ((nbact) * 50) + 70, p.y - 20 - (chargeEstimee * 10) }; int[] cote1 = { ((nbact) * 50) + 70, p.y - 20, ((nbact) * 50) + 70, p.y - 20 - (chargeEstimee * 10), ((nbact) * 50) + 85, p.y - 35 - (chargeEstimee * 10), ((nbact) * 50) + 85, p.y - 35 }; if (chargeReelle > chargeEstimee) { int[] dessus2 = { ((nbact) * 50) + 20, p.y - 20 - (chargeReelle * 10), ((nbact) * 50) + 35, p.y - 35 - (chargeReelle * 10), ((nbact) * 50) + 85, p.y - 35 - (chargeReelle * 10), ((nbact) * 50) + 70, p.y - 20 - (chargeReelle * 10) }; int[] cote2 = { ((nbact) * 50) + 70, p.y - 20, ((nbact) * 50) + 70, p.y - 20 - (chargeReelle * 10), ((nbact) * 50) + 85, p.y - 35 - (chargeReelle * 10), ((nbact) * 50) + 85, p.y - 35 }; ActiviteGraphique estimee = new ActiviteGraphique( actTemp, new Rectangle( ((nbact) * 50) + 20, p.y - 20 - (chargeEstimee * 10), 50, chargeEstimee * 10), dessus1, cote1); ActiviteGraphique reelle = new ActiviteGraphique( actTemp, new Rectangle( ((nbact) * 50) + 20, p.y - 20 - (chargeReelle * 10), 50, chargeReelle * 10), dessus2, cote2); rectActivites.add(estimee); rectActivites.add(reelle); // rectangle charge réelle gc.setBackground(red); gc.fillRectangle( ((nbact) * 50) + 20, p.y - 20 - (chargeReelle * 10), 50, chargeReelle * 10); gc.fillPolygon(dessus2); gc.fillPolygon(dessus1); gc.fillPolygon(cote2); gc.setForeground(black); gc.drawRectangle( ((nbact) * 50) + 20, p.y - 20 - (chargeReelle * 10), 50, chargeReelle * 10); gc.drawPolygon(dessus2); gc.drawPolygon(cote2); // rectangle charge estimée gc.setBackground(blue); gc.fillRectangle( ((nbact) * 50) + 20, p.y - 20 - (chargeEstimee * 10), 50, chargeEstimee * 10); gc.fillPolygon(cote1); gc.setForeground(black); gc.drawRectangle( ((nbact) * 50) + 20, p.y - 20 - (chargeEstimee * 10), 50, chargeEstimee * 10); // gc.drawPolygon(dessus1); gc.drawPolygon(cote1); } else { int[] dessus2 = { ((nbact) * 50) + 20, p.y - 20 - (chargeReelle * 10), ((nbact) * 50) + 35, p.y - 35 - (chargeReelle * 10), ((nbact) * 50) + 85, p.y - 35 - (chargeReelle * 10), ((nbact) * 50) + 70, p.y - 20 - (chargeReelle * 10) }; ActiviteGraphique estimee = new ActiviteGraphique( actTemp, new Rectangle( ((nbact) * 50) + 20, p.y - 20 - (chargeEstimee * 10), 50, chargeEstimee * 10), dessus1, cote1); ActiviteGraphique reelle = new ActiviteGraphique( actTemp, new Rectangle( ((nbact) * 50) + 20, p.y - 20 - (chargeReelle * 10), 50, chargeReelle * 10), dessus2, cote1); rectActivites.add(estimee); rectActivites.add(reelle); // rectangle charge estimée gc.setBackground(blue); gc.fillRectangle( ((nbact) * 50) + 20, p.y - 20 - (chargeEstimee * 10), 50, chargeEstimee * 10); gc.fillPolygon(cote1); gc.fillPolygon(dessus1); gc.setBackground(green); gc.fillPolygon(dessus2); gc.setForeground(black); gc.drawPolygon(dessus2); gc.setForeground(black); gc.drawRectangle( ((nbact) * 50) + 20, p.y - 20 - (chargeEstimee * 10), 50, chargeEstimee * 10); gc.drawPolygon(dessus1); gc.drawPolygon(cote1); } } nbact++; } } } } }); canvas.redraw(); }