private void validateUserForm() {

    if (!txtFirstName.getText().equals("")
        && !txtLastName.getText().equals("")
        && !txtEmail.getText().equals("")
        && StringUtils.isValidEmailAddress(txtEmail.getText())) {

      btnAdd.setEnabled(true);
      btnClear.setEnabled(true);

      if (lblUserId.getText().equals("")) btnAdd.setText("Add");
      else btnAdd.setText("Update");
    } else btnAdd.setEnabled(false);

    // check if form is blank
    if (txtFirstName.getText().equals("")
        && txtLastName.getText().equals("")
        && txtEmail.getText().equals("")) {

      btnAdd.setText("Add");
      btnAdd.setEnabled(false);
    }

    // update mode
    if (!lstUsers.getSelectedValuesList().isEmpty()) btnClear.setEnabled(false);
  }
Beispiel #2
0
 public void launchDialog(ArrayList<String> values) {
   ok = false;
   display.clearSelection();
   setVisible(true);
   values.clear();
   if (ok) values.addAll(display.getSelectedValuesList());
 }
  @Override
  public void actionPerformed(ActionEvent arg0) {
    if (arg0.getActionCommand().equalsIgnoreCase("ADD_REQUIRED")) {
      addRequiredDialog = new AddRequiredDialog(this);
    } else if (arg0.getActionCommand().equalsIgnoreCase("REMOVE_REQUIRED")) {
      for (Object obj : requiredSkills.getSelectedValuesList()) {
        String selected = (String) obj;
        model.removeElement(obj);
        st.removeSkillRequirement(selected.substring(0, selected.indexOf("-") - 1).trim());
      }
    } else if (arg0.getActionCommand().equals(AddRequiredDialog.SAVE)) {
      String name = addRequiredDialog.getSkillName();
      int level = addRequiredDialog.getLevel();
      model.addElement(name + " - " + level);
      addRequiredDialog.setVisible(false);
      st.addSkillRequirement(name, level);
    } else {
      st.setName(nameField.getText());
      st.setSpcost(Integer.parseInt(this.spText.getText()));
      st.setMaxLevel(Integer.parseInt(this.levelsText.getText()));
      st.setRequiredLevel(Integer.parseInt(requiredLevelText.getText()));
      st.setTree(getFolderToPutIn());
      if (this.startLevelCheck.isSelected()) {
        st.setEntrycost(-1);
      } else {
        st.setEntrycost(Integer.parseInt(this.initialCostText.getText()));
      }

      if (XMLWriter.getInstance().skillToXML(st, getFolderToPutIn())) {
        JOptionPane.showMessageDialog(this, "File created successfully");
      }
    }
  }
Beispiel #4
0
 public MainForm() {
   alfa.setValue(1);
   beta.setValue(1);
   gamma.setValue(1);
   loadDatabase.addActionListener(
       e -> {
         fileChooser.setCurrentDirectory(new File(database.getText()));
         int returnVal = fileChooser.showOpenDialog(panel1);
         if (returnVal == JFileChooser.APPROVE_OPTION) {
           File file = fileChooser.getSelectedFile();
           database.setText(file.getPath());
         }
       });
   loadKeyword.addActionListener(
       e -> {
         fileChooser.setCurrentDirectory(new File(keywords.getText()));
         int returnVal = fileChooser.showOpenDialog(panel1);
         if (returnVal == JFileChooser.APPROVE_OPTION) {
           File file = fileChooser.getSelectedFile();
           keywords.setText(file.getPath());
         }
       });
   search.addActionListener(
       e -> {
         isKeywordsEnabled = keywordsEnabled.getSelectedIndex() != 0;
         DatabaseCollection.clear();
         if (isKeywordsEnabled) {
           new KeywordParser(keywords.getText()).parse();
         }
         new DocumentParser(database.getText()).parse();
         Method method1 = Method.valueOf((String) MainForm.this.method.getSelectedItem());
         Document query1 = new Document(MainForm.this.query.getText(), "", false);
         showResults(method1, query1);
       });
   oznacz.addActionListener(
       e -> {
         for (Result result : results.getSelectedValuesList()) {
           result.setMarkedAsGood(!result.isMarkedAsGood());
         }
         results.repaint();
       });
   newQuestion.addActionListener(
       e -> {
         ResultModel model = (ResultModel) results.getModel();
         Document query1 = model.getQuery();
         calculateRelevance(
             model.getResultList(),
             query1,
             (Integer) alfa.getValue(),
             (Integer) beta.getValue(),
             (Integer) gamma.getValue());
         queryHelp.setText(query1.getQueryText());
         Method method1 = Method.valueOf((String) MainForm.this.method.getSelectedItem());
         showResults(method1, query1);
       });
 }
 private void setUpTransitions(int length) {
   List<Value> sequences = sequenceToShowChooser.getSelectedValuesList();
   if (this.serializeSequencesBox.isSelected() && sequences.size() > 1) {
     int numSeq = sequences.size();
     timeController.setEndTime(length * numSeq);
     addTransitionsSerialized(timeController.getAllFadedTime(), true);
   } else {
     timeController.setEndTime(length);
     addTransitions(timeController.getAllFadedTime(), true);
   }
 }
  // l'azione eseguita alla selezione di un file nella lista
  @Override
  public void valueChanged(ListSelectionEvent e) {
    if (!e.getValueIsAdjusting()) {
      if (list.getSelectedValuesList().size() > 1) {
        System.out.println("selezione multipla ");
        for (String s : list.getSelectedValuesList()) {

          System.out.println(s);
        }
      } else {
        String selected = list.getSelectedValue();
        int pos_selected = list.getSelectedIndex();
        if (selected != null && pos_selected != -1) {
          setList_selected(selected);
          setPos_list_selected(pos_selected);
          System.out.println("selezionato " + selected + ", posizione " + pos_selected);
        }
      }
    }
  }
 @Override
 public String getValue() {
   Object[] selectedValues = list.getSelectedValuesList().toArray();
   value = shapefile + ";";
   for (int i = 0; i < selectedValues.length; i++) {
     if (i < selectedValues.length - 1) {
       value = value + selectedValues[i].toString() + ";";
     } else {
       value = value + selectedValues[i].toString();
     }
   }
   return value.trim();
 }
  private List<OsmPrimitive> getSelectedSubjectPrimitives() {
    List<OsmPrimitive> selection = new ArrayList<>();
    if (tabbedPane == null || tabbedPane.getSelectedComponent() == null) return selection;

    if (tabbedPane.getSelectedComponent().equals(matchTable)) {
      for (SimpleMatch c : matches.getSelected()) {
        selection.add(c.getSubjectObject());
      }
    } else if (tabbedPane.getSelectedComponent().equals(subjectOnlyList)) {
      selection.addAll(subjectOnlyList.getSelectedValuesList());
    }
    return selection;
  }
Beispiel #9
0
 @Override
 public void valueChanged(ListSelectionEvent selectEvent) {
   correctionsListModel.clear();
   if (!errorsList.getValueIsAdjusting() && !errorsList.isSelectionEmpty()) {
     List<String> selectionValues = errorsList.getSelectedValuesList();
     String selection = (String) selectionValues.get(0);
     String[] nearWords = closeMatches(selection);
     if (!arrayIsEmpty(nearWords)) {
       for (int i = 0; i < nearWords.length; i++) {
         correctionsListModel.addElement(nearWords[i]);
       }
     }
   }
 }
 private void selectProcess() {
   if (processing) {
     return;
   }
   selProcesses = list.getSelectedValuesList();
   if (!selProcesses.isEmpty()) {
     processing = true;
     tableRes.setEnabled(false);
     resTableModel.getDataVector().removeAllElements();
     resTableModel.fireTableDataChanged();
     foundIs = null;
     progress.setIndeterminate(true);
     progress.setString(translate("searching"));
     progress.setStringPainted(true);
     progress.setVisible(true);
     final SelectProcessWorker wrk = new SelectProcessWorker(selProcesses);
     wrk.addPropertyChangeListener(
         new PropertyChangeListener() {
           @Override
           public void propertyChange(PropertyChangeEvent evt) {
             switch (evt.getPropertyName()) {
               case "progress":
                 progress.setIndeterminate(false);
                 progress.setStringPainted(false);
                 progress.setValue((Integer) evt.getNewValue());
                 break;
               case "state":
                 if (((StateValue) evt.getNewValue()) == StateValue.DONE) {
                   try {
                     foundIs = wrk.get();
                   } catch (InterruptedException | ExecutionException ex) {
                     Logger.getLogger(LoadFromMemoryFrame.class.getName())
                         .log(Level.SEVERE, null, ex);
                   }
                   if (foundIs == null) {
                     addResultRow(null);
                   }
                   tableRes.setEnabled(foundIs != null);
                   progress.setVisible(false);
                   processing = false;
                 }
             }
           }
         });
     wrk.execute();
   }
 }
  /**
   * @todo Copy and paste code, refactor. Maybe it is best to add the transitions once they are
   *     known and not every time a button is pressed. The buttons would then change only the time
   *     controller and not affect the canvas items directly.
   */
  private void addTransitionsSerialized(final double newTargetTime, final boolean highlightStates) {
    List<Value> selected = sequenceToShowChooser.getSelectedValuesList();
    List<ArrayList<FCAElement>> objectSequences = calculateObjectSequences();
    Iterator<Value> seqValIt = sequenceValues.iterator();
    int seqNum = 0;
    int seqLength = timelineValues.size();
    List<FCAElement> lastSequence = null;
    ArrowStyle[] styles = DiagramSchema.getCurrentSchema().getArrowStyles();
    ArrowStyle style = null;
    int trailCount = 0;
    for (ArrayList<FCAElement> sequence : objectSequences) {
      Value curSequenceValue = seqValIt.next();
      if (!selected.contains(curSequenceValue)) {
        seqNum++;
        continue;
      }
      if (lastSequence != null) {
        Color nextColor = styles[seqNum % styles.length].getColor();
        DiagramNode endLast = findObjectConceptNode(lastSequence.get(lastSequence.size() - 1));
        DiagramNode startNew = findObjectConceptNode(sequence.get(0));
        if (endLast == null) {
          continue;
        }
        if (endLast != startNew) {
          SimpleLineDiagram diagram = (SimpleLineDiagram) diagramView.getDiagram();
          diagram.addExtraCanvasItem(
              new InterSequenceTransitionArrow(
                  endLast,
                  startNew,
                  style,
                  nextColor,
                  trailCount * seqLength + 0.5,
                  timeController));
        }
      }

      style = styles[seqNum % styles.length];
      if (lastSequence == null) {
        this.targetTime = newTargetTime;
        this.lastAnimationTime = 0;
      }
      addTransitions(curSequenceValue, sequence, style, highlightStates, trailCount * seqLength);
      seqNum++;
      trailCount++;
      lastSequence = sequence;
    }
  }
 private void addTransitions(double newTargetTime, boolean highlightStates) {
   List<Value> selected = sequenceToShowChooser.getSelectedValuesList();
   List<ArrayList<FCAElement>> objectSequences = calculateObjectSequences();
   Iterator<Value> seqValIt = sequenceValues.iterator();
   int styleNum = 0;
   boolean start = true;
   for (List<FCAElement> sequence : objectSequences) {
     Value curSequenceValue = seqValIt.next();
     if (start) {
       start = false;
       this.targetTime = newTargetTime;
       this.lastAnimationTime = 0;
     }
     ArrowStyle[] styles = DiagramSchema.getCurrentSchema().getArrowStyles();
     if (selected.contains(curSequenceValue)) {
       addTransitions(curSequenceValue, sequence, styles[styleNum], highlightStates, 0);
     }
     styleNum = (styleNum + 1) % styles.length;
   }
 }
 @Override
 public List<String> getgruposList() {
   return gruposList.getSelectedValuesList();
 }
 @Override
 public List<String> getpruebasList() {
   return pruebasList.getSelectedValuesList();
 }
Beispiel #15
0
  // 리스너 자리
  @Override
  public void actionPerformed(ActionEvent arg0) {
    // TODO Auto-generated method stub
    System.out.println("버튼눌림" + arg0.getActionCommand());
    switch (arg0.getActionCommand()) {
      case "< 폴더선택":
        pathSearch();
        break;
      case "< 선택삭제":
        List<String> temp = list_image.getSelectedValuesList();
        int[] number = list_image.getSelectedIndices();

        if (temp.size() <= 0) {
          JOptionPane.showMessageDialog(this, "삭제할 파일을 선택해 주세요!!");
          break;
        }

        if (JOptionPane.showConfirmDialog(this, "선택한 파일을 삭제 할까요?", "", JOptionPane.YES_NO_OPTION)
            == 1) {
          break;
        }

        for (int i = temp.size() - 1; i >= 0; i--) {
          String file = temp.get(i);
          File tempFile = new File(text_path.getText(), file);
          if (tempFile.isFile()) {
            if (tempFile.delete()) {
              dlm.remove(number[i]);
            }
          }
        }
        break;

      case "< 전체선택":
        if (dlm.size() <= 0) {
          JOptionPane.showMessageDialog(this, "목록에 파일이 존재 하지 않습니다.");
          break;
        }

        Robot robot;
        try {
          robot = new Robot();
        } catch (AWTException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          break;
        }
        list_image.requestFocus();
        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_A);
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.keyRelease(KeyEvent.VK_A);
        break;

      case "업로드 >>":
        uploadImage();
        break;
      case "검색":
        viewImgaeSearch();
        break;
      case "삭제":
        if (table_ftp_view.getSelectedRow() == -1) {
          JOptionPane.showMessageDialog(this, "삭제할 파일을 선택해 주세요!!");
          return;
        }
        if (JOptionPane.showConfirmDialog(
                this, "선택한 파일을 삭제 하시겠습니까?", "파일삭제", JOptionPane.OK_CANCEL_OPTION)
            == 0) {
          ftp_image_delete();
        }
        break;
      case "다운로드":
        if (table_ftp_view.getSelectedRow() == -1) {
          JOptionPane.showMessageDialog(this, "다운로드할 파일을 선택해 주세요!!");
          return;
        }
        ftpFile_DownLoad();
        break;
    }
  }
Beispiel #16
0
 public void valueChanged(ListSelectionEvent e) {
   if (!e.getValueIsAdjusting()) {
     selected.removeAll();
     for (String s : display.getSelectedValuesList()) selected.add(s);
   }
 }
Beispiel #17
0
  @Override
  public void valueChanged(ListSelectionEvent arg0) {
    JList<SocketThread> src = (JList<SocketThread>) arg0.getSource();

    selectedParticipants = src.getSelectedValuesList();
  }
Beispiel #18
0
  // 파일을 FTP서버로 업로드 합니다.
  private void uploadImage() {

    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

    // FTP로 이미지를 업로드 합니다.
    // FTP 서버에 접속 합니다.
    FTPClient ftpConn = new FTPClient();

    try {
      ftpConn.connect(Server_Config.getFTPIP(), Server_Config.getFTPPORT());
      ftpConn.login(Server_Config.getFTPID(), Server_Config.getFTPPW());
    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
      // TODO Auto-generated catch block
      JOptionPane.showMessageDialog(this, "접속에 실패 했습니다.");
      e.printStackTrace();
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      return;
    }

    // 단독폴더 경로를 설정합니다.
    try {
      ftpConn.changeDirectory(Server_Config.getFTPMARTPATH());
    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
      // TODO Auto-generated catch block
      // 디렉토리 없어서 오류가발생했다면
      String test;
      try {
        // 현재 디렉토리를 체크하고
        test = ftpConn.currentDirectory();
        System.out.println(test);
        // 그것이 루트 디렉토리라면
        if (test.equals("/")) {
          // 디렉토리를 생성한다.
          ftpConn.createDirectory(Server_Config.getFTPMARTPATH());
        }
      } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      JOptionPane.showMessageDialog(this, "디렉토리 변경에 실패 했습니다. 다시 시도해 주세요!");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      e.printStackTrace();
      return;
    } catch (NullPointerException e) {

      JOptionPane.showMessageDialog(this, "단독폴더경로 설정을 하셔야 합니다.");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      e.printStackTrace();
      return;
    }

    // 전송할 파일을 불러옵니다.
    List<String> temp = list_image.getSelectedValuesList();
    if (temp.size() <= 0) {
      JOptionPane.showMessageDialog(this, "업로드할 파일을 선택해 주세요!");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      return;
    }

    // 파일을 업로드 합니다.
    ArrayList<String> queryList = new ArrayList<String>();

    // 실패 파일을 저장합니다.
    ArrayList<String> uploadFail = new ArrayList<String>();

    for (String file : temp) {

      File tempFile = new File(text_path.getText(), file);

      if (fileSizeCheck(tempFile)) {
        try {
          ftpConn.upload(tempFile);
        } catch (IllegalStateException
            | IOException
            | FTPIllegalReplyException
            | FTPException
            | FTPDataTransferException
            | FTPAbortedException e) {
          // TODO Auto-generated catch block
          JOptionPane.showMessageDialog(this, "파일을 업로드 하지 못했습니다.");
          e.printStackTrace();
          this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          return;
        }

        // 이미지디비에 저장하기 위해 쿼리를 모아 둡니다.
        String query =
            "Insert into FTP_Image values('"
                + file.substring(0, file.indexOf("."))
                + "', '"
                + Server_Config.getFTPMARTPATH()
                + "', '0', '', '"
                + file.substring(file.indexOf(".") + 1, file.length())
                + "', '')";
        queryList.add(query);
      } else {
        // 업로드 실패시 저장합니다.
        uploadFail.add(tempFile.getName());
      }
    }

    // 저장할 상품이 있을때만 합니다.
    if (queryList.size() > 0) {
      ms_connect.setImageSetting();
      int result = ms_connect.connect_update(queryList);
      switch (result) {
        case 0:
          String queryOver =
              "Delete From Ftp_Image Where idx in( select a.idx as idx "
                  + "From Ftp_Image A INNER JOIN ( Select Min(idx) as idx, barcode, count(*) as overlapCount "
                  + "From Ftp_Image Where path_gubun='0' and path='"
                  + Server_Config.getFTPMARTPATH()
                  + "' Group by barcode Having count(*) > 1 ) B "
                  + "on a.barcode = b.barcode and A.idx <> B.idx and a.path_gubun='0' and path='"
                  + Server_Config.getFTPMARTPATH()
                  + "')";

          ms_connect.connect_update(queryOver);
          this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          JOptionPane.showMessageDialog(this, "저장이 완료 되었습니다.");
          // 검색창에 파일을 표시합니다.
          viewImgaeSearch();
          break;
        default:
          this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          JOptionPane.showMessageDialog(this, "저장을 완료 하지 못했습니다.");
          break;
      }
    }

    // 마무리합니다.
    try {
      if (ftpConn.isConnected()) {
        ftpConn.disconnect(true);
      }
    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }