@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); } }
public void dbRemoveElement(int id) { lm.remove(id); dbItems.remove(id); dbItemsK.remove(id); dbItemsK2.remove(id); this.setModel(lm); }
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); } }
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; }
/** * Removes a <tt>ConfigurationForm</tt> from this list. * * @param configForm The <tt>ConfigurationForm</tt> to remove. */ public void removeConfigForm(ConfigurationForm configForm) { DefaultListModel listModel = (DefaultListModel) configList.getModel(); for (int count = listModel.getSize(), i = count - 1; i >= 0; i--) { ConfigurationForm form = (ConfigurationForm) listModel.get(i); if (form.equals(configForm)) { listModel.remove(i); /* * TODO We may just consider not allowing duplicates on addition * and then break here. */ } } }
public void removeTileButton(int index) { tiles.remove(index); DefaultListModel lm = (DefaultListModel) gui.tileList.getModel(); lm.remove(index); gui.tileList.setModel(lm); }
private void subZListBoxEintrag() { if (zielJList.getSelectedIndex() < 0) return; else zielListModel.remove(zielJList.getSelectedIndex()); if (zielListModel.getSize() > 0) zielJList.setSelectedIndex(zielListModel.getSize() - 1); }
private void subQListBoxEintrag() { if (quellJList.getSelectedIndex() < 0) return; else quellListModel.remove(quellJList.getSelectedIndex()); if (quellListModel.getSize() > 0) quellJList.setSelectedIndex(quellListModel.getSize() - 1); }
public void actionPerformed(ActionEvent e) { if (e.getSource() == remoteAppletPath) {//apparently no events are fired to reach this, maybe "enter" does it String path = remoteAppletPath.getText(); WebExport.setAppletPath(path, true); return; } if (e.getSource() == localAppletPath) {//apparently no events are fired to reach this, maybe "enter" does it String path = localAppletPath.getText(); WebExport.setAppletPath(path, false); return; } //Handle open button action. if (e.getSource() == addInstanceButton) { //make dialog to get name for instance //create an instance with this name. Each instance is just a container for a string with the Jmol state //which contains the full information on the file that is loaded and manipulations done. String label = (instanceList.getSelectedIndices().length != 1 ? "" : getInstanceName(-1)); String name = JOptionPane.showInputDialog( GT._("Give the occurrence of Jmol a name:"), label); if (name == null) return; //need to get the script... String script = viewer.getStateInfo(); if (script == null) { LogPanel.log("Error trying to get Jmol State within pop_in_Jmol."); } DefaultListModel listModel = (DefaultListModel) instanceList.getModel(); int width = 300; int height = 300; if (appletSizeSpinnerH != null) { width = ((SpinnerNumberModel) (appletSizeSpinnerW.getModel())) .getNumber().intValue(); height = ((SpinnerNumberModel) (appletSizeSpinnerH.getModel())) .getNumber().intValue(); } JmolInstance instance = new JmolInstance(viewer, name, script, width, height); if (instance == null) { LogPanel .log(GT._("Error creating new instance containing script(s) and image.")); } int i; for (i = instanceList.getModel().getSize(); --i >= 0;) if (getInstanceName(i).equals(instance.name)) break; if (i < 0) { i = listModel.getSize(); listModel.addElement(instance); LogPanel.log(GT._("added Instance {0}", instance.name)); } else { listModel.setElementAt(instance, i); LogPanel.log(GT._("updated Instance {0}", instance.name)); } instanceList.setSelectedIndex(i); syncLists(); return; } if (e.getSource() == deleteInstanceButton) { DefaultListModel listModel = (DefaultListModel) instanceList.getModel(); //find out which are selected and remove them. int[] todelete = instanceList.getSelectedIndices(); int nDeleted = 0; for (int i = 0; i < todelete.length; i++){ JmolInstance instance = (JmolInstance) listModel.get(todelete[i]); try { instance.delete(); } catch (IOException err) { LogPanel.log(err.getMessage()); } listModel.remove(todelete[i] - nDeleted++); } syncLists(); return; } if (e.getSource() == showInstanceButton) { DefaultListModel listModel = (DefaultListModel) instanceList.getModel(); //find out which are selected and remove them. int[] list = instanceList.getSelectedIndices(); if (list.length != 1) return; JmolInstance instance = (JmolInstance) listModel.get(list[0]); viewer.evalStringQuiet(")" + instance.script); //leading paren disabled history return; } if (e.getSource() == saveButton) { fc.setDialogTitle(GT._("Select a directory to create or an HTML file to save")); int returnVal = fc.showSaveDialog(this); if (returnVal != JFileChooser.APPROVE_OPTION) return; File file = fc.getSelectedFile(); boolean retVal = true; try { String path = remoteAppletPath.getText(); WebExport.setAppletPath(path, true); path = localAppletPath.getText(); WebExport.setAppletPath(path, false); String authorName = pageAuthorName.getText(); WebExport.setWebPageAuthor(authorName); retVal = fileWriter(file, instanceList); } catch (IOException IOe) { LogPanel.log(IOe.getMessage()); } if (!retVal) { LogPanel.log(GT._("Call to FileWriter unsuccessful.")); } } if (e.getSource() == helpButton){ HelpDialog webExportHelp = new HelpDialog(WebExport.getFrame(), WebExport.getHtmlResource(this, panelName + "_instructions")); webExportHelp.setVisible(true); webExportHelp.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); } }