Search in sources :

Example 56 with JProgressBar

use of javax.swing.JProgressBar in project knime-core by knime.

the class FileReaderNodeDialog method createAnalysisPanel.

private JPanel createAnalysisPanel() {
    JLabel scanLimitLabel = new JLabel("scan limit (number of lines): ");
    m_scanLimitSpinner = new JSpinner();
    m_scanLimitSpinner.setValue(FileAnalyzer.NUMOFLINES);
    m_analyzeCancel = new JButton("Quick Scan");
    m_analyzeCancel.setToolTipText("Analyze the specified number of lines only.");
    m_analyzeCancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if ((int) m_scanLimitSpinner.getValue() < 0) {
                m_scanLimitSpinner.setValue(0);
            }
            m_analyzeCancel.setText("Scanning quickly");
            int limit = (int) m_scanLimitSpinner.getValue();
            m_scanLimitSpinner.setEnabled(false);
            m_analyzeCancel.setEnabled(false);
            m_analysisExecMonitor.setShortCutLines(limit);
            m_analysisExecMonitor.setExecuteCanceled();
        }
    });
    m_analyzeCancel.setEnabled(false);
    m_scanLimitSpinner.setEnabled(false);
    m_analyzeProgressBar = new JProgressBar();
    m_analyzeProgressBar.setIndeterminate(false);
    m_analyzeProgressBar.setStringPainted(false);
    m_analyzeProgressBar.setValue(0);
    Box msgBox = Box.createHorizontalBox();
    msgBox.add(Box.createVerticalStrut(25));
    msgBox.add(m_analyzeProgressMsg);
    msgBox.add(Box.createGlue());
    Box progressBox = Box.createVerticalBox();
    progressBox.add(msgBox);
    progressBox.add(Box.createVerticalStrut(3));
    progressBox.add(m_analyzeProgressBar);
    Box buttonBox = Box.createHorizontalBox();
    buttonBox.add(Box.createHorizontalGlue());
    buttonBox.add(scanLimitLabel);
    buttonBox.add(m_scanLimitSpinner);
    buttonBox.add(m_analyzeCancel);
    buttonBox.add(Box.createHorizontalGlue());
    Box allBox = Box.createVerticalBox();
    allBox.add(progressBox);
    allBox.add(Box.createVerticalStrut(5));
    allBox.add(buttonBox);
    Box hBox = Box.createHorizontalBox();
    hBox.add(Box.createGlue());
    hBox.add(Box.createGlue());
    hBox.add(allBox);
    hBox.add(Box.createGlue());
    hBox.add(Box.createGlue());
    JPanel result = new JPanel();
    result.setLayout(new BorderLayout());
    result.add(hBox, BorderLayout.NORTH);
    return result;
}
Also used : JPanel(javax.swing.JPanel) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JLabel(javax.swing.JLabel) JSpinner(javax.swing.JSpinner) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox)

Example 57 with JProgressBar

use of javax.swing.JProgressBar in project vcell by virtualcell.

the class SimulationListPanel method initConnections.

/**
 * Initializes connections
 * @exception java.lang.Exception The exception description.
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initConnections() throws java.lang.Exception {
    // user code begin {1}
    // user code end
    getNewButton().addActionListener(ivjEventHandler);
    getEditButton().addActionListener(ivjEventHandler);
    getDeleteButton().addActionListener(ivjEventHandler);
    getRunButton().addActionListener(ivjEventHandler);
    // getPythonResultsButton().addActionListener(ivjEventHandler);
    getNativeResultsButton().addActionListener(ivjEventHandler);
    getMoreActionsButton().addActionListener(ivjEventHandler);
    getScrollPaneTable().addPropertyChangeListener(ivjEventHandler);
    getOutputFunctionsPanel().addPropertyChangeListener(ivjEventHandler);
    getScrollPaneTable().getSelectionModel().addListSelectionListener(ivjEventHandler);
    DefaultScrollTableCellRenderer renderer = new DefaultScrollTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (value instanceof OutputTimeSpec) {
                SimulationWorkspace sw = getSimulationWorkspace();
                SimulationOwner so = sw.getSimulationOwner();
                UnitInfo unitInfo = so.getUnitInfo();
                Objects.requireNonNull(unitInfo);
                OutputTimeSpec ots = (OutputTimeSpec) value;
                String text = ots.describe(unitInfo);
                setText(text);
            } else if (value instanceof Double) {
                setText(value + "");
            }
            boolean bFinitVolumeRerun = false;
            if (value instanceof SolverDescription) {
                SolverDescription solverDescription = (SolverDescription) value;
                try {
                    if (FINITEVOLUME_CUTTOFF != null && solverDescription.equals(SolverDescription.FiniteVolume)) /*Compiled Solver*/
                    {
                        SimulationStatus simStatus = getSimulationWorkspace().getSimulationStatus(getSimulationListTableModel1().getValueAt(row));
                        if (simStatus.getHasData()) {
                            int statusIndex = 0;
                            while (simStatus.getJobStatus(statusIndex) != null) {
                                if (simStatus.getJobStatus(statusIndex).getEndDate().compareTo(FINITEVOLUME_CUTTOFF) > 0) {
                                    bFinitVolumeRerun = true;
                                    break;
                                }
                                statusIndex++;
                            }
                        }
                    }
                } catch (Exception e) {
                    // ignore, let table cell render anyway
                    e.printStackTrace();
                }
                setText(solverDescription.getShortDisplayLabel());
                setToolTipText(solverDescription.getDisplayLabel());
            } else {
                setToolTipText(getText());
            }
            if (bFinitVolumeRerun) {
                setText(getText() + (bFinitVolumeRerun ? "(*)" : ""));
                setToolTipText(getToolTipText() + (bFinitVolumeRerun ? " (data regenerated using FiniteVolumeStandalone)" : ""));
            }
            return this;
        }
    };
    getScrollPaneTable().setDefaultRenderer(OutputTimeSpec.class, renderer);
    getScrollPaneTable().setDefaultRenderer(Double.class, renderer);
    getScrollPaneTable().setDefaultRenderer(String.class, renderer);
    getScrollPaneTable().setDefaultRenderer(SolverDescription.class, renderer);
    getScrollPaneTable().setDefaultEditor(OutputTimeSpec.class, new DefaultCellEditor(new JTextField()));
    getScrollPaneTable().setDefaultRenderer(SimulationStatus.class, new DefaultScrollTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            Object obj = getSimulationStatusDisplay(row);
            if (obj instanceof JProgressBar) {
                return (JProgressBar) obj;
            }
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (value instanceof SimulationStatus) {
                setText(obj.toString());
                String details = ((SimulationStatus) value).getDetails();
                setToolTipText(details);
            }
            return this;
        }
    });
}
Also used : SolverDescription(cbit.vcell.solver.SolverDescription) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) PropertyVetoException(java.beans.PropertyVetoException) IOException(java.io.IOException) DefaultCellEditor(javax.swing.DefaultCellEditor) SimulationOwner(cbit.vcell.solver.SimulationOwner) UnitInfo(cbit.vcell.solver.SimulationOwner.UnitInfo) OutputTimeSpec(cbit.vcell.solver.OutputTimeSpec) SimulationStatus(cbit.vcell.server.SimulationStatus) JTable(javax.swing.JTable) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) Component(java.awt.Component)

Example 58 with JProgressBar

use of javax.swing.JProgressBar in project vcell by virtualcell.

the class SimulationListPanel method getSimulationStatusDisplay.

private Object getSimulationStatusDisplay(int row) {
    Simulation simulation = getSimulationListTableModel1().getValueAt(row);
    SimulationStatus simStatus = getSimulationWorkspace().getSimulationStatus(simulation);
    boolean displayProgress = (simStatus.isRunning() || (simStatus.isFailed() && simStatus.numberOfJobsDone() < simulation.getScanCount())) && simStatus.getProgress() != null && simStatus.getProgress().doubleValue() >= 0;
    if (displayProgress) {
        double progress = simStatus.getProgress().doubleValue() / simulation.getScanCount();
        JProgressBar progressBar = new JProgressBar();
        progressBar.setStringPainted(true);
        progressBar.setValue((int) (progress * 100));
        if (simStatus.isFailed()) {
            progressBar.setString("one or more jobs failed");
        } else {
            progressBar.setString(NumberUtils.formatNumber(progress * 100, 4) + "%");
        }
        return progressBar;
    } else if (simStatus.isFailed()) {
        return simStatus.getFailedMessage();
    } else {
        return simStatus.getDetails();
    }
}
Also used : Simulation(cbit.vcell.solver.Simulation) SimulationStatus(cbit.vcell.server.SimulationStatus) JProgressBar(javax.swing.JProgressBar)

Example 59 with JProgressBar

use of javax.swing.JProgressBar in project vcell by virtualcell.

the class ProgressDialog method initializeContentPane.

private void initializeContentPane(boolean indeterminate) {
    progressBar = new JProgressBar(0, 100);
    progressBar.setStringPainted(true);
    progressBar.setIndeterminate(indeterminate);
    final JOptionPane optionPane = new JOptionPane(progressBar, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] {});
    setContentPane(optionPane);
    setPreferredSize(new Dimension(500, 100));
}
Also used : JProgressBar(javax.swing.JProgressBar) Dimension(java.awt.Dimension) JOptionPane(javax.swing.JOptionPane)

Example 60 with JProgressBar

use of javax.swing.JProgressBar in project lotro-companion by dmorcellet.

the class CharacterReputationDialogController method buildReputationPanelForCategory.

private JPanel buildReputationPanelForCategory(String category, List<Faction> factions) {
    JPanel panel = GuiFactory.buildBackgroundPanel(new GridBagLayout());
    // Factions
    GridBagConstraints cLabel = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0);
    GridBagConstraints cBar = new GridBagConstraints(1, 0, 1, 1, 1.0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
    GridBagConstraints cEdit = new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0);
    int y = 0;
    for (Faction faction : factions) {
        FactionEditionPanelController editionController = new FactionEditionPanelController(faction);
        _editors.put(faction.getKey(), editionController);
        // Label
        JLabel label = editionController.getLabel();
        cLabel.gridy = y;
        panel.add(label, cLabel);
        // Bar and buttons panel
        FlowLayout layout = new FlowLayout(FlowLayout.TRAILING);
        layout.setVgap(0);
        JPanel barButtonsPanel = GuiFactory.buildPanel(layout);
        // - button minus
        JButton minus = editionController.getMinusButton();
        minus.addActionListener(this);
        barButtonsPanel.add(minus);
        // - bar
        JProgressBar bar = editionController.getBar();
        barButtonsPanel.add(bar);
        // - button plus
        JButton plus = editionController.getPlusButton();
        plus.addActionListener(this);
        barButtonsPanel.add(plus);
        cBar.gridy = y;
        panel.add(barButtonsPanel, cBar);
        // - button edit
        JButton edit = editionController.getEditButton();
        edit.addActionListener(this);
        cEdit.gridy = y;
        panel.add(edit, cEdit);
        y++;
    }
    JPanel gluePanel = GuiFactory.buildPanel(new BorderLayout());
    GridBagConstraints glueC = new GridBagConstraints(0, y, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);
    panel.add(gluePanel, glueC);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) BorderLayout(java.awt.BorderLayout) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JLabel(javax.swing.JLabel) Faction(delta.games.lotro.lore.reputation.Faction)

Aggregations

JProgressBar (javax.swing.JProgressBar)86 JLabel (javax.swing.JLabel)52 JPanel (javax.swing.JPanel)39 JButton (javax.swing.JButton)32 Dimension (java.awt.Dimension)30 BorderLayout (java.awt.BorderLayout)27 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 JCheckBox (javax.swing.JCheckBox)12 FlowLayout (java.awt.FlowLayout)11 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