private void parseDirective(String directive) { if (directive == null) { System.err.println("Directive is null."); return; } String[] pair = directive.split("="); if (pair == null || pair.length != 2) { System.err.println("Unable to parse directive: \"" + directive + "\" Ignored."); return; } String key = pair[0].trim(), value = pair[1].trim(); // clean these, might have too much whitespace around commas if (validKeys.indexOf(key) == FONT || validKeys.indexOf(key) == PRELOAD) { value = value.replaceAll("[\\s]*,[\\s]*", ","); } if (validKeys.indexOf(key) == -1) { System.err.println("Directive key not recognized: \"" + key + "\" Ignored."); return; } if (value.equals("")) { System.err.println("Directive value empty. Ignored."); return; } value = value.replaceAll("^\"|\"$", "").replaceAll("^'|'$", ""); // System.out.println( key + " = " + value ); boolean v; switch (validKeys.indexOf(key)) { case CRISP: v = value.toLowerCase().equals("true"); crispBox.setSelected(v); break; case FONT: fontField.setText(value); break; case GLOBAL_KEY_EVENTS: v = value.toLowerCase().equals("true"); globalKeyEventsBox.setSelected(v); break; case PAUSE_ON_BLUR: v = value.toLowerCase().equals("true"); pauseOnBlurBox.setSelected(v); break; case PRELOAD: preloadField.setText(value); break; case TRANSPARENT: v = value.toLowerCase().equals("true"); // transparentBox.setSelected(v); break; } }
void handleScanFiles(JTextField field, String[] extensions) { String[] dataFiles = scanDataFolderForFilesByType(extensions); if (dataFiles == null || dataFiles.length == 0) return; String[] oldFileList = field.getText().trim().split(","); ArrayList<String> newFileList = new ArrayList<String>(); for (String c : oldFileList) { c = c.trim(); if (!c.equals("") && newFileList.indexOf(c) == -1) // TODO check exists() here? { newFileList.add(c); } } for (String c : dataFiles) { c = c.trim(); if (!c.equals("") && newFileList.indexOf(c) == -1) { newFileList.add(c); } } Collections.sort(newFileList); String finalFileList = ""; int i = 0; for (String s : newFileList) { finalFileList += (i > 0 ? ", " : "") + s; i++; } field.setText(finalFileList); }
void profileList_mouseClicked(MouseEvent e) { JList theList = (JList) e.getSource(); ListModel aModel = theList.getModel(); int index = theList.locationToIndex(e.getPoint()); if (index < 0) return; UniProfile aProfile = (UniProfile) aModel.getElementAt(index); nameTextField.setText(aProfile.toString()); }
private void resetInterface() { for (JCheckBox b : new JCheckBox[] {crispBox, globalKeyEventsBox, pauseOnBlurBox /*, transparentBox*/}) { b.setSelected(false); } for (JTextField f : new JTextField[] {fontField, preloadField}) { f.setText(""); } }
private void myInit2( SanBootView _view, Backupable _bakable, int _mode, int _type, BootHost host) { view = _view; bakable = _bakable; mode = _mode; type = _type; setupProfileType(); setupList(); setupLanguage(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); Date date = new Date(); String time = df.format(date); System.out.println(host.getID() + "-" + time); nameTextField.setText(host.getID() + "-" + time); if (mode == ProfileChooser.MODE_SAVEAS || mode == ProfileChooser.MODE_SAVE) { saveAsProfile = new UniProfile(); nameTextField.requestFocus(); } }