void (@NotNull DataContext dataContext) { TableView<EnvironmentVariable> view = getTableView(); if (view.isEditing()) { int row = view.getEditingRow(); int column = view.getEditingColumn(); if (row < 0 || column < 0) { row = view.getSelectedRow(); column = view.getSelectedColumn(); } if (row >= 0 && column >= 0) { Component component = ((DefaultCellEditor)view.getCellEditor()).getComponent(); String text = ""; if (component instanceof JTextField) { text = ((JTextField)component).getSelectedText(); } else if (component instanceof JComboBox<?>) { text = ((JTextField)((JComboBox<?>)component).getEditor().getEditorComponent()).getSelectedText(); } else { Logger.getInstance(EnvVariablesTable.class).error("Unknown editor type: " + component); } CopyPasteManager.getInstance().setContents(new StringSelection(text)); } return; } stopEditing(); StringBuilder sb = new StringBuilder(); List<EnvironmentVariable> variables = getSelection(); for (EnvironmentVariable environmentVariable : variables) { if (isEmpty(environmentVariable)) continue; if (sb.length() > 0) sb.append(';'); sb.append(StringUtil.escapeChars(environmentVariable.getName(), '=', ';')).append('=') .append(StringUtil.escapeChars(environmentVariable.getValue(), '=', ';')); } CopyPasteManager.getInstance().setContents(new StringSelection(sb.toString())); }