1
/*FreeMind - A Program for creating and viewing Mindmaps
2
*Copyright (C) 2000-2006 Joerg Mueller, Daniel Polansky, Christian Foltin, Dimitri Polivaev and others.
4
*See COPYING for Details
6
*This program is free software; you can redistribute it and/or
7
*modify it under the terms of the GNU General Public License
8
*as published by the Free Software Foundation; either version 2
9
*of the License, or (at your option) any later version.
11
*This program is distributed in the hope that it will be useful,
12
*but WITHOUT ANY WARRANTY; without even the implied warranty of
13
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
*GNU General Public License for more details.
16
*You should have received a copy of the GNU General Public License
17
*along with this program; if not, write to the Free Software
18
*Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
* Created on 24.07.2005
22
* Copyright (C) 2005 Dimitri Polivaev
24
package freemind.modes.attributes;
26
import javax.swing.event.ChangeEvent;
27
import javax.swing.event.EventListenerList;
30
* @author Dimitri Polivaev
33
public class AttributeTableLayoutModel {
34
public static final String SHOW_SELECTED = "selected";
35
public static final String SHOW_ALL = "extended";
36
public static final String HIDE_ALL = "hide";
37
public static final int DEFAULT_COLUMN_WIDTH = 75;
38
private int[] width = {DEFAULT_COLUMN_WIDTH, DEFAULT_COLUMN_WIDTH};
40
private EventListenerList listenerList = null;
41
ChangeEvent changeEvent = null;
42
ColumnWidthChangeEvent[] layoutChangeEvent = {null, null};
44
public AttributeTableLayoutModel() {
47
public int getColumnWidth(int col) {
50
public void setColumnWidth(int col, int width) {
51
if(this.width[col] != width){
52
this.width[col] = width;
53
fireColumnWidthChanged(col);
57
* @param listenerList The listenerList to set.
59
private void setListenerList(EventListenerList listenerList) {
60
this.listenerList = listenerList;
63
* @return Returns the listenerList.
65
private EventListenerList getListenerList() {
66
if(listenerList == null)
67
listenerList = new EventListenerList();
70
public void addColumnWidthChangeListener(ColumnWidthChangeListener l) {
71
getListenerList().add(ColumnWidthChangeListener.class, l);
74
public void removeColumnWidthChangeListener(ColumnWidthChangeListener l) {
75
getListenerList().remove(ColumnWidthChangeListener.class, l);
79
// Notify all listeners that have registered interest for
80
// notification on this event type. The event instance
81
// is lazily created using the parameters passed into
84
protected void fireColumnWidthChanged(int col) {
85
// Guaranteed to return a non-null array
86
Object[] listeners = getListenerList().getListenerList();
87
// Process the listeners last to first, notifying
88
// those that are interested in this event
89
for (int i = listeners.length-2; i>=0; i-=2) {
90
if (listeners[i]==ColumnWidthChangeListener.class) {
91
// Lazily create the event:
92
if (layoutChangeEvent[col] == null)
93
layoutChangeEvent[col] = new ColumnWidthChangeEvent(this, col);
94
((ColumnWidthChangeListener)listeners[i+1]).columnWidthChanged(layoutChangeEvent[col]);