public String getFragmentText() { return StringUtils.discloseDoubleQuotes(getText()); }
public void setSelected(AnActionEvent event, boolean b) { switch (command) { case REFRESH_RESULTSET: { QueryResultPanel resultPanel = getSelectedResultPanel(); if (isConnected && resultPanel instanceof DataGridPanel && resultPanel.isRefreshSupported()) { try { resultPanel.refresh(); } catch (DBException e) { } } break; } case CLOSE_PANEL: close(); break; case STICKY_OPTION: selected ^= true; break; case EXPORT_DATA: { QueryResultPanel resultPanel = getSelectedResultPanel(); if (resultPanel instanceof DataGridPanel) { DataGridPanel grid = (DataGridPanel) resultPanel; JTable _table = grid.getTable(); int numcols = _table.getSelectedColumnCount(); int numrows = _table.getSelectedRowCount(); if (numcols == 0 && numrows == 0) { // nothing to copy return; } ExportSettings settings = new ExportSettings(); settings.show(); if (!settings.isOK()) { return; } File fileToSave = null; if (settings.saveToFile()) { String path = settings.getFilePathToSave(); if (path == null || path.length() == 0) { Messages.showInfoMessage( "File not specified, content will be saved in Clipboard", "File not specified"); // } else if (new File(path).getParentFile().exists()) // { } else { // todo -- fileToSave = new File(path); } } String delimiter; switch (settings.getDelimiter()) { case TAB: delimiter = "\t"; break; case COMMA: delimiter = ","; break; default: // SEMICOLON: delimiter = ";"; break; } String content = extractContent( grid, delimiter, settings.saveColumnHeaders(), settings.encloseFieldsInDowubleQuotes()); if (content != null) { if (fileToSave != null) { // save in the file try { StringUtils.string2file(content, fileToSave); } catch (IOException e) { Messages.showErrorDialog(e.getMessage(), "Export failed"); } } else { // save in Clipboard StringSelection stsel = new StringSelection(content); Clipboard system = Toolkit.getDefaultToolkit().getSystemClipboard(); system.setContents(stsel, stsel); } } } break; } } // notifyListeners(command); }