[Nextobjects-devel] nextobjects/nextobjects/src/org/devaki/nextobjects/ui/toolbars NOToolBar2.java,1
Status: Alpha
Brought to you by:
eflorent
From: <efl...@us...> - 2003-06-08 09:28:29
|
Update of /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/ui/toolbars In directory sc8-pr-cvs1:/tmp/cvs-serv28289/src/org/devaki/nextobjects/ui/toolbars Modified Files: NOToolBar2.java Log Message: First step in adding ability to have mabels and model's titles + checkstyle Index: NOToolBar2.java =================================================================== RCS file: /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/ui/toolbars/NOToolBar2.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** NOToolBar2.java 3 May 2003 12:50:49 -0000 1.4 --- NOToolBar2.java 8 Jun 2003 09:28:26 -0000 1.5 *************** *** 33,289 **** /** ! * ! * <p>Title: NOToolBar2</p> ! * <p>Description: </p> ! * <p>Copyright: Copyright (c) 2002</p> ! * <p>Company: devaki.org</p> ! * @version 1.0 */ public class NOToolBar2 extends JToolBar { - /** Variables **/ - public static final int TOOL_TABLE = 0; - public static final int TOOL_SELECTION = 1; - public static final int TOOL_RESIZE = 2; - public static final int TOOL_INHERITANCE = 6; - // CDM - public static final int TOOL_ASSOCIATION = 3; - public static final int TOOL_ASSOCIATION_LINK = 4; - // PDM - public static final int TOOL_CONSTRAINT = 5; - // Current selected tool - private static int currentTool = TOOL_SELECTION; ! /**Components**/ ! // Toggle buttons ! private static CustomToggleButton jToggleButtonTable; ! private static CustomToggleButton jToggleButtonAssociation; ! private static CustomToggleButton jToggleButtonAssociationLink; ! private static CustomToggleButton jToggleButtonInheritancy; ! private static CustomToggleButton jToggleButtonConstraint; ! private static CustomToggleButton jToggleButtonSelection; ! // Button group ! private static ButtonGroup buttonGroup = new ButtonGroup(); ! /** ! * Construct a new 'NOToolBar2' object ! */ ! public NOToolBar2() ! { ! /** Initialization **/ ! super(JToolBar.HORIZONTAL); ! this.setFloatable(true); ! /** Components **/ ! // Toggle buttons ! jToggleButtonTable = new CustomToggleButton(CstImages.ICN_TABLE, ! "Draw a table", ! "Create a new table or a new entity according to the type of the current model", ! false, ! false); ! jToggleButtonAssociation = new CustomToggleButton(CstImages.ICN_ASSOCIATION, ! "Draw an association", ! "Create a new association", ! false, ! false); ! jToggleButtonAssociationLink = new CustomToggleButton(CstImages. ! ICN_ASSOCIATIONLINK, ! "Draw an association link", ! "Create a new association link", ! false, ! false); ! jToggleButtonInheritancy = new CustomToggleButton(CstImages.ICN_INHERITANCE, ! "Draw an inheritance link", ! "Create a new inheritance link", ! false, ! false); ! jToggleButtonConstraint = new CustomToggleButton(CstImages.ICN_CONSTRAINT, ! "Draw a constraint", ! "Create a new constraint", ! false, ! false); ! jToggleButtonSelection = new CustomToggleButton(CstImages.ICN_SELECTION, ! "Select/Move an object", ! "Select/Move an object in the current model", ! true, ! true); ! // Button group ! buttonGroup.add(jToggleButtonTable); ! buttonGroup.add(jToggleButtonAssociation); ! buttonGroup.add(jToggleButtonAssociationLink); ! buttonGroup.add(jToggleButtonInheritancy); ! buttonGroup.add(jToggleButtonConstraint); ! buttonGroup.add(jToggleButtonSelection); ! /** Listeners **/ ! jToggleButtonTable.addMouseListener(new MouseAdapter() ! { ! public void mousePressed(MouseEvent e) ! { ! setCurrentTool(TOOL_TABLE); ! // Set there is no current object ! ModelMan.setCurrentObject(null); ! } ! }); ! jToggleButtonAssociation.addMouseListener(new MouseAdapter() ! { ! public void mousePressed(MouseEvent e) ! { ! setCurrentTool(TOOL_ASSOCIATION); ! // Set there is no current object ! ModelMan.setCurrentObject(null); ! } ! }); ! jToggleButtonAssociationLink.addMouseListener(new MouseAdapter() ! { ! public void mousePressed(MouseEvent e) ! { ! setCurrentTool(TOOL_ASSOCIATION_LINK); ! if (ModelMan.getCurrentModel() instanceof ConceptualModel) { ! ((ConceptualModel)ModelMan.getCurrentModel()) ! .getConceptualView() ! .setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); ! } ! } ! }); ! jToggleButtonInheritancy.addMouseListener(new MouseAdapter() ! { ! public void mousePressed(MouseEvent e) ! { ! setCurrentTool(TOOL_INHERITANCE); ! if(ModelMan.getCurrentModel()instanceof ConceptualModel) ! { ! ((ConceptualModel)ModelMan.getCurrentModel()) ! .getConceptualView() ! .setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); ! } ! else if(ModelMan.getCurrentModel()instanceof PhysicalModel) ! { ! ((PhysicalModel)ModelMan.getCurrentModel()) ! .getPhysicalView() ! .setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); ! } ! } ! }); ! jToggleButtonConstraint.addMouseListener(new MouseAdapter() ! { ! public void mousePressed(MouseEvent e) ! { ! setCurrentTool(TOOL_CONSTRAINT); ! if(ModelMan.getCurrentModel()instanceof PhysicalModel) ! { // only if! ! ((PhysicalModel)ModelMan.getCurrentModel()) ! .getPhysicalView() ! .setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); ! } ! } ! }); ! jToggleButtonSelection.addMouseListener(new MouseAdapter() ! { ! public void mousePressed(MouseEvent e) ! { ! setCurrentTool(TOOL_SELECTION); ! } ! }); ! /** Assembling components **/ ! this.add(jToggleButtonTable); ! this.add(new JToolBar.Separator(new Dimension(2, 0))); ! this.add(jToggleButtonAssociation); ! this.add(new JToolBar.Separator(new Dimension(2, 0))); ! this.add(jToggleButtonAssociationLink); ! // not completly implemented. ! this.add(new JToolBar.Separator(new Dimension(2, 0))); ! this.add(jToggleButtonInheritancy); ! this.add(new JToolBar.Separator(new Dimension(2, 0))); ! this.add(jToggleButtonConstraint); ! this.add(new JToolBar.Separator(new Dimension(2, 0))); ! this.add(jToggleButtonSelection); ! } ! /** ! * Return the current used tool ! * @return ! */ ! static public int getCurrentTool() ! { ! return currentTool; ! } ! /** ! * Defines the current button used ! * @param pCurrentTool ! */ ! static public void setCurrentTool(int pCurrentTool) ! { ! currentTool = pCurrentTool; ! switch(currentTool) ! { ! case TOOL_TABLE: ! jToggleButtonTable.setSelected(true); ! break; ! case TOOL_ASSOCIATION: ! jToggleButtonAssociation.setSelected(true); ! break; ! case TOOL_ASSOCIATION_LINK: ! jToggleButtonAssociationLink.setSelected(true); ! break; ! case TOOL_INHERITANCE: ! jToggleButtonInheritancy.setSelected(true); ! break; ! case TOOL_CONSTRAINT: ! jToggleButtonConstraint.setSelected(true); ! break; ! case TOOL_SELECTION: ! jToggleButtonSelection.setSelected(true); ! break; ! } ! } ! /** ! * Enable/Disable icons ! */ ! static public void fixIcons() ! { ! if(ModelMan.getCurrentModel() != null) ! { ! jToggleButtonTable.setEnabled(true); ! // CDM ! if(ModelMan.getCurrentModel()instanceof ConceptualModel) ! { ! jToggleButtonAssociation.setEnabled(true); ! jToggleButtonAssociationLink.setEnabled(true); ! jToggleButtonConstraint.setEnabled(false); ! jToggleButtonInheritancy.setEnabled(true); ! if(jToggleButtonConstraint.isSelected()) ! { ! jToggleButtonSelection.setSelected(true); ! } ! } ! // PDM ! else ! { ! jToggleButtonAssociation.setEnabled(false); ! jToggleButtonAssociationLink.setEnabled(false); ! jToggleButtonConstraint.setEnabled(true); ! jToggleButtonInheritancy.setEnabled(true); ! if(jToggleButtonAssociation.isSelected()) ! { ! jToggleButtonSelection.setSelected(true); ! } ! } ! } ! else ! { ! jToggleButtonTable.setEnabled(false); ! jToggleButtonAssociation.setEnabled(false); ! jToggleButtonAssociationLink.setEnabled(false); ! jToggleButtonConstraint.setEnabled(false); ! jToggleButtonInheritancy.setEnabled(false); ! jToggleButtonSelection.setSelected(true); ! } ! } } --- 33,388 ---- /** ! * This class is responsible for drawing the draw toolbar ! * @author efl...@de... */ public class NOToolBar2 extends JToolBar { ! /** ! * TOOL_TABLE ! */ ! public static final int TOOL_TABLE = 0; ! /** ! * TOOL_SELECTION ! */ ! public static final int TOOL_SELECTION = 1; ! /** ! * TOOL_RESIZE ! */ ! public static final int TOOL_RESIZE = 2; ! /** ! * TOOL_ASSOCIATION ! */ ! public static final int TOOL_ASSOCIATION = 3; ! /** ! * TOOL_ASSOCIATION_LINK ! */ ! public static final int TOOL_ASSOCIATION_LINK = 4; ! /** ! * TOOL_CONSTRAINT ! */ ! public static final int TOOL_CONSTRAINT = 5; ! /** ! * TOOL_INHERITANCE ! */ ! public static final int TOOL_INHERITANCE = 6; ! /** ! * TOOL_LABEL ! */ ! public static final int TOOL_LABEL = 7; ! /** ! * The current tool ! */ ! private static int currentTool = TOOL_SELECTION; ! /** ! * this button activate drawing table. Clicking on the drawing ! * drop a table centered on the point you have just clicked. ! * This button is activated only on physical model. ! */ ! private static CustomToggleButton jToggleButtonTable; ! ! /** ! * This button activate the drawing of an association. Cliking ! * on the drawing will drop an association centered on the point ! * you have just clicked. This button is activated only on conceptual ! * model. ! */ ! private static CustomToggleButton jToggleButtonAssociation; ! ! /** ! * This button activate the association link tool , represented by a line and ! * a pair of number called cardinaliities. When the tool is activated, dragging ! * cause a line to be streched. If the line is between two entites an association ! * and two association links are created. If it's between an entity and an ! * association then a single association link is created. ! */ ! private static CustomToggleButton jToggleButtonAssociationLink; ! ! /** ! * This button activate the Inheritancy tool. ! */ ! private static CustomToggleButton jToggleButtonInheritancy; ! ! /** ! * This button activate the Constraint tool. ! */ ! private static CustomToggleButton jToggleButtonConstraint; ! ! /** ! * This button activate the Selection tool. ! */ ! private static CustomToggleButton jToggleButtonSelection; ! ! /** ! * The button Label ! */ ! private static CustomToggleButton jToggleButtonLabel; ! ! /** ! * The button group ! */ ! private static ButtonGroup buttonGroup = new ButtonGroup(); ! ! /** ! * Construct a new 'NOToolBar2' object ! */ ! public NOToolBar2() ! { ! /** Initialization **/ ! super(JToolBar.HORIZONTAL); ! this.setFloatable(true); ! ! /** Components **/ ! // Toggle buttons ! ! jToggleButtonTable = ! new CustomToggleButton( ! CstImages.ICN_TABLE, ! "Draw a table", ! "Create a new table or a new entity according to the type of the current model", ! false, ! false); ! jToggleButtonAssociation = ! new CustomToggleButton( ! CstImages.ICN_ASSOCIATION, ! "Draw an association", ! "Create a new association", ! false, ! false); ! jToggleButtonAssociationLink = ! new CustomToggleButton( ! CstImages.ICN_ASSOCIATIONLINK, ! "Draw an association link", ! "Create a new association link", ! false, ! false); ! jToggleButtonInheritancy = ! new CustomToggleButton( ! CstImages.ICN_INHERITANCE, ! "Draw an inheritance link", ! "Create a new inheritance link", ! false, ! false); ! jToggleButtonConstraint = ! new CustomToggleButton( ! CstImages.ICN_CONSTRAINT, ! "Draw a constraint", ! "Create a new constraint", ! false, ! false); ! jToggleButtonSelection = ! new CustomToggleButton( ! CstImages.ICN_SELECTION, ! "Select an object", ! "Select an object.", ! true, ! true); ! jToggleButtonLabel = ! new CustomToggleButton( ! CstImages.ICN_LABEL, ! "Add a label", ! "Add a label to the current object.", ! true, ! true); ! // Button group ! buttonGroup.add(jToggleButtonTable); ! buttonGroup.add(jToggleButtonAssociation); ! buttonGroup.add(jToggleButtonAssociationLink); ! buttonGroup.add(jToggleButtonInheritancy); ! buttonGroup.add(jToggleButtonConstraint); ! buttonGroup.add(jToggleButtonSelection); ! buttonGroup.add(jToggleButtonLabel); ! ! /** Listeners **/ ! jToggleButtonTable.addMouseListener(new MouseAdapter() ! { ! public void mousePressed(MouseEvent e) ! { ! setCurrentTool(TOOL_TABLE); ! // Set there is no current object ! ModelMan.setCurrentObject(null); ! } ! }); ! jToggleButtonAssociation.addMouseListener(new MouseAdapter() ! { ! public void mousePressed(MouseEvent e) ! { ! setCurrentTool(TOOL_ASSOCIATION); ! // Set there is no current object ! ModelMan.setCurrentObject(null); ! } ! }); ! jToggleButtonAssociationLink.addMouseListener(new MouseAdapter() ! { ! public void mousePressed(MouseEvent e) ! { ! setCurrentTool(TOOL_ASSOCIATION_LINK); ! if (ModelMan.getCurrentModel() instanceof ConceptualModel) ! { ! ((ConceptualModel) ModelMan.getCurrentModel()) ! .getModelView() ! .setCursor( ! new Cursor(Cursor.CROSSHAIR_CURSOR)); ! } ! } ! }); ! jToggleButtonInheritancy.addMouseListener(new MouseAdapter() ! { ! public void mousePressed(MouseEvent e) ! { ! setCurrentTool(TOOL_INHERITANCE); ! if (ModelMan.getCurrentModel() instanceof ConceptualModel) ! { ! ((ConceptualModel) ModelMan.getCurrentModel()) ! .getModelView() ! .setCursor( ! new Cursor(Cursor.CROSSHAIR_CURSOR)); ! } else if (ModelMan.getCurrentModel() instanceof PhysicalModel) ! { ! ((PhysicalModel) ModelMan.getCurrentModel()) ! .getModelView() ! .setCursor( ! new Cursor(Cursor.CROSSHAIR_CURSOR)); ! ! } ! } ! }); ! jToggleButtonConstraint.addMouseListener(new MouseAdapter() ! { ! public void mousePressed(MouseEvent e) ! { ! setCurrentTool(TOOL_CONSTRAINT); ! if (ModelMan.getCurrentModel() instanceof PhysicalModel) ! { // only if! ! ((PhysicalModel) ModelMan.getCurrentModel()) ! .getModelView() ! .setCursor( ! new Cursor(Cursor.CROSSHAIR_CURSOR)); ! } ! } ! }); ! jToggleButtonSelection.addMouseListener(new MouseAdapter() ! { ! public void mousePressed(MouseEvent e) ! { ! setCurrentTool(TOOL_SELECTION); ! } ! }); ! jToggleButtonLabel.addMouseListener(new MouseAdapter() ! { ! public void mousePressed(MouseEvent e) ! { ! setCurrentTool(TOOL_LABEL); ! } ! }); ! ! /** Assembling components **/ ! this.add(jToggleButtonTable); ! this.add(new JToolBar.Separator(new Dimension(2, 0))); ! this.add(jToggleButtonAssociation); ! this.add(new JToolBar.Separator(new Dimension(2, 0))); ! this.add(jToggleButtonAssociationLink); ! // not completly implemented. ! this.add(new JToolBar.Separator(new Dimension(2, 0))); ! this.add(jToggleButtonInheritancy); ! this.add(new JToolBar.Separator(new Dimension(2, 0))); ! this.add(jToggleButtonConstraint); ! this.add(new JToolBar.Separator(new Dimension(2, 0))); ! this.add(jToggleButtonSelection); ! this.add(new JToolBar.Separator(new Dimension(2, 0))); ! this.add(jToggleButtonLabel); ! fixIcons(); ! } ! ! /** ! * Return the current used tool ! * @return the current tool ! */ ! static public int getCurrentTool() ! { ! return currentTool; ! } ! ! /** ! * Defines the current button used ! * @param pCurrentTool the new current tool ! */ ! static public void setCurrentTool(int pCurrentTool) ! { ! currentTool = pCurrentTool; ! switch (currentTool) ! { ! case TOOL_TABLE : ! jToggleButtonTable.setSelected(true); ! break; ! case TOOL_ASSOCIATION : ! jToggleButtonAssociation.setSelected(true); ! break; ! case TOOL_ASSOCIATION_LINK : ! jToggleButtonAssociationLink.setSelected(true); ! break; ! case TOOL_INHERITANCE : ! jToggleButtonInheritancy.setSelected(true); ! break; ! case TOOL_CONSTRAINT : ! jToggleButtonConstraint.setSelected(true); ! break; ! case TOOL_SELECTION : ! jToggleButtonSelection.setSelected(true); ! break; ! case TOOL_LABEL : ! jToggleButtonLabel.setSelected(true); ! break; ! } ! } ! ! /** ! * Enable/Disable icons ! */ ! static public void fixIcons() ! { ! if (ModelMan.getCurrentModel() != null) ! { ! jToggleButtonTable.setEnabled(true); ! jToggleButtonSelection.setEnabled(true); ! jToggleButtonInheritancy.setEnabled(true); ! jToggleButtonLabel.setEnabled(true); ! ! // CDM ! if (ModelMan.getCurrentModel() instanceof ConceptualModel) ! { ! jToggleButtonAssociation.setEnabled(true); ! jToggleButtonAssociationLink.setEnabled(true); ! jToggleButtonConstraint.setEnabled(false); ! } ! // PDM ! else ! { ! jToggleButtonAssociation.setEnabled(false); ! jToggleButtonAssociationLink.setEnabled(false); ! jToggleButtonConstraint.setEnabled(true); ! } ! } ! // there is no current model ! else ! { ! jToggleButtonTable.setEnabled(false); ! jToggleButtonAssociation.setEnabled(false); ! jToggleButtonAssociationLink.setEnabled(false); ! jToggleButtonConstraint.setEnabled(false); ! jToggleButtonInheritancy.setEnabled(false); ! jToggleButtonSelection.setEnabled(false); ! jToggleButtonLabel.setEnabled(false); ! } ! } } |