@Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { Control c = data.get(rowIndex); if (columnIndex == 1) { c.setDescription((String) aValue); } else { } }
@Override public Object getValueAt(int rowIndex, int columnIndex) { Control c = data.get(rowIndex); if (columnIndex == 0) { return ImportExport.getStringFromControlKeys(new ArrayList<KeysEvent>(c.getKeysEvents()), -1); } if (columnIndex == 1) { return c.getDescription(); } return ""; }
public static ControlInterface[] getControlMultiCommand( App app, String name, List<Integer> repeat, List<Set<Integer>> keys, Integer row, Integer position) { Control c = new Control(name.toLowerCase()); int i = 0; for (Set<Integer> k : keys) { KeysEvent keysEvent = new KeysEvent(k, repeat.get(i++)); c.addKeysEvent(keysEvent); } c.validate(); VisualControl vc = new VisualControl(c, row, position); vc.validate(); if (app != null) { app.getControlsManager().addControl(c); app.getVisualControlsManager().addControl(vc); } return new ControlInterface[] {c, vc}; }
public void addControl() { Control c = new Control("name"); c.addKeysEvent(new KeysEvent(65)); data.add(c); fireTableRowsInserted(data.size() - 1, data.size() - 1); }
private void btnEditAppSaveActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnEditAppSaveActionPerformed Persistable p = panelListPersistable.getSelectedItem(); if (p != null) { App app = (App) p; app.setName(textFieldNameApp.getText()); // app.setDescription(textFieldDescriptionCategory.getText()); app.setExtensions(new HashSet<>(Arrays.asList(textFieldExtensionsApp.getText().split(",")))); app.setForceOneInstance(checkInstanceApp.isSelected()); app.setArgumentsFile(textFieldArgFileApp.getText()); app.setArgumentsDir(textFieldArgDirApp.getText()); app.setPath(textFieldPathApp.getText()); app.setWindowName(comboWindowName.getSelectedItem().toString()); // determining app.relativePath if (!Utils.isEmpty(app.getPath())) { Map<String, String> env = System.getenv(); for (String commonPath : PcControllerFactory.getPcController().getBinDefaultPaths()) { if (commonPath.startsWith("%")) { String s = commonPath.substring(1, commonPath.length() - 1); for (String k : env.keySet()) { if (k.equalsIgnoreCase(s.toUpperCase())) { commonPath = env.get(k); break; } } } if (!Utils.isEmpty(commonPath)) { if (app.getPath().startsWith(commonPath)) { String relativePath = app.getPath().substring(commonPath.length()); if (relativePath.startsWith("" + File.separatorChar)) { relativePath = relativePath.substring(1); } app.setRelativePath(relativePath); break; } } } } ControlsManager controlsManager = app.getControlsManager(); VisualControlsManager visualControlsManager = app.getVisualControlsManager(); // controlsManager.clear(); // visualControlsManager.clear(); Iterator<Control> it = controlsManager.getControls().iterator(); while (it.hasNext()) { Control control = it.next(); if (((AppControlsTableModel) tableControls.getModel()).getControlPosition(control)[0] == -1) { it.remove(); } } for (int i = 0; i < tableControls.getRowCount(); i++) { Control c = (Control) ((AppControlsTableModel) tableControls.getModel()).getControlAt(i, -1); if (c != null) { c.clean(); if (!c.isEmpty()) { try { c.validate(); } catch (IllegalArgumentException e) { // TODO e.printStackTrace(); } if (c.getId() == null) { controlsManager.addControl(c); } } } } Iterator<VisualControl> it2 = visualControlsManager.getControls().iterator(); while (it2.hasNext()) { VisualControl control = it2.next(); boolean found = false; for (int i = 0; i < tableVisualControls.getRowCount(); i++) { for (int j = 0; j < tableVisualControls.getColumnCount(); j++) { VisualControl c = (VisualControl) tableVisualControls.getModel().getValueAt(i, j); if (control == c) { found = true; break; } } } if (!found) { it2.remove(); } } for (int i = 0; i < tableVisualControls.getRowCount(); i++) { for (int j = 0; j < tableVisualControls.getColumnCount(); j++) { VisualControl c = (VisualControl) tableVisualControls.getModel().getValueAt(i, j); if (c != null) { try { c.validate(); } catch (IllegalArgumentException e) { // TODO e.printStackTrace(); } if (c.getId() == null) { visualControlsManager.addControl(c); } } } } } panelListPersistable.clearSelection(); } // GEN-LAST:event_btnEditAppSaveActionPerformed