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();
  }
 private void hideNestedTable(int level) {
   int n = nestedTableList.size();
   for (int i = n - 1; i >= level; i--) {
     NestedTable ntable = nestedTableList.get(i);
     ntable.hide();
   }
 }
 public List<VariableBean> getVariableBeans(NetcdfFile ds) {
   List<VariableBean> vlist = new ArrayList<VariableBean>();
   for (Variable v : ds.getVariables()) {
     vlist.add(new VariableBean(v));
   }
   return vlist;
 }
 public List<VariableBean> getStructureVariables(Structure s) {
   List<VariableBean> vlist = new ArrayList<VariableBean>();
   for (Variable v : s.getVariables()) {
     vlist.add(new VariableBean(v));
   }
   return vlist;
 }
  // 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
    }
  }
    @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();
        }
      }
    }
 @Override
 public Object getValueAt(int row, int col) {
   if (col == 0) {
     return journals.get(row).name;
   } else {
     return journals.get(row).abbreviation;
   }
 }
 private static AttachingConnector getAttachingConnectorFor(String transport) {
   List acs = Bootstrap.virtualMachineManager().attachingConnectors();
   AttachingConnector ac;
   int i, k = acs.size();
   for (i = 0; i < k; i++)
     if ((ac = (AttachingConnector) acs.get(i)).transport().name().equals(transport)) return ac;
   return null;
 }
Exemple #9
0
 /** Called externally when the underlying corpus has changed. */
 private void dataChanged() {
   List<String> newDocs = new ArrayList<String>();
   if (corpus != null) {
     newDocs.addAll(corpus.getDocumentNames());
   }
   List<String> oldDocs = documentNames;
   documentNames = newDocs;
   oldDocs.clear();
 }
  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;
  }
Exemple #11
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;
 }
  public void initComponents() {
    /** ******************** The main container *************************** */
    Container container = this.getContentPane();
    container.setLayout(new BorderLayout());
    container.setBackground(Color.black);
    this.setSize(650, 600);
    this.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {}
        });

    /** ************************* MAIN PANEL ******************************* */
    mainPanel = new JPanel();
    // If put to False: we see the container's background
    mainPanel.setOpaque(false);
    mainPanel.setLayout(new BorderLayout());
    container.add(mainPanel, BorderLayout.CENTER);

    allmessagesTextArea = new TextArea();
    allmessagesTextArea.setEditable(false);
    allmessagesTextArea.setFont(new Font("Dialog", 1, 12));
    allmessagesTextArea.setForeground(Color.black);
    allmessagesTextArea.append("Select a session in the list to view its messages");
    mainPanel.add(allmessagesTextArea, BorderLayout.CENTER);

    sessionsList = new List();
    sessionsList.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            showMessages(e);
          }
        });
    sessionsList.setForeground(Color.black);
    sessionsList.setFont(new Font("Dialog", 1, 14));
    mainPanel.add(sessionsList, BorderLayout.WEST);

    okButton = new JButton("  OK  ");
    okButton.setToolTipText("Returns to the main frame");
    okButton.setFont(new Font("Dialog", 1, 16));
    okButton.setFocusPainted(false);
    okButton.setBackground(Color.lightGray);
    okButton.setBorder(new BevelBorder(BevelBorder.RAISED));
    okButton.setVerticalAlignment(SwingConstants.CENTER);
    okButton.setHorizontalAlignment(SwingConstants.CENTER);
    container.add(okButton, BorderLayout.SOUTH);
    okButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            setVisible(false);
          }
        });
  }
 @Override
 protected void doOKAction() {
   final String errorString = myComponent.canCreateAllFilesForAllLocales();
   if (errorString != null) {
     Messages.showErrorDialog(getContentPanel(), errorString);
   } else {
     final List<PsiFile> createFiles = myComponent.createPropertiesFiles();
     myCreatedFiles = createFiles.toArray(new PsiElement[createFiles.size()]);
     super.doOKAction();
   }
 }
  // masuda$
  // ChartEventListener
  @Override
  public void propertyChange(PropertyChangeEvent pce) {

    if (tableModel == null) {
      return;
    }

    ChartEventModel evt = (ChartEventModel) pce.getNewValue();

    int sRow = -1;
    long ptPk = evt.getPtPk();
    List<PatientModel> list = tableModel.getDataProvider();

    // minagawa^
    // ChartEventModel.EVENT eventType = evt.getEventType();
    int eventType = evt.getEventType();
    // minagawa$

    switch (eventType) {
      case ChartEventModel.PVT_STATE:
        for (int row = 0; row < list.size(); ++row) {
          PatientModel pm = list.get(row);
          if (ptPk == pm.getId()) {
            sRow = row;
            pm.setOwnerUUID(evt.getOwnerUUID());
            break;
          }
        }
        break;
      case ChartEventModel.PM_MERGE:
        for (int row = 0; row < list.size(); ++row) {
          PatientModel pm = list.get(row);
          if (ptPk == pm.getId()) {
            sRow = row;
            // pm = msg.getPatientModel();
            list.set(row, evt.getPatientModel());
            break;
          }
        }
        break;
      case ChartEventModel.PVT_MERGE:
        for (int row = 0; row < list.size(); ++row) {
          PatientModel pm = list.get(row);
          if (ptPk == pm.getId()) {
            sRow = row;
            // pm = msg.getPatientVisitModel().getPatientModel();
            list.set(row, evt.getPatientVisitModel().getPatientModel());
            break;
          }
        }
        break;
      default:
        break;
    }

    if (sRow != -1) {
      tableModel.fireTableRowsUpdated(sRow, sRow);
    }
  }
Exemple #15
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
  }
Exemple #16
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;
 }
 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);
     }
   }
 }
  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();
    }
  }
  private void mouseMethod(AWTGLAutoDrawable window, int modifiers, boolean isPress, int x, int y) {
    if ((modifiers & InputEvent.BUTTON1_MASK) != 0) {
      WindowInfo info = (WindowInfo) windowToInfoMap.get(window);

      if (isPress) {
        // Compute ray in 3D
        Vec3f rayStart = new Vec3f();
        Vec3f rayDirection = new Vec3f();
        computeRay(info.params, x, y, rayStart, rayDirection);
        // Compute all hits
        List hits = new ArrayList();
        for (Iterator iter = info.manips.iterator(); iter.hasNext(); ) {
          ((Manip) iter.next()).intersectRay(rayStart, rayDirection, hits);
        }
        // Find closest one
        HitPoint hp = null;
        for (Iterator iter = hits.iterator(); iter.hasNext(); ) {
          HitPoint cur = (HitPoint) iter.next();
          if ((hp == null) || (cur.intPt.getT() < hp.intPt.getT())) {
            hp = cur;
          }
        }
        if (hp != null) {
          if (info.curHighlightedManip != null) {
            info.curHighlightedManip.clearHighlight();
            fireUpdate(info.curHighlightedManip);
            info.curHighlightedManip = null;
          }

          if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
            hp.shiftDown = true;
          }

          hp.manipulator.makeActive(hp);
          info.curManip = hp.manipulator;
          info.dragging = true;
          fireUpdate(info.curManip);
        }
      } else {
        if (info.curManip != null) {
          info.curManip.makeInactive();
          info.dragging = false;
          fireUpdate(info.curManip);
          info.curManip = null;
          // Check to see where mouse is
          passiveMotionMethod(window, x, y);
        }
      }
    }
  }
 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);
 }
 private void ListValueChanged(
     javax.swing.event.ListSelectionEvent evt) { // GEN-FIRST:event_ListValueChanged
   // TODO add your handling code here:
   // String part=partno.getText();
   try {
     String sql =
         "SELECT  TYPE,ITEM_NAME,QUANTITY,MRP FROM MOTORS WHERE ITEM_NAME='"
             + List.getSelectedValue()
             + "'";
     Class.forName("com.mysql.jdbc.Driver");
     Connection con =
         (Connection)
             DriverManager.getConnection("jdbc:mysql://localhost:3306/bharatmotors", "root", "");
     Statement stmt = con.createStatement();
     ResultSet rs = stmt.executeQuery(sql);
     while (rs.next()) {
       partno.setText(rs.getString("TYPE"));
       name.setText(rs.getString("ITEM_NAME"));
       qty.setText(rs.getString("QUANTITY"));
       rate.setText(rs.getString("MRP"));
     }
   } catch (Exception e) {
     JOptionPane.showMessageDialog(null, e.toString());
   }
 } // GEN-LAST:event_ListValueChanged
  public void itemStateChanged(ItemEvent E) {
    // The 'log chat' checkbox
    if (E.getSource() == logChat) {
      server.logChats = logChat.getState();

      // Loop through all of the chat rooms, and set the logging
      // state to be the same as the value of the checkbox
      for (int count = 0; count < server.chatRooms.size(); count++) {
        babylonChatRoom tmp = (babylonChatRoom) server.chatRooms.elementAt(count);
        try {
          tmp.setLogging(server.logChats);
        } catch (IOException e) {
          server.serverOutput(
              server.strings.get(thisClass, "togglelogerror") + " " + tmp.name + "\n");
        }
      }
    }

    // The user list
    if (E.getSource() == userList) {
      // If anything is selected, enable the 'disconnect user'
      // button, otherwise disable it
      synchronized (userList) {
        disconnect.setEnabled(userList.getSelectedItem() != null);
      }
    }
  }
Exemple #23
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;
  }
Exemple #24
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;
  }
Exemple #25
0
  public void setDataset(NetcdfFile ds) {
    this.ds = ds;
    NestedTable nt = nestedTableList.get(0);
    nt.table.setBeans(getVariableBeans(ds));
    hideNestedTable(1);

    datasetTree.setFile(ds);
  }
  protected void control(List nodes) {
    Iterator sel_nodes = nodes.iterator();
    double mid = (X_min + ((X_max - X_min) / 2));

    while (sel_nodes.hasNext()) {
      ((NodeView) sel_nodes.next()).setXPosition(mid);
    }
  }
Exemple #27
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);
 }
Exemple #28
0
 public void actionPerformed(ActionEvent e) {
   List<Resource> loadedDocuments;
   try {
     // get all the documents loaded in the system
     loadedDocuments = Gate.getCreoleRegister().getAllInstances("gate.Document");
   } catch (GateException ge) {
     // gate.Document is not registered in creole.xml....what is!?
     throw new GateRuntimeException(
         "gate.Document is not registered in the creole register!\n"
             + "Something must be terribly wrong...take a vacation!");
   }
   Vector<String> docNames = new Vector<String>();
   for (Resource loadedDocument : new ArrayList<Resource>(loadedDocuments)) {
     if (corpus.contains(loadedDocument)) {
       loadedDocuments.remove(loadedDocument);
     } else {
       docNames.add(loadedDocument.getName());
     }
   }
   JList docList = new JList(docNames);
   docList.getSelectionModel().setSelectionInterval(0, docNames.size() - 1);
   docList.setCellRenderer(renderer);
   final JOptionPane optionPane =
       new JOptionPane(
           new JScrollPane(docList), JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
   final JDialog dialog =
       optionPane.createDialog(CorpusEditor.this, "Add document(s) to this corpus");
   docList.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() == 2) {
             optionPane.setValue(JOptionPane.OK_OPTION);
             dialog.dispose();
           }
         }
       });
   dialog.setVisible(true);
   if (optionPane.getValue().equals(JOptionPane.OK_OPTION)) {
     int[] selectedIndices = docList.getSelectedIndices();
     for (int selectedIndice : selectedIndices) {
       corpus.add((Document) loadedDocuments.get(selectedIndice));
     }
   }
   changeMessage();
 }
Exemple #29
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;
  }
 @Override
 public void setValueAt(Object object, int row, int col) {
   JournalEntry entry = journals.get(row);
   if (col == 0) {
     entry.name = (String) object;
   } else {
     entry.abbreviation = (String) object;
   }
 }