Search in sources :

Example 1 with StateValue

use of javax.swing.SwingWorker.StateValue in project com.revolsys.open by revolsys.

the class BackgroundTaskTableModel method updateCounts.

private void updateCounts() {
    this.pendingCount = 0;
    this.runningCount = 0;
    this.doneCount = 0;
    for (final BackgroundTask task : this.tasks) {
        final StateValue taskStatus = task.getTaskStatus();
        if (taskStatus == StateValue.PENDING) {
            this.pendingCount++;
        } else if (taskStatus == StateValue.STARTED) {
            this.runningCount++;
        } else if (!task.isTaskClosed()) {
            this.doneCount++;
        }
    }
    if (this.runningCount == 0) {
        this.timer.stop();
    } else {
        this.timer.start();
    }
    firePropertyChange("pendingCount", -1, this.pendingCount);
    firePropertyChange("runningCount", -1, this.runningCount);
    firePropertyChange("doneCount", -1, this.doneCount);
}
Also used : StateValue(javax.swing.SwingWorker.StateValue)

Example 2 with StateValue

use of javax.swing.SwingWorker.StateValue in project com.revolsys.open by revolsys.

the class BackgroundTaskTableModel method addHighlighter.

private static void addHighlighter(final BaseJTable table, final BackgroundTaskTableModel model, final StateValue state, final Color background, final Color foreground) {
    final HighlightPredicate predicate = (renderer, adapter) -> {
        final int rowIndex = adapter.convertRowIndexToModel(adapter.row);
        final BackgroundTask task = model.tasks.get(rowIndex);
        return task.getTaskStatus() == state;
    };
    final ColorHighlighter highlighter = new ColorHighlighter(predicate, background, foreground, foreground, background);
    table.addHighlighter(highlighter);
}
Also used : Color(java.awt.Color) Arrays(java.util.Arrays) JTextField(javax.swing.JTextField) SwingUtil(com.revolsys.swing.SwingUtil) BaseJPopupMenu(com.revolsys.swing.menu.BaseJPopupMenu) TableColumnExt(org.jdesktop.swingx.table.TableColumnExt) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) WebColors(com.revolsys.awt.WebColors) Map(java.util.Map) SwingWorker(javax.swing.SwingWorker) BaseJTable(com.revolsys.swing.table.BaseJTable) MenuFactory(com.revolsys.swing.menu.MenuFactory) PropertyChangeEvent(java.beans.PropertyChangeEvent) StateValue(javax.swing.SwingWorker.StateValue) Timer(javax.swing.Timer) JToolBar(javax.swing.JToolBar) TabbedPane(com.revolsys.swing.TabbedPane) Iterator(java.util.Iterator) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) TablePanel(com.revolsys.swing.table.TablePanel) PropertyChangeSupport(com.revolsys.beans.PropertyChangeSupport) Dimension(java.awt.Dimension) List(java.util.List) PropertyChangeListener(java.beans.PropertyChangeListener) JLabel(javax.swing.JLabel) AbstractTableModel(com.revolsys.swing.table.AbstractTableModel) Entry(java.util.Map.Entry) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) JTable(javax.swing.JTable) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate)

Aggregations

StateValue (javax.swing.SwingWorker.StateValue)2 WebColors (com.revolsys.awt.WebColors)1 PropertyChangeSupport (com.revolsys.beans.PropertyChangeSupport)1 SwingUtil (com.revolsys.swing.SwingUtil)1 TabbedPane (com.revolsys.swing.TabbedPane)1 BaseJPopupMenu (com.revolsys.swing.menu.BaseJPopupMenu)1 MenuFactory (com.revolsys.swing.menu.MenuFactory)1 AbstractTableModel (com.revolsys.swing.table.AbstractTableModel)1 BaseJTable (com.revolsys.swing.table.BaseJTable)1 TablePanel (com.revolsys.swing.table.TablePanel)1 ColorHighlighter (com.revolsys.swing.table.highlighter.ColorHighlighter)1 Color (java.awt.Color)1 Dimension (java.awt.Dimension)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1