// File: UmlPalette.java // Classes: UmlPalette // Original Author: Kedar Patankar // $Id: UmlPalette.java,v 1.1.1.1 1997/02/27 20:52:49 chandra Exp $ package uci.graphedit; import java.awt.Panel; import java.awt.Event; import java.awt.Toolkit; import java.awt.Frame; import java.awt.BorderLayout; import gjt.ImageButtonPanel; import gjt.Separator; import gjt.ImageButton; import gjt.ImageButtonEvent; import gjt.Orientation; import gjt.StickyImageButtonController; /** A class to define the left hand column of buttons in the Example * application. Right now it just has one kind of node. * * @see Example */ public class UmlPalette extends Panel { private ImageButton _constvert,_constedge,_altvert,_altedge; private Editor _editor; /** Construct a new palette of example nodes for the Example application */ public UmlPalette(Editor editor) { _editor=editor; setLayout(new BorderLayout()); String INSTALL_DIR=_editor.getInstallDir(); ImageButtonPanel palette = new UmlPanel(); _constvert = new ImageButton(Toolkit.getDefaultToolkit().getImage (INSTALL_DIR + "/images/cv.gif")); _constedge = new ImageButton(Toolkit.getDefaultToolkit().getImage (INSTALL_DIR + "/images/ce.gif")); _altvert = new ImageButton(Toolkit.getDefaultToolkit().getImage (INSTALL_DIR + "/images/av.gif")); _altedge = new ImageButton(Toolkit.getDefaultToolkit().getImage (INSTALL_DIR + "/images/ae.gif")); switchoff(); palette.add(_constvert); palette.add(_constedge); palette.add(_altvert); palette.add(_altedge); add("Center",palette); /* simulating the sticky mode */ /* new StickyImageButtonController(_constvert); new StickyImageButtonController(_constedge); new StickyImageButtonController(_altvert); new StickyImageButtonController(_altedge); */ Separator separator = new Separator(3); add("East",separator); } public void refresh() { int i=_editor.getNoOfOpenDocuments(); if(i<=0) switchoff(); else switchon(); } private void switchoff() { _constvert.disable(); _altvert.disable(); _constedge.disable(); _altedge.disable(); } private void switchon() { _constvert.enable(); _altvert.enable(); _constedge.enable(); _altedge.enable(); } public boolean handleEvent(Event event) { if(event instanceof ImageButtonEvent) { ImageButtonEvent ibevent = (ImageButtonEvent)event; if(ibevent.isActivated()) { if(event.target == _constvert) { Mode createVertexMode=new ModeCreateVertex (_editor.curDocument(),_editor,"uci.graphedit.ConstClass"); _editor.curDocument().mode(createVertexMode,false); } if(event.target == _constedge) { Mode createConstEdgeMode = new ModeCreateConstEdge (_editor.curDocument(),_editor); _editor.curDocument().mode(createConstEdgeMode,false); } if(event.target == _altvert) { Mode createVertexMode=new ModeCreateVertex (_editor.curDocument(),_editor,"uci.graphedit.AltClass"); _editor.curDocument().mode(createVertexMode,false); } if(event.target == _altedge) { Mode createAltEdgeMode = new ModeCreateAltEdge (_editor.curDocument()); _editor.curDocument().mode(createAltEdgeMode,false); } return true; } } return super.handleEvent(event); } } /* end class UmlPalette */