Search in sources :

Example 6 with JProgressBar

use of javax.swing.JProgressBar in project platform_frameworks_base by android.

the class SwingUI method showWaitDialog.

@Override
public void showWaitDialog() {
    if (currentWaitDialog == null) {
        currentWaitDialog = new JDialog(this, "Please wait...", true);
        currentWaitDialog.getContentPane().add(new JLabel("Please be patient."), BorderLayout.CENTER);
        JProgressBar progress = new JProgressBar(JProgressBar.HORIZONTAL);
        progress.setIndeterminate(true);
        currentWaitDialog.getContentPane().add(progress, BorderLayout.SOUTH);
        currentWaitDialog.setSize(200, 100);
        currentWaitDialog.setLocationRelativeTo(null);
        showWaitDialogLater();
    }
}
Also used : JProgressBar(javax.swing.JProgressBar) JLabel(javax.swing.JLabel) JDialog(javax.swing.JDialog)

Example 7 with JProgressBar

use of javax.swing.JProgressBar in project processing by processing.

the class UpdateContributionTab method setLayout.

@Override
protected void setLayout(boolean error, boolean loading) {
    if (progressBar == null) {
        progressBar = new JProgressBar();
        progressBar.setVisible(false);
        buildErrorPanel();
        loaderLabel = new JLabel(Toolkit.getLibIcon("manager/loader.gif"));
        loaderLabel.setOpaque(false);
    //      loaderLabel.setBackground(Color.WHITE);
    }
    GroupLayout layout = new GroupLayout(this);
    setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER).addComponent(loaderLabel).addComponent(contributionListPanel).addComponent(errorPanel).addComponent(statusPanel));
    layout.setVerticalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER).addComponent(loaderLabel).addComponent(contributionListPanel)).addComponent(errorPanel).addComponent(statusPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE));
    layout.setHonorsVisibility(contributionListPanel, false);
    setBackground(Color.WHITE);
}
Also used : JProgressBar(javax.swing.JProgressBar) GroupLayout(javax.swing.GroupLayout) JLabel(javax.swing.JLabel)

Example 8 with JProgressBar

use of javax.swing.JProgressBar in project jgnash by ccavanaugh.

the class CurrencyExchangeDialog method initComponents.

private void initComponents() {
    baseCurrencyCombo = new CurrencyComboBox();
    exchangeCurrencyCombo = new CurrencyComboBox();
    dateField = new DatePanel();
    baseCurrencyCombo.addActionListener(this);
    exchangeCurrencyCombo.addActionListener(this);
    model = new HistoryModel();
    table = new HistoryTable();
    table.setModel(model);
    table.setPreferredScrollableViewportSize(new java.awt.Dimension(150, 150));
    table.setCellSelectionEnabled(false);
    table.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(true);
    table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table.setRowSorter(new TableRowSorter<>(model));
    table.setFillsViewportHeight(true);
    table.getSelectionModel().addListSelectionListener(this);
    closeButton = new JButton(rb.getString("Button.Close"));
    deleteButton = new JButton(rb.getString("Button.Delete"));
    clearButton = new JButton(rb.getString("Button.Clear"));
    addButton = new JButton(rb.getString("Button.Add"));
    updateButton = new JButton(rb.getString("Button.UpdateOnline"));
    updateButton.setIcon(IconUtils.getIcon("/jgnash/resource/applications-internet.png"));
    progressBar = new JProgressBar();
    stopButton = new JButton(rb.getString("Button.Stop"));
    stopButton.setIcon(IconUtils.getIcon("/jgnash/resource/process-stop.png"));
    stopButton.setEnabled(false);
    addButton.addActionListener(this);
    clearButton.addActionListener(this);
    closeButton.addActionListener(this);
    deleteButton.addActionListener(this);
    updateButton.addActionListener(this);
    stopButton.addActionListener(this);
    EventQueue.invokeLater(CurrencyExchangeDialog.this::updateModel);
}
Also used : DatePanel(jgnash.ui.components.DatePanel) CurrencyComboBox(jgnash.ui.components.CurrencyComboBox) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar)

Example 9 with JProgressBar

use of javax.swing.JProgressBar in project jabref by JabRef.

the class AutoSetLinks method autoSetLinks.

/**
     * Automatically add links for this set of entries, based on the globally stored list of external file types. The
     * entries are modified, and corresponding UndoEdit elements added to the NamedCompound given as argument.
     * Furthermore, all entries which are modified are added to the Set of entries given as an argument.
     * <p>
     * The entries' bibtex keys must have been set - entries lacking key are ignored. The operation is done in a new
     * thread, which is returned for the caller to wait for if needed.
     *
     * @param entries          A collection of BibEntry objects to find links for.
     * @param ce               A NamedCompound to add UndoEdit elements to.
     * @param changedEntries   MODIFIED, optional. A Set of BibEntry objects to which all modified entries is added.
     *                         This is used for status output and debugging
     * @param singleTableModel UGLY HACK. The table model to insert links into. Already existing links are not
     *                         duplicated or removed. This parameter has to be null if entries.count() != 1. The hack has been
     *                         introduced as a bibtexentry does not (yet) support the function getListTableModel() and the
     *                         FileListEntryEditor editor holds an instance of that table model and does not reconstruct it after the
     *                         search has succeeded.
     * @param databaseContext  The database providing the relevant file directory, if any.
     * @param callback         An ActionListener that is notified (on the event dispatch thread) when the search is finished.
     *                         The ActionEvent has id=0 if no new links were added, and id=1 if one or more links were added. This
     *                         parameter can be null, which means that no callback will be notified.
     * @param diag             An instantiated modal JDialog which will be used to display the progress of the automatically setting. This
     *                         parameter can be null, which means that no progress update will be shown.
     * @return the thread performing the automatically setting
     */
public static Runnable autoSetLinks(final List<BibEntry> entries, final NamedCompound ce, final Set<BibEntry> changedEntries, final FileListTableModel singleTableModel, final BibDatabaseContext databaseContext, final ActionListener callback, final JDialog diag) {
    final Collection<ExternalFileType> types = ExternalFileTypes.getInstance().getExternalFileTypeSelection();
    if (diag != null) {
        final JProgressBar prog = new JProgressBar(SwingConstants.HORIZONTAL, 0, types.size() - 1);
        final JLabel label = new JLabel(Localization.lang("Searching for files"));
        prog.setIndeterminate(true);
        prog.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        diag.setTitle(Localization.lang("Automatically setting file links"));
        diag.getContentPane().add(prog, BorderLayout.CENTER);
        diag.getContentPane().add(label, BorderLayout.SOUTH);
        diag.pack();
        diag.setLocationRelativeTo(diag.getParent());
    }
    Runnable r = new Runnable() {

        @Override
        public void run() {
            // determine directories to search in
            final List<Path> dirs = databaseContext.getFileDirectoriesAsPaths(Globals.prefs.getFileDirectoryPreferences());
            // determine extensions
            final List<String> extensions = types.stream().map(ExternalFileType::getExtension).collect(Collectors.toList());
            // Run the search operation:
            FileFinder fileFinder = FileFinders.constructFromConfiguration(Globals.prefs.getAutoLinkPreferences());
            Map<BibEntry, List<Path>> result = fileFinder.findAssociatedFiles(entries, dirs, extensions);
            boolean foundAny = false;
            // Iterate over the entries:
            for (Entry<BibEntry, List<Path>> entryFilePair : result.entrySet()) {
                FileListTableModel tableModel;
                Optional<String> oldVal = entryFilePair.getKey().getField(FieldName.FILE);
                if (singleTableModel == null) {
                    tableModel = new FileListTableModel();
                    oldVal.ifPresent(tableModel::setContent);
                } else {
                    assert entries.size() == 1;
                    tableModel = singleTableModel;
                }
                List<Path> files = entryFilePair.getValue();
                for (Path f : files) {
                    f = FileUtil.shortenFileName(f, dirs);
                    boolean alreadyHas = false;
                    //System.out.println("File: "+f.getPath());
                    for (int j = 0; j < tableModel.getRowCount(); j++) {
                        FileListEntry existingEntry = tableModel.getEntry(j);
                        //System.out.println("Comp: "+existingEntry.getLink());
                        if (Paths.get(existingEntry.getLink()).equals(f)) {
                            alreadyHas = true;
                            foundAny = true;
                            break;
                        }
                    }
                    if (!alreadyHas) {
                        foundAny = true;
                        Optional<ExternalFileType> type;
                        Optional<String> extension = FileHelper.getFileExtension(f);
                        if (extension.isPresent()) {
                            type = ExternalFileTypes.getInstance().getExternalFileTypeByExt(extension.get());
                        } else {
                            type = Optional.of(new UnknownExternalFileType(""));
                        }
                        FileListEntry flEntry = new FileListEntry(f.getFileName().toString(), f.toString(), type);
                        tableModel.addEntry(tableModel.getRowCount(), flEntry);
                        String newVal = tableModel.getStringRepresentation();
                        if (newVal.isEmpty()) {
                            newVal = null;
                        }
                        if (ce != null) {
                            // store undo information
                            UndoableFieldChange change = new UndoableFieldChange(entryFilePair.getKey(), FieldName.FILE, oldVal.orElse(null), newVal);
                            ce.addEdit(change);
                        }
                        // hack: if table model is given, do NOT modify entry
                        if (singleTableModel == null) {
                            entryFilePair.getKey().setField(FieldName.FILE, newVal);
                        }
                        if (changedEntries != null) {
                            changedEntries.add(entryFilePair.getKey());
                        }
                    }
                }
            }
            // handle callbacks and dialog
            // FIXME: The ID signals if action was successful :/
            final int id = foundAny ? 1 : 0;
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    if (diag != null) {
                        diag.dispose();
                    }
                    if (callback != null) {
                        callback.actionPerformed(new ActionEvent(this, id, ""));
                    }
                }
            });
        }
    };
    SwingUtilities.invokeLater(() -> {
        // show dialog which will be hidden when the task is done
        if (diag != null) {
            diag.setVisible(true);
        }
    });
    return r;
}
Also used : ActionEvent(java.awt.event.ActionEvent) JProgressBar(javax.swing.JProgressBar) FileListEntry(org.jabref.gui.filelist.FileListEntry) FileFinder(org.jabref.logic.util.io.FileFinder) UnknownExternalFileType(org.jabref.gui.externalfiletype.UnknownExternalFileType) UnknownExternalFileType(org.jabref.gui.externalfiletype.UnknownExternalFileType) ExternalFileType(org.jabref.gui.externalfiletype.ExternalFileType) UndoableFieldChange(org.jabref.gui.undo.UndoableFieldChange) List(java.util.List) Path(java.nio.file.Path) BibEntry(org.jabref.model.entry.BibEntry) FileListTableModel(org.jabref.gui.filelist.FileListTableModel) JLabel(javax.swing.JLabel)

Example 10 with JProgressBar

use of javax.swing.JProgressBar in project jabref by JabRef.

the class DetectOpenOfficeInstallation method showProgressDialog.

public JDialog showProgressDialog(JDialog progressParent, String title, String message) {
    JProgressBar bar = new JProgressBar(SwingConstants.HORIZONTAL);
    final JDialog progressDialog = new JDialog(progressParent, title, false);
    bar.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    bar.setIndeterminate(true);
    progressDialog.add(new JLabel(message), BorderLayout.NORTH);
    progressDialog.add(bar, BorderLayout.CENTER);
    progressDialog.pack();
    progressDialog.setLocationRelativeTo(null);
    progressDialog.setVisible(true);
    return progressDialog;
}
Also used : JProgressBar(javax.swing.JProgressBar) JLabel(javax.swing.JLabel) JDialog(javax.swing.JDialog)

Aggregations

JProgressBar (javax.swing.JProgressBar)87 JLabel (javax.swing.JLabel)53 JPanel (javax.swing.JPanel)40 JButton (javax.swing.JButton)32 Dimension (java.awt.Dimension)30 BorderLayout (java.awt.BorderLayout)28 ActionEvent (java.awt.event.ActionEvent)20 JScrollPane (javax.swing.JScrollPane)20 ActionListener (java.awt.event.ActionListener)16 Insets (java.awt.Insets)14 IOException (java.io.IOException)14 GridBagConstraints (java.awt.GridBagConstraints)13 GridBagLayout (java.awt.GridBagLayout)13 FlowLayout (java.awt.FlowLayout)12 JCheckBox (javax.swing.JCheckBox)12 ArrayList (java.util.ArrayList)11 JDialog (javax.swing.JDialog)11 File (java.io.File)10 ImageIcon (javax.swing.ImageIcon)10 JComboBox (javax.swing.JComboBox)9