Initial revision
[old-projects.git] / ekit / com / hexidec / ekit / component / SymbolDialog.java
diff --git a/ekit/com/hexidec/ekit/component/SymbolDialog.java b/ekit/com/hexidec/ekit/component/SymbolDialog.java
new file mode 100644 (file)
index 0000000..bb7a214
--- /dev/null
@@ -0,0 +1,122 @@
+/*\r
+GNU Lesser General Public License\r
+\r
+SymbolInputDialog\r
+Copyright (C) 2000-2003 Howard Kistler\r
+\r
+This library is free software; you can redistribute it and/or\r
+modify it under the terms of the GNU Lesser General Public\r
+License as published by the Free Software Foundation; either\r
+version 2.1 of the License, or (at your option) any later version.\r
+\r
+This library is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+Lesser General Public License for more details.\r
+\r
+You should have received a copy of the GNU Lesser General Public\r
+License along with this library; if not, write to the Free Software\r
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+*/\r
+\r
+package com.hexidec.ekit.component;\r
+\r
+import com.hexidec.ekit.EkitCore;\r
+import com.hexidec.util.Translatrix;\r
+import java.awt.Container;\r
+import java.awt.GridLayout;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import javax.swing.border.*;\r
+import javax.swing.BoxLayout;\r
+import javax.swing.JButton;\r
+import javax.swing.JToggleButton;\r
+import javax.swing.ButtonGroup;\r
+import javax.swing.JDialog;\r
+import javax.swing.JPanel;\r
+import javax.swing.WindowConstants;\r
+import javax.swing.SwingConstants;\r
+\r
+public class SymbolDialog extends JDialog implements ActionListener\r
+{\r
+       private final static String SYMBOLS = Translatrix.getTranslationString("Symbols");\r
+       \r
+       private EkitCore parentEkit;\r
+       private ButtonGroup buttonGroup;\r
+       private String returnSymbol;\r
+\r
+       public SymbolDialog(EkitCore peKit, String title, boolean bModal)\r
+       {\r
+               super(peKit.getFrame(), title, bModal);\r
+               parentEkit = peKit;\r
+               init();\r
+       }\r
+\r
+       public void actionPerformed(ActionEvent e)\r
+       {\r
+               if(e.getActionCommand().equals("accept"))\r
+               {\r
+                       setVisible(false);\r
+                       if(buttonGroup.getSelection() == null)\r
+                       {\r
+                               returnSymbol = null;\r
+                       }\r
+                       else\r
+                       {\r
+                               returnSymbol = buttonGroup.getSelection().getActionCommand();\r
+                       }\r
+               }\r
+               else if(e.getActionCommand().equals("cancel"))\r
+               {\r
+                       setVisible(false);\r
+                       returnSymbol = null;\r
+               }\r
+       }\r
+\r
+       public void init()\r
+       {\r
+               Container contentPane = getContentPane();\r
+               contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));\r
+               setBounds(100,100,400,300);\r
+               setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);\r
+\r
+               JPanel centerPanel = new JPanel();\r
+               centerPanel.setLayout(new GridLayout(0, 8, 0, 0));\r
+               buttonGroup = new ButtonGroup();\r
+               for(int i = 0; i < SYMBOLS.length(); i++)\r
+               {\r
+                       String symbol = Character.toString(SYMBOLS.charAt(i));\r
+                       JToggleButton b = new JToggleButton(symbol);\r
+                       b.getModel().setActionCommand(symbol);\r
+                       centerPanel.add(b);\r
+                       buttonGroup.add(b);\r
+               }\r
+\r
+               JPanel buttonPanel= new JPanel();\r
+               buttonPanel.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));\r
+\r
+               JButton saveButton = new JButton(Translatrix.getTranslationString("DialogAccept"));\r
+               saveButton.setActionCommand("accept");\r
+               saveButton.addActionListener(this);\r
+\r
+               JButton cancelButton = new JButton(Translatrix.getTranslationString("DialogCancel"));\r
+               cancelButton.setActionCommand("cancel");\r
+               cancelButton.addActionListener(this);\r
+\r
+               buttonPanel.add(saveButton);\r
+               buttonPanel.add(cancelButton);\r
+\r
+               contentPane.add(centerPanel);\r
+               contentPane.add(buttonPanel);\r
+\r
+               this.pack();\r
+               this.setVisible(true);\r
+       }\r
+\r
+       public String getInputText()\r
+       {\r
+               return returnSymbol;\r
+       }\r
+\r
+}\r
+\r