@SuppressWarnings("unchecked") public void addSource(File file, boolean resolve) { // TODO: put in some whitelist / blacklist parameters if (resolve && file.isDirectory()) { // resolve the /src/main/java portion of source directories. File next = new File(file, "src"); if (next.exists()) { file = next; next = new File(file, "main"); if (next.exists()) { file = next; next = new File(file, "java"); if (next.exists()) { file = next; } } } } if (file.isDirectory() || file.toString().endsWith(".jar")) { int was = dir.indexOf(file); if (was > -1) { dir.remove(was); } dir.add(dir.getSize(), file); } }
/** Fetch movie names from the database and display them in the name list. */ private void fillNameList() { nameListModel.removeAllElements(); ArrayList<String> list = db.getMovies(); for (String s : list) { nameListModel.addElement(s); } }
public void updateHelper() { if (model.GuessORHint == 0) { label1.setText("Entered:"); } if (model.GuessORHint == 1) { label1.setText("Hints:"); } DefaultListModel<String> listTemp = new DefaultListModel<String>(); if (model.GuessORHint == 0) { for (String str : model.haveEntered) { listTemp.addElement(str); } } else { if (model.hintWords != null) { for (String MM : model.hintWords) { if (MM == null) { listTemp.addElement("APPLE"); } else { listTemp.addElement(MM); } } } } list.setModel(listTemp); scroll.setViewportView(list); }
protected DictionaryWindow(MainFrame parent) { super(parent, true); setTitle("Dictionary"); setBounds(new Rectangle(0, 0, 330, 330)); JPanel mainPanel = new JPanel(new BorderLayout()); DefaultListModel<String> listModel = new DefaultListModel<String>(); JList<String> list = new JList<String>(listModel); JScrollPane scroll = new JScrollPane(list); for (String word : parent.dictionary.getSortedDictionary()) listModel.addElement(word); JButton ok = new JButton("OK"); ok.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); mainPanel.add(scroll, BorderLayout.CENTER); mainPanel.add(ok, BorderLayout.SOUTH); add(mainPanel); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setLocationRelativeTo(null); setVisible(true); }
protected void exportDone(JComponent c, Transferable data, int action) { //System.out.println("action="+action + " " + addCount + " " + sourceIndices); if ((action == MOVE) && (sourceIndices != null)) { DefaultListModel model = (DefaultListModel) source.getModel(); //If we are moving items around in the same list, we //need to adjust the indices accordingly since those //after the insertion point have moved. if (addCount > 0) { for (int i = 0; i < sourceIndices.length; i++) { if (sourceIndices[i] > addIndex) { sourceIndices[i] += addCount; } } } for (int i = sourceIndices.length - 1; i >= 0; i--) model.remove(sourceIndices[i]); ((JList) c).setSelectedIndices(new int[] {}); if (webPanel != null) webPanel.syncLists(); } sourceIndices = null; addIndex = -1; addCount = 0; }
private void updateButtons() { int index = list.getSelectedIndex(); remove.setEnabled(index != -1 && listModel.getSize() != 0); moveUp.setEnabled(index > 0); moveDown.setEnabled(index != -1 && index != listModel.getSize() - 1); edit.setEnabled(index != -1); }
private void fillList(final HighlightSeverity severity) { DefaultListModel model = new DefaultListModel(); model.removeAllElements(); final List<SeverityBasedTextAttributes> infoTypes = new ArrayList<SeverityBasedTextAttributes>(); infoTypes.addAll(SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar)); Collections.sort( infoTypes, new Comparator<SeverityBasedTextAttributes>() { @Override public int compare( SeverityBasedTextAttributes attributes1, SeverityBasedTextAttributes attributes2) { return -mySeverityRegistrar.compare( attributes1.getSeverity(), attributes2.getSeverity()); } }); SeverityBasedTextAttributes preselection = null; for (SeverityBasedTextAttributes type : infoTypes) { model.addElement(type); if (type.getSeverity().equals(severity)) { preselection = type; } } myOptionsList.setModel(model); myOptionsList.setSelectedValue(preselection, true); }
public void update(Observable o, Object arg) { if (arg != null && arg instanceof ISOMsg) { ISOMsg m = (ISOMsg) arg; log.addElement(m); if (log.getSize() > LOG_CAPACITY) log.remove(0); } }
/** Description of the Method */ public void removeAllElements() { for (Enumeration<BPM_Element> e = listModel.elements(); e.hasMoreElements(); ) { BPM_Element elm = e.nextElement(); elm.stopMonitor(); } listModel.removeAllElements(); }
public void addClass() { int varNo = listObject.getSize(); int opNo = listMethod.getSize(); ClassDiagData cDD = new ClassDiagData(); cDD.setClassName(className.getText()); for (int i = 0; i < varNo; i++) { cDD.addInstanceVar( listObject .get(i) .toString()); // Create new data input 'template' and populate with use inputted data } for (int i = 0; i < opNo; i++) { cDD.addMethod( listMethod .get(i) .toString()); // Create new data input 'template' and populate with use inputted data } cDD.setAccessModifier("+"); ClassDiag e = new ClassDiag(x, y, varNo, opNo); // Create a new class object and set the details of it e.setData(cDD); // Set the associated data with from the cDD. canvasPanel.addDrawable(e); canvasPanel.repaint(); canvasPanel.setStatus("Class Created Successfully"); }
protected void init() { super.init(); java.util.List<Macro> macros = new ArrayList<Macro>(MacroManager.getInstance().getMacros()); Collections.sort( macros, new Comparator<Macro>() { public int compare(Macro macro1, Macro macro2) { String name1 = macro1.getName(); String name2 = macro2.getName(); if (!StringUtil.startsWithChar(name1, '/')) { name1 = ZERO + name1; } if (!StringUtil.startsWithChar(name2, '/')) { name2 = ZERO + name2; } return name1.compareToIgnoreCase(name2); } private final String ZERO = new String(new char[] {0}); }); for (Macro macro : macros) { myMacrosModel.addElement(new MacroWrapper(macro)); } addListeners(); if (myMacrosModel.size() > 0) { myMacrosList.setSelectedIndex(0); } else { setOKActionEnabled(false); } }
private void updateFrameList(ThreadReferenceProxyImpl thread) { try { if (!getSuspendContext().getDebugProcess().getSuspendManager().isSuspended(thread)) { return; } } catch (ObjectCollectedException e) { return; } final EvaluationContextImpl evaluationContext = getDebuggerContext().createEvaluationContext(); final List<StackFrameDescriptorImpl> descriptors = new ArrayList<StackFrameDescriptorImpl>(); synchronized (myFramesList) { final DefaultListModel model = myFramesList.getModel(); final int size = model.getSize(); for (int i = 0; i < size; i++) { final Object elem = model.getElementAt(i); if (elem instanceof StackFrameDescriptorImpl) { descriptors.add((StackFrameDescriptorImpl) elem); } } } for (StackFrameDescriptorImpl descriptor : descriptors) { descriptor.setContext(evaluationContext); descriptor.updateRepresentation(evaluationContext, DescriptorLabelListener.DUMMY_LISTENER); } }
private void populateActiveKitList() { // populate the active kits list with the current kits available in the factory listModel.removeAllElements(); for (Integer i : kits.keySet()) { Kits currentKit = kits.get(i); listModel.addElement(currentKit); } }
public List<BufferedImage> getExamples() { List<BufferedImage> list = new ArrayList<BufferedImage>(); for (int i = 0; i < model.size(); i++) { Example example = (Example) model.get(i); list.add(example.getBufferedImage()); } return list; }
/** Called to populate the List of users */ private void populateUsers() { listModel.clear(); users = control.list_users(); for (int i = 0; i < users.length; i++) { listModel.addElement(users[i]); } userList.setSelectedIndex(0); }
private void getNewDataModel() { if (listModel.size() != 0) listModel.removeAllElements(); if (rssFeed != null) { for (Data row = rssFeed.resetCursor(); row != null; row = rssFeed.next()) listModel.addElement(row.getTitle()); } }
/** List results by alphabetical name */ private void listByProgramName() { int nresult = datasets.size(); String res[] = new String[nresult]; for (int i = 0; i < nresult; i++) res[i] = (String) datasets.getElementAt(i); Arrays.sort(res); datasets.removeAllElements(); for (int i = 0; i < nresult; i++) datasets.addElement(res[i]); }
public void setPluginHosts(final List<String> pluginHosts) { final DefaultListModel model = (DefaultListModel) myUrlsList.getModel(); model.clear(); for (String host : pluginHosts) { //noinspection unchecked model.addElement(host); } }
/** * Adds the given Bean to the collection of Beans with preferences editors. When the dialog box is * opened, the editor associated with the Bean will be included in the GUI. */ public void addPrefsBean(BeanPreferences bean) { mPrefsBeans.add(bean); mTabbedViewPane.add(new JScrollPane(bean.getEditor()), bean.getEditorName()); bean.initPrefsGUI(); mTabbedViewPane.revalidate(); DefaultListModel model = (DefaultListModel) mListViewBeans.getModel(); model.addElement(bean.getEditorName()); }
/** Fetch performance dates from the database and display them in the date list. */ private void fillDateList(String movieName) { dateListModel.removeAllElements(); /* --- insert own code here --- */ ArrayList<String> list = db.getShowdates(movieName); for (String s : list) { dateListModel.addElement(s); } }
private int findPos(DefaultListModel lm, String item) { for (int i = 0; i < lm.size(); i++) { String s = (String) lm.get(i); if (item.compareToIgnoreCase(s) < 0) { // item precedes s return i; } } return lm.size(); }
private UniProfile isSameProfile(String name) { int size = model.getSize(); for (int i = 0; i < size; i++) { UniProfile aProfile = (UniProfile) model.getElementAt(i); if (aProfile.toString().equals(name)) return aProfile; } return null; }
/** This method loads the names of the state groups that have been defined so far */ private static void populateStateGroupsList() { StateLabelManager.updateAvailableStateGroups(); String[] stateGrpNames = StateLabelManager.getStateNames(StateLabelManager.availableStateGroups); DefaultListModel model = new DefaultListModel(); for (String stateName : stateGrpNames) { model.addElement(stateName); } StateLabelManager.stateGroupsList.setModel(model); }
public void populate(List<String> items) { model.clear(); Iterator<String> iterator = items.iterator(); while (iterator.hasNext()) { String item = iterator.next(); model.addElement(item); } }
/** * Methode, um die ausgewählten Objekte zu übergeben. * * @param objects die ausgewählten Objekte */ private void setObjects(List<SystemObject> objects) { _objects.clear(); _objects.addAll(objects); if (_objects.size() >= 1) { DefaultListModel defaultListModel = new DefaultListModel(); for (Iterator iterator = _objects.iterator(); iterator.hasNext(); ) { defaultListModel.addElement(iterator.next()); } _objList.setModel(defaultListModel); } }
private static Object objectOf(DefaultListModel listModel, Object objectName) { if (objectName instanceof String) { String name = (String) objectName; Object o; for (int i = listModel.size(); --i >= 0;) if (!((o = listModel.get(i)) instanceof String) && o.toString().equals(name)) return listModel.get(i); } return objectName; }
public void invertSelection() { int[] sel = this.list.getSelectedIndices(); int[] newSel = new int[listModel.getSize() - sel.length]; int idx = 0; int lastIdx = -1; for (int i : sel) { for (int i2 = lastIdx + 1; i2 < i; i2++) newSel[idx++] = i2; lastIdx = i; } for (int i2 = lastIdx + 1; i2 < listModel.getSize(); i2++) newSel[idx++] = i2; list.setSelectedIndices(newSel); }
private void register() { if (session != null && session.isConnected()) { onlineUsers.clear(); // get the current list Message msg = session.sendMessage("", "list", ""); System.out.println("LIST: " + msg.getBody()); StringTokenizer st = new StringTokenizer(msg.getBody(), "\n"); while (st.hasMoreTokens()) { onlineUsers.addElement(new HostItem(st.nextToken())); } session.postMessage("", "register", ""); } }
public void addTileButton() { DefaultListModel lm = (DefaultListModel) gui.tileList.getModel(); if (gui.tileList.getSelectedIndex() == -1) { tiles.add(ctx.players.local().tile()); lm.addElement(ctx.players.local().tile().x() + ", " + ctx.players.local().tile().y()); } else { tiles.add(gui.tileList.getSelectedIndex() + 1, ctx.players.local().tile()); lm.add( gui.tileList.getSelectedIndex() + 1, ctx.players.local().tile().x() + ", " + ctx.players.local().tile().y()); } gui.tileList.setModel(lm); }
/** * List results by date * * @param reslist result list * @param ldisp */ private void listByDateRun(ResultList reslist, boolean ldisp) { StringTokenizer tokenizer = new StringTokenizer((String) reslist.get("list"), "\n"); Vector vdata = new Vector(); while (tokenizer.hasMoreTokens()) { String data = convertToPretty(tokenizer.nextToken()); if (datasets.contains(data) || ldisp) vdata.add(data); } datasets.removeAllElements(); Enumeration en = vdata.elements(); while (en.hasMoreElements()) datasets.addElement(en.nextElement()); }