예제 #1
0
 /**
  * Method called when OK button was pressed.
  *
  * @param evt Event that invoked this action.
  */
 private void btOKActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btOKActionPerformed
   AbstractTaskFilter newTaskFilter =
       (AbstractTaskFilter) cmbFilterName.getItemAt(cmbFilterName.getSelectedIndex());
   newTaskFilter.setContentRule(cmbContentRule.getSelectedIndex());
   String content = null;
   if (newTaskFilter instanceof DescriptionFilter) content = txtContent.getText();
   if (newTaskFilter instanceof KeywordFilter) content = txtContent.getText();
   if (newTaskFilter instanceof DurationFilter) {
     String text = txtContent.getText();
     long duration;
     try {
       if (text.length() != 8)
         throw new NumberFormatException("Error: invalid task duration specified: " + text);
       duration = Tools.getTime(text);
     } catch (NumberFormatException e) {
       e.printStackTrace();
       JOptionPane.showMessageDialog(
           this,
           Translator.getTranslation("WARNING.INVALID_DURATION"),
           Translator.getTranslation("WARNING.WARNING_TITLE"),
           JOptionPane.WARNING_MESSAGE);
       txtContent.setText(Tools.getTime(0));
       return;
     }
     content = Tools.getTime(duration);
   }
   if (newTaskFilter instanceof PriorityFilter) content = "" + cmbContent.getSelectedIndex();
   if (newTaskFilter instanceof StateFilter) content = "" + cmbContent.getSelectedIndex();
   if (newTaskFilter instanceof PrivateFilter)
     content = Boolean.toString(cmbContent.getSelectedIndex() == 0);
   newTaskFilter.setContent(content);
   if (taskFilter == null) filtersTableModel.addFilter(newTaskFilter);
   else filtersTableModel.replaceFilter(taskFilter, newTaskFilter);
   formWindowClosing(null);
 } // GEN-LAST:event_btOKActionPerformed
예제 #2
0
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    lbFilterName = new javax.swing.JLabel();
    cmbFilterName = new javax.swing.JComboBox();
    lblContentRule = new javax.swing.JLabel();
    cmbContentRule = new javax.swing.JComboBox();
    lblContent = new javax.swing.JLabel();
    cmbContent = new javax.swing.JComboBox();
    txtContent = new javax.swing.JTextField();
    pnButtons = new javax.swing.JPanel();
    btOK = new javax.swing.JButton();
    btCancel = new javax.swing.JButton();

    setTitle(Translator.getTranslation("FILTERDIALOG.TITLE"));
    setModal(true);
    addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseEntered(java.awt.event.MouseEvent evt) {
            formMouseEntered(evt);
          }
        });
    addWindowListener(
        new java.awt.event.WindowAdapter() {
          public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
          }
        });
    getContentPane().setLayout(new java.awt.GridBagLayout());

    lbFilterName.setDisplayedMnemonic(Translator.getMnemonic("FILTERDIALOG.NAME"));
    lbFilterName.setFont(getFont());
    lbFilterName.setLabelFor(cmbFilterName);
    lbFilterName.setText(Translator.getTranslation("FILTERDIALOG.NAME"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(lbFilterName, gridBagConstraints);

    cmbFilterName.setFont(getFont());
    cmbFilterName.setToolTipText(Translator.getTranslation("FILTERDIALOG.NAME_TOOLTIP"));
    cmbFilterName.addItemListener(
        new java.awt.event.ItemListener() {
          public void itemStateChanged(java.awt.event.ItemEvent evt) {
            cmbFilterNameItemStateChanged(evt);
          }
        });
    cmbFilterName.addKeyListener(
        new java.awt.event.KeyAdapter() {
          public void keyPressed(java.awt.event.KeyEvent evt) {
            cmbFilterNameKeyPressed(evt);
          }
        });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(cmbFilterName, gridBagConstraints);

    lblContentRule.setDisplayedMnemonic(Translator.getMnemonic("FILTERDIALOG.CONTENT_RULE"));
    lblContentRule.setFont(getFont());
    lblContentRule.setLabelFor(cmbContentRule);
    lblContentRule.setText(Translator.getTranslation("FILTERDIALOG.CONTENT_RULE"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(lblContentRule, gridBagConstraints);

    cmbContentRule.setFont(getFont());
    cmbContentRule.setToolTipText(Translator.getTranslation("FILTERDIALOG.CONTENT_RULE_TOOLTIP"));
    cmbContentRule.addKeyListener(
        new java.awt.event.KeyAdapter() {
          public void keyPressed(java.awt.event.KeyEvent evt) {
            cmbContentRuleKeyPressed(evt);
          }
        });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(cmbContentRule, gridBagConstraints);

    lblContent.setDisplayedMnemonic(Translator.getMnemonic("FILTERDIALOG.CONTENT"));
    lblContent.setFont(getFont());
    lblContent.setLabelFor(txtContent);
    lblContent.setText(Translator.getTranslation("FILTERDIALOG.CONTENT"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(lblContent, gridBagConstraints);

    cmbContent.setFont(getFont());
    cmbContent.setToolTipText(Translator.getTranslation("FILTERDIALOG.CONTENT_TOOLTIP"));
    cmbContent.setEnabled(false);
    cmbContent.addKeyListener(
        new java.awt.event.KeyAdapter() {
          public void keyPressed(java.awt.event.KeyEvent evt) {
            cmbContentKeyPressed(evt);
          }
        });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(cmbContent, gridBagConstraints);

    txtContent.setFont(getFont());
    txtContent.setToolTipText(Translator.getTranslation("FILTERDIALOG.CONTENT_TOOLTIP"));
    txtContent.setPreferredSize(new java.awt.Dimension(100, 19));
    txtContent.addKeyListener(
        new java.awt.event.KeyAdapter() {
          public void keyPressed(java.awt.event.KeyEvent evt) {
            txtContentKeyPressed(evt);
          }
        });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(txtContent, gridBagConstraints);

    pnButtons.setLayout(new java.awt.GridBagLayout());

    btOK.setFont(getFont());
    btOK.setMnemonic(Translator.getMnemonic("FILTERDIALOG.BT_OK"));
    btOK.setText(Translator.getTranslation("FILTERDIALOG.BT_OK"));
    btOK.setToolTipText(Translator.getTranslation("FILTERDIALOG.BT_OK_TOOLTIP"));
    btOK.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btOKActionPerformed(evt);
          }
        });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    pnButtons.add(btOK, gridBagConstraints);

    btCancel.setFont(getFont());
    btCancel.setMnemonic(Translator.getMnemonic("FILTERDIALOG.BT_CANCEL"));
    btCancel.setText(Translator.getTranslation("FILTERDIALOG.BT_CANCEL"));
    btCancel.setToolTipText(Translator.getTranslation("FILTERDIALOG.BT_CANCEL_TOOLTIP"));
    btCancel.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btCancelActionPerformed(evt);
          }
        });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    pnButtons.add(btCancel, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridy = 4;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(pnButtons, gridBagConstraints);

    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 265) / 2, (screenSize.height - 240) / 2, 265, 240);
  } // </editor-fold>//GEN-END:initComponents