1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/suggestions_framework/src/org/netbeans/modules/tasklist/suggestions/columns.xml Sat Apr 26 07:50:06 2003 +0000
1.3 @@ -0,0 +1,25 @@
1.4 +<?xml version="1.0"?>
1.5 +
1.6 +<!--
1.7 + Sun Public License Notice
1.8 +
1.9 +The contents of this file are subject to the Sun Public License
1.10 +Version 1.0 (the "License"). You may not use this file except in
1.11 +compliance with the License. A copy of the License is available at
1.12 +http://www.sun.com/
1.13 +
1.14 +The Original Code is NetBeans. The Initial Developer of the Original
1.15 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
1.16 +Microsystems, Inc. All Rights Reserved.
1.17 +-->
1.18 +
1.19 +<!DOCTYPE settings PUBLIC "-//NetBeans org.netbeans.modules.tasklist//DTD Columns 1.0//EN"
1.20 + "http://tasklist.netbeans.org/dtd/columns-1_0.dtd">
1.21 +
1.22 +<columns>
1.23 + <column property="taskDesc" width="800"/>
1.24 + <column property="suggPrio" width="100"/>
1.25 + <column property="suggFile" width="150"/>
1.26 + <column property="suggLine" width="50"/>
1.27 + <column property="suggCat" width="150"/>
1.28 +</columns>
2.1 --- a/suggestions_framework/src/org/netbeans/modules/tasklist/suggestions/mf-layer.xml Thu Apr 24 21:05:32 2003 +0000
2.2 +++ b/suggestions_framework/src/org/netbeans/modules/tasklist/suggestions/mf-layer.xml Sat Apr 26 07:50:06 2003 +0000
2.3 @@ -80,5 +80,12 @@
2.4 </folder>
2.5 </folder>
2.6
2.7 + <folder name="TaskList">
2.8 + <folder name="suggestions">
2.9 + <file name="columns.settings" url="columns.xml">
2.10 + <attr name="instanceClass" stringvalue="org.netbeans.modules.tasklist.core.columns.ColumnsConfiguration"/>
2.11 + </file>
2.12 + </folder>
2.13 + </folder>
2.14 </filesystem>
2.15
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/tasklist.bugs/src/org/netbeans/modules/tasklist/bugs/columns.xml Sat Apr 26 07:50:06 2003 +0000
3.3 @@ -0,0 +1,23 @@
3.4 +<?xml version="1.0"?>
3.5 +
3.6 +<!--
3.7 + Sun Public License Notice
3.8 +
3.9 +The contents of this file are subject to the Sun Public License
3.10 +Version 1.0 (the "License"). You may not use this file except in
3.11 +compliance with the License. A copy of the License is available at
3.12 +http://www.sun.com/
3.13 +
3.14 +The Original Code is NetBeans. The Initial Developer of the Original
3.15 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
3.16 +Microsystems, Inc. All Rights Reserved.
3.17 +-->
3.18 +
3.19 +<!DOCTYPE settings PUBLIC "-//NetBeans org.netbeans.modules.tasklist//DTD Columns 1.0//EN"
3.20 + "http://tasklist.netbeans.org/dtd/columns-1_0.dtd">
3.21 +
3.22 +<columns>
3.23 + <column property="taskDesc" width="800"/>
3.24 + <column property="bugStatus" width="150"/>
3.25 + <column property="bugPrio" width="100"/>
3.26 +</columns>
4.1 --- a/tasklist.bugs/src/org/netbeans/modules/tasklist/bugs/mf-layer.xml Thu Apr 24 21:05:32 2003 +0000
4.2 +++ b/tasklist.bugs/src/org/netbeans/modules/tasklist/bugs/mf-layer.xml Sat Apr 26 07:50:06 2003 +0000
4.3 @@ -34,5 +34,13 @@
4.4 <attr name="org-netbeans-modules-tasklist-usertasks-ViewTasksAction.instance/org-netbeans-modules-tasklist-bugs-NewQueryAction.instance" boolvalue="true" />
4.5 </folder>
4.6 </folder>
4.7 +
4.8 + <folder name="TaskList">
4.9 + <folder name="bugs">
4.10 + <file name="columns.settings" url="columns.xml">
4.11 + <attr name="instanceClass" stringvalue="org.netbeans.modules.tasklist.core.columns.ColumnsConfiguration"/>
4.12 + </file>
4.13 + </folder>
4.14 + </folder>
4.15 </filesystem>
4.16
5.1 --- a/tasklist.core/build.xml Thu Apr 24 21:05:32 2003 +0000
5.2 +++ b/tasklist.core/build.xml Sat Apr 26 07:50:06 2003 +0000
5.3 @@ -33,6 +33,7 @@
5.4 <pathelement location="${nb_all}/openide/openide-13javac-workaround.jar"/>
5.5 <pathelement location="${nb_all}/openide/netbeans/lib/openide.jar"/>
5.6 <pathelement location="${nb_all}/openide/loaders/netbeans/lib/openide-loaders.jar"/>
5.7 + <pathelement location="${nb_all}/core/settings/netbeans/modules/autoload/core-settings.jar"/>
5.8 <!-- tasklist api -->
5.9 <pathelement path="../api/src"/>
5.10 <!-- depend on core/output so we can override F12 action -->
6.1 --- a/tasklist.core/manifest.mf Thu Apr 24 21:05:32 2003 +0000
6.2 +++ b/tasklist.core/manifest.mf Sat Apr 26 07:50:06 2003 +0000
6.3 @@ -4,7 +4,8 @@
6.4 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/tasklist/core/Bundle.properties
6.5 OpenIDE-Module-Implementation-Version: @BUILD_NUMBER_SUBST@
6.6 OpenIDE-Module-IDE-Dependencies: IDE/1 > 3.42
6.7 -OpenIDE-Module-Module-Dependencies: org.netbeans.modules.javahelp/1 > 1.0, org.netbeans.api.tasklist/1 > 1.1
6.8 +OpenIDE-Module-Module-Dependencies: org.netbeans.modules.javahelp/1 > 1.0,
6.9 + org.netbeans.api.tasklist/1 > 1.1, org.netbeans.modules.settings/1 > 1.4
6.10 OpenIDE-Module-Requires: org.netbeans.api.javahelp.Help
6.11 OpenIDE-Module-Layer: org/netbeans/modules/tasklist/core/mf-layer.xml
6.12 Class-Path: docs/tasklist-manual.zip
7.1 --- a/tasklist.core/src/org/netbeans/modules/tasklist/core/TaskListView.java Thu Apr 24 21:05:32 2003 +0000
7.2 +++ b/tasklist.core/src/org/netbeans/modules/tasklist/core/TaskListView.java Sat Apr 26 07:50:06 2003 +0000
7.3 @@ -35,6 +35,7 @@
7.4 import java.awt.event.ActionListener;
7.5 import java.beans.PropertyVetoException;
7.6 import java.io.IOException;
7.7 +import java.util.Map;
7.8 import javax.swing.JPanel;
7.9 import javax.swing.JScrollPane;
7.10 import javax.swing.JTable;
7.11 @@ -44,6 +45,7 @@
7.12 import javax.swing.table.TableColumnModel;
7.13 import javax.swing.table.TableModel;
7.14 import javax.swing.tree.TreePath;
7.15 +import org.netbeans.modules.tasklist.core.columns.ColumnsConfiguration;
7.16 import org.netbeans.modules.tasklist.core.filter.Filter;
7.17 import org.netbeans.modules.tasklist.core.filter.FilterAction;
7.18 import org.openide.filesystems.FileObject;
7.19 @@ -61,7 +63,11 @@
7.20 import org.openide.awt.StatusDisplayer;
7.21 import org.openide.ErrorManager;
7.22 import org.openide.actions.FindAction;
7.23 +import org.openide.cookies.InstanceCookie;
7.24 import org.openide.explorer.ExplorerPanel;
7.25 +import org.openide.filesystems.FileSystem;
7.26 +import org.openide.loaders.DataObject;
7.27 +import org.openide.loaders.DataObjectNotFoundException;
7.28 import org.openide.text.Line;
7.29 import org.openide.util.actions.ActionPerformer;
7.30 import org.openide.util.actions.SystemAction;
7.31 @@ -71,7 +77,6 @@
7.32 import org.openide.util.actions.CallbackSystemAction;
7.33
7.34
7.35 -
7.36 /** View showing the todo list items
7.37 * @author Tor Norbye, Tim Lebedkov, Trond Norbye
7.38 * @todo Figure out why the window system sometimes creates multiple objects
7.39 @@ -82,6 +87,9 @@
7.40 /** Property "task summary" */
7.41 public static final String PROP_TASK_SUMMARY = "taskDesc"; // NOI18N
7.42
7.43 + /** String (category of a view) -> ColumnsConfiguration */
7.44 + private static Map defColumns = new HashMap();
7.45 +
7.46 transient protected TaskNode rootNode = null;
7.47 transient protected MyTreeTable treeTable;
7.48
7.49 @@ -233,6 +241,33 @@
7.50 return columns;
7.51 }
7.52
7.53 + /**
7.54 + * Returns default configuration for visible columns
7.55 + *
7.56 + * @return default columns configuration
7.57 + */
7.58 + protected ColumnsConfiguration getDefaultColumns() {
7.59 + ColumnsConfiguration cc = (ColumnsConfiguration) defColumns.get(category);
7.60 + if (cc != null)
7.61 + return cc;
7.62 +
7.63 + FileSystem fs = Repository.getDefault().getDefaultFileSystem();
7.64 + FileObject fo = fs.findResource("TaskList/" + category + "/columns.settings"); // NOI18N
7.65 +
7.66 + try {
7.67 + DataObject dobj = DataObject.find(fo);
7.68 + InstanceCookie ic = (InstanceCookie) dobj.getCookie(InstanceCookie.class);
7.69 + cc = (ColumnsConfiguration) ic.instanceCreate();
7.70 + } catch (ClassNotFoundException e) {
7.71 + ErrorManager.getDefault().notify(e);
7.72 + } catch (DataObjectNotFoundException e) {
7.73 + ErrorManager.getDefault().notify(e);
7.74 + } catch (IOException e) {
7.75 + ErrorManager.getDefault().notify(e);
7.76 + }
7.77 + return cc;
7.78 + }
7.79 +
7.80 /** Called when the object is opened. Add the GUI.
7.81 @todo Trigger source listening on window getting VISIBLE instead
7.82 of getting opened.
7.83 @@ -247,6 +282,9 @@
7.84 }
7.85 initialized = true;
7.86
7.87 + ColumnsConfiguration cc = getDefaultColumns();
7.88 + cc.configure(this);
7.89 +
7.90 FindAction find = (FindAction) FindAction.get(FindAction.class);
7.91 FilterAction filter = (FilterAction) FilterAction.get(FilterAction.class);
7.92 getActionMap().put(find.getActionMapKey(), filter);
7.93 @@ -320,6 +358,8 @@
7.94
7.95 protected void componentDeactivated() {
7.96 super.componentDeactivated();
7.97 + ColumnsConfiguration columns = getDefaultColumns();
7.98 + columns.loadFrom(this);
7.99 }
7.100
7.101 /** Create the root node to be used in this view */
7.102 @@ -462,11 +502,14 @@
7.103 //super.readExternal(objectInput);
7.104
7.105 int ver = objectInput.read();
7.106 - //assert ver <= 3 : "serialization version incorrect; should be 1, 2 or 3";
7.107 + //assert ver <= 4 : "serialization version incorrect; should be 1 to 4";
7.108
7.109 // Read in the UID of the currently selected task, or null if none
7.110 + // TODO: Not yet implemented
7.111 String selUID = (String)objectInput.readObject();
7.112 - // Unused: Not yet implemented
7.113 +
7.114 + if (ver == 4)
7.115 + return;
7.116
7.117 int sortingColumn = objectInput.read();
7.118 int sortAscendingInt = objectInput.read();
7.119 @@ -512,7 +555,8 @@
7.120 }
7.121 }
7.122
7.123 - if (index != -1) {
7.124 + /* don't do anything. we just read the bytes
7.125 + if (index != -1) {
7.126 columnVisible[index] = true;
7.127
7.128 // Set sorting attribute
7.129 @@ -526,10 +570,12 @@
7.130 }
7.131 }
7.132 }
7.133 + */
7.134 }
7.135
7.136 //System.out.print("Column visibility: {");
7.137 - for (int i = 0; i < columns.length; i++) {
7.138 + /* we don't do anything. we just read the bytes
7.139 + for (int i = 0; i < columns.length; i++) {
7.140 //System.out.print(" " + columnVisible[i]);
7.141
7.142 // Is this column visible?
7.143 @@ -546,6 +592,7 @@
7.144 Boolean.TRUE);
7.145 }
7.146 }
7.147 + */
7.148 //System.out.println(" }");
7.149 }
7.150
7.151 @@ -590,116 +637,35 @@
7.152 // don't want this.)
7.153 // TopComponent persists the name and tooltip text; we
7.154 // don't care about that either.
7.155 - //super.writeExternal(objectOutput);
7.156 + // super.writeExternal(objectOutput);
7.157
7.158 -
7.159 - // Here I should record a few things; in particular, sorting order, view
7.160 - // preferences, etc.
7.161 - // Since I'm not doing that yet, let's at a minimum put in a version
7.162 - // byte so we can do the right thing later without corrupting the userdir
7.163 - objectOutput.write(3); // SERIAL VERSION
7.164 -
7.165 - // Write out the UID of the currently selected task, or null if none
7.166 - objectOutput.writeObject(null); // Not yet implemented
7.167 -
7.168 // Version 1 format:
7.169 // String: selected uid
7.170 // byte: sortingColumn (255: no sort, otherwise, sorting id)
7.171 // byte: sort ascending (0:false or 1:true)
7.172 // byte: number of visible columns (N)
7.173 // N bytes: visible column uids
7.174 +
7.175 + // Version 4 format:
7.176 + // String: selected UID
7.177 + // String: category
7.178 + // String: title
7.179 + // byte: persistent
7.180
7.181 // TODO Additional:
7.182 - // N bytes: visible column order id's
7.183 - // N bytes: column widths?
7.184 - // (Question: should the above two lines be written for ALL columns
7.185 - // or just visible?)
7.186 // String Object: selected task? (should this be a multi-selection?)
7.187
7.188 - // Look at column properties and figure out which columns are visible,
7.189 - // which column is the sorting column and which whether or not the sort
7.190 - // is ascending/descending
7.191 - int[] visibleColumns = null;
7.192 - int numVisible = 0;
7.193 - int sortingColumn = -1;
7.194 - boolean ascending = false;
7.195 - if (columns != null) {
7.196 - int numColumns = columns.length;
7.197 - visibleColumns = new int[numColumns];
7.198 -
7.199 - for (int i = 0; i < columns.length; i++) {
7.200 - Boolean invisible =
7.201 - (Boolean)columns[i].getValue("InvisibleInTreeTableView"); // NOI18N
7.202 -
7.203 - // Is the column visible?
7.204 -
7.205 - // Grrr.... openide must not be using the Boolean enum's;
7.206 - // it must be creating new Boolean objects.... so I've
7.207 - // gotta use boolean value instead of this nice line:
7.208 - // if (!(invisible == Boolean.TRUE)) {
7.209 - if ((invisible == null) || !invisible.booleanValue()) {
7.210 - // yes
7.211 - visibleColumns[numVisible++] = columns[i].uid;
7.212 - }
7.213 -
7.214 - Boolean sorting =
7.215 - (Boolean)columns[i].getValue( "SortingColumnTTV"); // NOI18N
7.216 - if ((sorting != null) && (sorting.booleanValue())) {
7.217 - //assert sortingColumn == -1; // Only one column should be it
7.218 - sortingColumn = columns[i].uid;
7.219 - Boolean desc = (Boolean)columns[i].getValue( "DescendingOrderTTV"); // NOI18N
7.220 - ascending = (desc != Boolean.TRUE);
7.221 - }
7.222 -
7.223 - }
7.224 - }
7.225 -
7.226 - /*
7.227 - System.out.println("writeExternal: " + getClass().getName()); // NOI18N
7.228 - System.out.println("Sorting column: " + sortingColumn); // NOI18N
7.229 - System.out.println("Sorting ascending: " + ascending); // NOI18N
7.230 - System.out.println("Number of visible columns: " + numVisible); // NOI18N
7.231 - for (int i = 0; i < numVisible; i++) {
7.232 - System.out.print(" " + visibleColumns[i]); // NOI18N
7.233 - }
7.234 - System.out.println("\n"); // NOI18N
7.235 - */
7.236 -
7.237 - int sortAscendingInt = ascending ? 1 : 0;
7.238 -
7.239 - // WARNING! These write functions write BYTES! So don't try to
7.240 - // write negative numbers
7.241 - if (sortingColumn == -1) {
7.242 - sortingColumn = 255;
7.243 - }
7.244 -
7.245 - //assert ((sortingColumn >= 0) && (sortingColumn <= 255));
7.246 - //assert ((sortAscendingInt >= 0) &&
7.247 - // (sortAscendingInt <= 255));
7.248 - //assert ((numVisible >= 0) && (numVisible <= 255));
7.249 -
7.250 - objectOutput.write(sortingColumn);
7.251 - objectOutput.write(sortAscendingInt);
7.252 - objectOutput.write(numVisible);
7.253 -
7.254 - for (int i = 0; i < numVisible; i++) {
7.255 - // Can only write bytes...
7.256 - //assert((visibleColumns[i] >= 0) &&
7.257 - // (visibleColumns[i] <= 255));
7.258 -
7.259 - objectOutput.write(visibleColumns[i]);
7.260 - }
7.261 - /*
7.262 - column order in ttv ( columns can be moved )
7.263 - (Integer)columns[i].getValue( "OrderNumberTTV" ));
7.264 - */
7.265 + // Write out the UID of the currently selected task, or null if none
7.266 + objectOutput.write(4); // SERIAL VERSION
7.267
7.268 // Write out the UID of the currently selected task, or null if none
7.269 + objectOutput.writeObject(null); // Not yet implemented
7.270
7.271 // Write out the window's properties:
7.272 - objectOutput.writeObject(category);
7.273 - objectOutput.writeObject(title);
7.274 - objectOutput.write(persistent ? 1 : 0);
7.275 + // TODO: do we really need these properties?
7.276 + // objectOutput.writeObject(category);
7.277 + // objectOutput.writeObject(title);
7.278 + // objectOutput.write(persistent ? 1 : 0);
7.279 }
7.280
7.281 /** Create the list of columns to be used in the view.
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/tasklist.core/src/org/netbeans/modules/tasklist/core/columns/ColumnsConfiguration.java Sat Apr 26 07:50:06 2003 +0000
8.3 @@ -0,0 +1,245 @@
8.4 +/*
8.5 + * Sun Public License Notice
8.6 + *
8.7 + * The contents of this file are subject to the Sun Public License
8.8 + * Version 1.0 (the "License"). You may not use this file except in
8.9 + * compliance with the License. A copy of the License is available at
8.10 + * http://www.sun.com/
8.11 + *
8.12 + * The Original Code is NetBeans. The Initial Developer of the Original
8.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
8.14 + * Microsystems, Inc. All Rights Reserved.
8.15 + */
8.16 +
8.17 +package org.netbeans.modules.tasklist.core.columns;
8.18 +
8.19 +import java.awt.Font;
8.20 +import java.awt.Graphics;
8.21 +import java.awt.Graphics2D;
8.22 +import java.awt.Toolkit;
8.23 +import java.awt.font.FontRenderContext;
8.24 +import java.beans.PropertyChangeSupport;
8.25 +import java.io.BufferedInputStream;
8.26 +import java.io.BufferedOutputStream;
8.27 +import java.io.IOException;
8.28 +import java.io.ObjectInputStream;
8.29 +import java.io.ObjectOutputStream;
8.30 +import java.io.Serializable;
8.31 +import java.util.ArrayList;
8.32 +import java.util.Map;
8.33 +import javax.swing.event.ChangeEvent;
8.34 +import javax.swing.event.ChangeListener;
8.35 +import javax.swing.table.TableColumnModel;
8.36 +import javax.swing.table.TableModel;
8.37 +import org.netbeans.modules.tasklist.core.ColumnProperty;
8.38 +import org.netbeans.modules.tasklist.core.TaskListView;
8.39 +import org.openide.ErrorManager;
8.40 +import org.openide.filesystems.FileObject;
8.41 +import org.openide.filesystems.FileSystem;
8.42 +import org.openide.filesystems.Repository;
8.43 +
8.44 +/**
8.45 + * View's columns
8.46 + *
8.47 + * @author Tim Lebedkov
8.48 + */
8.49 +public class ColumnsConfiguration {
8.50 + private ArrayList listeners = new ArrayList();
8.51 +
8.52 + /** Widths of visible columns */
8.53 + private int widths[];
8.54 +
8.55 + private String[] properties;
8.56 +
8.57 + /** property of the sorting column or null */
8.58 + private String sortingColumn;
8.59 +
8.60 + private boolean ascending;
8.61 +
8.62 + /**
8.63 + * Constructor
8.64 + *
8.65 + * @param properties names of the properties for visible columns
8.66 + * @param widths widths of the visible columns
8.67 + * @param sort name of the sorting column or null
8.68 + * @param ascending true = ascending order, false = descending order
8.69 + */
8.70 + public ColumnsConfiguration(String[] properties, int[] widths, String sort,
8.71 + boolean ascending) {
8.72 + this.properties = properties;
8.73 + this.widths = widths;
8.74 + this.sortingColumn = sort;
8.75 + this.ascending = ascending;
8.76 + }
8.77 +
8.78 + /**
8.79 + * Returns widths of the columns
8.80 + *
8.81 + * @return widths
8.82 + */
8.83 + public int[] getWidths() {
8.84 + return widths;
8.85 + }
8.86 +
8.87 + /**
8.88 + * Returns names of the properties for visible columns
8.89 + *
8.90 + * @return properties
8.91 + */
8.92 + public String[] getProperties() {
8.93 + return properties;
8.94 + }
8.95 +
8.96 + /**
8.97 + * Returns property of the column the view is sorted on or null.
8.98 + *
8.99 + * @return name of a property or null
8.100 + */
8.101 + public String getSortingColumn() {
8.102 + return sortingColumn;
8.103 + }
8.104 +
8.105 + /**
8.106 + * Returns sorting order
8.107 + *
8.108 + * @return true = ascending, false = descending
8.109 + */
8.110 + public boolean getSortingOrder() {
8.111 + return ascending;
8.112 + }
8.113 +
8.114 + /**
8.115 + * Loads column configuration from a view
8.116 + *
8.117 + * @param v a view
8.118 + */
8.119 + public void loadFrom(TaskListView v) {
8.120 + // String[]
8.121 + ArrayList props = new ArrayList();
8.122 +
8.123 + sortingColumn = null;
8.124 + ColumnProperty columns[] = v.getColumns();
8.125 + for (int i = 0; i < columns.length; i++) {
8.126 + Boolean treeColumn =
8.127 + (Boolean) columns[i].getValue("TreeColumnTTV"); // NOI18N
8.128 + // Is the column visible?
8.129 + Boolean invisible =
8.130 + (Boolean) columns[i].getValue("InvisibleInTreeTableView"); // NOI18N
8.131 +
8.132 + // Grrr.... openide must not be using the Boolean enum's;
8.133 + // it must be creating new Boolean objects.... so I've
8.134 + // gotta use boolean value instead of this nice line:
8.135 + // if (!(invisible == Boolean.TRUE)) {
8.136 + if (treeColumn != null && treeColumn.booleanValue()) {
8.137 + props.add(0, columns[i].getName());
8.138 + } else if ((invisible == null) || !invisible.booleanValue()) {
8.139 + props.add(columns[i].getName());
8.140 + }
8.141 +
8.142 + Boolean sorting = (Boolean) columns[i].getValue(
8.143 + "SortingColumnTTV"); // NOI18N
8.144 + if ((sorting != null) && (sorting.booleanValue())) {
8.145 + sortingColumn = columns[i].getName();
8.146 + Boolean desc = (Boolean) columns[i].getValue(
8.147 + "DescendingOrderTTV"); // NOI18N
8.148 + ascending = (desc != Boolean.TRUE);
8.149 + }
8.150 + }
8.151 +
8.152 + TableColumnModel m = v.getTable().getColumnModel();
8.153 + properties = (String[]) props.toArray(new String[props.size()]);
8.154 +
8.155 + widths = new int[props.size()];
8.156 + for (int i = 0; i < props.size(); i++) {
8.157 + widths[i] = m.getColumn(i).getWidth();
8.158 + }
8.159 +
8.160 + fireChange();
8.161 + }
8.162 +
8.163 + /**
8.164 + * Configures view's column widths.
8.165 + *
8.166 + * @param v view that should be configured
8.167 + */
8.168 + public void configure(TaskListView v) {
8.169 + ColumnProperty columns[] = v.getColumns();
8.170 +
8.171 + for (int i = 0; i < columns.length; i++) {
8.172 + // NOTE reverse logic: this is INvisible
8.173 + columns[i].setValue("InvisibleInTreeTableView", // NOI18N
8.174 + Boolean.TRUE);
8.175 + }
8.176 +
8.177 + for (int i = 0; i < properties.length; i++) {
8.178 + ColumnProperty c = findColumn(columns, properties[i]);
8.179 + if (c != null) {
8.180 + // Necessary because by default some columns
8.181 + // set invisible by default, so I have to
8.182 + // override these
8.183 + // NOTE reverse logic: this is INvisible
8.184 + c.setValue("InvisibleInTreeTableView", // NOI18N
8.185 + Boolean.FALSE);
8.186 + c.width = widths[i];
8.187 + }
8.188 + }
8.189 +
8.190 + // Set sorting attribute
8.191 + if (sortingColumn != null) {
8.192 + ColumnProperty c = findColumn(columns, sortingColumn);
8.193 + if (c != null) {
8.194 + c.setValue("SortingColumnTTV", Boolean.TRUE); // NOI18N
8.195 + // Descending sort?
8.196 + c.setValue("DescendingOrderTTV", // NOI18N
8.197 + (!ascending) ? Boolean.TRUE : Boolean.FALSE);
8.198 + }
8.199 + }
8.200 + }
8.201 +
8.202 + /**
8.203 + * Searches a column by name
8.204 + *
8.205 + * @param columns view columns
8.206 + * @param name name of a property
8.207 + * @return found column or null
8.208 + */
8.209 + private static ColumnProperty findColumn(ColumnProperty columns[], String name) {
8.210 + for (int i = 0; i < columns.length; i++) {
8.211 + if (columns[i].getName().equals(name))
8.212 + return columns[i];
8.213 + }
8.214 +
8.215 + return null;
8.216 + }
8.217 +
8.218 + /**
8.219 + * Adds a ChangeListener to the listener list.
8.220 + *
8.221 + * @param l The listener to add.
8.222 + */
8.223 + public void addChangeListener(ChangeListener l) {
8.224 + listeners.add(l);
8.225 + }
8.226 +
8.227 + /**
8.228 + * Removes a ChangeListener from the listener list.
8.229 + *
8.230 + * @param l The listener to remove.
8.231 + */
8.232 + public void removeChangeListener(ChangeListener l) {
8.233 + listeners.remove(l);
8.234 + }
8.235 +
8.236 + /**
8.237 + * Fires a change event
8.238 + */
8.239 + private void fireChange() {
8.240 + ChangeEvent e = null;
8.241 + for (int i = 0; i < listeners.size(); i++) {
8.242 + ChangeListener l = (ChangeListener) listeners.get(i);
8.243 + if (e == null)
8.244 + e = new ChangeEvent(this);
8.245 + l.stateChanged(e);
8.246 + }
8.247 + }
8.248 +}
8.249 \ No newline at end of file
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/tasklist.core/src/org/netbeans/modules/tasklist/core/columns/ColumnsConfigurationConvertor.java Sat Apr 26 07:50:06 2003 +0000
9.3 @@ -0,0 +1,142 @@
9.4 +/*
9.5 + * Sun Public License Notice
9.6 + *
9.7 + * The contents of this file are subject to the Sun Public License
9.8 + * Version 1.0 (the "License"). You may not use this file except in
9.9 + * compliance with the License. A copy of the License is available at
9.10 + * http://www.sun.com/
9.11 + *
9.12 + * The Original Code is NetBeans. The Initial Developer of the Original
9.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
9.14 + * Microsystems, Inc. All Rights Reserved.
9.15 + */
9.16 +
9.17 +package org.netbeans.modules.tasklist.core.columns;
9.18 +
9.19 +import java.beans.PropertyChangeEvent;
9.20 +import java.beans.PropertyChangeListener;
9.21 +import java.io.IOException;
9.22 +import java.util.ArrayList;
9.23 +import javax.swing.event.ChangeEvent;
9.24 +import javax.swing.event.ChangeListener;
9.25 +import org.netbeans.spi.settings.Convertor;
9.26 +import org.netbeans.spi.settings.DOMConvertor;
9.27 +import org.netbeans.spi.settings.Saver;
9.28 +import org.openide.ErrorManager;
9.29 +import org.w3c.dom.Document;
9.30 +import org.w3c.dom.Element;
9.31 +import org.w3c.dom.Node;
9.32 +import org.w3c.dom.NodeList;
9.33 +
9.34 +/**
9.35 + * Convertor for column widths in XML format.
9.36 + * Public ID: "-//NetBeans org.netbeans.modules.tasklist//DTD Column Widths 1.0//EN"
9.37 + *
9.38 + * @author Tim Lebedkov
9.39 + */
9.40 +public class ColumnsConfigurationConvertor extends DOMConvertor
9.41 +implements ChangeListener {
9.42 + /**
9.43 + * Creates a converter for the specified FO
9.44 + *
9.45 + * @param fo an XML FO with Column Widths DTD
9.46 + */
9.47 + private static Object create(org.openide.filesystems.FileObject fo) {
9.48 + ColumnsConfigurationConvertor conv = new ColumnsConfigurationConvertor();
9.49 + return conv;
9.50 + }
9.51 +
9.52 + private Saver saver;
9.53 +
9.54 + /**
9.55 + * Creates a new instance
9.56 + */
9.57 + public ColumnsConfigurationConvertor() {
9.58 + super("-//NetBeans org.netbeans.modules.tasklist//DTD Columns 1.0//EN", // NOI18N
9.59 + "http://tasklist.netbeans.org/dtd/columns-1_0.dtd", "columns"); // NOI18N
9.60 + }
9.61 +
9.62 + protected Object readElement(Element element) {
9.63 + NodeList nl = element.getChildNodes();
9.64 +
9.65 + ArrayList w = new ArrayList();
9.66 + ArrayList n = new ArrayList();
9.67 + boolean ascending = true;
9.68 + String sortingColumn = null;
9.69 +
9.70 + for (int i = 0; i < nl.getLength(); i++) {
9.71 + if (nl.item(i).getNodeType() != Node.ELEMENT_NODE)
9.72 + continue;
9.73 +
9.74 + Element node = (Element) nl.item(i);
9.75 +
9.76 + n.add(node.getAttribute("property")); // NOI18N
9.77 + w.add(node.getAttribute("width")); // NOI18N
9.78 +
9.79 + if (sortingColumn == null) {
9.80 + String sort = node.getAttribute("sort"); // NOI18N
9.81 + if (sort.equals("ascending")) { // NOI18N
9.82 + sortingColumn = node.getAttribute("property"); // NOI18N
9.83 + ascending = true;
9.84 + } else if (sort.equals("descending")) { // NOI18N
9.85 + sortingColumn = node.getAttribute("property"); // NOI18N
9.86 + ascending = false;
9.87 + }
9.88 + }
9.89 + }
9.90 +
9.91 + int[] ww = new int[w.size()];
9.92 + for (int i = 0; i < w.size(); i++) {
9.93 + try {
9.94 + ww[i] = Integer.parseInt((String) w.get(i));
9.95 + } catch (NumberFormatException e) {
9.96 + ErrorManager.getDefault().notify(e);
9.97 + }
9.98 + }
9.99 + String[] nn = (String[]) n.toArray(new String[n.size()]);
9.100 +
9.101 + return new ColumnsConfiguration(nn, ww, sortingColumn, ascending);
9.102 + }
9.103 +
9.104 + protected void writeElement(Document doc, Element element, Object obj) {
9.105 + ColumnsConfiguration cw = (ColumnsConfiguration) obj;
9.106 + int[] w = cw.getWidths();
9.107 + String[] n = cw.getProperties();
9.108 + String sortingColumn = cw.getSortingColumn();
9.109 + boolean ascending = cw.getSortingOrder();
9.110 + for (int i = 0; i < n.length; i++) {
9.111 + Element col = doc.createElement("column"); // NOI18N
9.112 + col.setAttribute("property", n[i]); // NOI18N
9.113 + col.setAttribute("width", String.valueOf(w[i])); // NOI18N
9.114 + if (n[i].equals(sortingColumn)) {
9.115 + col.setAttribute("sort", ascending ? "ascending" : "descending"); // NOI18N
9.116 + }
9.117 + element.appendChild(col);
9.118 + }
9.119 + }
9.120 +
9.121 + public void registerSaver(Object inst, Saver s) {
9.122 + this.saver = s;
9.123 + ((ColumnsConfiguration) inst).addChangeListener(this);
9.124 + }
9.125 +
9.126 + public void unregisterSaver(Object inst, Saver s) {
9.127 + if (s == null || s != saver) {
9.128 + ErrorManager.getDefault().notify(ErrorManager.ERROR,
9.129 + new IllegalArgumentException(
9.130 + "Wrong argument for unregisterSaver(Object=" + inst + // NOI18N
9.131 + ", Saver=" + s + ")")); // NOI18N
9.132 + }
9.133 + this.saver = null;
9.134 + ((ColumnsConfiguration) inst).removeChangeListener(this);
9.135 + }
9.136 +
9.137 + public void stateChanged(ChangeEvent ev) {
9.138 + try {
9.139 + saver.requestSave();
9.140 + } catch (IOException e) {
9.141 + ErrorManager.getDefault().notify(e);
9.142 + }
9.143 + }
9.144 +}
9.145 +
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/tasklist.core/src/org/netbeans/modules/tasklist/core/columns/columns-1_0.dtd Sat Apr 26 07:50:06 2003 +0000
10.3 @@ -0,0 +1,29 @@
10.4 +<?xml version="1.0" encoding="UTF-8"?>
10.5 +
10.6 +<!--
10.7 + Sun Public License Notice
10.8 +
10.9 +The contents of this file are subject to the Sun Public License
10.10 +Version 1.0 (the "License"). You may not use this file except in
10.11 +compliance with the License. A copy of the License is available at
10.12 +http://www.sun.com/
10.13 +
10.14 +The Original Code is NetBeans. The Initial Developer of the Original
10.15 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
10.16 +Microsystems, Inc. All Rights Reserved.
10.17 +-->
10.18 +
10.19 +<!--
10.20 + Author : Tim Lebedkov
10.21 + Description: Format for storing column configuration
10.22 +-->
10.23 +
10.24 +<!ELEMENT columns (column)+>
10.25 +<!ATTLIST columns
10.26 +>
10.27 +<!ELEMENT column EMPTY>
10.28 +<!ATTLIST column
10.29 + property CDATA #REQUIRED
10.30 + width CDATA #REQUIRED
10.31 + sort (ascending | descending | none) "none"
10.32 +>
11.1 --- a/tasklist.core/src/org/netbeans/modules/tasklist/core/mf-layer.xml Thu Apr 24 21:05:32 2003 +0000
11.2 +++ b/tasklist.core/src/org/netbeans/modules/tasklist/core/mf-layer.xml Sat Apr 26 07:50:06 2003 +0000
11.3 @@ -50,5 +50,53 @@
11.4 </folder>
11.5 </folder>
11.6
11.7 + <folder name="xml">
11.8 + <folder name="memory">
11.9 + <folder name="org">
11.10 + <folder name="netbeans">
11.11 + <folder name="modules">
11.12 + <folder name="tasklist">
11.13 + <folder name="core">
11.14 + <folder name="columns">
11.15 + <file name="ColumnsConfiguration">
11.16 + <attr name="settings.providerPath"
11.17 + stringvalue="xml/lookups/NetBeans_org_netbeans_modules_tasklist/DTD_Columns_1_0"/>
11.18 + </file>
11.19 + </folder>
11.20 + </folder>
11.21 + </folder>
11.22 + </folder>
11.23 + </folder>
11.24 + </folder>
11.25 + </folder>
11.26 + </folder>
11.27 +
11.28 + <folder name="xml">
11.29 + <folder name="entities">
11.30 + <!--Entity registration-->
11.31 + <folder name="NetBeans_org_netbeans_modules_tasklist">
11.32 + <file name="DTD_Columns_1_0" url="columns/columns-1_0.dtd">
11.33 + <attr name="hint.originalPublicID"
11.34 + stringvalue="-//NetBeans org.netbeans.modules.tasklist//DTD Columns 1.0//EN"/>
11.35 + </file>
11.36 + </folder>
11.37 + </folder>
11.38 + <folder name="lookups">
11.39 + <folder name="NetBeans_org_netbeans_modules_tasklist">
11.40 + <file name="DTD_Columns_1_0.instance">
11.41 + <!--Environment Provider provided by the settings module-->
11.42 + <attr name="instanceCreate" methodvalue="org.netbeans.api.settings.Factory.create"/>
11.43 + <!--Custom convertor object-->
11.44 + <attr name="settings.convertor" methodvalue="org.netbeans.modules.tasklist.core.columns.ColumnsConfigurationConvertor.create"/>
11.45 + <!--class name of the setting object-->
11.46 + <attr name="settings.instanceClass" stringvalue="org.netbeans.modules.tasklist.core.columns.ColumnsConfiguration"/>
11.47 + <!--class name and subclass names of the setting object separated by comma;
11.48 + used for performance reasons; be careful what you include or exclude here to ensure
11.49 + your setting is accessible via the Lookup API -->
11.50 + <attr name="settings.instanceOf" stringvalue="org.netbeans.modules.tasklist.core.columns.ColumnsConfiguration"/>
11.51 + </file>
11.52 + </folder>
11.53 + </folder>
11.54 + </folder>
11.55 </filesystem>
11.56
12.1 --- a/tasklist.usertasks/src/org/netbeans/modules/tasklist/usertasks/mf-layer.xml Thu Apr 24 21:05:32 2003 +0000
12.2 +++ b/tasklist.usertasks/src/org/netbeans/modules/tasklist/usertasks/mf-layer.xml Sat Apr 26 07:50:06 2003 +0000
12.3 @@ -85,5 +85,12 @@
12.4 </folder>
12.5 </folder>
12.6
12.7 + <folder name="TaskList">
12.8 + <folder name="usertasks">
12.9 + <file name="columns.settings" url="columns.xml">
12.10 + <attr name="instanceClass" stringvalue="org.netbeans.modules.tasklist.core.columns.ColumnsConfiguration"/>
12.11 + </file>
12.12 + </folder>
12.13 + </folder>
12.14 </filesystem>
12.15