private String extractContent( DataGridPanel grid, String delimiter, boolean saveHeader, boolean ecloseWithDowbleQuotes) { JTable _table = grid.getTable(); int numcols = _table.getSelectedColumnCount(); int numrows = _table.getSelectedRowCount(); if (numcols > 0 && numrows > 0) { StringBuffer sbf = new StringBuffer(); int[] rowsselected = _table.getSelectedRows(); int[] colsselected = _table.getSelectedColumns(); if (saveHeader) { // put header name list for (int j = 0; j < numcols; j++) { String text = (String) _table .getTableHeader() .getColumnModel() .getColumn(colsselected[j]) .getHeaderValue(); sbf.append(text); if (j < numcols - 1) sbf.append(delimiter); } sbf.append("\n"); } // put content for (int i = 0; i < numrows; i++) { for (int j = 0; j < numcols; j++) { Object value = _table.getValueAt(rowsselected[i], colsselected[j]); String _value = ""; if (value != null) { _value = value.toString(); } if (ecloseWithDowbleQuotes) { sbf.append("\"").append(_value).append("\""); } else { sbf.append(_value); } if (j < numcols - 1) sbf.append(delimiter); } sbf.append("\n"); } // StringSelection stsel = new StringSelection(sbf.toString()); // Clipboard system = Toolkit.getDefaultToolkit().getSystemClipboard(); // system.setContents(stsel, stsel); return sbf.toString(); } return null; }
private void traverseToLeaves( final PackageDependenciesNode treeNode, final StringBuffer denyRules, final StringBuffer allowRules) { final Enumeration enumeration = treeNode.breadthFirstEnumeration(); while (enumeration.hasMoreElements()) { PsiElement childPsiElement = ((PackageDependenciesNode) enumeration.nextElement()).getPsiElement(); if (myIllegalDependencies.containsKey(childPsiElement)) { final Map<DependencyRule, Set<PsiFile>> illegalDeps = myIllegalDependencies.get(childPsiElement); for (final DependencyRule rule : illegalDeps.keySet()) { if (rule.isDenyRule()) { if (denyRules.indexOf(rule.getDisplayText()) == -1) { denyRules.append(rule.getDisplayText()); denyRules.append("\n"); } } else { if (allowRules.indexOf(rule.getDisplayText()) == -1) { allowRules.append(rule.getDisplayText()); allowRules.append("\n"); } } } } } }
public void actionPerformed(final AnActionEvent e) { @NonNls final String delim = " -> "; final StringBuffer buf = new StringBuffer(); processDependencies( getSelectedScope(myLeftTree), getSelectedScope(myRightTree), new Processor<List<PsiFile>>() { public boolean process(final List<PsiFile> path) { if (buf.length() > 0) buf.append("<br>"); buf.append( StringUtil.join( path, new Function<PsiFile, String>() { public String fun(final PsiFile psiFile) { return psiFile.getName(); } }, delim)); return true; } }); final JEditorPane pane = new JEditorPane(UIUtil.HTML_MIME, "<html>" + buf.toString() + "</html>"); pane.setForeground(Color.black); pane.setBackground(HintUtil.INFORMATION_COLOR); pane.setOpaque(true); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(pane); final Dimension dimension = pane.getPreferredSize(); scrollPane.setMinimumSize(new Dimension(dimension.width, dimension.height + 20)); scrollPane.setPreferredSize(new Dimension(dimension.width, dimension.height + 20)); JBPopupFactory.getInstance() .createComponentPopupBuilder(scrollPane, pane) .setTitle("Dependencies") .setMovable(true) .createPopup() .showInBestPositionFor(e.getDataContext()); }
public void generateTo(StringBuffer script) { if (TypeCommand.containsUnicode(myText)) { script.append(KeyCodeTypeCommand.PREFIX).append(" "); for (int i = 0; i < myKeyCodes.size(); i++) { Integer each = myKeyCodes.get(i); script.append(each.toString()); script.append(KeyCodeTypeCommand.MODIFIER_DELIMITER); script.append(myModifiers.get(i)); if (i < myKeyCodes.size() - 1) { script.append(KeyCodeTypeCommand.CODE_DELIMITER); } } script.append(" ").append(myText).append("\n"); } else { script.append(myText); script.append("\n"); } }
public void generateTo(StringBuffer script) { script.append("%action ").append(getActionId()).append("\n"); }
public void generateTo(StringBuffer script) { script.append("%[").append(myKeyStroke).append("]\n"); }
@NotNull private Pattern getPattern(String pattern) { if (!Comparing.strEqual(pattern, myPattern)) { myCompiledPattern = null; myPattern = pattern; } if (myCompiledPattern == null) { boolean allowToLower = true; final int eol = pattern.indexOf('\n'); if (eol != -1) { pattern = pattern.substring(0, eol); } if (pattern.length() >= 80) { pattern = pattern.substring(0, 80); } final @NonNls StringBuffer buffer = new StringBuffer(); if (containsOnlyUppercaseLetters(pattern)) { allowToLower = false; } if (allowToLower) { buffer.append(".*"); } boolean firstIdentifierLetter = true; for (int i = 0; i < pattern.length(); i++) { final char c = pattern.charAt(i); if (Character.isLetterOrDigit(c)) { // This logic allows to use uppercase letters only to catch the name like PDM for // PsiDocumentManager if (Character.isUpperCase(c) || Character.isDigit(c)) { if (!firstIdentifierLetter) { buffer.append("[^A-Z]*"); } buffer.append("["); buffer.append(c); if (allowToLower || i == 0) { buffer.append('|'); buffer.append(Character.toLowerCase(c)); } buffer.append("]"); } else if (Character.isLowerCase(c)) { buffer.append('['); buffer.append(c); buffer.append('|'); buffer.append(Character.toUpperCase(c)); buffer.append(']'); } else { buffer.append(c); } firstIdentifierLetter = false; } else if (c == '*') { buffer.append(".*"); firstIdentifierLetter = true; } else if (c == '.') { buffer.append("\\."); firstIdentifierLetter = true; } else if (c == ' ') { buffer.append("[^A-Z]*\\ "); firstIdentifierLetter = true; } else { firstIdentifierLetter = true; // for standard RegExp engine // buffer.append("\\u"); // buffer.append(Integer.toHexString(c + 0x20000).substring(1)); // for OROMATCHER RegExp engine buffer.append("\\x"); buffer.append(Integer.toHexString(c + 0x20000).substring(3)); } } buffer.append(".*"); try { myCompiledPattern = new Perl5Compiler().compile(buffer.toString()); } catch (MalformedPatternException e) { // do nothing } } return myCompiledPattern; }