1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
| public class SearchContainer extends UnderFrame implements ActionListener, DocumentListener, FocusListener{
private String[] labelsButtons = {"COMPLET >>> PARTIEL", "PARTIEL >>> COMPLET", "SUPPRIMER LE CONTENEUR", "SORTIR DE L'EMPLACEMENT", "VOIR", "FERMER"},
titles;
private String from;
private javarch.components.Container container;
private Object [][] allOfContainer;
private boolean yes = true;
public SearchContainer (Javarch javarch, String from) {
super(790, 650, "Recherche de conteneurs", javarch);
this.setJavarch(javarch);
this.from = from;
if (from.equals("search")) {
String [] tmp = {"NUMERO DE CONTENEUR","EMPLACEMENT", "ETAT"};
titles = tmp;
}
else if (from.equals("location")) {
String[] tmp = {"NUMERO CONTENEUR", "NOMBRE PRESENTS","EMPLACEMENT"};
titles = tmp;
setTitle("Recherche de conteneurs");
}
else if (from.equals("storing")) {
String[] tmp = {"NUMERO DE CONTENEUR","EMPLACEMENT", "NOMBRE PRESENTS","ETAT" };
titles = tmp;
this.setTitle("Recherche de conteneur");
}
EngineMethods.centerFrame(this);//to center the frame
itemsContructor(javarch);//create items
initItems();
addContain();//add items construted on a panel
this.getContentPane().add(getMainPanel());
this.setVisible(yes);
}
public void itemsContructor(Javarch javarch) {
final int NBBOX = 6,NBHORIZ = 5, NBFIELDS = 3, NBBUTTONS = 6, NBTABLES =1, NBCKITEM = titles.length-1;
boxes = new Box[NBBOX];
fields = new Field[NBFIELDS];
buttons = new Button[NBBUTTONS];
tables = new Table[NBTABLES];
scrolls = new JScrollPane[NBTABLES];
isSelectedCollumns = new boolean[NBCKITEM+1];
tableModels = new TableModel[NBTABLES];
sorter = new TableRowSorter[NBTABLES];
for (int i=0; i<NBBOX; i++) {
if (i<NBHORIZ) boxes[i] = Box.createHorizontalBox();
else boxes[i] = Box.createVerticalBox();
}
for (int i=0; i<NBFIELDS; i++) {
if(i==0)fields[i]=new Field(5);
if(i==1)fields[i]=new Field(6);
if(i==2)fields[i]=new Field(20);
if(i==3)fields[i]=new Field(6);
if (i>0) {
fields[i].setDisabled();
}
else {
fields[i].getDocument().addDocumentListener(this);
fields[i].addFocusListener(this);
}
}
for (int i=0; i<NBBUTTONS; i++) {
if (from.equals("storing")) {
if (i<4) {
buttons = new Button[10];
// buttons[i].setVisible(false);
}
else if (i==4) {
buttons = new Button[10];
buttons[0].setText("SELECTIONNER");
}
}
String type = "";
switch (i) {
case 0 : type = "completPartiel";break;
case 1 : type = "partielComplet";break;
case 2 : type = "deleteContainer";break;
case 3 : type = "outOfLocation";break;
case 4 : type = "view";break;
case 5 : type = "close";break;
}
buttons[i] = new Button(labelsButtons[i], type);
buttons[i].addActionListener(this);
}
try {
tables[0] = createTable();
scrolls[0] = new JScrollPane(tables[0]);
}
catch (SQLException ex) {JOptionPane.showMessageDialog(this, "Impossible de créer la table.\n"+ex.toString(), "Erreur", JOptionPane.ERROR_MESSAGE);}
for(int i=0; i<isSelectedCollumns.length; i++) {
isSelectedCollumns[i]=true;
}
isSelectedRows = new boolean[listForTable.length];
for (int i=0; i<isSelectedRows.length; i++) {
isSelectedRows[i] = true;
}
sorter[0] = new TableRowSorter<TableModel>(tableModels[0]);
MouseAdapter mouseAdapter = new MouseAdapter() {
public void mouseClicked(MouseEvent m) {
if (m.getClickCount() == 2) {
actionPerformed(new ActionEvent(buttons[4], 0, ""));
}
if (m.getButton()==MouseEvent.BUTTON3) {
int indRow = tables[0].rowAtPoint(m.getPoint());
int indCol = tables[0].columnAtPoint(m.getPoint());
tables[0].changeSelection(indRow, indCol, false, false);
displayPopup(m);
}
}
};
tables[0].addMouseListener(mouseAdapter);
}
public void addContain() {
boxes[0].add(new JLabel("RECHERCHE D'UN CONTENEUR"));
boxes[0].add(Box.createHorizontalStrut(10));
boxes[0].add(fields[0]);
boxes[0].add(Box.createHorizontalStrut(320));
boxes[0].add(buttons[0]);
boxes[1].add(Box.createHorizontalGlue());
boxes[1].add(buttons[1]);
boxes[2].add(scrolls[0]);
if (!(from.equals("location")||from.equals("storing"))){
boxes[3].add(buttons[2]);
boxes[3].add(Box.createHorizontalStrut(10));
boxes[3].add(buttons[3]);
boxes[3].add(Box.createHorizontalStrut(10));
}
boxes[3].add(Box.createHorizontalStrut(10));
boxes[3].add(buttons[4]);
boxes[3].add(Box.createHorizontalStrut(50));
boxes[3].add(buttons[5]);
boxes[4].add(new JLabel("CODE CLIENT"));
boxes[4].add(Box.createHorizontalStrut(10));
boxes[4].add(fields[1]);
boxes[4].add(Box.createHorizontalStrut(100));
boxes[4].add(new JLabel("NOM DE LA SOCIETE"));
boxes[4].add(Box.createHorizontalStrut(10));
boxes[4].add(fields[2]);
boxes[4].add(Box.createHorizontalStrut(100));
boxes[5].add(boxes[0]);
boxes[5].add(Box.createVerticalStrut(20));
boxes[5].add(boxes[1]);
boxes[5].add(Box.createVerticalStrut(20));
boxes[5].add(boxes[2]);
boxes[5].add(Box.createVerticalStrut(20));
boxes[5].add(boxes[3]);
boxes[5].add(Box.createVerticalStrut(20));
boxes[5].add(boxes[4]);
getMainPanel().add(boxes[5]);
}
public void initItems() {
fields[1].setText(getJavarch().getCurrentCustomer().getIdentifiantCustomer());
fields[2].setText(getJavarch().getCurrentCustomer().getNomSociete());
if (from.equals("storing")) {
buttons[4].setText("SELECTIONNER LE CONTENEUR");
}
}
public Table createTable() throws SQLException {
Table ret = new Table();
String querry;
if (from.equals("search")) {
querry = "SELECT client, identifiantConteneur, emplacement, nombrePresent, etat FROM Conteneur WHERE client ='"+getJavarch().getCurrentCustomer().getIdentifiantCustomer()+"' AND etat <> 'ABANDONNE';";
ResultSet res = getJavarch().getDatabase().getResult(querry);
allOfContainer = EngineMethods.getObjects(res,5);
int[] collumns = {1,2,4};
listForTable = EngineMethods.keepUsedOnly(allOfContainer, collumns);
}
else if (from.equals("location")) {
querry = "SELECT DISTINCT identifiantConteneur, E.etat, E.nombrePresent, capacite, emplacement FROM Conteneur C , Emplacement E WHERE emplacement = identifiantEmplacement AND client = '"+getJavarch().getCurrentCustomer().getIdentifiantCustomer()+"' AND C.etat <> 'ABANDONNE';";
System.out.println(querry);
ResultSet res = getJavarch().getDatabase().getResult(querry);
allOfContainer = EngineMethods.getObjects(res,5);
int[] collumns = {0,2,4};
listForTable = EngineMethods.keepUsedOnly(allOfContainer, collumns);
}
else if (from.equals("storing")) {
querry = "SELECT client, identifiantConteneur, emplacement, nombrePresent, etat FROM Conteneur WHERE client ='"+getJavarch().getCurrentCustomer().getIdentifiantCustomer()+"' AND etat <> 'COMPLET' AND etat <> 'ABANDONNE';";
ResultSet res = getJavarch().getDatabase().getResult(querry);
allOfContainer = EngineMethods.getObjects(res,5);
int[] collumns = {1,2,3,4};
querry = "SELECT identifiantConteneur, COUNT(*) FROM Conteneur WHERE client = '"+getJavarch().getCurrentCustomer().getIdentifiantCustomer()+"'";
res = getJavarch().getDatabase().getResult(querry);
res.next();
int nbContainer = res.getInt(1);
if (nbContainer==0) {
JOptionPane.showMessageDialog(this, "Ce client n'a aucun conteneur à ce jour.", "Mise en emplacement", JOptionPane.INFORMATION_MESSAGE);
}
else {
try {allOfContainer[0][0].toString();}
catch(ArrayIndexOutOfBoundsException ex) {
int choice = JOptionPane.showConfirmDialog(this, "Tous les conteneurs de ce client sont complets.Pour définir un conteneur partiel :\n - Cliquez sur le menu recherche\n - Sélectionnez le conteneur réellement partiel\n - Cliquez sur le boutton \"COMPLET >> PARTIEL\"\n\nDésirez-ouvrir cette fenêtre maintenant ?", "Mise en conteneur", JOptionPane.YES_NO_OPTION);
if (choice==JOptionPane.YES_OPTION) {
new SearchContainer (getJavarch(), "search");
yes=false;
}
}
}
listForTable = EngineMethods.keepUsedOnly(allOfContainer, collumns);
}
tableModels[0] = new TableModel(listForTable, titles);
ret.setModel(new TableModel(listForTable, titles));
ret.setPreferredScrollableViewportSize(new Dimension (0,400));
return ret;
}
public void displayPopup(MouseEvent me) {
final int NBITEMS = 5;
JPopupMenu popup = new JPopupMenu();
JMenu menu = new JMenu("Sélectionner les colonnes");
options = EngineMethods.cuttingString(titles, 0);
checkMenuList = new JCheckBoxMenuItem[options.length];
for(int i=0; i<checkMenuList.length; i++) {
checkMenuList[i] = new JCheckBoxMenuItem(options[i]);
checkMenuList[i].addActionListener(this);
checkMenuList[i].setSelected(isSelectedCollumns[i+1]);
menu.add(checkMenuList[i]);
}
String [] listItemTitles = {"Copier la ligne", "Tout copier", "Exporter la table vers Excel", "Exporter la table vers Word", "Imprimer"};
listItems = new JMenuItem[NBITEMS];
popup.add(menu);
for (int i=0; i<listItems.length; i++) {
listItems[i] = new JMenuItem(listItemTitles[i]);
listItems[i].addActionListener(this);
popup.add(listItems[i]);
}
popup.show(tables[0], me.getX(), me.getY());
}
private void getSelection() throws ArrayIndexOutOfBoundsException {
String[] attributes = new String[allOfContainer[0].length];
for (int i=0; i<allOfContainer.length; i++) {
if (allOfContainer[i][0] == tables[0].getValueAt(tables[0].getSelectedRow(), 0)) {
for (int j=0; j<allOfContainer[0].length; j++) {
attributes [j] = allOfContainer[i][j].toString();
}
}
}
if (attributes[0].equals("")) throw new ArrayIndexOutOfBoundsException();//no container
container = new javarch.components.Container(attributes);
getJavarch().setCurrentContainer(container);
this.dispose();
}
private void updateContain(String state) throws SQLException, ArrayIndexOutOfBoundsException{
ArrayList<Integer> idContainer = EngineMethods.getSelectedRowNumber(listForTable, EngineMethods.getSelectedKeysTable(tables[0]));
int selectedRow = tables[0].getSelectedRow();
if (idContainer.size()<1) throw new ArrayIndexOutOfBoundsException();
getJavarch().getDatabase().update("START TRANSACTION;");
for (int i=0; i<idContainer.size(); i++) {
String querry = "UPDATE Conteneur SET etat = '"+state+"' WHERE identifiantConteneur = '"+listForTable[idContainer.get(i)][0]+"' AND client = '"+getJavarch().getCurrentCustomer().getIdentifiantCustomer()+"';";
getJavarch().getDatabase().update(querry);
if (from.equals("search")) listForTable[idContainer.get(i)][2] = state;
else if (from.equals("location")) listForTable[idContainer.get(i)][2] = state;
else if (from.equals("storing")) listForTable[idContainer.get(i)][3] = state;
}
getJavarch().getDatabase().update("COMMIT;");
tables[0].setModel(new TableModel(EngineMethods.setData(isSelectedCollumns, isSelectedRows, listForTable), EngineMethods.setTitle(isSelectedCollumns, titles)));
tables[0].setRowSelectionInterval(selectedRow, selectedRow);
}
private void outLocation() throws SQLException, ArrayIndexOutOfBoundsException{
int row = tables[0].getSelectedRow();
ArrayList<Integer> idContainer = EngineMethods.getSelectedRowNumber(listForTable, EngineMethods.getSelectedKeysTable(tables[0]));
if (idContainer.size()<1) throw new ArrayIndexOutOfBoundsException();
if (from.equals("search")||(from.equals(""))) {
getJavarch().getDatabase().update("START TRANSACTION;");
for (int i=0; i<idContainer.size(); i++) {
String querry = "UPDATE Conteneur SET emplacement = NULL WHERE identifiantConteneur = '"+listForTable[idContainer.get(i)][0]+"' AND client = '"+getJavarch().getCurrentCustomer().getIdentifiantCustomer()+"';";
getJavarch().getDatabase().update(querry);
listForTable[idContainer.get(i)][1] = "";
}
getJavarch().getDatabase().update("COMMIT;");
}
else if(from.equals("location")) {
getJavarch().getDatabase().update("START TRANSACTION;");
for (int i=0; i<idContainer.size(); i++) {
String querry = "UPDATE Conteneur SET emplacement = NULL WHERE identifiantConteneur = '"+listForTable[idContainer.get(i)][0]+"' AND client = '"+getJavarch().getCurrentCustomer().getIdentifiantCustomer()+"';";
getJavarch().getDatabase().update(querry);
}
getJavarch().getDatabase().update("COMMIT;");
for (int i=0; i<idContainer.size(); i++) {
isSelectedRows[idContainer.get(i)] = false;
}
}
tables[0].setModel(new TableModel(EngineMethods.setData(isSelectedCollumns, isSelectedRows, listForTable), EngineMethods.setTitle(isSelectedCollumns, titles)));
tables[0].setRowSelectionInterval(row, row);
}
private void deleteContainer() throws SQLException, ArrayIndexOutOfBoundsException {
int row = tables[0].getSelectedRow();
int choice = JOptionPane.showConfirmDialog(this, "Le fait de supprimer un conteneur va considérer l'ensemble des boîtes qu'il contient comme étant nouvelle.\nEtes-vous sûr de vouloir supprimer le conteneur ?", "Demande de confirmation", JOptionPane.YES_NO_OPTION);
if (choice==JOptionPane.YES_OPTION) {
ArrayList<Integer> idContainer = EngineMethods.getSelectedRowNumber(listForTable, EngineMethods.getSelectedKeysTable(tables[0]));
if (idContainer.size()<1) throw new ArrayIndexOutOfBoundsException();
getJavarch().getDatabase().update("START TRANSACTION;");
for (int i=0; i<idContainer.size(); i++) {
String querry = "UPDATE Boite SET etat = 'NOUVELLE' WHERE conteneur = '"+listForTable[idContainer.get(i)][0]+"' AND client = '"+getJavarch().getCurrentCustomer().getIdentifiantCustomer()+"';";
getJavarch().getDatabase().update(querry);
querry = "UPDATE Conteneur SET etat = 'ABANDONNE', emplacement = NULL WHERE identifiantConteneur = '"+listForTable[idContainer.get(i)][0]+"' AND client = '"+getJavarch().getCurrentCustomer().getIdentifiantCustomer()+"';";
getJavarch().getDatabase().update(querry);
isSelectedRows[idContainer.get(i)] = false;//to don't display the selected row
}
getJavarch().getDatabase().update("COMMIT;");
tables[0].setModel(new TableModel(EngineMethods.setData(isSelectedCollumns, isSelectedRows, listForTable), EngineMethods.setTitle(isSelectedCollumns, titles)));
try {
tables[0].setRowSelectionInterval(row, row);
}
catch (IllegalArgumentException e) {
try {
tables[0].setRowSelectionInterval(row-1, row-1);
}
catch (IllegalArgumentException ex) {
JOptionPane.showMessageDialog(this, "Tous les conteneurs du client ont été supprimés. La liste est donc vide.\nLa fenêtre va se fermer", "Le client n'a plus de conteneur", JOptionPane.INFORMATION_MESSAGE);
this.dispose();
}
}
}
}
private String selectContainer() throws ArrayIndexOutOfBoundsException{
String ret = "";
String [] attributes = new String[allOfContainer[0].length];
for (int i=0; i<listForTable.length; i++) {
if (listForTable[i][0] == tables[0].getValueAt(tables[0].getSelectedRow(), 0)) {
if (from.equals("")){
for (int j=0; j<listForTable[0].length; j++) {
attributes [j] = listForTable[i][j].toString();
}
ret = listForTable[i][1].toString();
}
else if (from.equals("location")) {
System.out.println(i);
attributes [0] = allOfContainer[i][0].toString();
attributes [1] = getJavarch().getCurrentCustomer().getIdentifiantCustomer();
attributes [2] = listForTable[i][2].toString();
attributes [3] = listForTable[i][1].toString();
attributes [4] = listForTable[i][0].toString();
}
else if (from.equals("storing")) {
attributes [0] = listForTable[i][0].toString();//id
attributes [1] = getJavarch().getCurrentCustomer().getIdentifiantCustomer();//client
attributes [2] = listForTable[i][3].toString();//emplacement
attributes [3] = listForTable[i][2].toString();//nbpres
attributes [4] = listForTable[i][1].toString();//etat
}
else if (from.equals("search")) {
attributes [0] = allOfContainer[i][1].toString();//id
attributes [1] = getJavarch().getCurrentCustomer().getIdentifiantCustomer();//client
attributes [2] = allOfContainer[i][2].toString();//emplacement
attributes [3] = allOfContainer[i][3].toString();//nbpres
attributes [4] = allOfContainer[i][4].toString();//etat
}
}
}
getJavarch().setCurrentContainer(new javarch.components.Container(attributes));
return ret;
}
public void actionPerformed(ActionEvent e) {
for (int i=0; i<buttons.length; i++) {
if (e.getSource().equals(buttons[i])) {
switch (i) {
case (0) :
try {updateContain("PARTIEL");}
catch (SQLException ex) {JOptionPane.showMessageDialog(this, "Impossible de définir le conteneur comme étant partiel.\n"+ex.getMessage(), "Erreur", JOptionPane.ERROR_MESSAGE);}
catch (ArrayIndexOutOfBoundsException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(this, "Veuillez sélectionner un conteneur", "Pas de sélection", JOptionPane.WARNING_MESSAGE);}
break;
case (1) :
try {updateContain("COMPLET");}
catch (SQLException ex) {JOptionPane.showMessageDialog(this, "impossible de définir le conteneur comme étant complet.\n"+ex.getMessage(), "Erreur", JOptionPane.ERROR_MESSAGE);}
catch (ArrayIndexOutOfBoundsException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(this, "Veuillez sélectionner un conteneur", "Pas de sélection", JOptionPane.WARNING_MESSAGE);}
break;
case (2) :
try {deleteContainer();}
catch (SQLException ex) {JOptionPane.showMessageDialog(this, "Impossible de supprimer le conteneur dans la base de données.\n"+ex.getMessage(), "Erreur", JOptionPane.ERROR_MESSAGE);}
catch (ArrayIndexOutOfBoundsException ex) {JOptionPane.showMessageDialog(this, "Veuillez sélectionner un conteneur", "Pas de sélection", JOptionPane.WARNING_MESSAGE);}
break;
case (3) :
try {outLocation();}
catch (SQLException ex) {JOptionPane.showMessageDialog(this, "Impossible de sortir le conteneur de son emplacement.\n"+ex.getMessage(), "Erreur", JOptionPane.ERROR_MESSAGE);}
catch (ArrayIndexOutOfBoundsException ex) {JOptionPane.showMessageDialog(this, "Veuillez sélectionner un conteneur", "Pas de sélection", JOptionPane.WARNING_MESSAGE);}
break;
case (4) :
selectContainer();
if(from.equals("location")||from.equals("search")){
try {
// getJavarch().setCurrentLocation(selectLocation());
new ViewContainer(getJavarch(), "search");
this.dispose();
}
catch (ArrayIndexOutOfBoundsException ex) {JOptionPane.showMessageDialog(this, "Veuillez sélectionner un emplacement", "Pas de sélection", JOptionPane.WARNING_MESSAGE);}
}
else if (from.equals("storing")){
try {
//String customer = selectContainer();
new ContaineringBySelection(getJavarch());
this.dispose();
}
catch (ArrayIndexOutOfBoundsException ex) {JOptionPane.showMessageDialog(this, "Veuillez sélectionner un conteneur", "Pas de sélection", JOptionPane.WARNING_MESSAGE);}
}
break;
case (5) :this.dispose();
break;
}
}
}
try {
for(int i=0; i<listItems.length; i++) {
if (e.getSource().equals(listItems[i])) {
switch(i) {
case(0):
String currentRow = EngineMethods.getSelectedRowString(tables[0].getSelectedRow(), listForTable);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(currentRow), null);
break;
case(1):
String allRows = EngineMethods.getAllRowsString(tables[0].getRowCount(), listForTable);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(allRows), null);
break;
case(2):
try {new XLSGenerator();}
catch (FileNotFoundException ex) {}
catch (IOException ex) {}
break;
case(3):
try {new DOCGenerator();}
catch (FileNotFoundException ex) {}
catch (IOException ex) {}
break;
case(4): EngineMethods.Print();
break;
}
}
}
for(int i=0; i<checkMenuList.length; i++) {
if(e.getSource().equals(checkMenuList[i])){
EngineMethods.setIsSelected(isSelectedCollumns, !isSelectedCollumns[i+1], i+1);
tables[0].setModel(new TableModel(EngineMethods.setDataByCollumn(isSelectedCollumns, listForTable), EngineMethods.setTitle(isSelectedCollumns, titles)));
tables[0].clearSelection();
}
}
}
catch (NullPointerException ex) {}
}
public void insertUpdate(DocumentEvent e) {
if (e.getDocument().equals(fields[0].getDocument())) {
try {
sorter[0].setRowFilter(new RowFilter<TableModel,Integer>() {
public boolean include(Entry<? extends TableModel, ? extends Integer> entry) {
return (EngineMethods.isSmaller((String)entry.getValue(0), EngineMethods.completeNumber(Integer.parseInt(fields[0].getText()), 6)));
}
});
}
catch (NumberFormatException ex){}
if (fields[0].getText().equals("")) {
sorter[0].setRowFilter(new RowFilter<TableModel,Integer>() {
public boolean include(Entry<? extends TableModel, ? extends Integer> entry) {
return (EngineMethods.isSmaller((String)entry.getValue(0), EngineMethods.completeNumber(Integer.parseInt("0"), 6)));
}
});
}
}
}
public void removeUpdate(DocumentEvent e) {
insertUpdate(e);
}
public void changedUpdate(DocumentEvent e) {
}
public void focusGained(FocusEvent e) {
try {
getListSorter().add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
getSorter()[0].setSortKeys(getListSorter());
tables[0].setRowSorter(getSorter()[0]);
}
catch (IllegalArgumentException ex) {}
catch (NullPointerException ex) {}
catch (ArrayIndexOutOfBoundsException ex) {}
getListSorter().clear();
}
public void focusLost(FocusEvent e) {
}
private String selectLocation() throws ArrayIndexOutOfBoundsException{
String ret = "";
String [] attributes = new String[listForTable[0].length+1];
for (int i=0; i<listForTable.length; i++) {
if (listForTable[i][0] == tables[0].getValueAt(tables[0].getSelectedRow(), 0)) {
if (from.equals("")){
for (int j=0; j<listForTable[0].length; j++) {
attributes [j] = listForTable[i][j].toString();
}
ret = listForTable[i][1].toString();
attributes [0] = listForTable[i][0].toString();
attributes [1] = listForTable[i][3].toString();
attributes [2] = getJavarch().getCurrentLocation().getIdentifiantEmplacement();
attributes [3] = listForTable[i][1].toString();
attributes [4] = listForTable[i][2].toString();
ret = listForTable[i][3].toString();
}
}
}
getJavarch().setCurrentLocation(new javarch.components.Location(attributes));
return ret;
}
public void keyTyped(KeyEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void keyPressed(KeyEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void keyReleased(KeyEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
} |
Partager