Esempio n. 1
0
  public void init() {
    setLayout(new BorderLayout());

    single.add("0");
    single.add("1");
    single.add("2");
    single.add("3");
    single.add("4");
    single.add("5");
    single.add("6");
    single.add("7");
    single.add("8");

    multiple.add("0");
    multiple.add("1");
    multiple.add("2");
    multiple.add("3");
    multiple.add("4");
    multiple.add("5");
    multiple.add("6");
    multiple.add("7");
    multiple.add("8");

    single.addKeyListener(this);
    single.addItemListener(this);
    single.addFocusListener(this);
    p1.add(single);
    add("North", p1);

    multiple.addKeyListener(this);
    multiple.addItemListener(this);
    multiple.addFocusListener(this);
    p2.add(multiple);
    add("South", p2);
  } // End  init()
  public List<FormItem> getExtraEditItems(ActionListener onSave) {

    List<FormItem> items = new ArrayList();
    items.add(new FormItem("Web Page", this.urlEdit));

    UIUtils.addDoActionOnReturnPressed(this.urlEdit, onSave);

    return items;
  }
Esempio n. 3
0
  public void init() {
    List actionList = new List(3); // makes a list to choose from
    actionList.add("wave");
    actionList.add("think");
    actionList.add("write");

    actionList.addActionListener(this); // tell Java to listen for user input
    add(actionList);

    myDuke = new Dukes(); // make an instance of Duke
    action = myDuke.getActionImage(); // see what Duke's current action is
  }
 private void setupExternals() {
   List<String> externalFiles =
       Globals.prefs.getStringList(JabRefPreferences.EXTERNAL_JOURNAL_LISTS);
   if (externalFiles.isEmpty()) {
     ExternalFileEntry efe = new ExternalFileEntry();
     externals.add(efe);
   } else {
     for (String externalFile : externalFiles) {
       ExternalFileEntry efe = new ExternalFileEntry(externalFile);
       externals.add(efe);
     }
   }
 }
 public void setTracesSessions(TracesSessions tracesSessions) {
   sessionsList.removeAll();
   this.tracesSessions = tracesSessions;
   for (int i = 0; i < tracesSessions.size(); i++) {
     TracesSession tracesSession = tracesSessions.elementAt(i);
     String name = tracesSession.getName();
     // System.out.println("name:"+name);
     if (name.equals("No available session yet, click on refresh")) sessionsList.add(name);
     else {
       String trueName = getTrueName(name);
       sessionsList.add("Trace " + (i + 1) + " from " + trueName);
     }
   }
   if (tracesSessions.size() != 0) sessionsList.select(0);
 }
Esempio n. 6
0
  public void showAtts() {
    if (ds == null) return;
    if (attTable == null) {
      // global attributes
      attTable =
          new BeanTableSorted(
              AttributeBean.class, (PreferencesExt) prefs.node("AttributeBeans"), false);
      PopupMenu varPopup = new ucar.nc2.ui.widget.PopupMenu(attTable.getJTable(), "Options");
      varPopup.addAction(
          "Show Attribute",
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              AttributeBean bean = (AttributeBean) attTable.getSelectedBean();
              if (bean != null) {
                infoTA.setText(bean.att.toString());
                infoTA.gotoTop();
                infoWindow.show();
              }
            }
          });
      attWindow =
          new IndependentWindow("Global Attributes", BAMutil.getImage("netcdfUI"), attTable);
      attWindow.setBounds(
          (Rectangle) prefs.getBean("AttWindowBounds", new Rectangle(300, 100, 500, 800)));
    }

    List<AttributeBean> attlist = new ArrayList<AttributeBean>();
    for (Attribute att : ds.getGlobalAttributes()) {
      attlist.add(new AttributeBean(att));
    }
    attTable.setBeans(attlist);
    attWindow.show();
  }
    @Override
    public void actionPerformed(ActionEvent e) {
      if (e.getSource() == add) {
        // int sel = userTable.getSelectedRow();
        // if (sel < 0)
        //    sel = 0;

        nameTf.setText("");
        abbrTf.setText("");
        if (JOptionPane.showConfirmDialog(
                dialog,
                journalEditPanel,
                Localization.lang("Edit journal"),
                JOptionPane.OK_CANCEL_OPTION)
            == JOptionPane.OK_OPTION) {
          journals.add(new JournalEntry(nameTf.getText(), abbrTf.getText()));
          // setValueAt(nameTf.getText(), sel, 0);
          // setValueAt(abbrTf.getText(), sel, 1);
          Collections.sort(journals);
          fireTableDataChanged();
        }
      } else if (e.getSource() == remove) {
        int[] rows = userTable.getSelectedRows();
        if (rows.length > 0) {
          for (int i = rows.length - 1; i >= 0; i--) {
            journals.remove(rows[i]);
          }
          fireTableDataChanged();
        }
      }
    }
Esempio n. 8
0
 public List<VariableBean> getStructureVariables(Structure s) {
   List<VariableBean> vlist = new ArrayList<VariableBean>();
   for (Variable v : s.getVariables()) {
     vlist.add(new VariableBean(v));
   }
   return vlist;
 }
Esempio n. 9
0
  public PlayerPanel(ActionListener listener) {

    Dimension size;
    Insets in = this.getInsets();

    this.numberOfPlayersButtons = new ArrayList<JButton>(this.possiblePlayersAmount);
    this.colorButtons = new LinkedList<JButton>();

    label = new JLabel("Escolha a quantidade de jogadores:");
    this.add(label);

    size = label.getPreferredSize();
    label.setBounds(90, 5 + in.top, size.width, size.height);

    for (int i = 0; i < this.possiblePlayersAmount; i++) {

      JButton tempButton = new JButton(String.format("%d", i + 3));
      numberOfPlayersButtons.add(tempButton);

      size = tempButton.getPreferredSize();
      tempButton.setBounds(45 + 75 * i + in.left, 80 + in.top, size.width, size.height);
      tempButton.addActionListener(listener);

      this.add(tempButton);
    }

    this.setSize(this.getPreferredSize());
    this.setLayout(null);
    this.listener = listener;
  }
  // check if sudo password is correct (so sudo can be used in all other scripts, even without
  // password, lasts for 5 minutes)
  private void doSudoCmd() {
    String pass = passwordField.getText();

    File file = null;
    try {
      // write file in /tmp
      file = new File("/tmp/cmd_sudo.sh"); // ""c:/temp/run.bat""
      FileOutputStream fos = new FileOutputStream(file);
      fos.write("echo $password | sudo -S ls\nexit $?".getBytes()); // "echo $password > pipo.txt"
      fos.close();

      // execute
      HashMap vars = new HashMap();
      vars.put("password", pass);

      List oses = new ArrayList();
      oses.add(
          new OsConstraint(
              "unix", null, null,
              null)); // "windows",System.getProperty("os.name"),System.getProperty("os.version"),System.getProperty("os.arch")));

      ArrayList plist = new ArrayList();
      ParsableFile pf = new ParsableFile(file.getAbsolutePath(), null, null, oses);
      plist.add(pf);
      ScriptParser sp = new ScriptParser(plist, new VariableSubstitutor(vars));
      sp.parseFiles();

      ArrayList elist = new ArrayList();
      ExecutableFile ef =
          new ExecutableFile(
              file.getAbsolutePath(),
              ExecutableFile.POSTINSTALL,
              ExecutableFile.ABORT,
              oses,
              false);
      elist.add(ef);
      FileExecutor fe = new FileExecutor(elist);
      int retval = fe.executeFiles(ExecutableFile.POSTINSTALL, this);
      if (retval == 0) {
        idata.setVariable("password", pass);
        isValid = true;
      }
      //			else is already showing dialog
      //			{
      //				JOptionPane.showMessageDialog(this, "Cannot execute 'sudo' cmd, check your password",
      // "Error", JOptionPane.ERROR_MESSAGE);
      //			}
    } catch (Exception e) {
      //				JOptionPane.showMessageDialog(this, "Cannot execute 'sudo' cmd, check your password",
      // "Error", JOptionPane.ERROR_MESSAGE);
      e.printStackTrace();
      isValid = false;
    }
    try {
      if (file != null && file.exists())
        file.delete(); // you don't want the file with password tobe arround, in case of error
    } catch (Exception e) {
      // ignore
    }
  }
Esempio n. 11
0
 public List<VariableBean> getVariableBeans(NetcdfFile ds) {
   List<VariableBean> vlist = new ArrayList<VariableBean>();
   for (Variable v : ds.getVariables()) {
     vlist.add(new VariableBean(v));
   }
   return vlist;
 }
Esempio n. 12
0
 public synchronized List<Element> getRestriccionColored() {
   List<Element> resp = new ArrayList();
   for (Element e : restriccion) {
     if (!e.getCol().equals(WHITE)) {
       resp.add(e);
     }
   }
   return resp;
 }
Esempio n. 13
0
  private void setSelected(Variable v) {
    eventsOK = false;

    List<Variable> vchain = new ArrayList<Variable>();
    vchain.add(v);

    Variable vp = v;
    while (vp.isMemberOfStructure()) {
      vp = vp.getParentStructure();
      vchain.add(0, vp); // reverse
    }

    for (int i = 0; i < vchain.size(); i++) {
      vp = vchain.get(i);
      NestedTable ntable = setNestedTable(i, vp.getParentStructure());
      ntable.setSelected(vp);
    }

    eventsOK = true;
  }
Esempio n. 14
0
 public List getOpenGroups() {
   List tempList = new LinkedList();
   JIDStatusTree tree = ((JIDStatusTree) getModel().getRoot());
   if (tree == null) return null;
   for (int i = 0; i < tree.getSize(); i++) {
     TreePath path = new TreePath(new Object[] {tree, tree.get(i)});
     if (isExpanded(path)) {
       tempList.add(tree.get(i).toString());
     }
   }
   return tempList;
 }
Esempio n. 15
0
 public void go() {
   f = new Frame("좋아하는 선수 고르기");
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           f.setVisible(false);
           f.dispose();
           System.exit(0);
         }
       });
   lstSunsu = new List(4, true); // 4개 보여주고,여러명 선택가능
   lstSunsu.addItemListener(this); // 2. step
   lstSunsu.add("==선수선택==");
   lstSunsu.add("조오련");
   lstSunsu.add("박찬호");
   lstSunsu.add("박세리");
   lstSunsu.add("안정환");
   lstSunsu.add("이천수");
   lstSunsu.add("이영표");
   lstSunsu.add("차범근");
   lstSunsu.add("김남일");
   lstSunsu.add("차두리");
   tf = new TextField();
   f.add(new Label("좋아하는 선수를 여러명 선택하세요"), "North");
   f.add(lstSunsu, "Center");
   f.add(tf, "South");
   f.setSize(200, 300);
   f.setVisible(true);
 }
  private void storeSettings() throws FileNotFoundException {
    File f = null;
    if (newFile.isSelected()) {
      if (!newNameTf.getText().isEmpty()) {
        f = new File(newNameTf.getText());
      } // else {
      //    return; // Nothing to do.
      // }
    } else {
      f = new File(personalFile.getText());
    }

    if (f != null) {
      if (!f.exists()) {
        throw new FileNotFoundException(f.getAbsolutePath());
      }
      try (FileWriter fw = new FileWriter(f, false)) {
        for (JournalEntry entry : tableModel.getJournals()) {
          fw.write(entry.name);
          fw.write(" = ");
          fw.write(entry.abbreviation);
          fw.write(Globals.NEWLINE);
        }
      } catch (IOException e) {
        LOGGER.warn("Problem writing abbreviation file", e);
      }
      String filename = f.getPath();
      if ("".equals(filename)) {
        filename = null;
      }
      Globals.prefs.put(JabRefPreferences.PERSONAL_JOURNAL_LIST, filename);
    }

    // Store the list of external files set up:
    List<String> extFiles = new ArrayList<>();
    for (ExternalFileEntry efe : externals) {
      if (!"".equals(efe.getValue())) {
        extFiles.add(efe.getValue());
      }
    }
    Globals.prefs.putStringList(JabRefPreferences.EXTERNAL_JOURNAL_LISTS, extFiles);

    Abbreviations.initializeJournalNames(Globals.prefs);

    // Update the autocompleter for the "journal" field in all base panels,
    // so added journal names are available:
    for (int i = 0; i < frame.getBasePanelCount(); i++) {
      frame.getBasePanelAt(i).getAutoCompleters().addJournalListToAutoCompleter();
    }
  }
Esempio n. 17
0
  private NestedTable setNestedTable(int level, Structure s) {
    NestedTable ntable;
    if (nestedTableList.size() < level + 1) {
      ntable = new NestedTable(level);
      nestedTableList.add(ntable);

    } else {
      ntable = nestedTableList.get(level);
    }

    if (s != null) // variables inside of records
    ntable.table.setBeans(getStructureVariables(s));

    ntable.show();
    return ntable;
  }
Esempio n. 18
0
  protected void updateContributionListing() {
    if (editor != null) {
      List<Contribution> contributions = new ArrayList<Contribution>();

      List<Library> libraries = new ArrayList<Library>(editor.getMode().contribLibraries);

      // Only add core libraries that are installed in the sketchbook
      // https://github.com/processing/processing/issues/3688
      // libraries.addAll(editor.getMode().coreLibraries);
      final String sketchbookPath = Base.getSketchbookLibrariesFolder().getAbsolutePath();
      for (Library lib : editor.getMode().coreLibraries) {
        if (lib.getLibraryPath().startsWith(sketchbookPath)) {
          libraries.add(lib);
        }
      }

      contributions.addAll(libraries);

      Base base = editor.getBase();

      List<ToolContribution> tools = base.getToolContribs();
      contributions.addAll(tools);

      List<ModeContribution> modes = base.getModeContribs();
      contributions.addAll(modes);

      List<ExamplesContribution> examples = base.getExampleContribs();
      contributions.addAll(examples);

      //    ArrayList<LibraryCompilation> compilations = LibraryCompilation.list(libraries);
      //
      //    // Remove libraries from the list that are part of a compilations
      //    for (LibraryCompilation compilation : compilations) {
      //      Iterator<Library> it = libraries.iterator();
      //      while (it.hasNext()) {
      //        Library current = it.next();
      //        if (compilation.getFolder().equals(current.getFolder().getParentFile())) {
      //          it.remove();
      //        }
      //      }
      //    }

      contribListing.updateInstalledList(contributions);
    }
  }
Esempio n. 19
0
  private List<Node> getSelectedNodes() {
    List<Node> selectedNodes = new Vector<Node>();
    NodeStatusTableModel myTableModel = (NodeStatusTableModel) getModel();

    ListSelectionModel lsm = getSelectionModel();
    int minIndex = lsm.getMinSelectionIndex();
    int maxIndex = lsm.getMaxSelectionIndex();

    for (int i = minIndex; i <= maxIndex; i++) {
      if (lsm.isSelectedIndex(i)) {
        // System.out.println("row " + i + " is selected");
        Node currNode = myTableModel.getNode(i);
        if (currNode != null) selectedNodes.add(currNode);
      }
    }

    return selectedNodes;
  }
  @Nullable
  private static List<Locale> extractLocalesFromString(final String rawLocales) {
    if (rawLocales.isEmpty()) {
      return Collections.emptyList();
    }
    final String[] splitRawLocales = rawLocales.split(",");
    final List<Locale> locales = new ArrayList<>(splitRawLocales.length);

    for (String rawLocale : splitRawLocales) {
      final Locale locale = PropertiesUtil.getLocale("_" + rawLocale + ".properties");
      if (locale == PropertiesUtil.DEFAULT_LOCALE) {
        return null;
      } else if (!locales.contains(locale)) {
        locales.add(locale);
      }
    }
    return locales;
  }
  private void okActionPerformed(java.awt.event.ActionEvent evt) {
    if (smtp.getText().trim().isEmpty()) {
      CommonFunctions.showErrorMessage(this, "You must enter a SMTP server.");
      return;
    } else if (smtpUsername.getText().trim().isEmpty()) {
      CommonFunctions.showErrorMessage(this, "You must enter the SMTP username.");
      return;
    } else {
      try {
        int port = Integer.parseInt(smtpPort.getText());
        if (port <= 0) throw new NumberFormatException();

        new InternetAddress(email.getText()).validate();
      } catch (NumberFormatException e) {
        CommonFunctions.showErrorMessage(this, "You must enter a valid SMTP port.");
        return;
      } catch (AddressException e) {
        CommonFunctions.showErrorMessage(this, "You must enter a valid source email address.");
        return;
      }
    }

    retval = 0;

    List<Student> selectedStudents = new ArrayList();
    for (int i = 0; i < studentsTbl.getRowCount(); i++) {
      if ((boolean) studentsTbl.getValueAt(i, 0)) {
        selectedStudents.add(students.get(studentsTbl.convertRowIndexToModel(i)));
      }
    }

    output =
        new Object[] {
          email.getText(),
          smtp.getText(),
          smtpPort.getText(),
          smtpUsername.getText(),
          new String(smtpPassword.getPassword()),
          selectedStudents
        };

    setVisible(false);
  }
 private MyExistLocalesListModel() {
   myLocales = new ArrayList<>();
   myLocales.add(PropertiesUtil.DEFAULT_LOCALE);
   PropertiesReferenceManager.getInstance(myProject)
       .processPropertiesFiles(
           GlobalSearchScope.projectScope(myProject),
           new PropertiesFileProcessor() {
             @Override
             public boolean process(String baseName, PropertiesFile propertiesFile) {
               final Locale locale = propertiesFile.getLocale();
               if (locale != PropertiesUtil.DEFAULT_LOCALE && !myLocales.contains(locale)) {
                 myLocales.add(locale);
               }
               return true;
             }
           },
           BundleNameEvaluator.DEFAULT);
   Collections.sort(myLocales, LOCALE_COMPARATOR);
 }
Esempio n. 23
0
  public void showColorButtons() {

    Color colors[] = {Color.RED, Color.BLACK, Color.WHITE, Color.GREEN, Color.YELLOW, Color.BLUE};
    Insets in = this.getInsets();

    this.input = new JTextField();
    this.add(this.input);
    this.input.setBounds(100 + in.left, 36 + in.top, 200, 30);

    int arrayAmount = numberOfPlayersButtons.size();

    for (int i = 0; i < numberOfPlayersButtons.size(); i++) {

      this.remove(numberOfPlayersButtons.get(i));
    }

    numberOfPlayersButtons = null;

    arrayAmount = this.maxPlayersAmount;

    for (int i = 0; i < arrayAmount; i++) {

      JButton tempButton = new JButton();
      colorButtons.add(tempButton);

      tempButton.setBackground(colors[i]);
      tempButton.setBorderPainted(false);
      tempButton.setOpaque(true);
      tempButton.setBounds(65 + i * 45 + in.left, 81 + in.top, 25, 25);
      tempButton.addActionListener(this.listener);

      this.add(tempButton);
    }

    Dimension size;

    size = label.getPreferredSize();
    label.setBounds(65, 5 + in.top, size.width + 48, size.height);

    label.setText("Jogador 1, informe a sua cor e o seu nome:");
    this.repaint();
  }
Esempio n. 24
0
  /**
   *   Handles when aides cover each other. They must tell
   *   us who they're covering so that that poor person
   *   doesn't get a missed shift. This of course means i
   *   have to work on MyHours some more... If they select
   *   a valid userid to cover for makes the appropriate
   *   entry in AIDELOG.
   *
   *   @param An SaoWorker who is covering someone else
   */
  public void WhoRUCovering(final SaoWorker w)
  {
    int i = 0;
    int h = bd.getHours();
    int m = bd.getMinutes();
    if (((m >= 20) && (m < 30)) || ((m >= 50) && (m < 60)))
    {
      if (m < 30) { m = m + 10; }
      else { m = m + 10 - 60; h = h + 1; }      
    }
    int dopp = bd.getDoPP();
    if (dopp > 7) { dopp = dopp - 7; }
    String slotid = bd.getSlot(h, m, dopp);
    String q = "select * from AIDESCHED where " + slotid + "=1";
    final String[] userids = {"", "", "", "", "", "", "", "", "", ""};
    final BatSQL bSQL = new BatSQL();
    ResultSet rs = bSQL.query(q);
    
    try
    {
      boolean more = rs.next();
      if (more) //because there might be only one person for this slot
      {
        while (more)
        {
          userids[i] = rs.getString(1);
          i++;
          more = rs.next();
        }
      } //end of if more
    } //end of try
    catch (SQLException ex)
    {
      System.out.println("!*******SQLException caught*******!");
      System.out.println("WhoRUCovering");
      while (ex != null)
      {
        System.out.println ("SQLState: " + ex.getSQLState ());
        System.out.println ("Message:  " + ex.getMessage ());
        System.out.println ("Vendor:   " + ex.getErrorCode ());
        ex = ex.getNextException ();
        System.out.println ("");
      }
      System.exit(0);
    } //end catching SQLExceptions
    catch (java.lang.Exception ex)
    {
      System.out.println("!*******Exception caught*******!");
      System.out.println("WhoRUCovering");      
      System.exit(0);
    } //end catching other Exceptions
    
    final Frame coverF = new Frame("Covering?");
    final Panel     p  = new Panel();
    final Panel  btnP  = new Panel();
    final List  coverL = new List();
    Button    ok = new Button("Cover");
    Button   nok = new Button("Cancel");
    final int i2 = i;
    
    ok.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
        String id = coverL.getSelectedItem();
        BatSQL bS = new BatSQL();
        String a = "insert into aidelog values ('C', \"" + id + "\", \"" + bd.getDate() + "\", " + bd.getStringHours() + bd.getStringMinutes() + ", 'I')";
        bS.update(a);
        a = "update AIDEDIN set COVERING='" + id + "' where USERID='" + w.getUserID() + "'";
        bS.update(a);
        bS.disconnect();
        coverF.dispose();
      }
    });
    nok.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
        coverF.dispose();
      }
    });
    
    btnP.setLayout(new FlowLayout());
    btnP.add(ok);
    btnP.add(nok);
    
    p.setLayout(new BorderLayout());
    p.add(new Label("Who are you covering for?"), BorderLayout.NORTH);
    int j;
    for (j = 0; j <= i; j++)
    {
      coverL.add(userids[j]);
    }
    p.add(coverL, BorderLayout.CENTER);
    p.add(btnP, BorderLayout.SOUTH);
    
    coverL.select(0);
    
    coverF.setLayout(new FlowLayout());
    coverF.add(p);    
    coverF.pack();
    coverF.setLocation(200, 200);
    coverF.show();

  } //end of WhoRUCovering
 public void addActionListener(ActionListener l) {
   actionListeners.add(l);
 }