1 19 24 package org.openide.explorer.propertysheet; 25 26 import java.util.Enumeration ; 27 28 import javax.swing.*; 29 import javax.swing.event.*; 30 import javax.swing.table.*; 31 32 33 39 final class SheetColumnModel implements TableColumnModel { 40 static final Object NAMES_IDENTIFIER = "names"; static final Object VALUES_IDENTIFIER = "values"; TableColumn namesColumn; 43 TableColumn valuesColumn; 44 ListSelectionModel lsm = new DefaultListSelectionModel(); 45 46 47 public SheetColumnModel() { 48 namesColumn = new TableColumn(0); 49 namesColumn.setIdentifier(NAMES_IDENTIFIER); 50 valuesColumn = new TableColumn(1); 51 valuesColumn.setIdentifier(VALUES_IDENTIFIER); 52 namesColumn.setMinWidth(60); 53 valuesColumn.setMinWidth(30); 54 } 55 56 public void addColumn(TableColumn aColumn) { 57 throw new UnsupportedOperationException ("Adding columns not supported"); } 59 60 public void addColumnModelListener(TableColumnModelListener x) { 61 } 63 64 public TableColumn getColumn(int columnIndex) { 65 switch (columnIndex) { 66 case 0: 67 return namesColumn; 68 69 case 1: 70 return valuesColumn; 71 } 72 73 throw new IllegalArgumentException ("Property sheet only has 2 columns - " + Integer.toString(columnIndex)); } 75 76 public int getColumnCount() { 77 return 2; 78 } 79 80 public int getColumnIndex(Object columnIdentifier) { 81 if (columnIdentifier instanceof String ) { 82 if (columnIdentifier.equals(NAMES_IDENTIFIER)) { 83 return 0; 84 } 85 86 if (columnIdentifier.equals(VALUES_IDENTIFIER)) { 87 return 1; 88 } 89 } 90 91 throw new IllegalArgumentException ("Illegal value: " + columnIdentifier); 92 } 93 94 public int getColumnIndexAtX(int xPosition) { 95 int width0 = namesColumn.getWidth(); 96 97 if (xPosition < width0) { 98 return 0; 99 } 100 101 if (xPosition < (width0 + valuesColumn.getWidth())) { 102 return 1; 103 } 104 105 return -1; 106 } 107 108 public int getColumnMargin() { 109 return 1; } 111 112 public boolean getColumnSelectionAllowed() { 113 return false; 114 } 115 116 public Enumeration <TableColumn> getColumns() { 117 return new Enumeration <TableColumn>() { 118 private boolean done = false; 119 private boolean doneOne = false; 120 121 public boolean hasMoreElements() { 122 return !done; 123 } 124 125 public TableColumn nextElement() { 126 if (done) { 127 return null; 128 } 129 130 if (doneOne) { 131 done = true; 132 133 return valuesColumn; 134 } 135 136 doneOne = true; 137 138 return namesColumn; 139 } 140 }; 141 } 142 143 public int getSelectedColumnCount() { 144 return 0; 145 } 146 147 public int[] getSelectedColumns() { 148 return new int[] { }; 149 } 150 151 public ListSelectionModel getSelectionModel() { 152 return lsm; 153 } 154 155 public int getTotalColumnWidth() { 156 return namesColumn.getWidth() + valuesColumn.getWidth(); 157 } 158 159 public void moveColumn(int columnIndex, int newIndex) { 160 } 162 163 public void removeColumn(TableColumn column) { 164 throw new UnsupportedOperationException ("Deleting columns not supported"); } 166 167 public void removeColumnModelListener(TableColumnModelListener x) { 168 } 170 171 public void setColumnMargin(int newMargin) { 172 } 174 175 public void setColumnSelectionAllowed(boolean flag) { 176 } 178 179 public void setSelectionModel(ListSelectionModel newModel) { 180 } 182 } 183 | Popular Tags |