From: <kp...@us...> - 2007-10-07 11:19:43
|
Revision: 10831 http://jedit.svn.sourceforge.net/jedit/?rev=10831&view=rev Author: kpouer Date: 2007-10-07 04:19:10 -0700 (Sun, 07 Oct 2007) Log Message: ----------- A new GUIUtilities.listConfirm() method that returns also the selected items in the list Modified Paths: -------------- jEdit/trunk/org/gjt/sp/jedit/GUIUtilities.java Modified: jEdit/trunk/org/gjt/sp/jedit/GUIUtilities.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/GUIUtilities.java 2007-10-06 23:53:52 UTC (rev 10830) +++ jEdit/trunk/org/gjt/sp/jedit/GUIUtilities.java 2007-10-07 11:19:10 UTC (rev 10831) @@ -24,54 +24,25 @@ //{{{ Imports -import java.awt.Color; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Frame; -import java.awt.GraphicsConfiguration; -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; -import java.awt.Image; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.Window; -import java.awt.Dialog; - -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.event.WindowStateListener; - -import java.net.URL; - -import java.util.Hashtable; -import java.util.Locale; -import java.util.Map; -import java.util.StringTokenizer; - -import javax.swing.*; - import org.gjt.sp.jedit.browser.VFSFileChooserDialog; - import org.gjt.sp.jedit.gui.EnhancedButton; import org.gjt.sp.jedit.gui.FloatingWindowContainer; import org.gjt.sp.jedit.gui.SplashScreen; import org.gjt.sp.jedit.gui.VariableGridLayout; - import org.gjt.sp.jedit.menu.EnhancedCheckBoxMenuItem; import org.gjt.sp.jedit.menu.EnhancedMenu; import org.gjt.sp.jedit.menu.EnhancedMenuItem; - import org.gjt.sp.jedit.syntax.SyntaxStyle; import org.gjt.sp.jedit.syntax.Token; - import org.gjt.sp.jedit.textarea.TextAreaMouseHandler; +import org.gjt.sp.util.Log; -import org.gjt.sp.util.Log; +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.net.URL; +import java.util.*; +import java.util.List; //}}} /** @@ -724,6 +695,11 @@ * from the <code><i>name</i>.message</code> property. The dialog * also shows a list of entries given by the <code>listModel</code> * parameter. + * @param comp the parent component + * @param name the name of the confirm dialog + * @param args the for the message + * @param listModel the items in the list + * @return an integer indicating the option selected by the user * @since jEdit 4.3pre1 */ public static int listConfirm(Component comp, String name, String[] args, @@ -744,6 +720,48 @@ JOptionPane.QUESTION_MESSAGE); } //}}} + //{{{ listConfirm() method + /** + * Displays a confirm dialog box and returns the button pushed by the + * user. The title of the dialog is fetched from the + * <code><i>name</i>.title</code> property. The message is fetched + * from the <code><i>name</i>.message</code> property. The dialog + * also shows a list of entries given by the <code>listModel</code> + * parameter. + * @param comp the parent component + * @param name the name of the confirm dialog + * @param args the for the message + * @param listModel the items in the list + * @param selectedItems give an empty list, it will contains in return the selected items + * @return an integer indicating the option selected by the user + * @since jEdit 4.3pre12 + */ + public static int listConfirm(Component comp, String name, String[] args, + Object[] listModel, List selectedItems) + { + JList list = new JList(listModel); + list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + list.setVisibleRowCount(8); + list.addSelectionInterval(0,listModel.length - 1); + + Object[] message = { + jEdit.getProperty(name + ".message",args), + new JScrollPane(list) + }; + + int ret = JOptionPane.showConfirmDialog(comp, + message, + jEdit.getProperty(name + ".title"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + Object[] selectedValues = list.getSelectedValues(); + for (Object selectedValue : selectedValues) + { + selectedItems.add(selectedValue); + } + return ret; + } //}}} + //{{{ showVFSFileDialog() methods /** * Displays a VFS file selection dialog box. @@ -1723,12 +1741,12 @@ //{{{ SizeSaver class /** * A combined ComponentListener and WindowStateListener to continually save a Frames size.<br /> - * For non-Frame's use {@link #saveGeometry(Window,String)} + * For non-Frame's use {@link GUIUtilities#saveGeometry(Window,String)} * * @author Björn Kautler * @version $Id$ * @since jEdit 4.3pre6 - * @see #saveGeometry(Window,Container,String) + * @see GUIUtilities#saveGeometry(Window,Container,String) */ static class SizeSaver extends ComponentAdapter implements WindowStateListener { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |