41228 use proper priority options editors. BLD200404041800
authorpkuzel@netbeans.org
Sat, 03 Apr 2004 22:07:04 +0000
changeset 435991fe62cf8476
parent 4358 70865537e7ac
child 4360 0279e9e5efe2
41228 use proper priority options editors.
o.n.tasklistapi/src/org/netbeans/modules/tasklist/client/SuggestionPriority.java
tasklist.core/src/org/netbeans/modules/tasklist/core/PriorityListCellRenderer.java
tasklist.core/src/org/netbeans/modules/tasklist/core/editors/PriorityTableCellRenderer.java
tasklist.docscan/src/org/netbeans/modules/tasklist/docscan/TaskTagsPanel.java
     1.1 --- a/o.n.tasklistapi/src/org/netbeans/modules/tasklist/client/SuggestionPriority.java	Sat Apr 03 21:08:21 2004 +0000
     1.2 +++ b/o.n.tasklistapi/src/org/netbeans/modules/tasklist/client/SuggestionPriority.java	Sat Apr 03 22:07:04 2004 +0000
     1.3 @@ -74,6 +74,7 @@
     1.4       *  higher priority. Don't depend on the actual values; they may
     1.5       *  change without notice. 
     1.6       * @return Numeric value for the priority
     1.7 +     * XXX clients often use as index to getPriorityNames
     1.8       */
     1.9      public int intValue() {
    1.10          return priority;
    1.11 @@ -99,7 +100,7 @@
    1.12      }
    1.13  
    1.14      /**
    1.15 -     * Returns names for priorities
    1.16 +     * Returns localized names for priorities
    1.17       *
    1.18       * @return [0] - high, [1] - medium-high, ...
    1.19       */
     2.1 --- a/tasklist.core/src/org/netbeans/modules/tasklist/core/PriorityListCellRenderer.java	Sat Apr 03 21:08:21 2004 +0000
     2.2 +++ b/tasklist.core/src/org/netbeans/modules/tasklist/core/PriorityListCellRenderer.java	Sat Apr 03 22:07:04 2004 +0000
     2.3 @@ -30,7 +30,7 @@
     2.4      private static final long serialVersionUID = 1;
     2.5  
     2.6      private static final String[] TAGS = SuggestionPriority.getPriorityNames();
     2.7 -    
     2.8 +
     2.9      /**
    2.10       * Default colors for diferent priorities
    2.11       * [0] - high, [1] - medium-high, ...
    2.12 @@ -42,17 +42,16 @@
    2.13          new Color(0, 187, 0),
    2.14          new Color(0, 128, 0)
    2.15      };
    2.16 -    
    2.17 +
    2.18      public Component getListCellRendererComponent(JList list, Object value,
    2.19 -    int index, boolean isSelected, boolean cellHasFocus) {
    2.20 -        super.getListCellRendererComponent(
    2.21 -            list, value, index, isSelected, cellHasFocus);
    2.22 -        if (index >= 0) {
    2.23 -            setText(TAGS[index]);
    2.24 -            if (!isSelected)
    2.25 -                setForeground(COLORS[index]);
    2.26 -        } else {
    2.27 -            setText((String) value);
    2.28 +                                                  int index, boolean isSelected, boolean cellHasFocus) {
    2.29 +        super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    2.30 +        if (value instanceof SuggestionPriority) {
    2.31 +            SuggestionPriority prio = (SuggestionPriority) value;
    2.32 +            setText(TAGS[prio.intValue() - 1]);
    2.33 +            if (!isSelected) {
    2.34 +                setForeground(COLORS[prio.intValue() - 1]);
    2.35 +            }
    2.36          }
    2.37          return this;
    2.38      }
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tasklist.core/src/org/netbeans/modules/tasklist/core/editors/PriorityTableCellRenderer.java	Sat Apr 03 22:07:04 2004 +0000
     3.3 @@ -0,0 +1,47 @@
     3.4 +/*
     3.5 + *                 Sun Public License Notice
     3.6 + *
     3.7 + * The contents of this file are subject to the Sun Public License
     3.8 + * Version 1.0 (the "License"). You may not use this file except in
     3.9 + * compliance with the License. A copy of the License is available at
    3.10 + * http://www.sun.com/
    3.11 + *
    3.12 + * The Original Code is NetBeans. The Initial Developer of the Original
    3.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
    3.14 + * Microsystems, Inc. All Rights Reserved.
    3.15 + */
    3.16 +
    3.17 +package org.netbeans.modules.tasklist.core.editors;
    3.18 +
    3.19 +import org.netbeans.modules.tasklist.client.SuggestionPriority;
    3.20 +import org.netbeans.modules.tasklist.core.PriorityListCellRenderer;
    3.21 +
    3.22 +import java.awt.Color;
    3.23 +import java.awt.Component;
    3.24 +import javax.swing.*;
    3.25 +import javax.swing.table.DefaultTableCellRenderer;
    3.26 +
    3.27 +/**
    3.28 + * TableCellRenderer for priorities
    3.29 + *
    3.30 + * @author Petr Kuzel
    3.31 + */
    3.32 +public final class PriorityTableCellRenderer extends DefaultTableCellRenderer {
    3.33 +
    3.34 +    private static final long serialVersionUID = 1;
    3.35 +
    3.36 +    private static final String[] TAGS = SuggestionPriority.getPriorityNames();
    3.37 +
    3.38 +
    3.39 +    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean cellHasFocus, int row, int col) {
    3.40 +        super.getTableCellRendererComponent(table, value, isSelected, cellHasFocus, row, col);
    3.41 +        if (value instanceof SuggestionPriority) {
    3.42 +            SuggestionPriority prio = (SuggestionPriority) value;
    3.43 +            setText(TAGS[prio.intValue() - 1]);
    3.44 +            if (!isSelected) {
    3.45 +                setForeground(PriorityListCellRenderer.COLORS[prio.intValue() - 1]);
    3.46 +            }
    3.47 +        }
    3.48 +        return this;
    3.49 +    }
    3.50 +}
     4.1 --- a/tasklist.docscan/src/org/netbeans/modules/tasklist/docscan/TaskTagsPanel.java	Sat Apr 03 21:08:21 2004 +0000
     4.2 +++ b/tasklist.docscan/src/org/netbeans/modules/tasklist/docscan/TaskTagsPanel.java	Sat Apr 03 22:07:04 2004 +0000
     4.3 @@ -14,6 +14,8 @@
     4.4  package org.netbeans.modules.tasklist.docscan;
     4.5  
     4.6  import org.netbeans.modules.tasklist.client.SuggestionPriority;
     4.7 +import org.netbeans.modules.tasklist.core.PriorityListCellRenderer;
     4.8 +import org.netbeans.modules.tasklist.core.editors.PriorityTableCellRenderer;
     4.9  import org.openide.DialogDisplayer;
    4.10  import org.openide.NotifyDescriptor;
    4.11  import org.openide.awt.Mnemonics;
    4.12 @@ -89,7 +91,9 @@
    4.13          combo.addItem(SuggestionPriority.MEDIUM);
    4.14          combo.addItem(SuggestionPriority.MEDIUM_LOW);
    4.15          combo.addItem(SuggestionPriority.LOW);
    4.16 +        combo.setRenderer(new PriorityListCellRenderer());
    4.17          sportColumn.setCellEditor(new DefaultCellEditor(combo));
    4.18 +        sportColumn.setCellRenderer(new PriorityTableCellRenderer());
    4.19  
    4.20          addButton.addActionListener(this);
    4.21          changeButton.addActionListener(this);