Ejemplo n.º 1
0
  public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();

    if (cmd.equals("ok")) System.out.println("do ok");
    else if (cmd.equals("cancel")) this.setVisible(false);
    else if (cmd.equals("help")) displayHelp();
  }
Ejemplo n.º 2
0
 /**
  * Handle the event
  *
  * @param ae The event
  */
 public void actionPerformed(ActionEvent ae) {
   String cmd = ae.getActionCommand();
   if (cmd.equals(CMD_CONNECT)) {
     doConnect();
   } else {
     super.actionPerformed(ae);
   }
 }
Ejemplo n.º 3
0
    public void actionPerformed(ActionEvent event) {

      JMenuItem mi;
      String label = "";

      if (warningPopup == null) {
        warningPopup = new WarningDialog(textViewerFrame);
      }
      if ((editor1 == null) || (editor1.getDocument() == null)) {
        String errstr = "TextViewer:editor1 or document is null";
        warningPopup.display(errstr);
        return;
      }
      String actionStr = event.getActionCommand(); // is not makeing anysense
      // when keystrokes typed
      if ((event.getSource() instanceof JMenuItem)) {
        mi = (JMenuItem) event.getSource();
        label = mi.getText();
      } else if ((event.getSource() instanceof JTextArea)) { // keystroke
        label = "FindAgain"; // just set it to findagain
      } else {
        System.err.println("Debug:TextViewer:" + actionStr);
        System.err.println("Debug:TextViewer:" + event.getSource().toString());
        String errstr =
            "TextViewer:FindAction: "
                + event.getSource().toString()
                + " not an instance of JMenuItem or JTextArea";
        warningPopup.display(errstr);
        return;
      }

      if (label.equals("FindAgain")) {
        isFindAgain = true;
        lastFindStr = lastFindStr;
      } else {
        isFindAgain = false;
        lastFindStr = "";
      }
      StringBoolean content = new StringBoolean(lastFindStr, forwardFindDirection);

      boolean okPressed = mySearchDialog.display(content);
      if (!okPressed) {
        return;
      }
      lastFindStr = content.mystring;
      forwardFindDirection = content.myboolean;

      if (forwardFindDirection) {
        lastFindIndex = searchForward(lastFindStr);
        //		System.out.println("Debug:TextViewer: lastFindIndex:"+lastFindIndex);

      } else {
        lastFindIndex = searchBackward(lastFindStr);
        //		System.out.println("Debug:TextViewer: lastFindIndex:"+lastFindIndex);
      }
    }
Ejemplo n.º 4
0
 public void doAction(ActionEvent e) {
   String cmd = e.getActionCommand();
   // the new button creates a new set of texfields
   if (cmd.equals("new")) {
     Container container = getParent();
     if (container != null) container.setVisible(false);
     displayNewTxf("", "");
     if (container != null) container.setVisible(true);
   }
 }
Ejemplo n.º 5
0
 /**
  * Handle action events
  *
  * @param event event to handle
  */
 public void actionPerformed(ActionEvent event) {
   String cmd = event.getActionCommand();
   if (cmd.equals(GuiUtils.CMD_OK) || cmd.equals(GuiUtils.CMD_APPLY)) {
     accept();
   }
   if (cmd.equals(GuiUtils.CMD_OK) || cmd.equals(GuiUtils.CMD_CANCEL)) {
     close();
   }
   if (cmd.equals(GuiUtils.CMD_HELP)) {
     ucar.unidata.ui.Help.getDefaultHelp().gotoTarget(helpId);
   }
 }
Ejemplo n.º 6
0
 /**
  * Checks the passwords of the user
  *
  * @param e The ActionEvent for this action.
  */
 public void actionPerformed(ActionEvent e) {
   String cmd = e.getActionCommand();
   // checks if the user has a unix password, if it matches, then logs the user
   // in the interface, otherwise checks for the vnmrj password,
   // if neither password matches, then the user is not logged in the interface
   if (cmd.equalsIgnoreCase("enter")) enterLogin();
   else if (cmd.equalsIgnoreCase("cancel")) {
     m_passwordField.setText("");
     m_lblLogin.setForeground(getBackground());
     // setVisible(false);
   } else if (cmd.equalsIgnoreCase("help")) displayHelp();
 }
Ejemplo n.º 7
0
    public void actionPerformed(ActionEvent e) {
      if (!this.isEnabled()) {
        return;
      }

      if (NEW_AIRSPACE.equals(e.getActionCommand())) {
        this.createNewEntry(this.getView().getSelectedFactory());
      } else if (CLEAR_SELECTION.equals(e.getActionCommand())) {
        this.selectEntry(null, true);
      } else if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals(e.getActionCommand())) {
        if (e.getSource() instanceof AbstractButton) {
          boolean selected = ((AbstractButton) e.getSource()).isSelected();
          this.setResizeNewShapesToViewport(selected);
        }
      } else if (ENABLE_EDIT.equals(e.getActionCommand())) {
        if (e.getSource() instanceof AbstractButton) {
          boolean selected = ((AbstractButton) e.getSource()).isSelected();
          this.setEnableEdit(selected);
        }
      } else if (OPEN.equals(e.getActionCommand())) {
        this.openFromFile();
      } else if (OPEN_URL.equals(e.getActionCommand())) {
        this.openFromURL();
      } else if (OPEN_DEMO_AIRSPACES.equals(e.getActionCommand())) {
        this.openFromPath(DEMO_AIRSPACES_PATH);
        this.zoomTo(
            LatLon.fromDegrees(47.6584074779224, -122.3059199579634),
            Angle.fromDegrees(-152),
            Angle.fromDegrees(75),
            750);
      } else if (REMOVE_SELECTED.equals(e.getActionCommand())) {
        this.removeEntries(Arrays.asList(this.getSelectedEntries()));
      } else if (SAVE.equals(e.getActionCommand())) {
        this.saveToFile();
      } else if (SELECTION_CHANGED.equals(e.getActionCommand())) {
        this.viewSelectionChanged();
      }
    }
Ejemplo n.º 8
0
 /**
  * ************************************************
  *
  * <pre>
  * Summary: Listener for all buttons.
  *
  *
  * </pre>
  *
  * *************************************************
  */
 public void actionPerformed(ActionEvent e) {
   String cmd = e.getActionCommand();
   // Cancel
   if (cmd.equals("cancel")) {
     result = null;
     setVisible(false);
   }
   // Help
   else if (cmd.equals("help")) {
     // Do not call setVisible(false);  That will cause
     // the Block to release and the code which create
     // this object will try to use userText.  This way
     // the panel stays up and the Block stays in effect.
     displayHelp();
   } else if (cmd.equals("add")) {
     result = "add";
     setVisible(false);
   } else if (cmd.equals("remove")) {
     result = "remove";
     setVisible(false);
   }
 }
Ejemplo n.º 9
0
 public void actionPerformed(ActionEvent e) {
   String cmd = e.getActionCommand();
   if (cmd.equals("close")) {
     if (m_nType == CONFIG) saveData();
     else if (m_nType == DEFAULT && m_pnlAccPolicy != null) m_pnlAccPolicy.saveData();
     setVisible(false);
     dispose();
   } else if (cmd.equals("validate")) {
     if (timer != null) timer.cancel();
     if (m_nType == CHECKSUM && m_pnlChecksum != null) m_pnlChecksum.checksumValidation();
     else doSysValidation();
     validateButton.setBackground(closeButton.getBackground());
   } else if (cmd.equals("checksum")) {
     String strValue = m_pnlChecksum.getChecksum();
     m_pnlChecksum.setData(strValue);
   } else if (cmd.equals("checksumdir")) {
     m_pnlChecksum.setData("");
   } else if (cmd.equals("cancel")) {
     // build(m_bAccPolicy);
     setVisible(false);
     dispose();
   } else if (cmd.equals("help")) displayHelp();
 }
 /** Callback event handler to process clicks on any of the buttons. */
 public void actionPerformed(ActionEvent ae) {
   processCommand(ae.getActionCommand());
 }
Ejemplo n.º 11
0
 /**
  * Public by implementing ActionListener.
  *
  * @param e ActionEvent to check
  */
 public void actionPerformed(ActionEvent e) {
   actionPerformed(e.getActionCommand());
 }
Ejemplo n.º 12
0
  /** Invoked when the user presses the start button. */
  public void actionPerformed(ActionEvent evt) {
    if (evt.getActionCommand().equals("start")) {
      StartButton.setEnabled(false);
      cancelButton.setEnabled(true);
      setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      // Instances of javax.swing.SwingWorker are not reusuable, so
      // we create new instances as needed.
      DownloadMessage theMessage =
          new DownloadMessage() {
            public void setProgress(int Progress) {
              if (myState.equals("SPLIT")) {
                progressBar.setValue(Progress);

              } else if (myState.equals("DOWNLOADREMOTE")) {
                progressBar.setValue(Progress);

              } else if (myState.equals("DOWNLOADLOCALBASE")) {
                progressBar3.setValue(Progress);

              } else if (myState.equals("TOTAL")) {
                progressBar4.setValue(Progress);
                progressBar3.setValue(0);
                progressBar2.setValue(0);
                progressBar.setValue(0);
              }
            }

            public void messageChanged(int Progress, String message) {
              setProgress(Progress);

              taskOutput.append(message + "\n");
              taskOutput.setCaretPosition(taskOutput.getDocument().getLength());

              // TODO Auto-generated method stub

            }

            public void stateChanged(String theState) {

              myState = theState;
              // TODO Auto-generated method stub

            }

            public void messageChanged(String theMessage) {
              taskOutput.append(theMessage + "\n");
              taskOutput.setCaretPosition(taskOutput.getDocument().getLength());
              // TODO Auto-generated method stub
              // TODO Auto-generated method stub

            }
          };

      task = new Task(theMessage, (String) myDownloadOptions.getSelectedItem());
      task.addPropertyChangeListener(this);
      task.execute();
    } else if (evt.getActionCommand().equals("cancel")) {
      task.cancel(false);
      //	startButton.setEnabled(true);
      //	cancelButton.setEnabled(false);

    }
  }
Ejemplo n.º 13
0
    public void actionPerformed(ActionEvent e) {
      if (rebuilding) {
        return;
      }
      if (e.getActionCommand().equals("polygamy yes")) {
        ctxt.saveState = true;
        ctxt.polygamyPermit = true;
        SIL_Edit.edWin.chart.dirty = true;
      }
      if (e.getActionCommand().equals("polygamy no")) {
        ctxt.saveState = true;
        ctxt.polygamyPermit = false;
        SIL_Edit.edWin.chart.dirty = true;
      }
      if (e.getActionCommand().equals("distinct yes")) {
        ctxt.saveState = true;
        ctxt.distinctAdrTerms = true;
        SIL_Edit.edWin.setDistinctAdrMenuItemSelected(true);
        SIL_Edit.edWin.distinctAdrItemActionPerformed(null);
        SIL_Edit.edWin.chart.dirty = true;
        MainPane.topPane.setVisible(true);
      }
      if (e.getActionCommand().equals("distinct no")) {
        ctxt.saveState = true;
        ctxt.distinctAdrTerms = false;
        SIL_Edit.edWin.setDistinctAdrMenuItemSelected(false);
        SIL_Edit.edWin.distinctAdrItemActionPerformed(null);
        SIL_Edit.edWin.chart.dirty = true;
        MainPane.topPane.setVisible(true);
      }
      if (e.getActionCommand().equals("edit matrix")) {
        JOptionPane.showMessageDialog(
            ed,
            "Editing the Kin Term Matrix as a table" + "\nwill be a feature of a future version.",
            "Action Not Availabe",
            JOptionPane.INFORMATION_MESSAGE);
      }
      if (e.getActionCommand().equals("view/edit person")) {
        ctxt.saveState = true;
        Individual edee = (Individual) peopleList.get(indPick.getSelectedIndex());
        PersonEditor pEd = new PersonEditor(ctxt, ed, "View or Edit a Person", edee, "census", 0);
        if (!pEd.dupEditor) {
          pEd.desktop = desktop;
          desktop.add(pEd);
          pEd.miViewMe = menuView.add(pEd.windowNum);
          pEd.miViewMe.addActionListener(pEd);
          pEd.menuView = menuView;
          pEd.show();
          pEd.moveToFront();
          try {
            pEd.setSelected(true);
          } catch (PropertyVetoException pv) {
          }
        } else {
          try {
            pEd.setClosed(true);
          } catch (PropertyVetoException pv) {
          }
        }
      }
      if (e.getActionCommand().equals("view/edit family")) {
        ctxt.saveState = true;
        int serial = famPick.getSelectedIndex();
        Family edee = (Family) famList.get(serial);
        FamilyEditor fEd = new FamilyEditor(ctxt, ed, "View or Edit a Family", edee, "census");
        if (!fEd.dupEditor) {
          fEd.desktop = desktop;
          fEd.setLocation(350, 100);
          desktop.add(fEd);
          fEd.miViewMe = menuView.add(fEd.windowNum);
          fEd.miViewMe.addActionListener(fEd);
          fEd.menuView = menuView;
          fEd.show();
          fEd.moveToFront();
          try {
            fEd.setSelected(true);
          } catch (PropertyVetoException pv) {
          }
        } else {
          try {
            fEd.setClosed(true);
          } catch (PropertyVetoException pv) {
          }
        }
      }
      if (e.getActionCommand().equals("add UDP")) {
        UserDefinedProperty newU = new UserDefinedProperty("*newUDP");
        UDPEditor eddy = new UDPEditor(ctxt, ed, "Create New UDP", true, newU);
        eddy.desktop = desktop;
        eddy.setLocation(250, 50);
        desktop.add(eddy);
        eddy.miViewMe = menuView.add(eddy.windowNum);
        eddy.miViewMe.addActionListener(eddy);
        eddy.menuView = menuView;
        eddy.show();
        eddy.moveToFront();
        try {
          eddy.setSelected(true);
        } catch (PropertyVetoException pv) {
        }
      }
      if (e.getActionCommand().equals("view/edit UDP")) {
        String victim = (String) UDPick.getSelectedItem();
        UserDefinedProperty theUDP = (UserDefinedProperty) ctxt.userDefinedProperties.get(victim);
        UDPEditor eddy = new UDPEditor(ctxt, ed, "Edit UDP " + victim, false, theUDP);
        eddy.desktop = desktop;
        eddy.setLocation(250, 50);
        desktop.add(eddy);
        eddy.miViewMe = menuView.add(eddy.windowNum);
        eddy.miViewMe.addActionListener(eddy);
        eddy.menuView = menuView;
        eddy.show();
        eddy.moveToFront();
        try {
          eddy.setSelected(true);
        } catch (PropertyVetoException pv) {
        }
      }

      if (e.getActionCommand().equals("edit dtRef")) {
        ctxt.saveState = true;
        try {
          EditTheoryFrame etf = EditTheoryFrame.getEditTheoryFrame(ctxt.domTheoryRef());
          etf.setVisible(true);
        } catch (Exception exc) {
          System.err.println("ERROR in creating Edit Frame.\n" + exc);
        }
      }
      if (e.getActionCommand().equals("edit dtAddr")) {
        ctxt.saveState = true;
        try {
          EditTheoryFrame etf = EditTheoryFrame.getEditTheoryFrame(ctxt.domTheoryAdr());
          etf.setVisible(true);
        } catch (Exception exc) {
          System.err.println("ERROR in creating Edit Frame.\n" + exc);
        }
      }
    } //  end of ActionListener method actionPerformed