List of usage examples for org.apache.commons.lang StringUtils repeat
public static String repeat(String str, int repeat)
Repeat a String repeat
times to form a new String.
From source file:com.github.fritaly.dualcommander.DualCommander.java
public DualCommander() { // TODO Generate a fat jar at build time super(String.format("Dual Commander %s", Utils.getApplicationVersion())); if (logger.isInfoEnabled()) { logger.info(String.format("Dual Commander %s", Utils.getApplicationVersion())); }/*from w ww.ja va 2s . co m*/ try { // Apply the JGoodies L&F UIManager.setLookAndFeel(new WindowsLookAndFeel()); } catch (Exception e) { // Not supposed to happen } // Layout, columns & rows setLayout(new MigLayout("insets 0px", "[grow]0px[grow]", "[grow]0px[]")); // Create a menu bar final JMenu fileMenu = new JMenu("File"); fileMenu.add(new JMenuItem(preferencesAction)); fileMenu.add(new JSeparator()); fileMenu.add(new JMenuItem(quitAction)); final JMenu helpMenu = new JMenu("Help"); helpMenu.add(new JMenuItem(aboutAction)); final JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(helpMenu); setJMenuBar(menuBar); this.leftPane = new TabbedPane(preferences); this.leftPane.setName("Left"); this.leftPane.addChangeListener(this); this.leftPane.addKeyListener(this); this.leftPane.addFocusListener(this); this.rightPane = new TabbedPane(preferences); this.rightPane.setName("Right"); this.rightPane.addChangeListener(this); this.rightPane.addKeyListener(this); this.rightPane.addFocusListener(this); // Adding the 2 components to the same sizegroup ensures they always // keep the same width getContentPane().add(leftPane, "grow, sizegroup g1"); getContentPane().add(rightPane, "grow, sizegroup g1, wrap"); // The 7 buttons must all have the same width (they must belong to the // same size group) final JPanel buttonPanel = new JPanel( new MigLayout("insets 0px", StringUtils.repeat("[grow, sizegroup g1]", 7), "[grow]")); buttonPanel.add(viewButton, "grow"); buttonPanel.add(editButton, "grow"); buttonPanel.add(copyButton, "grow"); buttonPanel.add(moveButton, "grow"); buttonPanel.add(mkdirButton, "grow"); buttonPanel.add(deleteButton, "grow"); buttonPanel.add(quitButton, "grow"); getContentPane().add(buttonPanel, "grow, span 2"); // Register shortcuts at a global level (not on every component) final InputMap inputMap = this.leftPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0, true), "view"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0, true), "edit"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0, true), "copy"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0, true), "move"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0, true), "mkdir"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0, true), "delete"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, KeyEvent.ALT_DOWN_MASK), "quit"); final ActionMap actionMap = this.leftPane.getActionMap(); actionMap.put("view", viewAction); actionMap.put("edit", editAction); actionMap.put("copy", copyAction); actionMap.put("move", moveAction); actionMap.put("mkdir", mkdirAction); actionMap.put("delete", deleteAction); actionMap.put("quit", quitAction); addWindowListener(this); addKeyListener(this); // Listen to preference change events this.preferences.addPropertyChangeListener(this); // Reload the last configuration and init the left & right panels // accordingly final Preferences prefs = Preferences.userNodeForPackage(this.getClass()); // The user preferences must be loaded first because they're needed to // init the UI this.preferences.init(prefs.node("user.preferences")); this.leftPane.init(prefs.node("left.panel")); this.rightPane.init(prefs.node("right.panel")); if (logger.isInfoEnabled()) { logger.info("Loaded preferences"); } // Init the buttons refreshButtons(this.leftPane.getActiveBrowser().getSelection()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setExtendedState(JFrame.MAXIMIZED_BOTH); if (logger.isInfoEnabled()) { logger.info("UI initialized"); } }
From source file:com.jaxio.celerio.maven.plugin.bootstrap.BootstrapMojo.java
/** * Print the passed instruction in the console. *//* w w w. j a v a 2 s. c om*/ private void printInstruction(String instruction) { System.out.println(StringUtils.repeat("-", instruction.length())); System.out.println(instruction); System.out.println(StringUtils.repeat("-", instruction.length())); }
From source file:com.netscape.cmstools.cli.MainCLI.java
public static void printMessage(String message) { System.out.println(StringUtils.repeat("-", message.length())); System.out.println(message);/*from w w w.j a v a 2 s. co m*/ System.out.println(StringUtils.repeat("-", message.length())); }
From source file:adalid.core.Operation.java
@Override protected String fieldsToString(int n, String key, boolean verbose, boolean fields, boolean maps) { String tab = verbose ? StringUtils.repeat(" ", 4) : ""; String fee = verbose ? StringUtils.repeat(tab, n) : ""; String faa = " = "; String foo = verbose ? EOL : ", "; String string = super.fieldsToString(n, key, verbose, fields, maps); if (fields || verbose) { string += fee + tab + "parameters" + faa + _parameters.size() + foo; string += fee + tab + "expressions" + faa + _expressions.size() + foo; string += fee + tab + "transitions" + faa + _transitions.size() + foo; if (verbose) { }/*from ww w. j a v a2s . c om*/ } return string; }
From source file:de.codesourcery.flocking.KDTree.java
@Override public String toString() { final StringBuilder builder = new StringBuilder(); if (root != null) { final KDTreeVisitor<T> v = new KDTreeVisitor<T>() { @Override/* ww w .jav a 2 s . co m*/ public void visit(int depth, TreeNode<T> node) { final String indent = StringUtils.repeat(" ", depth); builder.append(indent + node.toString()).append("\n"); } }; root.visitPreOrder(0, v); } return builder.toString(); }
From source file:adalid.core.EntityAtlas.java
protected String fieldsToString(int n, String key, boolean verbose, boolean fields, boolean maps) { String tab = verbose ? StringUtils.repeat(" ", 4) : ""; String fee = verbose ? StringUtils.repeat(tab, n) : ""; String faa = " = "; String foo = verbose ? EOL : ", "; String string = ""; if (fields || verbose) { string += fee + tab + "properties" + faa + _properties.size() + foo; string += fee + tab + "references" + faa + _references.size() + foo; string += fee + tab + "keys" + faa + _keys.size() + foo; string += fee + tab + "tabs" + faa + _tabs.size() + foo; string += fee + tab + "views" + faa + _views.size() + foo; string += fee + tab + "instances" + faa + _instances.size() + foo; string += fee + tab + "values" + faa + _namedValues.size() + foo; string += fee + tab + "expressions" + faa + _expressions.size() + foo; string += fee + tab + "transitions" + faa + _transitions.size() + foo; string += fee + tab + "operations" + faa + _operations.size() + foo; string += fee + tab + "triggers" + faa + _triggers.size() + foo; if (verbose) { }//from ww w . j av a 2 s. c o m } return string; }
From source file:adalid.core.AbstractArtifact.java
@Override public String toString(int n, String key, boolean verbose, boolean fields, boolean maps) { String r4n = StringUtils.repeat(" ", 4 * n); String tab = verbose ? StringUtils.repeat(" ", 4) : ""; String fee = verbose ? StringUtils.repeat(tab, n) : ""; // String faa = " = "; String foo = verbose ? EOL : ""; String eol = verbose ? EOL : ", "; String string = EOL;/*from w w w.ja v a 2s . com*/ String c = classToString(n, key, verbose); String f = fieldsToString(n, key, verbose, fields, maps); String m = mapsToString(n, key, verbose, fields, maps); string += c; string += " " + "{" + " " + this + eol; string += f; string += m; if (!verbose) { string = StringUtils.removeEnd(string, eol); if (c.contains(EOL) || f.contains(EOL) || m.contains(EOL)) { fee = r4n; } } string += fee + "}" + EOL; return string.replaceAll(EOL + EOL, EOL); }
From source file:adalid.core.AbstractArtifact.java
protected String classToString(int n, String key, boolean verbose) { String tab = StringUtils.repeat(" ", 4); String fee = StringUtils.repeat(tab, n); // String faa = " = "; // String foo = EOL; String string = ""; String s1 = getDeclaringField() == null ? "" : getDeclaringField().getType().getSimpleName(); String s2 = getNamedClass().getSimpleName(); String s3 = StringUtils.isBlank(s1) || s1.equals(s2) ? s2 : StringUtils.removeEnd(s1, "[]") + " " + "(" + s2 + ")"; String s4 = StringUtils.isBlank(key) ? "" : " " + key; // String s5 = "@" + Integer.toHexString(hashCode()); // string += fee + s3 + s4 + s5; string += fee + s3 + s4;// w w w . j ava2 s. c o m return string; }
From source file:au.org.ala.delta.key.Key.java
private void generateKeyHeader(PrintFile printFile, TabularKey key, List<Character> includedCharacters, List<Item> includedItems, boolean outputTabularKey, boolean outputBracketedKey) { printFile.outputLine(_context.getHeading(HeadingType.HEADING)); int outputWidth = _context.getOutputFileSelector().getOutputWidth(); // The default markrtf sets the print width to zero, so use the default // here if the print width is zero. printFile.outputLine(/*w ww.j a v a 2 s . c o m*/ StringUtils.repeat("*", outputWidth > 0 ? outputWidth : KeyOutputFileManager.DEFAULT_PRINT_WIDTH)); printFile.writeBlankLines(1, 0); printFile.outputLine(generateCreditsString()); printFile.writeBlankLines(1, 0); Date currentDate = Calendar.getInstance().getTime(); printFile.outputLine(MessageFormat.format("Run at {0} on {1}", _timeFormat.format(currentDate), _dateFormat.format(currentDate))); printFile.writeBlankLines(1, 0); printFile.outputLine(MessageFormat.format("Characters - {0} in data, {1} included, {2} in key.", _context.getDataSet().getNumberOfCharacters(), includedCharacters.size(), key.getCharactersUsedInKey().size())); printFile.outputLine(MessageFormat.format("Items - {0} in data, {1} included, {2} in key.", _context.getDataSet().getMaximumNumberOfItems(), includedItems.size(), key.getNumberOfRows())); printFile.writeBlankLines(1, 0); printFile.outputLine(MessageFormat.format("RBASE = {0} ABASE = {1} REUSE = {2} VARYWT = {3}", formatDouble(_context.getRBase()), formatDouble(_context.getABase()), formatDouble(_context.getReuse()), formatDouble(_context.getVaryWt()))); printFile.outputLine(MessageFormat.format("Number of confirmatory characters = {0}", _context.getNumberOfConfirmatoryCharacters())); printFile.writeBlankLines(1, 0); printFile.outputLine(MessageFormat.format("Average length of key = {0} Average cost of key = {1}", String.format("%.1f", key.getAverageLength()), String.format("%.1f", key.getAverageCost()))); printFile.outputLine(MessageFormat.format("Maximum length of key = {0} Maximum cost of key = {1}", String.format("%.1f", key.getMaximumLength()), String.format("%.1f", key.getMaximumCost()))); printFile.writeBlankLines(1, 0); if (_context.getPresetCharacters().size() > 0) { printFile.outputLine(MessageFormat.format("Preset characters (character,column:group) {0}", KeyUtils.formatPresetCharacters(_context))); printFile.writeBlankLines(1, 0); } List<Integer> includedCharacterNumbers = new ArrayList<Integer>(); for (Character ch : includedCharacters) { includedCharacterNumbers.add(ch.getCharacterId()); } printFile.outputLine(MessageFormat.format("Characters included {0}", Utils.formatIntegersAsListOfRanges(includedCharacterNumbers))); List<Integer> includedItemNumbers = new ArrayList<Integer>(); for (Item it : includedItems) { includedItemNumbers.add(it.getItemNumber()); } printFile.outputLine(MessageFormat.format("Character reliabilities {0}", KeyUtils.formatCharacterReliabilities(_context, ",", "-"))); printFile.writeBlankLines(1, 0); printFile.outputLine(MessageFormat.format("Items included {0}", Utils.formatIntegersAsListOfRanges(includedItemNumbers))); printFile.outputLine( MessageFormat.format("Item abundances {0}", KeyUtils.formatTaxonAbunances(_context, ",", "-"))); printFile.writeBlankLines(1, 0); }
From source file:adalid.core.AbstractArtifact.java
protected String fieldsToString(int n, String key, boolean verbose, boolean fields, boolean maps) { String tab = verbose ? StringUtils.repeat(" ", 4) : ""; String fee = verbose ? StringUtils.repeat(tab, n) : ""; String faa = " = "; String foo = verbose ? EOL : ", "; String string = ""; if (fields || verbose) { if (verbose) { if (_declaringArtifact != null) { string += fee + tab + "declaringArtifact" + faa + _declaringArtifact + foo; if (_declaringField != null) { string += fee + tab + "declaringField" + faa + _declaringField + foo; if (_declaringField.getType().isArray()) { string += fee + tab + "declaringFieldIndex" + faa + _declaringFieldIndex + foo; }//from w ww . ja v a 2 s . c o m } string += fee + tab + "path" + faa + getPathString() + foo; } if (this instanceof Entity) { string += fee + tab + "depth" + faa + _depth + foo; string += fee + tab + "round" + faa + _round + foo; } if (_name != null) { string += fee + tab + "name" + faa + _name + foo; } if (_alias != null) { string += fee + tab + "alias" + faa + _alias + foo; } // string += fee + tab + "defaultLabel" + faa + _defaultLabel + foo; // string += fee + tab + "defaultShortLabel" + faa + _defaultShortLabel + foo; // string += fee + tab + "defaultDescription" + faa + _defaultDescription + foo; // string += fee + tab + "defaultShortDescription" + faa + _defaultShortDescription + foo; // string += fee + tab + "defaultTooltip" + faa + _defaultTooltip + foo; } else { string += fee + tab + "path" + faa + getPathString() + foo; } } return string; }