public void save() { for (String key : fields.keySet()) { JComponent comp = fields.get(key); if (comp instanceof JTextField) { JTextField c = (JTextField) comp; if (c.getText().trim().equals("")) { sketch.configFile.unset(key); } else { sketch.configFile.set(key, c.getText()); } } else if (comp instanceof JTextArea) { JTextArea c = (JTextArea) comp; if (c.getText().trim().equals("")) { sketch.configFile.unset(key); } else { sketch.configFile.set(key, c.getText()); } } } sketch.saveConfig(); }
public void setObjectValues() { ((JTextField) (fields.get("board"))).setText(sketch.getBoard().getName()); ((JTextField) (fields.get("core"))).setText(sketch.getCore().getName()); ((JTextField) (fields.get("compiler"))).setText(sketch.getCompiler().getName()); ((JTextField) (fields.get("port"))).setText(sketch.getDevice().toString()); ((JTextField) (fields.get("programmer"))).setText(sketch.getProgrammer()); }
public void add(Transferable t) { DataFlavor[] f = t.getTransferDataFlavors(); for (int i = 0; i < f.length; i++) { if (!transferables.containsKey(f[i])) { flavors.add(f[i]); } transferables.put(f[i], t); } }
/** * Returns an object which represents the data to be transferred. The class of the object returned * is defined by the representation class of the flavor. * * @param flavor the requested flavor for the data * @see DataFlavor#getRepresentationClass * @exception IOException if the data is no longer available in the requested flavor. * @exception UnsupportedFlavorException if the requested data flavor is not supported. */ @Override public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { Transferable t = (Transferable) transferables.get(flavor); if (t == null) { throw new UnsupportedFlavorException(flavor); } return t.getTransferData(flavor); }
void addTextField(JPanel panel, String key, String label) { JLabel lab = new JLabel(label); lab.setAlignmentX(LEFT_ALIGNMENT); panel.add(lab); JTextField field = new JTextField(); field.setText(sketch.configFile.get(key)); field.setMaximumSize(new Dimension(Integer.MAX_VALUE, field.getPreferredSize().height)); fields.put(key, field); panel.add(field); }
void addTextArea(JPanel panel, String key, String label) { JLabel lab = new JLabel(label); lab.setAlignmentX(LEFT_ALIGNMENT); panel.add(lab); JTextArea field = new JTextArea(); field.setText(sketch.configFile.get(key)); field.setLineWrap(true); field.setWrapStyleWord(true); fields.put(key, field); JScrollPane scroll = new JScrollPane(field); scroll.setAlignmentX(0.0f); panel.add(scroll); }
/** Reads in the property file. */ static { try { final String file = "/completions.properties"; final InputStream is = TextPanel.class.getResourceAsStream(file); if (is == null) { Util.errln(file + " not found."); } else { try (final NewlineInput nli = new NewlineInput(is)) { for (String line; (line = nli.readLine()) != null; ) { final int i = line.indexOf('='); if (i == -1 || line.startsWith("#")) continue; final String key = line.substring(0, i), value = line.substring(i + 1); if (REPLACE.put(key, value.replace("\\n", "\n")) != null) { Util.errln(file + ": " + key + " was assigned twice"); } } } } } catch (final IOException ex) { Util.errln(ex); } }
public static String getInfo(String item) { return pluginInfo.get(item); }
/** * Returns whether or not the specified data flavor is supported for this object. * * @param flavor the requested flavor for the data * @return boolean indicating wjether or not the data flavor is supported */ @Override public boolean isDataFlavorSupported(DataFlavor flavor) { return transferables.containsKey(flavor); }
/** * Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The * array should be ordered according to preference for providing the data (from most richly * descriptive to least descriptive). * * @return an array of data flavors in which this data can be transferred */ @Override public DataFlavor[] getTransferDataFlavors() { return (DataFlavor[]) flavors.toArray(new DataFlavor[transferables.size()]); }