public void saveDisplayObjectType() {
   DOTPoint newDOTPoint =
       (DOTPoint) _dotDefinitionDialogFrame.getScratchDisplayObjectType().getCopy(null);
   final String name = _dotDefinitionDialogFrame.getNameText();
   if ((name == null) || (name.length() == 0)) {
     JOptionPane.showMessageDialog(
         new JFrame(), "Bitte geben Sie einen Namen an!", "Fehler", JOptionPane.ERROR_MESSAGE);
     return;
   }
   if (!_dotDefinitionDialogFrame.isReviseOnly()) {
     if (_dotDefinitionDialogFrame.getDotManager().containsDisplayObjectType(name)) {
       JOptionPane.showMessageDialog(
           new JFrame(),
           "Ein Darstellungstyp mit diesem Namen existiert bereits!",
           "Fehler",
           JOptionPane.ERROR_MESSAGE);
       return;
     }
   }
   newDOTPoint.setName(name);
   newDOTPoint.setInfo(_dotDefinitionDialogFrame.getInfoText());
   final Object value = _translationFactorSpinner.getValue();
   if (value instanceof Number) {
     final Number number = (Number) value;
     newDOTPoint.setTranslationFactor(number.doubleValue());
   }
   newDOTPoint.setJoinByLine(_joinByLineCheckBox.isSelected());
   _dotDefinitionDialogFrame.getDotManager().saveDisplayObjectType(newDOTPoint);
   _dotDefinitionDialogFrame.setDisplayObjectType(newDOTPoint, true);
 }
Exemplo n.º 2
0
  public void JudgeWhoIsWinner() // 判断胜负
      {
    String winner = "";

    if (white == 0) {
      JOptionPane.showMessageDialog(null, "黑方胜!" + black + ":" + white);
      //			JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
      submit.setEnabled(false);
      winner = "黑";
    }
    if (black == 0) {
      JOptionPane.showMessageDialog(null, "白方胜!" + white + ":" + black);
      //			JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
      submit.setEnabled(false);
      winner = "白";
    }
    if (black + white == 64) {
      if (white > black) {
        JOptionPane.showMessageDialog(null, "白方胜!" + white + ":" + black);
        //				JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
        submit.setEnabled(false);
        winner = "白";
      } else if (black > white) {
        JOptionPane.showMessageDialog(null, "黑方胜!" + black + ":" + white);
        //				JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
        submit.setEnabled(false);
        winner = "白";
      } else if (black == white) {
        JOptionPane.showMessageDialog(null, "和局!");
        //				JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
        winner = "";
      }
    }
  }
Exemplo n.º 3
0
  private boolean confirmClose(String action, Collection modifiedLayers) {
    if (modifiedLayers.isEmpty()) {
      return true;
    }

    JOptionPane pane =
        new JOptionPane(
            StringUtil.split(
                modifiedLayers.size()
                    + " dataset"
                    + StringUtil.s(modifiedLayers.size())
                    + " "
                    + ((modifiedLayers.size() > 1) ? "have" : "has")
                    + " been modified ("
                    + ((modifiedLayers.size() > 3) ? "e.g. " : "")
                    + StringUtil.toCommaDelimitedString(
                        new ArrayList(modifiedLayers)
                            .subList(0, Math.min(3, modifiedLayers.size())))
                    + "). Continue?",
                80),
            JOptionPane.WARNING_MESSAGE);
    pane.setOptions(new String[] {action, "Cancel"});
    pane.createDialog(this, AppContext.getMessage("GeopistaName")).setVisible(true);

    return pane.getValue().equals(action);
  }
Exemplo n.º 4
0
  public void ConnectToSmartCard() {
    try {
      TerminalFactory factory = TerminalFactory.getDefault();
      List<CardTerminal> terminals = factory.terminals().list();
      System.out.println("Terminals: " + terminals);
      // get the first terminal
      // CardTerminals.State.
      CardTerminal terminal = terminals.get(0);

      if (terminal.isCardPresent()) {
        JOptionPane.showMessageDialog(null, "Card is Present");
        this.terminal = terminal;
      } else {
        JOptionPane.showMessageDialog(null, "Card is absent.Connnect it in 5 secs\nWaiting...");
        terminal.waitForCardPresent(5000);
        JOptionPane.showMessageDialog(null, "Time is Up!\nBye!!!");
        return;
      }
      // establish a connection with the card
      Card card = terminal.connect("*");
      this.card1 = card;
    } catch (CardException ce) {

    }
  }
Exemplo n.º 5
0
  private void realizarVenta() {
    boolean cantidadCorrecta = false;
    String str = "",
        strError =
            "Debes introducir una cantidad válida. Recuerda : \n 1) Sólo debes introducir números enteros; positivos \n 2) Debes dejar a lo más cero artículos en 'stock'";
    String strExistencia = tfExistencia.getText(), clave = "";
    int cantidad = 0;
    int existencia = Integer.parseInt(strExistencia);

    while (cantidadCorrecta == false) {
      str = JOptionPane.showInputDialog(null, "Cantidad a Vender = ");
      try {
        cantidad = Integer.parseInt(str);
        if ((cantidad < 0) || (cantidad > existencia))
          JOptionPane.showMessageDialog(null, strError);
        else {
          cantidadCorrecta = true;
          clave = tfClave.getText();
          resultado = lista.venderArticulos(cantidad, existencia);
          habilitarCampos(true);
          habilitarBotones(true);
          print(resultado);
        }
      } catch (NumberFormatException nfe) {
        System.out.println("Error: " + nfe);
        JOptionPane.showMessageDialog(null, strError);
      }
    }
  }
Exemplo n.º 6
0
  private static int GetInteger(String message) {
    // Forward declarations
    int ret;
    String temp;
    // Infinite loop
    while (true) {
      try {
        // Show the input dialog
        temp = JOptionPane.showInputDialog(message);

        // Attempt to parse the integer
        ret = Integer.parseInt(temp);

        if (ret <= 0) {
          // If some non-exception happened, force one
          throw new NumberFormatException();
        }

        // If everything looks okay, return the integer
        return ret;
      }
      // Tell the user not to do bad things
      catch (NumberFormatException e) {
        JOptionPane.showMessageDialog(null, "Please enter a valid integer.");
      } catch (NullPointerException e) {
        JOptionPane.showMessageDialog(null, "Please enter a valid integer.");
      }
    }
  }
    @Override
    public void actionPerformed(ActionEvent arg0) {
      File selectedFile = DATA_MODEL.getFile(TABLE.getSelectedRow());

      // can't create torrents out of empty folders.
      if (selectedFile.isDirectory() && selectedFile.listFiles().length == 0) {
        JOptionPane.showMessageDialog(
            null,
            I18n.tr("The folder you selected is empty."),
            I18n.tr("Invalid Folder"),
            JOptionPane.ERROR_MESSAGE);
        return;
      }

      // can't create torrents if the folder/file can't be read
      if (!selectedFile.canRead()) {
        JOptionPane.showMessageDialog(
            null,
            I18n.tr("Error: You can't read on that file/folder."),
            I18n.tr("Error"),
            JOptionPane.ERROR_MESSAGE);
        return;
      }

      CreateTorrentDialog dlg = new CreateTorrentDialog(GUIMediator.getAppFrame());
      dlg.setChosenContent(
          selectedFile,
          selectedFile.isFile() ? JFileChooser.FILES_ONLY : JFileChooser.DIRECTORIES_ONLY);
      dlg.setVisible(true);
    }
Exemplo n.º 8
0
 public void secureDelete() {
   int rw = tblItems.getSelectedRow();
   if (rw == -1) {
     JOptionPane.showMessageDialog(frm, "No item selected", "Error", JOptionPane.ERROR_MESSAGE);
     return;
   }
   int idx = tblItems.convertRowIndexToModel(rw);
   if (JOptionPane.showConfirmDialog(
           frm,
           "Delete " + store.plainName(idx) + "?",
           "Confirm Delete",
           JOptionPane.YES_NO_OPTION)
       != JOptionPane.YES_OPTION) return;
   File del = store.delete(idx);
   store.fireTableDataChanged();
   if (del != null) {
     if (del.delete()) {
       // successful
       needsSave = true;
     } else {
       System.err.println("Delete " + del.getAbsolutePath() + " failed");
     }
   }
   updateStatus();
 }
Exemplo n.º 9
0
 public void excluir(Oriundo oriundo) throws SQLException {
   Connection con =
       DriverManager.getConnection(
           new conexao().url,
           new conexao().config.getString("usuario"),
           new conexao().config.getString("senha"));
   PreparedStatement ps = null;
   String sqlExcluir = "DELETE FROM oriundo WHERE codigo=?";
   try {
     ps = con.prepareStatement(sqlExcluir);
     ps.setInt(1, oriundo.getCodigo());
     ps.executeUpdate();
     JOptionPane.showMessageDialog(
         null, "Ecluido Com Sucesso: ", "Mensagem do Sistema - Excluir", 1);
   } catch (NumberFormatException e) {
     JOptionPane.showMessageDialog(
         null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Excluir", 0);
     e.printStackTrace();
   } catch (NullPointerException e) {
     JOptionPane.showMessageDialog(
         null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Excluir", 0);
     e.printStackTrace();
   } catch (SQLException e) {
     JOptionPane.showMessageDialog(
         null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Excluir", 0);
     e.printStackTrace();
   } catch (Exception e) {
     JOptionPane.showMessageDialog(
         null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Excluir", 0);
     e.printStackTrace();
   } finally {
     ps.close();
     con.close();
   }
 }
Exemplo n.º 10
0
  // Sucecion de Fibonacci
  static void suce() {
    int numero, a = 1, b = 0, c;
    StringBuffer sb = new StringBuffer();
    String s1 =
        JOptionPane.showInputDialog("Ingrese el numero hasta el que desea ver la sucesion : ");
    numero = Integer.parseInt(s1);
    while (a < numero) {
      a += b;
      sb.append(a + " , ");
      b += a;
      sb.append(b + " , ");
    }

    JOptionPane.showMessageDialog(null, "Fibonacci = " + sb);

    int numero2 =
        JOptionPane.showOptionDialog(
            null,
            "Seleccione",
            "Escoja",
            JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            new Object[] {"Opcion 1", "Opcion 2", "Opcion 3"},
            "Opcion 3");
  }
 @Override
 public void actionPerformed(ActionEvent e) {
   String chosen;
   chosen = JOptionPane.showInputDialog(Localization.lang("Choose the URL to download."), "");
   if (chosen == null) {
     return;
   }
   File toFile;
   try {
     String toName =
         FileDialogs.getNewFile(
             frame,
             new File(System.getProperty("user.home")),
             null,
             JFileChooser.SAVE_DIALOG,
             false);
     if (toName == null) {
       return;
     } else {
       toFile = new File(toName);
     }
     URL url = new URL(chosen);
     MonitoredURLDownload.buildMonitoredDownload(comp, url).downloadToFile(toFile);
     comp.setText(toFile.getPath());
   } catch (Exception ex) {
     JOptionPane.showMessageDialog(
         null,
         Localization.lang("Error downloading file '%0'", chosen),
         Localization.lang("Download failed"),
         JOptionPane.ERROR_MESSAGE);
   }
 }
 private boolean readyToClose() {
   File f;
   if (newFile.isSelected()) {
     if (newNameTf.getText().isEmpty()) {
       if (tableModel.getRowCount() > 0) {
         JOptionPane.showMessageDialog(
             this,
             Localization.lang("You must choose a filename to store journal abbreviations"),
             Localization.lang("Store journal abbreviations"),
             JOptionPane.ERROR_MESSAGE);
         return false;
       } else {
         return true;
       }
     } else {
       f = new File(newNameTf.getText());
       return !f.exists()
           || (JOptionPane.showConfirmDialog(
                   this,
                   Localization.lang("'%0' exists. Overwrite file?", f.getName()),
                   Localization.lang("Store journal abbreviations"),
                   JOptionPane.OK_CANCEL_OPTION)
               == JOptionPane.OK_OPTION);
     }
   }
   return true;
 }
Exemplo n.º 13
0
  public String generateDatabaseName() { // prompts user for database name
    String dbNameDefault = "MySQLDB";
    // String databaseName = "";

    do {
      databaseName =
          (String)
              JOptionPane.showInputDialog(
                  null,
                  "Enter the database name:",
                  "Database Name",
                  JOptionPane.PLAIN_MESSAGE,
                  null,
                  null,
                  dbNameDefault);
      if (databaseName == null) {
        DatabaseConvertGUI.setReadSuccess(false);
        return "";
      }
      if (databaseName.equals("")) {
        JOptionPane.showMessageDialog(null, "You must select a name for your database.");
      }
    } while (databaseName.equals(""));
    return databaseName;
  }
 public void actionPerformed(ActionEvent e) {
   Object jbX = e.getSource();
   if (jbX == jbReg) {
     String an = tfAutoNr.getText();
     if (rg.registruotiAuto(an)) rodytiAutoRinkinius();
     else
       JOptionPane.showMessageDialog(
           this,
           "Registracija neįvyko:\n" + "arba kartojasi auto numeris arba nėra neregistruotų");
   }
   if (jbX == jbRasti) {
     String pag = tfAutoNr.getText();
     Automobilis a = rg.regAuto.get(pag);
     pag += a == null ? " automobilis nerastas" : "=" + a;
     JOptionPane.showMessageDialog(this, pag);
   }
   if (jbX == jbSkaityti) {
     rg.neregAuto.clear();
     String ats = rg.skaitytiNeregAutos("ban.automoto");
     JOptionPane.showMessageDialog(this, ats);
     rodytiAutoRinkinius();
   }
   if (jbX == jbSaveObj) {
     saveObject(rg, "temp.obj");
   }
   if (jbX == jbLoadObj) {
     loadObject("temp.obj");
     rodytiAutoRinkinius();
   }
 }
Exemplo n.º 15
0
  public void actionPerformed(ActionEvent e) {
    try {
      FileInputStream fin = new FileInputStream(obj.f);
      ObjectInputStream ois = new ObjectInputStream(fin);
      obj.a1 = (ArrayList) ois.readObject();

      String s1 = obj.t1.getText();
      String s2 = obj.t2.getText();

      int size = obj.a1.size();
      int f1 = 0;

      for (int i = 0; i < size; i++) {
        info r = (info) obj.a1.get(i);
        if (r.uid.equals(s1) && r.pass.equals(s2)) {
          JOptionPane.showMessageDialog(null, "VALID", "Welcome", JOptionPane.QUESTION_MESSAGE);
          f1 = 1;
        }
      }

      if (f1 == 0) {
        JOptionPane.showMessageDialog(null, "ALREADYEXIT", "Welcome", JOptionPane.QUESTION_MESSAGE);
      }

      fin.close();
      ois.close();
    } catch (Exception e1) {
    }
  }
Exemplo n.º 16
0
  void addButton_actionPerformed(ActionEvent e) {
    if (jTextFieldAccountname.getText().length() == 0) {
      JOptionPane.showMessageDialog(
          null, "Fill in the Account Name", "Error", JOptionPane.ERROR_MESSAGE);
      jTextFieldAccountname.requestFocus();
    } else if (jTextFieldFullname.getText().length() == 0) {
      JOptionPane.showMessageDialog(
          null, "Fill in the Full Name", "Error", JOptionPane.ERROR_MESSAGE);
      jTextFieldFullname.requestFocus();
    } else if ((String.valueOf(jPasswordField1.getPassword()))
            .equals(String.valueOf(jPasswordField2.getPassword()))
        == false) {

      JOptionPane.showMessageDialog(
          null, "Passwords don't match", "Error", JOptionPane.ERROR_MESSAGE);
      jPasswordField1.requestFocus();
    } else {
      usermodel.addUser(
          new User(
              jTextFieldAccountname.getText(),
              jTextFieldFullname.getText(),
              jPasswordField1.getPassword()));
      usermodel.fireTableDataChanged();
    }
  }
Exemplo n.º 17
0
  public void actionPerformed(ActionEvent e) {
    try {
      FileInputStream fin = new FileInputStream(obj1.f);
      ObjectInputStream ois = new ObjectInputStream(fin);
      obj1.a1 = (ArrayList) ois.readObject();

      String s3 = obj1.t3.getText();
      String s4 = obj1.t4.getText();
      String s5 = obj1.t5.getText();
      int size = obj1.a1.size();
      int f6 = 0;

      for (int i = 0; i < size; i++) {
        Stdinfo r2 = (Stdinfo) obj1.a1.get(i);
        if (r2.name.equals(s3) && r2.id.equals(s4) && r2.addr.equals(s5)) {
          JOptionPane.showMessageDialog(null, "FOUND", "Welcome", JOptionPane.QUESTION_MESSAGE);
          f6 = 1;
        }
      }

      if (f6 == 0) {
        JOptionPane.showMessageDialog(null, "NOT FOUND", "Welcome", JOptionPane.QUESTION_MESSAGE);
      }

      fin.close();
      ois.close();
    } catch (Exception e1) {
    }
  }
Exemplo n.º 18
0
 public void totalExport() {
   File expf = new File("export");
   if (expf.exists()) rmrf(expf);
   expf.mkdirs();
   for (int sto = 0; sto < storeLocs.size(); sto++) {
     try {
       String sl =
           storeLocs.get(sto).getAbsolutePath().replaceAll("/", "-").replaceAll("\\\\", "-");
       File estore = new File(expf, sl);
       estore.mkdir();
       File log = new File(estore, LIBRARY_NAME);
       PrintWriter pw = new PrintWriter(log);
       for (int i = 0; i < store.getRowCount(); i++)
         if (store.curStore(i) == sto) {
           File enc = store.locate(i);
           File dec = sec.prepareMainFile(enc, estore, false);
           pw.println(dec.getName());
           pw.println(store.getValueAt(i, Storage.COL_DATE));
           pw.println(store.getValueAt(i, Storage.COL_TAGS));
           synchronized (jobs) {
             jobs.addLast(expJob(enc, dec));
           }
         }
       pw.close();
     } catch (IOException exc) {
       exc.printStackTrace();
       JOptionPane.showMessageDialog(frm, "Exporting Failed");
       return;
     }
   }
   JOptionPane.showMessageDialog(frm, "Exporting to:\n   " + expf.getAbsolutePath());
 }
Exemplo n.º 19
0
  public void actionPerformed(ActionEvent e) {
    try {
      FileInputStream fin = new FileInputStream(obj.f);
      ObjectInputStream ois = new ObjectInputStream(fin);
      obj.a1 = (ArrayList) ois.readObject();

      String s1 = obj.t6.getText();
      String s2 = obj.t7.getText();

      int size = obj.a1.size();
      int f5 = 0;

      for (int i = 0; i < size; i++) {
        Bookinfo r2 = (Bookinfo) obj.a1.get(i);
        if (r2.bkisno.equals(s1) && r2.title.equals(s2)) {
          JOptionPane.showMessageDialog(
              null, "ALREADYEXIT", "Welcome", JOptionPane.QUESTION_MESSAGE);
          f5 = 1;
        }
      }

      if (f5 == 0) {
        JOptionPane.showMessageDialog(null, "ALREADYEXIT", "Welcome", JOptionPane.QUESTION_MESSAGE);
        ;
      }

      fin.close();
      ois.close();
    } catch (Exception e1) {
    }
  }
Exemplo n.º 20
0
  @Override
  public void actionPerformed(ActionEvent arg0) {
    // Pre-creation sanity
    if (gridPanel != null) {
      // Variable declaration
      String name, phone;
      // Make sure the fields have values
      if ((name = nameField.getText()) == "") {
        // Tell the user if not
        JOptionPane.showMessageDialog(null, "Please enter the client's name");
        return;
      }

      if ((phone = phoneField.getText()) == "") {
        JOptionPane.showMessageDialog(null, "Please enter the client's phone number");
        return;
      }

      if (hiddenRadio.isSelected()) {
        JOptionPane.showMessageDialog(null, "Please select the client's smoking preference");
        return;
      }

      // Calculate the party size
      int partySize = partyBox.getSelectedIndex() + 8;

      // Place the reservation
      bookRoom(name, phone, smokingRadio.isSelected(), partySize);
    } else {
      System.out.println("Grid panel is null");
    }
  }
Exemplo n.º 21
0
  public String check(String s) {
    String error = machine.check();
    if (error != null) {
      JOptionPane.showMessageDialog(
          null,
          Localized.getString("faCannotStart") + "\n" + error,
          Localized.getString("error"),
          JOptionPane.INFORMATION_MESSAGE,
          null);
      return null;
    }

    if (s == null)
      s =
          (String)
              JOptionPane.showInputDialog(
                  null,
                  Localized.getString("faParseString"),
                  Localized.getString("faStartTitle"),
                  JOptionPane.QUESTION_MESSAGE,
                  null,
                  null,
                  null);

    return s;
  }
Exemplo n.º 22
0
 public void actionPerformed(ActionEvent event) {
   if (typePanel.getSelection().equals("Confirm"))
     JOptionPane.showConfirmDialog(
         OptionDialogFrame.this,
         getMessage(),
         "Title",
         getType(optionTypePanel),
         getType(messageTypePanel));
   else if (typePanel.getSelection().equals("Input")) {
     if (inputPanel.getSelection().equals("Text field"))
       JOptionPane.showInputDialog(
           OptionDialogFrame.this, getMessage(), "Title", getType(messageTypePanel));
     else
       JOptionPane.showInputDialog(
           OptionDialogFrame.this,
           getMessage(),
           "Title",
           getType(messageTypePanel),
           null,
           new String[] {"Yellow", "Blue", "Red"},
           "Blue");
   } else if (typePanel.getSelection().equals("Message"))
     JOptionPane.showMessageDialog(
         OptionDialogFrame.this, getMessage(), "Title", getType(messageTypePanel));
   else if (typePanel.getSelection().equals("Option"))
     JOptionPane.showOptionDialog(
         OptionDialogFrame.this,
         getMessage(),
         "Title",
         getType(optionTypePanel),
         getType(messageTypePanel),
         null,
         getOptions(),
         getOptions()[0]);
 }
Exemplo n.º 23
0
 public void actionPerformed(ActionEvent e) {
   String name = null;
   name =
       JOptionPane.showInputDialog(
           objUpdate.this,
           "Enter a name (eg. John Russell)",
           "Input Person",
           JOptionPane.QUESTION_MESSAGE);
   if (!(name == null)) {
     // prompt the user for a date
     String date = null;
     date =
         JOptionPane.showInputDialog(
             objUpdate.this,
             "Enter Date (eg. 06/17/1946)",
             "Input Person",
             JOptionPane.QUESTION_MESSAGE);
     if (!(date == null)) {
       // convert String to Date
       try {
         Date d = f.parse(date);
         p = new Person(name, d);
         persons.add(p);
         index = persons.lastIndexOf(p);
         displayRecord();
       } catch (ParseException ex) {
         JOptionPane.showMessageDialog(
             objUpdate.this, "Invalid date format!", "Input Error", JOptionPane.ERROR_MESSAGE);
       }
     }
   }
 }
Exemplo n.º 24
0
  @Override
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() == salir) {
      JOptionPane.showMessageDialog(null, "Pantalla de Marlon");
    }

    if (e.getSource() == opc1) {
      JOptionPane.showMessageDialog(null, "Respuesta Incorrecta");
      Pregunta14 avance = new Pregunta14(s);
      dispose();
    }

    if (e.getSource() == opc2) {
      score = s + 10;
      JOptionPane.showMessageDialog(null, "Respuesta Correcta :0 ");
      Pregunta14 avance = new Pregunta14(score);
      dispose();
    }

    if (e.getSource() == opc3) {
      JOptionPane.showMessageDialog(null, "Respuesta Incorrecta");
      Pregunta14 avance = new Pregunta14(s);
      dispose();
    }

    if (e.getSource() == opc4) {
      JOptionPane.showMessageDialog(null, "Respuesta Incorrecta");
      Pregunta14 avance = new Pregunta14(s);
      dispose();
    }
  }
  public static int rollbackGUIConfigurationTransaction(String sConfigurationFileName) {

    String sConfigurationLockFile;
    File fFile;

    sConfigurationLockFile = new String(sConfigurationFileName + ".lck");

    try {
      fFile = new File(URLDecoder.decode(sConfigurationLockFile, "UTF-8"));
    } catch (IOException e) {
      JOptionPane.showMessageDialog(
          null, "URLDecoder.decode failed", "ConfigurationTransaction", JOptionPane.ERROR_MESSAGE);

      return 1;
    }

    if (fFile.delete() == false) {
      JOptionPane.showMessageDialog(
          null,
          "fFile.delete on " + sConfigurationLockFile + " failed",
          "ConfigurationTransaction",
          JOptionPane.ERROR_MESSAGE);

      return 3;
    }

    return 0;
  }
Exemplo n.º 26
0
  public boolean IsSmartCardFormated_Personalized() {
    byte id = (byte) 0x04;
    byte userregfileid = (byte) 0x02;

    Boolean IsWriiten = false;
    try {
      if (this.terminal != null && this.terminal.isCardPresent()) {
        if (this.SelectFileFromSmartCard(DATA, userregfileid)) {
          IsWriiten = true;
          // JOptionPane.showMessageDialog(null,"pls your card has  been formatted.");
        } else {
          System.out.println("pls your card has not been formatted");
          JOptionPane.showMessageDialog(null, "Please your card has not been formatted.");
        }
      } else {
        JOptionPane.showMessageDialog(
            null,
            "Card is absent.Please insert your smartCard\n to connnect it in 5 secs\nWaiting...");
      }

    } catch (CardException ce) {
      System.out.println("The Error cause is:" + ce.getMessage());
      ce.printStackTrace();
    }

    return IsWriiten;
  }
Exemplo n.º 27
0
    public void actionPerformed(ActionEvent e) {
      if (readOnly) {
        return;
      }
      JFileChooser fc = getFileChooser();
      File currentDirectory = fc.getCurrentDirectory();

      if (!currentDirectory.exists()) {
        JOptionPane.showMessageDialog(
            fc,
            newFolderParentDoesntExistText,
            newFolderParentDoesntExistTitleText,
            JOptionPane.WARNING_MESSAGE);
        return;
      }

      File newFolder;
      try {
        newFolder = fc.getFileSystemView().createNewFolder(currentDirectory);
        if (fc.isMultiSelectionEnabled()) {
          fc.setSelectedFiles(new File[] {newFolder});
        } else {
          fc.setSelectedFile(newFolder);
        }
      } catch (IOException exc) {
        JOptionPane.showMessageDialog(
            fc,
            newFolderErrorText + newFolderErrorSeparator + exc,
            newFolderErrorText,
            JOptionPane.ERROR_MESSAGE);
        return;
      }

      fc.rescanCurrentDirectory();
    }
Exemplo n.º 28
0
  private boolean validateModelName(String name) {
    //        System.err.println("Validating: " + modelName);
    // check that the name is valid

    if (name.equals(parameter.getName())) {
      return true;
    }

    if (name.trim().length() == 0) {
      Toolkit.getDefaultToolkit().beep();
      return false;
    }

    // check that a parameter with this name doesn't exist
    if (parameterExists(name)) {
      JOptionPane.showMessageDialog(
          frame,
          "A parameter with this name already exists.",
          "Linked parameter error",
          JOptionPane.WARNING_MESSAGE);
      return false;
    }

    // check that a model with this name doesn't exist
    if (modelExists(name)) {
      JOptionPane.showMessageDialog(
          frame,
          "A model with this name already exists.",
          "Linked parameter error",
          JOptionPane.WARNING_MESSAGE);
      return false;
    }

    return true;
  }
Exemplo n.º 29
0
  private boolean validateInput() {
    Character delimiter = getDelimiter();
    if (delimiter == null) {
      JOptionPane.showMessageDialog(
          this.contentPane,
          "The delimiter field must contain exactly one character.",
          "Error",
          JOptionPane.ERROR_MESSAGE);
      return false;
    }

    String path = this.tfFilePath.getText().trim();
    if (path.isEmpty()) {
      JOptionPane.showMessageDialog(
          this.contentPane, "The file path must be provided.", "Error", JOptionPane.ERROR_MESSAGE);
      return false;
    }

    if (!new File(path).exists()) {
      JOptionPane.showMessageDialog(
          this.contentPane,
          "The specified file does not exist.",
          "Error",
          JOptionPane.ERROR_MESSAGE);
      return false;
    }

    return true;
  }
 /**
  * Let the caller of this dialog know whether the user connected or cancelled.
  *
  * @return true if the user cancelled or closed the window.
  */
 public boolean userCanceled() {
   if (options.getValue() instanceof Integer) {
     int status = ((Integer) options.getValue()).intValue();
     return status != JOptionPane.OK_OPTION;
   } else {
     return false;
   }
 }