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();
    }
  }
Beispiel #2
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;
  }
Beispiel #3
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());
 }
  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;
  }
  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;
  }
Beispiel #6
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 = "";
      }
    }
  }
Beispiel #7
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) {
    }
  }
Beispiel #8
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) {
    }
  }
Beispiel #9
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) {
    }
  }
    @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);
    }
 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);
 }
Beispiel #12
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 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();
    }
Beispiel #14
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) {

    }
  }
Beispiel #15
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);
      }
    }
  }
  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.");
      }
    }
  }
Beispiel #17
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;
  }
  @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");
    }
  }
 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();
   }
 }
 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();
   }
 }
  public void actionPerformed(ActionEvent actionevent) {
    OResource selectedNode = ((OResourceNode) selectedNodes.get(0).getUserObject()).getResource();
    String ns = selectedNode.getONodeID().getNameSpace();
    if (gate.creole.ontology.Utils.hasSystemNameSpace(selectedNode.getONodeID().toString())) {
      ns = ontology.getDefaultNameSpace();
    }
    nameSpace.setText(ns);

    nameSpace.setText(
        ontology.getDefaultNameSpace() == null
            ? "http://gate.ac.uk/example#"
            : ontology.getDefaultNameSpace());
    JOptionPane pane =
        new JOptionPane(
            mainPanel,
            JOptionPane.QUESTION_MESSAGE,
            JOptionPane.OK_CANCEL_OPTION,
            MainFrame.getIcon("ontology-instance")) {
          public void selectInitialValue() {
            instanceName.requestFocusInWindow();
            instanceName.selectAll();
          }
        };
    pane.createDialog(MainFrame.getInstance(), "New Instance").setVisible(true);
    Object selectedValue = pane.getValue();
    if (selectedValue != null
        && selectedValue instanceof Integer
        && (Integer) selectedValue == JOptionPane.OK_OPTION) {
      String s = nameSpace.getText();
      if (!Utils.isValidNameSpace(s)) {
        JOptionPane.showMessageDialog(
            MainFrame.getInstance(),
            "Invalid Name Space: " + s + "\nExample: http://gate.ac.uk/example#");
        return;
      }
      if (!Utils.isValidOntologyResourceName(instanceName.getText())) {
        JOptionPane.showMessageDialog(
            MainFrame.getInstance(), "Invalid Instance: " + instanceName.getText());
        return;
      }
      if (Utils.getOResourceFromMap(ontology, s + instanceName.getText()) != null) {
        JOptionPane.showMessageDialog(
            MainFrame.getInstance(),
            "<html>" + "Resource <b>" + s + instanceName.getText() + "</b> already exists.");
        return;
      }

      for (int i = 0; i < selectedNodes.size(); i++) {
        Object obj = ((OResourceNode) selectedNodes.get(i).getUserObject()).getResource();
        if (obj instanceof OClass) {
          ontology.addOInstance(
              ontology.createOURI(nameSpace.getText() + instanceName.getText()), (OClass) obj);
        }
      }
    }
  }
Beispiel #22
0
 void writeNetCDF(String filename) {
   try {
     FileWriter2 writer = new FileWriter2(ds, filename, NetcdfFileWriter.Version.netcdf3);
     NetcdfFile result = writer.write();
     result.close();
     JOptionPane.showMessageDialog(this, "File successfully written");
   } catch (Exception ioe) {
     JOptionPane.showMessageDialog(this, "ERROR: " + ioe.getMessage());
     ioe.printStackTrace();
   }
 }
Beispiel #23
0
 void writeNcstreamHeader(String filename) {
   try {
     NcStreamWriter writer = new NcStreamWriter(ds, null);
     FileOutputStream fos = new FileOutputStream(filename);
     writer.sendHeader(fos);
     fos.close();
     JOptionPane.showMessageDialog(this, "File successfully written");
   } catch (Exception ioe) {
     JOptionPane.showMessageDialog(this, "ERROR: " + ioe.getMessage());
     ioe.printStackTrace();
   }
 }
Beispiel #24
0
  /** Returns false if Exception is thrown. */
  private boolean setDirectory() {
    String pathStr = dirTF.getText().trim();
    if (pathStr.equals("")) pathStr = System.getProperty("user.dir");
    try {
      File dirPath = new File(pathStr);
      if (!dirPath.isDirectory()) {
        if (!dirPath.exists()) {
          if (recursiveCheckBox.isSelected())
            throw new NotDirectoryException(dirPath.getAbsolutePath());
          else throw new NotFileException(dirPath.getAbsolutePath());
        } else {
          convertSet.setFile(dirPath);
          convertSet.setDestinationPath(dirPath.getParentFile());
        }
      } else {
        // Set the descriptors
        setMatchingFileNames();

        FlexFilter flexFilter = new FlexFilter();
        flexFilter.addDescriptors(descriptors);
        flexFilter.setFilesOnly(!recursiveCheckBox.isSelected());

        convertSet.setSourcePath(dirPath, flexFilter);
        convertSet.setDestinationPath(dirPath);
      }
    } catch (NotDirectoryException e1) {
      final String caption = ResourceHandler.getMessage("notdirectory_dialog.caption1");

      MessageFormat formatter;
      String info_msg;
      if (pathStr.equals("")) {
        info_msg = ResourceHandler.getMessage("notdirectory_dialog.info5");
      } else {
        formatter = new MessageFormat(ResourceHandler.getMessage("notdirectory_dialog.info0"));
        info_msg = formatter.format(new Object[] {pathStr});
      }
      final String info = info_msg;

      JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE);
      return false;
    } catch (NotFileException e2) {
      final String caption = ResourceHandler.getMessage("notdirectory_dialog.caption0");

      MessageFormat formatter =
          new MessageFormat(ResourceHandler.getMessage("notdirectory_dialog.info1"));
      final String info = formatter.format(new Object[] {pathStr});

      JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE);
      return false;
    }

    return true; // no exception thrown
  }
 @Override
 public void run() {
   try {
     receive();
   } catch (IOException ioException) {
     JOptionPane.showMessageDialog(null, "Problems with a server");
   } catch (InterruptedException interruptedException) {
     JOptionPane.showMessageDialog(null, "Interrupted exception thrown");
   } catch (ParserConfigurationException parserException) {
     parserException.printStackTrace();
   } catch (SAXException saxException) {
     saxException.printStackTrace();
   }
 }
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == save) {
     JFileChooser c = new JFileChooser(ResourceFactory.getRootDir());
     c.setDialogTitle("Save result");
     if (c.showSaveDialog(resultFrame) == JFileChooser.APPROVE_OPTION) {
       File output = c.getSelectedFile();
       if (output.exists()) {
         String[] options = {"Overwrite", "Cancel"};
         if (JOptionPane.showOptionDialog(
                 resultFrame,
                 output + "exists. Overwrite?",
                 "Save result",
                 JOptionPane.YES_NO_OPTION,
                 JOptionPane.WARNING_MESSAGE,
                 null,
                 options,
                 options[0])
             == 1) return;
       }
       try {
         PrintWriter w = new PrintWriter(new BufferedWriter(new FileWriter(output)));
         w.println("Searched for unused strings");
         w.println("Number of hits: " + table.getRowCount());
         w.println("");
         for (int i = 0; i < table.getRowCount(); i++) {
           w.println(
               "StringRef: "
                   + table.getTableItemAt(i).getObjectAt(1)
                   + " /* "
                   + table
                       .getTableItemAt(i)
                       .toString()
                       .replaceAll("\r\n", System.getProperty("line.separator"))
                   + " */");
         }
         w.close();
         JOptionPane.showMessageDialog(
             resultFrame,
             "Result saved to " + output,
             "Save complete",
             JOptionPane.INFORMATION_MESSAGE);
       } catch (IOException ex) {
         JOptionPane.showMessageDialog(
             resultFrame, "Error while saving " + output, "Error", JOptionPane.ERROR_MESSAGE);
         ex.printStackTrace();
       }
     }
   }
 }
 public List<Oriundo> listar() throws SQLException {
   List<Oriundo> resultado = new ArrayList<Oriundo>();
   conexao propCon = new conexao();
   Connection con =
       DriverManager.getConnection(
           new conexao().url,
           propCon.config.getString("usuario"),
           propCon.config.getString("senha"));
   PreparedStatement ps = null;
   ResultSet rs = null;
   String sqlListar = "SELECT * FROM oriundo Order by codigo DESC";
   Oriundo oriundo;
   try {
     ps = con.prepareStatement(sqlListar);
     rs = ps.executeQuery();
     // if(rs==null){
     // return null;
     // }
     while (rs.next()) {
       oriundo = new Oriundo();
       oriundo.setCodigo(rs.getInt("codigo"));
       oriundo.setDescricao(rs.getString("descricao"));
       oriundo.setData_cadastro(rs.getDate("data_cadastro"));
       oriundo.setDia_fechamento(rs.getInt("dia_fechamento"));
       oriundo.setDia_pag(rs.getInt("dia_pag"));
       resultado.add(oriundo);
     }
   } catch (NumberFormatException e) {
     JOptionPane.showMessageDialog(
         null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Localizar", 0);
     e.printStackTrace();
   } catch (NullPointerException e) {
     JOptionPane.showMessageDialog(
         null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0);
     e.printStackTrace();
   } catch (SQLException e) {
     JOptionPane.showMessageDialog(
         null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0);
     e.printStackTrace();
   } catch (Exception e) {
     JOptionPane.showMessageDialog(
         null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0);
     e.printStackTrace();
   } finally {
     ps.close();
     con.close();
   }
   return resultado;
 }
 private Object loadObject(String fName) {
   Object obj = null;
   try {
     FileInputStream fis = new FileInputStream(fName);
     ObjectInputStream oin = new ObjectInputStream(fis);
     obj = oin.readObject();
   } catch (IOException ex) {
     JOptionPane.showMessageDialog(this, "Problemos skaitant Objektus");
     return null;
   } catch (ClassNotFoundException ex) {
     JOptionPane.showMessageDialog(this, "Nerasta objekto klasė");
     return null;
   }
   return obj;
 }
Beispiel #29
0
  public void save() {
    BufferedWriter sourceFile = null;

    try {
      String sourceText = sourceArea.getText();

      String cleanText = cleanupSource(sourceText);

      if (cleanText.length() != sourceText.length()) {
        sourceArea.setText(cleanText);

        String message =
            String.format(
                "One or more invalid characters at the end of the source file have been removed.");
        JOptionPane.showMessageDialog(this, message, "ROPE", JOptionPane.INFORMATION_MESSAGE);
      }

      sourceFile = new BufferedWriter(new FileWriter(sourcePath, false));
      sourceFile.write(cleanText);

      setSourceChanged(false);

      setupMenus();
    } catch (IOException ex) {
      ex.printStackTrace();
    } finally {
      if (sourceFile != null) {
        try {
          sourceFile.close();
        } catch (IOException ignore) {
        }
      }
    }
  }
Beispiel #30
0
  /**
   * This method extract the content of a 'line with known length' packet
   *
   * <p>serial protocol is not error-prone, so our simple approach is to validate the length of
   * incoming strings
   *
   * @return null in case of error, line message if valid packed ine
   * @see #packString(String)
   */
  public static String unpackString(String message) {
    String prefix = "line" + PACKING_DELIMITER;
    if (message.contains(TS_PROTOCOL_TAG)) {
      JOptionPane.showMessageDialog(null, "Are you sure you are not connected to TS port?");
      return null;
    }
    if (!message.startsWith(prefix)) {
      FileLog.MAIN.logLine(
          "EngineState: unexpected header: " + message + " while looking for " + prefix);
      return null;
    }
    message = message.substring(prefix.length());
    int delimiterIndex = message.indexOf(PACKING_DELIMITER);
    if (delimiterIndex == -1) {
      FileLog.MAIN.logLine("Delimiter not found in: " + message);
      return null;
    }
    String lengthToken = message.substring(0, delimiterIndex);
    int expectedLen;
    try {
      expectedLen = Integer.parseInt(lengthToken);
    } catch (NumberFormatException e) {
      FileLog.MAIN.logLine("invalid len: " + lengthToken);
      return null;
    }

    String response = message.substring(delimiterIndex + 1);
    if (response.length() != expectedLen) {
      FileLog.MAIN.logLine("message len does not match header: " + message);
      response = null;
    }
    return response;
  }