home *** CD-ROM | disk | FTP | other *** search
- package jclass.bwt;
-
- import java.applet.Applet;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Font;
- import java.util.EventObject;
- import java.util.Vector;
- import jclass.util.JCSortInterface;
- import jclass.util.JCUtilConverter;
- import jclass.util.JCVector;
-
- public abstract class JCMultiColumnWindow extends JCScrolledWindow implements JCMultiColumnInterface, JCActionListener {
- public static final int ASCENDING = 0;
- public static final int DESCENDING = 1;
- JCSortInterface sort_method;
- boolean column_label_sort = true;
- protected Viewport headerArea;
- protected JCHeader header;
- protected JCMultiColumnInterface comp;
-
- public JCMultiColumnWindow() {
- super((Applet)null, (String)null);
- }
-
- public JCMultiColumnWindow(Applet var1, String var2) {
- super(var1, var2);
- }
-
- public JCHeader getHeader() {
- if (this.header == null) {
- this.setHeader(new JCHeader((String[])null, super.applet, ((Component)this).getName()));
- }
-
- return this.header;
- }
-
- public void setHeader(JCHeader var1) {
- this.header = var1;
- if (var1 == null) {
- if (this.headerArea != null) {
- ((Container)this).remove(this.headerArea);
- }
-
- this.headerArea = null;
- } else {
- if (this.headerArea == null) {
- this.headerArea = new Viewport();
- }
-
- this.headerArea.add(var1);
- var1.setMultiColumnComponent((JCMultiColumnInterface)super.viewport);
- var1.addActionListener(this);
- if (((Component)this).getPeer() != null) {
- ((JCScrolledWindow)this).addInternal(this.headerArea);
- }
-
- }
- }
-
- public String[] getColumnLabels() {
- if (this.header == null) {
- return null;
- } else {
- JCComponent[] var1 = this.header.getLabels();
- String[] var2 = new String[var1.length];
-
- for(int var3 = 0; var3 < var1.length; ++var3) {
- if (var1[var3] instanceof JCLabel) {
- Object var4 = ((JCLabel)var1[var3]).getLabel();
- var2[var3] = var4 != null ? var4.toString() : "";
- } else {
- var2[var3] = var1[var3].getName();
- }
- }
-
- return var2;
- }
- }
-
- public void setColumnLabels(String[] var1) {
- this.setColumnLabels(new JCVector(var1));
- }
-
- public void setColumnLabels(JCVector var1) {
- if (this.header == null) {
- if (var1 == null || ((Vector)var1).size() == 0) {
- return;
- }
-
- this.setHeader(new JCHeader((String[])null, super.applet, ((Component)this).getName()));
- }
-
- if (var1 != null && ((Vector)var1).size() != 0) {
- this.header.setLabels(var1);
- } else {
- this.setHeader((JCHeader)null);
- }
- }
-
- public void setColumnButtons(String[] var1) {
- this.setColumnButtons(new JCVector(var1));
- }
-
- public void setColumnButtons(JCVector var1) {
- if (this.header == null) {
- if (var1 == null || ((Vector)var1).size() == 0) {
- return;
- }
-
- this.setHeader(new JCHeader((String[])null, super.applet, ((Component)this).getName()));
- }
-
- if (var1 != null && ((Vector)var1).size() != 0) {
- this.header.setButtons(var1);
- } else {
- this.setHeader((JCHeader)null);
- }
- }
-
- protected void setViewport(JCMultiColumnInterface var1) {
- this.comp = var1;
- super.viewport = (Component)var1;
- }
-
- protected int reshapeHeader(int var1, int var2, int var3) {
- int var4 = this.headerHeight();
- if (this.headerArea != null) {
- this.headerArea.reshape(var1, var2, var3, var4);
- }
-
- return var4;
- }
-
- protected int headerHeight() {
- return this.headerArea == null ? 0 : this.headerArea.preferredSize().height;
- }
-
- protected int headerWidth() {
- return this.headerArea == null ? 0 : this.headerArea.preferredSize().width;
- }
-
- protected void reshapeViewport(int var1, int var2, int var3, int var4) {
- if (this.headerArea != null) {
- var2 -= ((JCComponent)this.comp).highlight;
- }
-
- super.reshapeViewport(var1, var2, var3, var4);
- }
-
- protected int preferredHeight() {
- int var1 = super.preferredHeight();
- if (this.headerArea != null) {
- var1 += this.headerArea.preferredSize().height;
- }
-
- return var1;
- }
-
- protected int getViewportWidth() {
- int var1 = super.getViewportWidth();
- if (this.headerArea != null) {
- var1 = Math.max(var1, this.headerArea.preferredSize().width);
- }
-
- return var1;
- }
-
- public synchronized void setFont(Font var1) {
- if (((Component)this).getFont() == null || !((Component)this).getFont().equals(var1)) {
- super.setFont(var1);
- if (((Component)this).getPeer() != null) {
- ((Component)this.comp).setFont(var1);
- if (this.header != null) {
- this.header.setFont(var1);
- }
-
- ((JCScrolledWindow)this).layout();
- }
- }
- }
-
- public boolean getColumnLabelSort() {
- return this.column_label_sort;
- }
-
- public void setColumnLabelSort(boolean var1) {
- this.column_label_sort = var1;
- }
-
- public void setColumnLabelSortMethod(JCSortInterface var1) {
- this.sort_method = var1;
- }
-
- public JCSortInterface getColumnLabelSortMethod() {
- return this.sort_method;
- }
-
- public void sortByColumn(int var1, JCSortInterface var2) {
- }
-
- public void sortByColumn(int var1, JCSortInterface var2, int var3) {
- }
-
- public void addNotify() {
- super.addNotify();
- if (this.headerArea != null) {
- ((JCScrolledWindow)this).addInternal(this.headerArea);
- this.header.setMultiColumnComponent((JCMultiColumnInterface)super.viewport);
- }
-
- }
-
- protected void scrollHorizontal(JCAdjustmentEvent var1, int var2) {
- if (this.headerArea != null) {
- this.headerArea.scrollHorizontal(var2);
- }
-
- super.scrollHorizontal(var1, var2);
- }
-
- public void actionPerformed(JCActionEvent var1) {
- if (this.header != null && this.getColumnLabelSort()) {
- int var2 = 0;
- Component var3 = (Component)((EventObject)var1).getSource();
- int var4 = this.header.getComponent(var3);
- if (var4 >= 0) {
- if (var3 instanceof HeaderButton) {
- var2 = ((HeaderButton)var3).direction;
- }
-
- this.sortByColumn(var4, this.sort_method, var2);
- if (var3 instanceof HeaderButton) {
- ((HeaderButton)var3).direction = var2 == 0 ? 1 : 0;
- }
-
- }
- }
- }
-
- public int[] getColumnWidths() {
- return this.comp.getColumnWidths();
- }
-
- public void setColumnWidths(int[] var1) {
- if (this.header != null) {
- this.header.setColumnWidths(var1);
- }
-
- this.comp.setColumnWidths(var1);
- }
-
- public int getColumnWidth(int var1) {
- return this.comp.getColumnWidth(var1);
- }
-
- public void setColumnWidth(int var1, int var2) {
- if (var2 < 0 && var2 != -998) {
- throw new IllegalArgumentException("invalid column width: " + var2);
- } else {
- if (this.header != null) {
- this.header.setColumnWidth(var1, var2);
- }
-
- this.comp.setColumnWidth(var1, var2);
- }
- }
-
- public int getNumColumns() {
- return this.comp.getNumColumns();
- }
-
- public void setNumColumns(int var1) {
- if (var1 < 0 && var1 != -998) {
- throw new IllegalArgumentException("invalid NumColumns: " + var1);
- } else {
- this.comp.setNumColumns(var1);
- if (this.header != null) {
- this.header.setNumColumns(var1);
- }
-
- ((JCScrolledWindow)this).layout();
- }
- }
-
- public int[] getColumnAlignments() {
- return this.comp.getColumnAlignments();
- }
-
- public int getColumnAlignment(int var1) {
- return this.comp.getColumnAlignment(var1);
- }
-
- public void setColumnAlignment(int var1, int var2) {
- JCUtilConverter.checkEnum(var2, "alignment", LabelConverter.alignment_values);
- this.comp.setColumnAlignment(var1, var2);
- }
-
- public void setColumnLabelAlignment(int var1, int var2) {
- JCUtilConverter.checkEnum(var2, "alignment", LabelConverter.alignment_values);
- if (this.header != null) {
- this.header.setColumnAlignment(var1, var2);
- }
-
- }
-
- public void setColumnAlignments(int[] var1) {
- this.comp.setColumnAlignments(var1);
- }
-
- public int getColumnPosition(int var1) {
- return this.comp.getColumnPosition(var1);
- }
-
- public int getColumnLeftMargin(int var1) {
- return this.comp.getColumnLeftMargin(var1);
- }
-
- public void setColumnLeftMargin(int var1, int var2) {
- this.comp.setColumnLeftMargin(var1, var2);
- if (this.header != null) {
- this.header.setColumnLeftMargin(var1, var2);
- }
-
- ((JCScrolledWindow)this).layout();
- }
-
- public int getColumnRightMargin(int var1) {
- return this.comp.getColumnRightMargin(var1);
- }
-
- public void setColumnRightMargin(int var1, int var2) {
- this.comp.setColumnRightMargin(var1, var2);
- if (this.header != null) {
- this.header.setColumnRightMargin(var1, var2);
- }
-
- ((JCScrolledWindow)this).layout();
- }
-
- public int calcWidth(int var1) {
- return this.comp.calcWidth(var1);
- }
-
- public JCMultiColumnData getMultiColumnData() {
- return this.comp.getMultiColumnData();
- }
- }
-