Index: openide/dialogs/nbproject/project.xml =================================================================== RCS file: /shared/data/ccvs/repository/openide/dialogs/nbproject/project.xml,v retrieving revision 1.5 retrieving revision 1.5.2.3 diff -u -r1.5 -r1.5.2.3 --- openide/dialogs/nbproject/project.xml 1 Jul 2006 09:07:41 -0000 1.5 +++ openide/dialogs/nbproject/project.xml 19 Jul 2006 14:15:22 -0000 1.5.2.3 @@ -24,15 +24,24 @@ org.openide.dialogs - org.openide.util + org.netbeans.api.progress - 6.2 + 1 + 1.6 org.openide.awt + + + + 6.2 + + + + org.openide.util Index: openide/dialogs/src/org/openide/WizardDescriptor.java =================================================================== RCS file: /shared/data/ccvs/repository/openide/dialogs/src/org/openide/WizardDescriptor.java,v retrieving revision 1.28 retrieving revision 1.28.2.6 diff -u -r1.28 -r1.28.2.6 --- openide/dialogs/src/org/openide/WizardDescriptor.java 1 Jul 2006 09:07:42 -0000 1.28 +++ openide/dialogs/src/org/openide/WizardDescriptor.java 1 Aug 2006 09:59:59 -0000 1.28.2.6 @@ -24,6 +24,7 @@ import java.awt.Component; import java.awt.Container; import java.awt.Cursor; +import java.awt.Dialog; import java.awt.Dimension; import java.awt.FocusTraversalPolicy; import java.awt.Font; @@ -57,6 +58,7 @@ import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; +import javax.swing.JProgressBar; import javax.swing.JScrollPane; import javax.swing.JSeparator; import javax.swing.JTabbedPane; @@ -76,6 +78,9 @@ import org.openide.util.RequestProcessor; import org.openide.util.Utilities; import org.openide.util.WeakListeners; +import org.netbeans.api.progress.ProgressHandle; +import org.netbeans.api.progress.ProgressHandleFactory; +import org.openide.awt.StatusDisplayer; /** * Implements a basic "wizard" GUI system. @@ -285,6 +290,8 @@ private boolean validationRuns; + private ProgressHandle handle; + { // button init ResourceBundle b = NbBundle.getBundle("org.openide.Bundle"); // NOI18N @@ -758,6 +765,7 @@ nextButton.setEnabled (next && valid); previousButton.setEnabled (prev); + cancelButton.setEnabled (true); if (current instanceof FinishablePanel) { // check if isFinishPanel @@ -1188,7 +1196,26 @@ private void callInstantiate() throws IOException { assert panels != null; - + + err.log (Level.FINE, "Is AsynchronousInstantiatingIterator? " + (panels instanceof AsynchronousInstantiatingIterator)); + err.log (Level.FINE, "Is ProgressInstantiatingIterator? " + (panels instanceof ProgressInstantiatingIterator)); + if (panels instanceof ProgressInstantiatingIterator) { + handle = ProgressHandleFactory.createHandle ("instantiate"); + + JComponent progressComp = ProgressHandleFactory.createProgressComponent (handle); + wizardPanel.setProgressComponent (progressComp, ((ProgressInstantiatingIterator)panels).getProgressLabel ()); + + err.log (Level.FINE, "Show progressPanel controlled by iterator later."); + } else if (panels instanceof AsynchronousInstantiatingIterator) { + ProgressHandle handle = ProgressHandleFactory.createHandle ("instantiate"); + + JComponent progressComp = ProgressHandleFactory.createProgressComponent (handle); + wizardPanel.setProgressComponent (progressComp, null); + + handle.start (); + err.log (Level.FINE, "Show progressPanel later."); + } + // bugfix #44444, force store settings before do instantiate new objects panels.current().storeSettings(settings); @@ -1197,8 +1224,15 @@ try { assert ! (panels instanceof AsynchronousInstantiatingIterator) || ! SwingUtilities.isEventDispatchThread () : "Cannot invoked within EDT if AsynchronousInstantiatingIterator!"; - err.log (Level.FINE, "Calls instantiate() on iterator: " + panels.getClass ().getName ()); - newObjects = ((InstantiatingIterator) panels).instantiate(); + + if (panels instanceof ProgressInstantiatingIterator) { + assert handle != null : "ProgressHandle must be not null."; + err.log (Level.FINE, "Calls instantiate(ProgressHandle) on iterator: " + panels.getClass ().getName ()); + newObjects = ((ProgressInstantiatingIterator) panels).instantiate (handle); + } else { + err.log (Level.FINE, "Calls instantiate() on iterator: " + panels.getClass ().getName ()); + newObjects = ((InstantiatingIterator) panels).instantiate (); + } } finally { // set cursor back to normal @@ -1495,11 +1529,42 @@ * instantating of newly created objects. * * @throws IOException when instantiate fails + * @return a set of objects created (the exact type is at the discretion of the caller) */ public Set /**/ instantiate () throws IOException; } + /** + * Iterator for a wizard that wants to notify users while instantiate is running by a progress bar. + * The method instantiate is called outside ATW queue. + * (This interface can replace + * TemplateWizard.Iterator + * in a template's declaration.) + * @since org.openide/1 7.0 + */ + public interface ProgressInstantiatingIterator extends AsynchronousInstantiatingIterator { + + /** + * Is called in separate thread when the Finish button + * are clicked and allows implement asynchronous + * instantating of newly created objects. + * + * @param handle progress bar handle + * @throws IOException when instantiate fails + * @return a set of objects created (the exact type is at the discretion of the caller) + */ + public Set /**/ instantiate (ProgressHandle handle) throws IOException; + + /** Returns a label of progress bar. + * This method is called when progress bar is being displayed. + * + * @return name of running task + */ + public JLabel getProgressLabel (); + + } + /** Special iterator that works on an array of Panels. */ public static class ArrayIterator extends Object implements Iterator { @@ -1668,6 +1733,7 @@ previousButton.setEnabled (false); nextButton.setEnabled (false); finishButton.setEnabled (false); + cancelButton.setEnabled (false); // write something to errorMessage (e.g. Wait to finishing.) if (wizardPanel != null) wizardPanel.setErrorMessage (NbBundle.getMessage (WizardDescriptor.class, "MSG_WizardDescriptor_FinishInProgress"), Boolean.TRUE); // NOI18N @@ -2050,6 +2116,8 @@ /** Label of steps pane */ private JLabel label; + + private JPanel progressBarPanel; /** Selected index of content */ private int selectedIndex; @@ -2128,6 +2196,15 @@ m_lblMessage = new FixedHeightLabel (); m_lblMessage.setForeground (nbErrorForeground); errorPanel.add(m_lblMessage, BorderLayout.CENTER); + + progressBarPanel = new JPanel (new BorderLayout ()); + // placeholder for progress bar components + progressBarPanel.add (new JLabel (), BorderLayout.NORTH); + progressBarPanel.add (new JProgressBar (), BorderLayout.CENTER); + progressBarPanel.setVisible (false); + + progressBarPanel.setBorder (BorderFactory.createEmptyBorder (4, 0, 0, 0)); + errorPanel.add (progressBarPanel, BorderLayout.SOUTH); JPanel fullRightPanel = new JPanel(new BorderLayout()); fullRightPanel.add(labelPanel, BorderLayout.NORTH); @@ -2158,6 +2235,16 @@ } m_lblMessage.setText(msg); + } + + private void setProgressComponent (JComponent progressComp, JLabel progressLabel) { + progressBarPanel.removeAll (); + if (progressLabel != null) { + progressBarPanel.add (progressLabel, BorderLayout.NORTH); + } + progressBarPanel.add (progressComp, BorderLayout.CENTER); + progressBarPanel.setVisible (true); + progressBarPanel.revalidate (); } /** Creates content panel.