tn5250j/src/org/tn5250j/gui SortArrowIcon.java,1.1,1.2 Wizard.java,1.2,1.3 DefaultSortTableModel.java,1.1,1.2 SortTableModel.java,1.1,1.2 ColumnComparator.java,1.1,1.2 SortHeaderRenderer.java,1.1,1.2 ToggleDocument.java,1.1,1.2
"Kenneth J. Pouncey" <[email protected]> Thu, 16 Jun 2005 04:41:20 +0000
| Newsgroups | gmane.comp.java.tn5250j.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tn5250j/tn5250j/src/org/tn5250j/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24279/src/org/tn5250j/gui
Modified Files:
SortArrowIcon.java Wizard.java DefaultSortTableModel.java
SortTableModel.java ColumnComparator.java
SortHeaderRenderer.java ToggleDocument.java
Log Message:
the rest of the story
Index: SortHeaderRenderer.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/gui/SortHeaderRenderer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SortHeaderRenderer.java 24 Jul 2002 19:35:48 -0000 1.1
--- SortHeaderRenderer.java 16 Jun 2005 04:41:18 -0000 1.2
***************
*** 1,60 ****
! package org.tn5250j.gui;
! /*
! =====================================================================
!
! SortHeaderRenderer.java
!
! Created by Claude Duguay
! Copyright (c) 2002
! This was taken from a Java Pro magazine article
! http://www.fawcette.com/javapro/codepage.asp?loccode=jp0208
!
! I have NOT asked for permission to use this.
!
! =====================================================================
! */
!
! import java.awt.*;
! import javax.swing.*;
! import javax.swing.table.*;
!
! public class SortHeaderRenderer extends DefaultTableCellRenderer {
!
! public static Icon NONSORTED = new SortArrowIcon(SortArrowIcon.NONE);
! public static Icon ASCENDING = new SortArrowIcon(SortArrowIcon.ASCENDING);
! public static Icon DECENDING = new SortArrowIcon(SortArrowIcon.DECENDING);
!
! public SortHeaderRenderer() {
! setHorizontalTextPosition(LEFT);
! setHorizontalAlignment(CENTER);
! }
!
! public Component getTableCellRendererComponent( JTable table,
! Object value,
! boolean isSelected,
! boolean hasFocus, int row, int col) {
!
! int index = -1;
! boolean ascending = true;
! if (table instanceof JSortTable) {
! JSortTable sortTable = (JSortTable)table;
! index = sortTable.getSortedColumnIndex();
! ascending = sortTable.isSortedColumnAscending();
! }
! if (table != null) {
! JTableHeader header = table.getTableHeader();
! if (header != null) {
! setForeground(header.getForeground());
! setBackground(header.getBackground());
! setFont(header.getFont());
! }
! }
!
! Icon icon = ascending ? ASCENDING : DECENDING;
! setIcon(col == index ? icon : NONSORTED);
! setText((value == null) ? "" : value.toString());
! setBorder(UIManager.getBorder("TableHeader.cellBorder"));
! return this;
! }
! }
!
--- 1,60 ----
! package org.tn5250j.gui;
! /*
! =====================================================================
!
! SortHeaderRenderer.java
!
! Created by Claude Duguay
! Copyright (c) 2002
! This was taken from a Java Pro magazine article
! http://www.fawcette.com/javapro/codepage.asp?loccode=jp0208
!
! I have NOT asked for permission to use this.
!
! =====================================================================
! */
!
! import java.awt.*;
! import javax.swing.*;
! import javax.swing.table.*;
!
! public class SortHeaderRenderer extends DefaultTableCellRenderer {
!
! public static Icon NONSORTED = new SortArrowIcon(SortArrowIcon.NONE);
! public static Icon ASCENDING = new SortArrowIcon(SortArrowIcon.ASCENDING);
! public static Icon DECENDING = new SortArrowIcon(SortArrowIcon.DECENDING);
!
! public SortHeaderRenderer() {
! setHorizontalTextPosition(LEFT);
! setHorizontalAlignment(CENTER);
! }
!
! public Component getTableCellRendererComponent( JTable table,
! Object value,
! boolean isSelected,
! boolean hasFocus, int row, int col) {
!
! int index = -1;
! boolean ascending = true;
! if (table instanceof JSortTable) {
! JSortTable sortTable = (JSortTable)table;
! index = sortTable.getSortedColumnIndex();
! ascending = sortTable.isSortedColumnAscending();
! }
! if (table != null) {
! JTableHeader header = table.getTableHeader();
! if (header != null) {
! setForeground(header.getForeground());
! setBackground(header.getBackground());
! setFont(header.getFont());
! }
! }
!
! Icon icon = ascending ? ASCENDING : DECENDING;
! setIcon(col == index ? icon : NONSORTED);
! setText((value == null) ? "" : value.toString());
! setBorder(UIManager.getBorder("TableHeader.cellBorder"));
! return this;
! }
! }
!
Index: ToggleDocument.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/gui/ToggleDocument.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ToggleDocument.java 17 Jun 2003 06:06:34 -0000 1.1
--- ToggleDocument.java 16 Jun 2005 04:41:18 -0000 1.2
***************
*** 1,108 ****
! /*
! * @(#)ToggleDocument.java
! * Copyright: Copyright (c) 2001
! *
! * This program is free software; you can redistribute it and/or modify
! * it under the terms of the GNU General Public License as published by
! * the Free Software Foundation; either version 2, or (at your option)
! * any later version.
! *
! * This program is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! * GNU General Public License for more details.
! *
! * You should have received a copy of the GNU General Public License
! * along with this software; see the file COPYING. If not, write to
! * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
! * Boston, MA 02111-1307 USA
! *
! */
! package org.tn5250j.gui;
!
! import java.util.Vector;
! import javax.swing.text.PlainDocument;
! import javax.swing.text.AttributeSet;
! import javax.swing.text.BadLocationException;
!
! import org.tn5250j.event.ToggleDocumentListener;
!
! public class ToggleDocument extends PlainDocument {
!
! Vector listeners;
!
! public void insertString(int offs, String str, AttributeSet a)
! throws BadLocationException {
!
! super.insertString(offs, str, a);
! if (getText(0, getLength()).length() > 0)
! fireNotEmpty();
! }
!
! public void remove(int offs, int len) throws BadLocationException {
! super.remove(offs, len);
! if (getText(0, getLength()).length() == 0)
! fireEmpty();
! }
!
! /**
! * Add a ToggleDocumentListener to the listener list.
! *
! * @param listener The ToggleDocumentListener to be added
! */
! public synchronized void addToggleDocumentListener(ToggleDocumentListener listener) {
!
! if (listeners == null) {
! listeners = new java.util.Vector(3);
! }
! listeners.addElement(listener);
!
! }
!
! /**
! * Remove a Toggle Document Listener from the listener list.
! *
! * @param listener The ToggleDocumentListener to be removed
! */
! public synchronized void removeToggleDocumentListener(ToggleDocumentListener listener) {
! if (listeners == null) {
! return;
! }
! listeners.removeElement(listener);
!
! }
!
! /**
! * Notify all registered listeners that the field is no longer empty.
! *
! */
! public void fireNotEmpty() {
!
! if (listeners != null) {
! int size = listeners.size();
! for (int i = 0; i < size; i++) {
! ToggleDocumentListener target =
! (ToggleDocumentListener)listeners.elementAt(i);
! target.toggleNotEmpty();
! }
! }
! }
!
! /**
! * Notify all registered listeners that the field is no longer empty.
! *
! */
! public void fireEmpty() {
!
! if (listeners != null) {
! int size = listeners.size();
! for (int i = 0; i < size; i++) {
! ToggleDocumentListener target =
! (ToggleDocumentListener)listeners.elementAt(i);
! target.toggleEmpty();
! }
! }
! }
!
! }
!
--- 1,108 ----
! /*
! * @(#)ToggleDocument.java
! * Copyright: Copyright (c) 2001
! *
! * This program is free software; you can redistribute it and/or modify
! * it under the terms of the GNU General Public License as published by
! * the Free Software Foundation; either version 2, or (at your option)
! * any later version.
! *
! * This program is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! * GNU General Public License for more details.
! *
! * You should have received a copy of the GNU General Public License
! * along with this software; see the file COPYING. If not, write to
! * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
! * Boston, MA 02111-1307 USA
! *
! */
! package org.tn5250j.gui;
!
! import java.util.Vector;
! import javax.swing.text.PlainDocument;
! import javax.swing.text.AttributeSet;
! import javax.swing.text.BadLocationException;
!
! import org.tn5250j.event.ToggleDocumentListener;
!
! public class ToggleDocument extends PlainDocument {
!
! Vector listeners;
!
! public void insertString(int offs, String str, AttributeSet a)
! throws BadLocationException {
!
! super.insertString(offs, str, a);
! if (getText(0, getLength()).length() > 0)
! fireNotEmpty();
! }
!
! public void remove(int offs, int len) throws BadLocationException {
! super.remove(offs, len);
! if (getText(0, getLength()).length() == 0)
! fireEmpty();
! }
!
! /**
! * Add a ToggleDocumentListener to the listener list.
! *
! * @param listener The ToggleDocumentListener to be added
! */
! public synchronized void addToggleDocumentListener(ToggleDocumentListener listener) {
!
! if (listeners == null) {
! listeners = new java.util.Vector(3);
! }
! listeners.addElement(listener);
!
! }
!
! /**
! * Remove a Toggle Document Listener from the listener list.
! *
! * @param listener The ToggleDocumentListener to be removed
! */
! public synchronized void removeToggleDocumentListener(ToggleDocumentListener listener) {
! if (listeners == null) {
! return;
! }
! listeners.removeElement(listener);
!
! }
!
! /**
! * Notify all registered listeners that the field is no longer empty.
! *
! */
! public void fireNotEmpty() {
!
! if (listeners != null) {
! int size = listeners.size();
! for (int i = 0; i < size; i++) {
! ToggleDocumentListener target =
! (ToggleDocumentListener)listeners.elementAt(i);
! target.toggleNotEmpty();
! }
! }
! }
!
! /**
! * Notify all registered listeners that the field is no longer empty.
! *
! */
! public void fireEmpty() {
!
! if (listeners != null) {
! int size = listeners.size();
! for (int i = 0; i < size; i++) {
! ToggleDocumentListener target =
! (ToggleDocumentListener)listeners.elementAt(i);
! target.toggleEmpty();
! }
! }
! }
!
! }
!
Index: Wizard.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/gui/Wizard.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Wizard.java 15 Feb 2003 10:55:20 -0000 1.2
--- Wizard.java 16 Jun 2005 04:41:18 -0000 1.3
***************
*** 1,494 ****
! /*
! * @(#)Wizard.java
! * Copyright: Copyright (c) 2001
! *
! * This program is free software; you can redistribute it and/or modify
! * it under the terms of the GNU General Public License as published by
! * the Free Software Foundation; either version 2, or (at your option)
! * any later version.
! *
! * This program is distributed in the hope that it will be useful,
[...961 lines suppressed...]
! b.removeActionListener(previousListener);
! }
! b = wp.getFinishButton();
! if (b != null) {
! b.removeActionListener(finishListener);
! }
! b = wp.getCancelButton();
! if (b != null) {
! b.removeActionListener(cancelListener);
! }
! b = wp.getHelpButton();
! if (b != null) {
! b.removeActionListener(helpListener);
! }
! }
! }
! };
!
}
\ No newline at end of file
Index: DefaultSortTableModel.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/gui/DefaultSortTableModel.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DefaultSortTableModel.java 24 Jul 2002 19:35:48 -0000 1.1
--- DefaultSortTableModel.java 16 Jun 2005 04:41:18 -0000 1.2
***************
*** 1,54 ****
! package org.tn5250j.gui;
! /*
! =====================================================================
!
! DefaultSortTableModel.java
!
! Created by Claude Duguay
! Copyright (c) 2002
! This was taken from a Java Pro magazine article
! http://www.fawcette.com/javapro/codepage.asp?loccode=jp0208
!
! I have NOT asked for permission to use this.
!
! =====================================================================
! */
!
! import java.util.*;
! import javax.swing.table.*;
!
! public class DefaultSortTableModel extends DefaultTableModel
! implements SortTableModel {
!
! public DefaultSortTableModel() {}
!
! public DefaultSortTableModel(int rows, int cols) {
! super(rows, cols);
! }
!
! public DefaultSortTableModel(Object[][] data, Object[] names) {
! super(data, names);
! }
!
! public DefaultSortTableModel(Object[] names, int rows) {
! super(names, rows);
! }
!
! public DefaultSortTableModel(Vector names, int rows) {
! super(names, rows);
! }
!
! public DefaultSortTableModel(Vector data, Vector names) {
! super(data, names);
! }
!
! public boolean isSortable(int col) {
! return true;
! }
!
! public void sortColumn(int col, boolean ascending) {
! Collections.sort(getDataVector(),
! new ColumnComparator(col, ascending));
! }
! }
!
--- 1,54 ----
! package org.tn5250j.gui;
! /*
! =====================================================================
!
! DefaultSortTableModel.java
!
! Created by Claude Duguay
! Copyright (c) 2002
! This was taken from a Java Pro magazine article
! http://www.fawcette.com/javapro/codepage.asp?loccode=jp0208
!
! I have NOT asked for permission to use this.
!
! =====================================================================
! */
!
! import java.util.*;
! import javax.swing.table.*;
!
! public class DefaultSortTableModel extends DefaultTableModel
! implements SortTableModel {
!
! public DefaultSortTableModel() {}
!
! public DefaultSortTableModel(int rows, int cols) {
! super(rows, cols);
! }
!
! public DefaultSortTableModel(Object[][] data, Object[] names) {
! super(data, names);
! }
!
! public DefaultSortTableModel(Object[] names, int rows) {
! super(names, rows);
! }
!
! public DefaultSortTableModel(Vector names, int rows) {
! super(names, rows);
! }
!
! public DefaultSortTableModel(Vector data, Vector names) {
! super(data, names);
! }
!
! public boolean isSortable(int col) {
! return true;
! }
!
! public void sortColumn(int col, boolean ascending) {
! Collections.sort(getDataVector(),
! new ColumnComparator(col, ascending));
! }
! }
!
Index: ColumnComparator.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/gui/ColumnComparator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ColumnComparator.java 24 Jul 2002 19:35:48 -0000 1.1
--- ColumnComparator.java 16 Jun 2005 04:41:18 -0000 1.2
***************
*** 1,49 ****
! package org.tn5250j.gui;
! /*
! =====================================================================
!
! ColumnComparator.java
!
! Created by Claude Duguay
! Copyright (c) 2002
! This was taken from a Java Pro magazine article
! http://www.fawcette.com/javapro/codepage.asp?loccode=jp0208
!
! I have NOT asked for permission to use this.
!
! =====================================================================
! */
!
! import java.util.*;
!
! public class ColumnComparator implements Comparator {
! protected int index;
! protected boolean ascending;
!
! public ColumnComparator(int index, boolean ascending) {
! this.index = index;
! this.ascending = ascending;
! }
!
! public int compare(Object one, Object two) {
! if (one instanceof Vector && two instanceof Vector) {
! Vector vOne = (Vector)one;
! Vector vTwo = (Vector)two;
! Object oOne = vOne.elementAt(index);
! Object oTwo = vTwo.elementAt(index);
! if (oOne instanceof Comparable && oTwo instanceof Comparable) {
! Comparable cOne = (Comparable)oOne;
! Comparable cTwo = (Comparable)oTwo;
! if (ascending) {
! return cOne.compareTo(cTwo);
! }
! else {
! return cTwo.compareTo(cOne);
! }
! }
! }
!
! return 1;
! }
! }
!
--- 1,49 ----
! package org.tn5250j.gui;
! /*
! =====================================================================
!
! ColumnComparator.java
!
! Created by Claude Duguay
! Copyright (c) 2002
! This was taken from a Java Pro magazine article
! http://www.fawcette.com/javapro/codepage.asp?loccode=jp0208
!
! I have NOT asked for permission to use this.
!
! =====================================================================
! */
!
! import java.util.*;
!
! public class ColumnComparator implements Comparator {
! protected int index;
! protected boolean ascending;
!
! public ColumnComparator(int index, boolean ascending) {
! this.index = index;
! this.ascending = ascending;
! }
!
! public int compare(Object one, Object two) {
! if (one instanceof Vector && two instanceof Vector) {
! Vector vOne = (Vector)one;
! Vector vTwo = (Vector)two;
! Object oOne = vOne.elementAt(index);
! Object oTwo = vTwo.elementAt(index);
! if (oOne instanceof Comparable && oTwo instanceof Comparable) {
! Comparable cOne = (Comparable)oOne;
! Comparable cTwo = (Comparable)oTwo;
! if (ascending) {
! return cOne.compareTo(cTwo);
! }
! else {
! return cTwo.compareTo(cOne);
! }
! }
! }
!
! return 1;
! }
! }
!
Index: SortTableModel.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/gui/SortTableModel.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SortTableModel.java 24 Jul 2002 19:35:48 -0000 1.1
--- SortTableModel.java 16 Jun 2005 04:41:18 -0000 1.2
***************
*** 1,22 ****
! package org.tn5250j.gui;
! /*
! =====================================================================
!
! SortTableModel.java
!
! Created by Claude Duguay
! Copyright (c) 2002
! This was taken from a Java Pro magazine article
! http://www.fawcette.com/javapro/codepage.asp?loccode=jp0208
!
! I have NOT asked for permission to use this.
! =====================================================================
! */
!
! import javax.swing.table.*;
!
! public interface SortTableModel extends TableModel {
! public boolean isSortable(int col);
! public void sortColumn(int col, boolean ascending);
! }
!
--- 1,22 ----
! package org.tn5250j.gui;
! /*
! =====================================================================
!
! SortTableModel.java
!
! Created by Claude Duguay
! Copyright (c) 2002
! This was taken from a Java Pro magazine article
! http://www.fawcette.com/javapro/codepage.asp?loccode=jp0208
!
! I have NOT asked for permission to use this.
! =====================================================================
! */
!
! import javax.swing.table.*;
!
! public interface SortTableModel extends TableModel {
! public boolean isSortable(int col);
! public void sortColumn(int col, boolean ascending);
! }
!
Index: SortArrowIcon.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/gui/SortArrowIcon.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SortArrowIcon.java 24 Jul 2002 19:35:48 -0000 1.1
--- SortArrowIcon.java 16 Jun 2005 04:41:18 -0000 1.2
***************
*** 1,66 ****
! package org.tn5250j.gui;
! /*
! =====================================================================
!
! SortArrowIcon.java
!
! Created by Claude Duguay
! Copyright (c) 2002
! This was taken from a Java Pro magazine article
! http://www.fawcette.com/javapro/codepage.asp?loccode=jp0208
!
! I have NOT asked for permission to use this.
!
! =====================================================================
! */
!
! import java.awt.*;
! import javax.swing.*;
!
! public class SortArrowIcon implements Icon {
!
! public static final int NONE = 0;
! public static final int DECENDING = 1;
! public static final int ASCENDING = 2;
!
! protected int direction;
! protected int width = 8;
! protected int height = 8;
!
! public SortArrowIcon(int direction) {
! this.direction = direction;
! }
!
! public int getIconWidth() {
! return width;
! }
!
! public int getIconHeight() {
! return height;
! }
!
! public void paintIcon(Component c, Graphics g, int x, int y) {
! Color bg = c.getBackground();
! Color light = bg.brighter();
! Color shade = bg.darker();
!
! int w = width;
! int h = height;
! int m = w / 2;
! if (direction == ASCENDING) {
! g.setColor(shade);
! g.drawLine(x, y, x + w, y);
! g.drawLine(x, y, x + m, y + h);
! g.setColor(light);
! g.drawLine(x + w, y, x + m, y + h);
! }
! if (direction == DECENDING) {
! g.setColor(shade);
! g.drawLine(x + m, y, x, y + h);
! g.setColor(light);
! g.drawLine(x, y + h, x + w, y + h);
! g.drawLine(x + m, y, x + w, y + h);
! }
! }
! }
!
--- 1,66 ----
! package org.tn5250j.gui;
! /*
! =====================================================================
!
! SortArrowIcon.java
!
! Created by Claude Duguay
! Copyright (c) 2002
! This was taken from a Java Pro magazine article
! http://www.fawcette.com/javapro/codepage.asp?loccode=jp0208
!
! I have NOT asked for permission to use this.
!
! =====================================================================
! */
!
! import java.awt.*;
! import javax.swing.*;
!
! public class SortArrowIcon implements Icon {
!
! public static final int NONE = 0;
! public static final int DECENDING = 1;
! public static final int ASCENDING = 2;
!
! protected int direction;
! protected int width = 8;
! protected int height = 8;
!
! public SortArrowIcon(int direction) {
! this.direction = direction;
! }
!
! public int getIconWidth() {
! return width;
! }
!
! public int getIconHeight() {
! return height;
! }
!
! public void paintIcon(Component c, Graphics g, int x, int y) {
! Color bg = c.getBackground();
! Color light = bg.brighter();
! Color shade = bg.darker();
!
! int w = width;
! int h = height;
! int m = w / 2;
! if (direction == ASCENDING) {
! g.setColor(shade);
! g.drawLine(x, y, x + w, y);
! g.drawLine(x, y, x + m, y + h);
! g.setColor(light);
! g.drawLine(x + w, y, x + m, y + h);
! }
! if (direction == DECENDING) {
! g.setColor(shade);
! g.drawLine(x + m, y, x, y + h);
! g.setColor(light);
! g.drawLine(x, y + h, x + w, y + h);
! g.drawLine(x + m, y, x + w, y + h);
! }
! }
! }
!
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click