コード例 #1
0
 public void actionPerformed(ActionEvent e) {
   if (e.getActionCommand() == "New") {
     //            Unit a = UnitManager.getInstance().GenerateUnit((Player)null, "Fixme!!!",
     // (MechUnitParameters)null, Rating.GREEN);
     //            UnitManager.RequestEdit(a);
     //            SwingUtilities.invokeLater(new
     // factorymanager.database.data.managers.UnitEditRequestor(a));
   }
   if (e.getActionCommand() == "Remove") {
     Unit a = m_UnitListPanel.GetSelectedUnit();
     if (a != null) {
       int Result =
           JOptionPane.showInternalConfirmDialog(
               this,
               "Are you sure you wish to delete this Unit?",
               "Remove Unit",
               JOptionPane.YES_NO_OPTION,
               JOptionPane.WARNING_MESSAGE);
       if (Result == JOptionPane.YES_OPTION) {
         UnitManager.getInstance().deleteUnit(a.getName());
       }
     }
   }
   if (e.getActionCommand() == "Edit") {
     Unit a = m_UnitListPanel.GetSelectedUnit();
     if (a != null) {
       //                UnitManager.RequestEdit(a);
     }
   }
 }
コード例 #2
0
 private void eventoKeyPressControles(java.awt.event.KeyEvent evt) {
   if (evt.getKeyChar() == java.awt.event.KeyEvent.VK_ESCAPE) cancelar();
   if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_F5) {
     try {
       int opcion =
           javax.swing.JOptionPane.showInternalConfirmDialog(
               rootPane, "Si actualiza el formulario, los datos se perderan..", title, 0);
       if (opcion == 0) {
         llenarCombo();
       }
     } catch (java.rmi.RemoteException re) {
       javax.swing.JOptionPane.showMessageDialog(
           null, "Se perdio la conexion. Contacte con el administrador...");
     } catch (javax.ejb.EJBException eje) {
       javax.swing.JOptionPane.showMessageDialog(
           null, "Se perdio la conexion. Contacte con el administrador...");
     } catch (javax.naming.NameNotFoundException nnfe) {
       javax.swing.JOptionPane.showMessageDialog(
           null, "El programa servidor no esta listo. Intente mas tarde...");
     } catch (Exception e) {
       shrimp.helper.Excepciones.guardarExcepcionesAC(
           e, getClass().getName(), mDIShrimp.getSisInfoTO());
     }
   }
 }
コード例 #3
0
ファイル: GamePanel.java プロジェクト: pasqualearieta/Pool
 @Override
 public void mouseReleased(MouseEvent arg0) {
   if (!matchManager
       .getPhysicsBallMovement()
       .checkThatThereAreNoOverlappingBalls(matchManager.getBalls())) {
     matchManager.setWhiteBallReposition();
     matchManager.setRepositionWithMouse(false);
   } else {
     JOptionPane.showInternalConfirmDialog(
         GamePanel.this,
         "You can not reposition WhiteBall over other Ball",
         "",
         JOptionPane.CLOSED_OPTION);
     Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
     repaint();
   }
 }
コード例 #4
0
 protected void doYouWantToSave() throws Exception {
   boolean refresh = false;
   if (((ContextTableModel) bargeTariffTable.getModel()).isContentUnsaved()) {
     MainFrame.setDefaultCursor();
     int answer =
         javax.swing.JOptionPane.showInternalConfirmDialog(
             MainFrame.getInstance().getContentPane(),
             "Do you want to close the window without saving the changes?",
             "",
             JOptionPane.YES_OPTION,
             JOptionPane.QUESTION_MESSAGE);
     if (answer == JOptionPane.NO_OPTION) {
       return;
     } else if (answer == JOptionPane.OK_OPTION) {
       refresh = true;
     }
   }
   super.doYouWantToSave();
   if (refresh) ((BargeTariffValue) getModel()).fillBargeTariffLines(null);
 }
コード例 #5
0
  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == open) {
      if (isInProgress()) {
        systemIsBusy();
        return;
      }

      checkRunned();

      chooser = new JFileChooser();
      chooser.setAcceptAllFileFilterUsed(false);
      chooser.setFileFilter(new InputFileFilter(false));
      if (loadedFile != null) chooser.setSelectedFile(loadedFile);
      int returnValue = chooser.showOpenDialog(this);
      if (returnValue == JFileChooser.APPROVE_OPTION) {
        boolean approved =
            ((InputFileFilter) chooser.getFileFilter()).isFileApproved(chooser.getSelectedFile());
        if (approved) {
          startProgress();
          new MultiThread(
                  new Runnable() {
                    public void run() {
                      try {

                        loadedFile = chooser.getSelectedFile();
                        FileInputStream fis = new FileInputStream(loadedFile);
                        InputParser ip = new InputParser(fis);
                        if (ip.parseInput()) {
                          field = new Field(new ArrayList<Point>(Arrays.asList(ip.getPoints())));
                          minAlgo.setText(String.valueOf(ip.minimumClusters));
                          maxAlgo.setText(String.valueOf(ip.maximumClusters));
                        }
                      } catch (FileNotFoundException e1) {
                      }
                      contentpanel.center();
                      stopProgress();
                    }
                  })
              .start();
        }
      }
    } else if (e.getSource() == center) {
      if (isInProgress()) {
        systemIsBusy();
        return;
      }

      startProgress();
      new MultiThread(
              new Runnable() {
                public void run() {
                  contentpanel.removeMouseWheelListener(contentpanel);
                  contentpanel.center();
                  contentpanel.addMouseWheelListener(contentpanel);
                  stopProgressRepaint();
                }
              })
          .start();
    } else if (e.getSource() == save) {
      if (isInProgress()) {
        systemIsBusy();
        return;
      }

      checkRunned();

      chooser = new JFileChooser();
      chooser.setAcceptAllFileFilterUsed(false);
      chooser.setFileFilter(new InputFileFilter(true));
      if (loadedFile != null) chooser.setSelectedFile(loadedFile);
      int returnValue = chooser.showSaveDialog(this);
      if (returnValue == JFileChooser.APPROVE_OPTION) {
        boolean approved =
            ((InputFileFilter) chooser.getFileFilter()).isFileApproved(chooser.getSelectedFile());
        if (approved) {
          loadedFile = chooser.getSelectedFile();
          boolean halt = loadedFile.exists();
          if (halt) {
            int i =
                JOptionPane.showInternalConfirmDialog(
                    c,
                    "Are you sure you want to override this file?",
                    "Warning",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.WARNING_MESSAGE);
            if (i == JOptionPane.YES_OPTION) {
              halt = false;
            }
          }

          if (!halt) {
            try {
              PrintWriter pw = new PrintWriter(new FileWriter(loadedFile));
              pw.println("find " + field.getNumberOfClusters() + " clusters");
              pw.println(field.size() + " points");
              Object[] obj = field.toArray();
              for (int i = 0; i < obj.length; i++) {
                Point p = (Point) obj[i];
                pw.println(p.getX() + " " + p.getY());
              }
              pw.close();
            } catch (IOException e1) {
            }
          }
        }
      }
    } else if (e.getSource() == clear) {
      if (isInProgress()) {
        systemIsBusy();
        return;
      }

      int i =
          JOptionPane.showInternalConfirmDialog(
              c,
              "Are you sure you want to clear the field?",
              "Warning",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.WARNING_MESSAGE);

      checkRunned();
      if (i == JOptionPane.YES_OPTION) {
        field = new Field();
        updateContentPanel();
      }
    } else if (e.getSource() == circle) {
      contentpanel.setSelectionMode(ContentPanel.SELECT_CIRCLE);
    } else if (e.getSource() == square) {
      contentpanel.setSelectionMode(ContentPanel.SELECT_SQUARE);
    } else if (e.getSource() == addacluster) {
      if (isInProgress()) {
        systemIsBusy();
        return;
      }

      checkRunned();

      contentpanel.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
    } else if (e.getSource() == addnoise) {
      if (isInProgress()) {
        systemIsBusy();
        return;
      }

      checkRunned();
      final String s =
          JOptionPane.showInternalInputDialog(
              c, "How many points?", "Add noise", JOptionPane.QUESTION_MESSAGE);

      startProgress();
      new MultiThread(
              new Runnable() {
                public void run() {
                  if (s != null) {
                    int number;
                    try {
                      number = Integer.parseInt(s);
                    } catch (Exception ex) {
                      number = 0;
                    }

                    int tillX = 1000000000;
                    int tillY = 1000000000;
                    int addX = 0;
                    int addY = 0;
                    if (inRectangle.isSelected()) {
                      Rectangle r = field.getBoundingRectangle();
                      if (!(r.x1 == 0 && r.y1 == 0 && r.x2 == 0 && r.y2 == 0)) {
                        tillX = r.x2 - r.x1;
                        addX = r.x1;
                        tillY = r.y2 - r.y1;
                        addY = r.y1;
                      } else {
                        tillX = 500000000;
                        tillY = 500000000;
                      }
                    }

                    for (int i = 0; i < number; i++) {
                      int x = random.nextInt(tillX);
                      x += addX;
                      int y;

                      boolean busy = true;
                      while (busy) {
                        y = random.nextInt(tillY);
                        y += addY;
                        boolean inside = false;
                        Object[] array = field.toArray();
                        for (int j = 0; j < field.size(); j++) {
                          if (((Point) array[j]).compareTo(x, y)) {
                            inside = true;
                            break;
                          }
                        }

                        if (!inside) {
                          field.add(new Point(x, y));
                          busy = false;
                        }
                      }
                    }
                  }
                  stopProgress();
                }
              })
          .start();
    } else if (e.getSource() == run) {
      if (isInProgress()) {
        systemIsBusy();
        return;
      }

      checkRunned();

      startProgress();

      runAlgo();
    }
  }