[Schmitzm-commits] r434 - branches/1.0-gt2-2.6/src/skrueger/swing
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sun Oct 4 20:38:14 CEST 2009
Author: alfonx
Date: 2009-10-04 20:38:11 +0200 (Sun, 04 Oct 2009)
New Revision: 434
Added:
branches/1.0-gt2-2.6/src/skrueger/swing/CancellableTabbedDialogAdapter.java
Log:
* EditMapJDialog now also uses the new DialogManager
Added: branches/1.0-gt2-2.6/src/skrueger/swing/CancellableTabbedDialogAdapter.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/swing/CancellableTabbedDialogAdapter.java 2009-10-04 16:57:29 UTC (rev 433)
+++ branches/1.0-gt2-2.6/src/skrueger/swing/CancellableTabbedDialogAdapter.java 2009-10-04 18:38:11 UTC (rev 434)
@@ -0,0 +1,134 @@
+package skrueger.swing;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.Icon;
+import javax.swing.JTabbedPane;
+
+import net.miginfocom.swing.MigLayout;
+import schmitzm.swing.JPanel;
+import schmitzm.swing.SwingUtil;
+
+public abstract class CancellableTabbedDialogAdapter extends
+ CancellableDialogAdapter {
+
+ private final JTabbedPane tabbedPane;
+
+ public CancellableTabbedDialogAdapter(Component owner) {
+ super(owner);
+
+ /**
+ * Prepare buttons
+ */
+ final JPanel buttons = createButtons();
+
+ /*** Build GUI ***/
+ tabbedPane = new JTabbedPane(){
+ @Override
+ public void insertTab(String title, Icon icon, Component component,
+ String tip, int index) {
+ super.insertTab(title, icon, component, tip, index);
+ CancellableTabbedDialogAdapter.this.pack();
+ }
+ };
+
+ /**
+ * Building the content pane
+ */
+ final JPanel contentPane = new JPanel(new MigLayout("wrap 1"));
+ contentPane.add(getTabbedPane());
+ contentPane.add(buttons);
+
+ setContentPane(contentPane);
+ SwingUtil.centerFrameOnScreen(this);
+
+ }
+
+ /**
+ * Is only called once! Doesn't use lazy initialization. Use
+ * <code>super.createButtons.add( newButton )</code> to add buttons.
+ *
+ * @return
+ */
+ protected JPanel createButtons() {
+ final JPanel buttonsJPanel = new JPanel(new MigLayout("width 100%"));
+
+ final OkButton okButton = new OkButton(new AbstractAction() {
+ {
+ // Set a mnemonic character. In most look and feels, this
+ // causes the
+ // specified character to be underlined This indicates that
+ // if the component
+ // using this action has the focus and In some look and
+ // feels, this causes
+ // the specified character in the label to be underlined and
+ putValue(Action.MNEMONIC_KEY, new Integer(
+ java.awt.event.KeyEvent.VK_E));
+
+ // Set tool tip text
+ putValue(Action.SHORT_DESCRIPTION,
+ "Accept the changes made in this dialog."); // i8n
+
+ }
+
+ //
+ public void actionPerformed(final ActionEvent evt) {
+ okClose();
+ }
+
+ });
+
+ buttonsJPanel.add(okButton);
+
+ final CancelButton cancelButton = new CancelButton(new AbstractAction(
+ "") {
+ public void actionPerformed(final ActionEvent evt) {
+ cancelClose();
+ }
+ });
+ buttonsJPanel.add(cancelButton);
+
+ return buttonsJPanel;
+ }
+
+ public JTabbedPane getTabbedPane() {
+ return tabbedPane;
+ }
+
+ /**
+ * Calling cancel() will call cancel to all {@link Cancellable} children in the tabbedPane.
+ */
+ @Override
+ public void cancel() {
+ cancelled = true;
+
+ for (int tIdx = 0; tIdx < tabbedPane.getTabCount(); tIdx++) {
+ final Component tab = tabbedPane.getComponentAt(tIdx);
+ if (tab instanceof Cancellable) {
+ ((Cancellable) tab).cancel();
+ }
+ }
+ }
+
+
+ @Override
+ public boolean okClose() {
+ // TranslationAskJDialog.this.firePropertyChange(
+ // PROPERTY_APPLY_AND_CLOSE, null, null);
+ //
+ for (int tIdx = 0; tIdx < tabbedPane.getTabCount(); tIdx++) {
+ final Component tab = tabbedPane.getComponentAt(tIdx);
+ if (tab instanceof Checkable) {
+ if (!((Checkable) tab).checkValidInputs())
+ return false;
+ }
+ }
+
+ dispose();
+
+ return true;
+ }
+}
Property changes on: branches/1.0-gt2-2.6/src/skrueger/swing/CancellableTabbedDialogAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id URL
Name: svn:eol-style
+ native
More information about the Schmitzm-commits
mailing list