[izpack-changes] r1813 - in izpack-src/branches/3.10: . src/lib/com/izforge/izpack/installer src/lib/com/izforge/izpack/panels
noreply at berlios.de
noreply at berlios.de
Thu Apr 19 21:44:47 CEST 2007
Author: jponge
Date: 2007-04-19 21:44:35 +0200 (Thu, 19 Apr 2007)
New Revision: 1813
Modified:
izpack-src/branches/3.10/Versions.txt
izpack-src/branches/3.10/src/lib/com/izforge/izpack/installer/InstallerFrame.java
izpack-src/branches/3.10/src/lib/com/izforge/izpack/panels/UserInputPanel.java
Log:
Enable next-button for search dialogs. (Michael Hagedorn via Julien Ponge).
Modified: izpack-src/branches/3.10/Versions.txt
===================================================================
--- izpack-src/branches/3.10/Versions.txt 2007-04-16 08:13:16 UTC (rev 1812)
+++ izpack-src/branches/3.10/Versions.txt 2007-04-19 19:44:35 UTC (rev 1813)
@@ -6,6 +6,8 @@
- Dutch Langpack fixes (Hans Aikema)
- Fix NPE for pack.id == null in dependencies/excludes (Hans Aikema)
- Indonesian Langpack fixes (Thomas Santosa via Hans Aikema)
+- UserInputPanel and InstallerFrame: enable the next button for search dialogs
+ (Michael Hagedorn via Julien Ponge)
> 3.10.1 (build 2007.03.29)
Modified: izpack-src/branches/3.10/src/lib/com/izforge/izpack/installer/InstallerFrame.java
===================================================================
--- izpack-src/branches/3.10/src/lib/com/izforge/izpack/installer/InstallerFrame.java 2007-04-16 08:13:16 UTC (rev 1812)
+++ izpack-src/branches/3.10/src/lib/com/izforge/izpack/installer/InstallerFrame.java 2007-04-19 19:44:35 UTC (rev 1813)
@@ -1363,8 +1363,18 @@
*/
public void unlockNextButton()
{
+ unlockNextButton(true);
+ }
+
+ /**
+ * Unlocks the 'next' button.
+ * @param requestFocus if <code>true</code> focus goes to <code>nextButton</code>
+ */
+ public void unlockNextButton(boolean requestFocus)
+ {
nextButton.setEnabled(true);
- nextButton.requestFocus();
+ if (requestFocus)
+ nextButton.requestFocus();
}
/**
Modified: izpack-src/branches/3.10/src/lib/com/izforge/izpack/panels/UserInputPanel.java
===================================================================
--- izpack-src/branches/3.10/src/lib/com/izforge/izpack/panels/UserInputPanel.java 2007-04-16 08:13:16 UTC (rev 1812)
+++ izpack-src/branches/3.10/src/lib/com/izforge/izpack/panels/UserInputPanel.java 2007-04-19 19:44:35 UTC (rev 1813)
@@ -45,6 +45,10 @@
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
import net.n3.nanoxml.NonValidator;
import net.n3.nanoxml.StdXMLBuilder;
@@ -2682,8 +2686,44 @@
this.autodetectButton.addActionListener(this);
this.browseButton.addActionListener(this);
+ /*
+ * add DocumentListener to manage nextButton if user enters input
+ */
+ ((JTextField)this.pathComboBox.getEditor().getEditorComponent()).getDocument().addDocumentListener(new DocumentListener()
+ {
+ public void changedUpdate(DocumentEvent e)
+ {
+ checkNextButtonState();
+ }
+ public void insertUpdate(DocumentEvent e)
+ {
+ checkNextButtonState();
+ }
+ public void removeUpdate(DocumentEvent e)
+ {
+ checkNextButtonState();
+ }
+ private void checkNextButtonState()
+ {
+ Document doc = ((JTextField)pathComboBox.getEditor().getEditorComponent()).getDocument();
+ try {
+ if (pathMatches(doc.getText(0, doc.getLength())))
+ getInstallerFrame().unlockNextButton(false);
+ else
+ getInstallerFrame().lockNextButton();
+ } catch (BadLocationException e) {/*ignore, it not happens*/}
+ }
+ });
+
autodetect();
}
+
+ /**
+ * convenient method
+ */
+ private InstallerFrame getInstallerFrame() {
+ return parent;
+ }
/**
* Check whether the given combobox belongs to this searchfield. This is used when reading
@@ -2742,7 +2782,10 @@
* Check if the user has entered data into the ComboBox and add it to the Itemlist
*/
String selected = (String) this.pathComboBox.getSelectedItem();
- if (selected == null) { return false; }
+ if (selected == null) {
+ parent.lockNextButton();
+ return false;
+ }
boolean found = false;
for (int x = 0; x < this.pathComboBox.getItemCount(); x++)
{
@@ -2811,14 +2854,19 @@
if (this.pathMatches(path))
{
this.pathComboBox.setSelectedIndex(i);
+ parent.unlockNextButton();
return true;
}
}
// if the user entered something else, it's not listed as an item
- return this.pathMatches((String) this.pathComboBox.getSelectedItem());
-
+ if (this.pathMatches((String) this.pathComboBox.getSelectedItem())) {
+ parent.unlockNextButton();
+ return true;
+ }
+ parent.lockNextButton();
+ return false;
}
/*--------------------------------------------------------------------------*/
More information about the izpack-changes
mailing list