Java Code Examples for org.netbeans.api.progress.ProgressHandleFactory#createProgressComponent()

The following examples show how to use org.netbeans.api.progress.ProgressHandleFactory#createProgressComponent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BindingCustomizer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static JPanel panelForHandle(ProgressHandle handle) {
    JLabel label = ProgressHandleFactory.createDetailLabelComponent(handle);
    JComponent progress = ProgressHandleFactory.createProgressComponent(handle);
    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addComponent(label)
                .addComponent(progress))
            .addContainerGap())
    );
    layout.setVerticalGroup(
        layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(label)
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(progress)
            .addContainerGap()
    );
    return panel;
}
 
Example 2
Source File: ProgressFrame.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Creates new form ProgressFrame */
public ProgressFrame() {
    propertySupport = new PropertyChangeSupport(this);
    
    initComponents ();
    this.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_ProgressFrameTabA11yDesc"));  // NOI18N
    okButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_CancelButtonA11yDesc"));  // NOI18N
    
    progressHandle = ProgressHandleFactory.createHandle(null);
    progressComponent = ProgressHandleFactory.createProgressComponent(progressHandle);
    progressPanel.add(progressComponent);
    progressHandle.start();

    javax.swing.ImageIcon ideIcon = new javax.swing.ImageIcon("/org/netbeans/core/resources/frames/ide.gif"); //NOI18N
    setIconImage(ideIcon.getImage());

    java.awt.Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setSize(380, 150);
    setLocation(dim.width/2 - 190, dim.height/2 - 80);
}
 
Example 3
Source File: ProgressPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Creates new form ProgressPanel */
public ProgressPanel() {
    initComponents();
    handle = ProgressHandleFactory.createHandle(
            NbBundle.getMessage(ImportProjectAction.class, "CTL_ProgressDialogTitle")); // NOI18N
    progress = ProgressHandleFactory.createProgressComponent(handle);
    setLayout(new GridBagLayout());
    setPreferredSize(new Dimension(450, 80));
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new Insets(0, 5, 0, 5);
    add(progress, gridBagConstraints);
}
 
Example 4
Source File: DetectPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void readSettings(WizardDescriptor settings) {           
    sources = null;
    sourcesString = null;
    javadoc = null;
    javadocString = null;
    this.wiz = settings;
    this.component.progressPanel.setVisible (true);
    this.component.progressLabel.setVisible (true);
    
    this.progressHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(DetectPanel.class,"TXT_PlatfromDetectProgress"));
    this.component.progressPanel.removeAll();
    this.component.progressPanel.setLayout (new GridBagLayout ());
    GridBagConstraints c = new GridBagConstraints ();
    c.gridx = c.gridy = GridBagConstraints.RELATIVE;
    c.gridheight = c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    JComponent pc = ProgressHandleFactory.createProgressComponent(this.progressHandle);
    ((GridBagLayout)this.component.progressPanel.getLayout ()).setConstraints(pc,c);
    this.component.progressPanel.add (pc);
    this.progressHandle.start ();
    task.schedule(0);
}
 
Example 5
Source File: RefactoringPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public ProgressL() {
    final String lab = NbBundle.getMessage(RefactoringPanel.class, "LBL_RefactorProgressLabel");
    handle = ProgressHandleFactory.createHandle(lab);
    JComponent progress = ProgressHandleFactory.createProgressComponent(handle);
    JPanel component = new JPanel();
    component.setLayout(new BorderLayout());
    component.setBorder(new EmptyBorder(12,12,11,11));
    JLabel label = new JLabel(lab);
    label.setBorder(new EmptyBorder(0, 0, 6, 0));
    component.add(label, BorderLayout.NORTH);
    component.add(progress, BorderLayout.CENTER);
    DialogDescriptor desc = new DialogDescriptor(component, NbBundle.getMessage(RefactoringPanel.class, "LBL_RefactoringInProgress"), true, new Object[]{}, null, 0, null, null);
    desc.setLeaf(true);
    d = DialogDisplayer.getDefault().createDialog(desc);
    ((JDialog) d).setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
}
 
Example 6
Source File: ConfigRunnable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void run() {
    JComponent progressComponent = ProgressHandleFactory.createProgressComponent(progressHandle);
    if (!stop) {
        progressHandle.start();
        started = true;
        progressHandle.switchToIndeterminate();
        progressPanel.open(progressComponent);
    }
}
 
Example 7
Source File: TableGeneratorPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static <T> T doWithProgress(String message, final Callable<? extends T> run) {
    final ProgressPanel panel = new ProgressPanel();
    panel.setCancelVisible(false);
    panel.setText(message);
    ProgressHandle handle = ProgressHandle.createHandle(null);
    JComponent progress = ProgressHandleFactory.createProgressComponent(handle);
    handle.start();
    final List<T> result = new ArrayList<>(1);
    try {
        Task task = RequestProcessor.getDefault().post(new Runnable() {
            @Override
            public void run() {
                if (!SwingUtilities.isEventDispatchThread()) {
                    try {
                        result.add(run.call());
                    } catch (Exception e) {
                        result.add(null);
                        Exceptions.printStackTrace(e);
                    } finally {
                        SwingUtilities.invokeLater(this);
                    }
                } else {
                    panel.close();
                }
            }
        });
        panel.open(progress);
        task.waitFinished();
    } finally {
        handle.finish();
    }
    return result.get(0);
}
 
Example 8
Source File: ProgressUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Start the progress indication for indeterminate task. */
public void start(Integer delay) {
    if (modal) {
        progressComponent = ProgressHandleFactory.createProgressComponent(handle);
    }
    if (delay != null) {
        handle.setInitialDelay(delay.intValue());
    }        
    handle.start();
}
 
Example 9
Source File: ProgressDialog.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public ProgressPanel(ProgressHandle pHandle) {
    messageLabel = ProgressHandleFactory.createDetailLabelComponent(pHandle);
    messageLabel.setText(NbBundle.getMessage(ProgressDialog.class,
            "MSG_StartingProgress"));
    progressBar = ProgressHandleFactory.createProgressComponent(pHandle);

    initComponents();
}
 
Example 10
Source File: LayoutLaunchingPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "MSG_LaunchingApplication=Launching your application"
})
@Override
protected void readFromDataModel() {
    checkValidity();
    if (task == null) {
        try {
            task = DesignSupport.invokeDesignMode(data.getProject(), userDir, false, !data.isIgnorePreviousRun());
        } catch (IOException ex) {
            setError(ex.getMessage());
        }
        if(task != null) {
            handle = ProgressHandleFactory.createHandle(Bundle.MSG_LaunchingApplication());
            JComponent pc = ProgressHandleFactory.createProgressComponent(handle);
            JLabel ml = ProgressHandleFactory.createMainLabelComponent(handle);

            progress.add(ml);
            progress.add(pc);

            handle.start();
            markInvalid();
            /* XXX what was the purpose of this? cannot do it now, we are in EQ
            try {
                DesignSupport.existingModes(data);
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
            */
            task.addTaskListener(this);
        }
    }
}
 
Example 11
Source File: BugzillaRepositoryController.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void preRun() {
    handle = ProgressHandleFactory.createHandle(labelText, this);
    JComponent comp = ProgressHandleFactory.createProgressComponent(handle);
    panel.progressPanel.removeAll();
    panel.progressPanel.add(comp, BorderLayout.CENTER);
    panel.cancelButton.addActionListener(this);
    panel.connectionLabel.setVisible(false);
    handle.start();
    panel.progressPanel.setVisible(true);
    panel.cancelButton.setVisible(true);
    panel.validateButton.setVisible(false);
    panel.validateLabel.setVisible(true);
    panel.enableFields(false);
    panel.validateLabel.setText(labelText); // NOI18N
}
 
Example 12
Source File: ConfigurationPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateProgress(final ProgressHandle progressHandle) {
    final JLabel tmpMainLabel = ProgressHandleFactory.createMainLabelComponent(progressHandle);
    final JComponent tmpProgressPanel = ProgressHandleFactory.createProgressComponent(progressHandle);
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            progressPanel.removeAll();
            progressPanel.add(tmpMainLabel);
            progressPanel.add(Box.createRigidArea(new Dimension(0, 5)));
            progressPanel.add(tmpProgressPanel);
            progressPanel.revalidate();
            progressPanel.repaint();
        }
    });
}
 
Example 13
Source File: DiffPresenter.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates <i>just computing diff</i> presenter. The mode
 * is left on {@link #initWithDiffInfo} call.
 */
public DiffPresenter() {
    String label = NbBundle.getMessage(DiffPresenter.class, "diff.prog");
    ProgressHandle progress = ProgressHandle.createHandle(label);
    progressPanel = ProgressHandleFactory.createProgressComponent(progress);
    add(progressPanel);
    progress.start();
}
 
Example 14
Source File: DbUtilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static <T> T doWithProgress(String message, final Callable<? extends T> run) throws InvocationTargetException {
    final ProgressPanel panel = new ProgressPanel();
    panel.setCancelVisible(false);
    panel.setText(message);
    ProgressHandle handle = ProgressHandleFactory.createHandle(null);
    JComponent progress = ProgressHandleFactory.createProgressComponent(handle);
    handle.start();
    final List<T> result = new ArrayList<T>(1);
    final List<Exception> exception = new ArrayList<Exception>(1);
    try {
        Task task = RequestProcessor.getDefault().post(new Runnable() {
            public void run() {
                if (!SwingUtilities.isEventDispatchThread()) {
                    try {
                        result.add(run.call());
                        exception.add(null);
                    } catch (Exception e) {
                        result.add(null);
                        exception.add(e);
                    } finally {
                        SwingUtilities.invokeLater(this);
                    }
                } else {
                    panel.close();
                }
            }
        });
        panel.open(progress);
        task.waitFinished();
    } finally {
        handle.finish();
    }
    Exception inner = exception.get(0);
    if (inner != null) {
        throw new InvocationTargetException(inner, inner.getMessage());
    }
    return result.get(0);
}
 
Example 15
Source File: ProgressDialog.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public ProgressPanel(ProgressHandle pHandle) {
    messageLabel = ProgressHandleFactory.createDetailLabelComponent(pHandle);
    messageLabel.setText(NbBundle.getMessage(ProgressDialog.class,
            "MSG_StartingProgress")); // NOI18N
    progressBar = ProgressHandleFactory.createProgressComponent(pHandle);
    
    initComponents();
}
 
Example 16
Source File: DBSchemaTablesPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void invokeHandlers(final List<Handler> handlers, final Parameters params) {
    final ProgressPanel progressPanel = new ProgressPanel();
    
    ProgressHandle progressHandle = ProgressHandleFactory.createHandle(null);
    JComponent progressComponent = ProgressHandleFactory.createProgressComponent(progressHandle);
    
    progressHandle.start();
    progressHandle.switchToIndeterminate();
    
    final int[] index = new int[1];
    
    try {
        RequestProcessor.Task task = RequestProcessor.getDefault().create(new Runnable() {
            public void run() {
                index[0] = invokeHandlers(handlers, index[0], params, progressPanel);
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        progressPanel.close();
                    }
                });
            }
        });
        
        while (index[0] < handlers.size()) {
            index[0] = invokeHandlers(handlers, index[0], params, null);
            if (index[0] < handlers.size()) {
                task.schedule(0);
                progressPanel.open(progressComponent);
            }
        }
    } finally {
        progressHandle.finish();
    }
}
 
Example 17
Source File: InstantRefactoringPerformer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static ProgressBar create(ProgressHandle handle) {
    ProgressBar instance = new ProgressBar();
    instance.setLayout(new BorderLayout());
    instance.label = new JLabel(" "); //NOI18N
    instance.label.setBorder(new EmptyBorder(0, 0, 2, 0));
    instance.add(instance.label, BorderLayout.NORTH);
    JComponent progress = ProgressHandleFactory.createProgressComponent(handle);
    instance.add(progress, BorderLayout.CENTER);
    return instance;
}
 
Example 18
Source File: CustomizerDialog.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void actionPerformed( final ActionEvent e ) {
    String command = e.getActionCommand();

    if ( COMMAND_OK.equals( command ) ) {
        // Call the OK option listener
        ProjectManager.mutex().writeAccess(new Mutex.Action<Object>() {
            public Object run() {
                okOptionListener.actionPerformed( e ); // XXX maybe create new event
                actionPerformed(e, categories);
                return null;
            }
        });
        
        final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(CustomizerDialog.class, "LBL_Saving_Project_data_progress"));
        JComponent component = ProgressHandleFactory.createProgressComponent(handle);
        Frame mainWindow = WindowManager.getDefault().getMainWindow();
        final JDialog dialog = new JDialog(mainWindow, 
                NbBundle.getMessage(CustomizerDialog.class, "LBL_Saving_Project_data"), true);
        SavingProjectDataPanel panel = new SavingProjectDataPanel(component);
        
        dialog.getContentPane().add(panel);
        dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        dialog.pack();
        
        Rectangle bounds = mainWindow.getBounds();
        int middleX = bounds.x + bounds.width / 2;
        int middleY = bounds.y + bounds.height / 2;
        Dimension size = dialog.getPreferredSize();
        dialog.setBounds(middleX - size.width / 2, middleY - size.height / 2, size.width, size.height);
        
        // Call storeListeners out of AWT EQ
        RequestProcessor.getDefault().post(new Runnable() {
            @Override
            public void run() {
                try {
                    ProjectManager.mutex().writeAccess(new Mutex.Action<Object>() {
                        @Override
                        public Object run() {
                            FileUtil.runAtomicAction(new Runnable() {
                                @Override
                                public void run() {
                            handle.start();
                            if (storeListener != null) {
                                storeListener.actionPerformed(e);
                            }
                            storePerformed(e, categories);
                            // #97998 related
                            saveModifiedProject();
                                }
                            });
                            return null;
                        }
                    });
                } finally {
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            dialog.setVisible(false);
                            dialog.dispose();
                        }
                    });
                }
            }
        });
        
        dialog.setVisible(true);
        
    }
}
 
Example 19
Source File: GitProgressSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public JComponent getProgressComponent() {
    return ProgressHandleFactory.createProgressComponent(getProgressHandle());
}
 
Example 20
Source File: AggregateProgressFactory.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 * Get the progress bar component for use in custom dialogs, the task won't 
 * show in the progress bar anymore.
 * @since org.netbeans.api.progress 1.3
 * @return the component to use in custom UI.
 */
public static JComponent createProgressComponent(AggregateProgressHandle handle) {
    return ProgressHandleFactory.createProgressComponent(getProgressHandle(handle));
}