From: <had...@us...> - 2008-08-18 07:49:40
|
Revision: 3812 http://fudaa.svn.sourceforge.net/fudaa/?rev=3812&view=rev Author: hadouxad Date: 2008-08-18 07:49:49 +0000 (Mon, 18 Aug 2008) Log Message: ----------- - Creation d un editeur docking pour le widget graphe. Utilisation similaire au calque Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EditCreator.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetGraphe.java Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EditCreator.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EditCreator.java 2008-08-18 07:16:38 UTC (rev 3811) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EditCreator.java 2008-08-18 07:49:49 UTC (rev 3812) @@ -16,6 +16,7 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JToolBar; +import javax.swing.JTree; import javax.swing.border.LineBorder; import org.flexdock.docking.DockingConstants; @@ -27,6 +28,8 @@ import org.fudaa.ebli.calque.ZEbliCalquesPanel; import org.fudaa.ebli.commun.EbliActionInterface; import org.fudaa.ebli.commun.EbliComponentFactory; +import org.fudaa.ebli.courbe.EGFillePanel; +import org.fudaa.ebli.courbe.EGGrapheTreeModel; /** * A ameliorer... @@ -82,7 +85,55 @@ return frame; } + + public JFrame createFrame(EGFillePanel pn) { + JFrame frame = new JFrame("Modification du graphe"); + frame.getContentPane().setLayout(new BorderLayout()); + EbliActionInterface[] specificInterfaces = pn.getSpecificActions(); + JMenuBar mb = new JMenuBar(); + frame.setJMenuBar(mb); + JMenu menu = new JMenu("Menu graphe"); + pn.fillSpecificMenu(menu); + + // for (int i = 0; i < specificInterfaces.length; i++) { + // mb.add(new JMenu(specificInterfaces[i])); + // } + mb.add(menu); + + JToolBar tb = new JToolBar(); + + for (int i = 0; i < specificInterfaces.length; i++) { + EbliActionInterface object = specificInterfaces[i]; + if (object == null) { + tb.addSeparator(); + } else { + tb.add(object.buildToolButton(EbliComponentFactory.INSTANCE)); + } + } + frame.getContentPane().add(tb, BorderLayout.NORTH); + pn.setPreferredSize(pn.getPreferredSize()); + final DefaultDockingPort globalPort = createDockingPort(); + JComponent centerComponent = createView(pn, "Graphe"); + DockingManager.dock(centerComponent, (DockingPort) globalPort); + JTree tree = new JTree((EGGrapheTreeModel) pn.getGraphe().getModel()); + JComponent rightComponent = createView(new JScrollPane(tree), "arbre", true); + DockingManager.dock(rightComponent, centerComponent, DockingConstants.EAST_REGION, 0.75f); + + frame.getContentPane().add(globalPort, BorderLayout.CENTER); + frame.addWindowListener(new WindowAdapter() { + + @Override + public void windowClosed(WindowEvent _e) { + globalPort.clear(); + } + + }); + return frame; + + } + + private static DefaultDockingPort createDockingPort() { DefaultDockingPort port = new DefaultDockingPort(); port.setPreferredSize(new Dimension(400, 400)); Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetGraphe.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetGraphe.java 2008-08-18 07:16:38 UTC (rev 3811) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetGraphe.java 2008-08-18 07:49:49 UTC (rev 3812) @@ -7,40 +7,50 @@ import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.util.EnumSet; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; -import javax.swing.JMenu; +import javax.swing.JComponent; +import javax.swing.JFrame; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; import org.fudaa.ctulu.CtuluResource; -import org.fudaa.ctulu.gui.CtuluPopupListener; import org.fudaa.ebli.courbe.EGConfigureActionPalette; import org.fudaa.ebli.courbe.EGFillePanel; import org.fudaa.ebli.courbe.EGGraphe; import org.fudaa.ebli.visuallibrary.EbliNodeDefault; import org.fudaa.ebli.visuallibrary.EbliScene; import org.fudaa.ebli.visuallibrary.EbliWidget; +import org.fudaa.ebli.visuallibrary.calque.EditCreator; import org.netbeans.api.visual.action.ActionFactory; -import org.netbeans.api.visual.action.InplaceEditorProvider; +import org.netbeans.api.visual.action.EditProvider; import org.netbeans.api.visual.action.PopupMenuProvider; import org.netbeans.api.visual.action.WidgetAction; import org.netbeans.api.visual.widget.Widget; -import com.memoire.bu.BuPanel; - /** * widget qui contient un objet graphe * @author adrien hadoux * */ -public class EbliWidgetGraphe extends EbliWidget implements InplaceEditorProvider<BuPanel>{ +public class EbliWidgetGraphe extends EbliWidget implements EditProvider/* + * , + * InplaceEditorProvider + * < + * BuPanel + * > + */{ private EGGraphe graphe; + JFrame frame_; + EditCreator editor_; + EGFillePanel panelGraphe_; + private EbliNodeDefault nodeLegende=null; - + public Color couleurContour=Color.black; public Color couleurFond=Color.white; @@ -57,11 +67,14 @@ // TODO Auto-generated constructor stub setGraphe(_graphe); - - + editor_ = EditCreator.INSTANCE; + panelGraphe_=new EGFillePanel(_graphe); //-- creation de l action pour editor --// - WidgetAction editorAction = ActionFactory.createInplaceEditorAction(this); + // WidgetAction editorAction = + // ActionFactory.createInplaceEditorAction(this); + WidgetAction editorAction = ActionFactory.createEditAction(this); + // -- ajout de l action au widget correspondant --// this.getActions().addAction(editorAction); @@ -112,10 +125,7 @@ * @param _popup */ private void constructPopupMenuSpecifique(JPopupMenu _popup){ - - - - JMenuItem menuItem=_popup.add ("Ajouter la l\xE9gende"); + JMenuItem menuItem = _popup.add("Ajouter la l\xE9gende"); menuItem.setIcon(CtuluResource.CTULU.getIcon("crystal22_commentaire")); menuItem.addActionListener(new ActionListener(){ @@ -163,64 +173,101 @@ /** * Methode appeleee pour creer un editor EGFillePanel correspondant a la vue */ - public /*EGFillePanel*/ BuPanel createEditorComponent( - org.netbeans.api.visual.action.InplaceEditorProvider.EditorController controller, - Widget widget) { - - //-- creation du menu d'actions--// - final JMenu menu = new JMenu(); - menu.setName("menu du graphe"); - menu.setText("menu du graphe"); - // creation du panel Egfille correspondant - final EGFillePanel panelGraphe=new EGFillePanel(this.graphe); - new CtuluPopupListener(new CtuluPopupListener.PopupReceiver() { - - public void popup(MouseEvent _evt) { - panelGraphe.popupMenu(_evt.getX(), _evt.getY()); - - } - },panelGraphe); - - //--remplissage du menu --// - panelGraphe.fillSpecificMenu(menu); - - //FIXME : comment construire le Jmenu principal ainsi que le tree qui qffiche les courbes ??? - - - return panelGraphe; - } + // public /*EGFillePanel*/ BuPanel createEditorComponent( + // org.netbeans.api.visual.action.InplaceEditorProvider.EditorController + // controller, + // Widget widget) { + // + // //-- creation du menu d'actions--// + // final JMenu menu = new JMenu(); + // menu.setName("menu du graphe"); + // menu.setText("menu du graphe"); + // // creation du panel Egfille correspondant + // final EGFillePanel panelGraphe=new EGFillePanel(this.graphe); + // new CtuluPopupListener(new CtuluPopupListener.PopupReceiver() { + // + // public void popup(MouseEvent _evt) { + // panelGraphe.popupMenu(_evt.getX(), _evt.getY()); + // + // } + // },panelGraphe); + // + // //--remplissage du menu --// + // panelGraphe.fillSpecificMenu(menu); + // + // //FIXME : comment construire le Jmenu principal ainsi que le tree qui + // qffiche les courbes ??? + // + // + // return panelGraphe; + // } - - + public void edit(Widget _widget) { + if (frame_ != null) frame_.toFront(); + else { + // final GrBoite gr = calquePanel_.getVueCalque().getViewBoite(); + Rectangle rec = convertLocalToScene(getClientArea()); + Point p = new Point(rec.x, rec.y); + JComponent jc = getEbliScene().getView(); + SwingUtilities.convertPointToScreen(p, jc); - public EnumSet<org.netbeans.api.visual.action.InplaceEditorProvider.ExpansionDirection> getExpansionDirections( - org.netbeans.api.visual.action.InplaceEditorProvider.EditorController controller, - Widget widget, /*EGFillePanel*/BuPanel editor) { - // TODO Auto-generated method stub - return null; - } + frame_ = editor_.createFrame(panelGraphe_); + frame_.setLocation(p); + frame_.pack(); + // calquePanel_.getVueCalque().changeRepere(this, gr); + frame_.setVisible(true); + frame_.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame_.addWindowListener(new WindowAdapter() { - public Rectangle getInitialEditorComponentBounds( - org.netbeans.api.visual.action.InplaceEditorProvider.EditorController controller, - Widget widget, /*EGFillePanel*/BuPanel editor, Rectangle viewBounds) { - // TODO Auto-generated method stub - return null; - } + @Override + public void windowClosed(WindowEvent _e) { + if (frame_ != null) frame_.dispose(); + frame_ = null; + } - public void notifyClosing( - org.netbeans.api.visual.action.InplaceEditorProvider.EditorController controller, - Widget widget, /*EGFillePanel*/BuPanel editor, boolean commit) { - // TODO Auto-generated method stub - - } + +// public void windowClosing(WindowEvent _e) { +// zoom_ = calquePanel_.getVueCalque().getViewBoite(); +// // image = null; +// // getEbliScene().refresh(); +// } - public void notifyOpened( - org.netbeans.api.visual.action.InplaceEditorProvider.EditorController controller, - Widget widget, /*EGFillePanel*/BuPanel editor) { - // TODO Auto-generated method stub - + }); + } + } + + + +// public EnumSet<org.netbeans.api.visual.action.InplaceEditorProvider.ExpansionDirection> getExpansionDirections( +// org.netbeans.api.visual.action.InplaceEditorProvider.EditorController controller, +// Widget widget, /*EGFillePanel*/BuPanel editor) { +// // TODO Auto-generated method stub +// return null; +// } +// +// public Rectangle getInitialEditorComponentBounds( +// org.netbeans.api.visual.action.InplaceEditorProvider.EditorController controller, +// Widget widget, /*EGFillePanel*/BuPanel editor, Rectangle viewBounds) { +// // TODO Auto-generated method stub +// return null; +// } +// +// public void notifyClosing( +// org.netbeans.api.visual.action.InplaceEditorProvider.EditorController controller, +// Widget widget, /*EGFillePanel*/BuPanel editor, boolean commit) { +// // TODO Auto-generated method stub +// +// } +// +// public void notifyOpened( +// org.netbeans.api.visual.action.InplaceEditorProvider.EditorController controller, +// Widget widget, /*EGFillePanel*/BuPanel editor) { +// // TODO Auto-generated method stub +// +// } + // public void setColorContour(Color newColor){ // couleurContour=newColor; // repaint(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |