List of usage examples for org.apache.commons.lang StringUtils abbreviate
public static String abbreviate(String str, int maxWidth)
Abbreviates a String using ellipses.
From source file:org.integratedmodelling.aries.webapp.view.ScenarioEditor.java
private ZKComponent createLayerSelector() { if (this.xy == null) { this.xy = VisualizationFactory.get().getPlotSize(58, 58, storyline.getContext()); }//from w ww.j av a 2 s. c om ArrayList<ZK.ZKComponent> components = new ArrayList<ZK.ZKComponent>(); WebZKVisualization visualization = (WebZKVisualization) storyline.getVisualization(); for (final IConcept c : editables) { StorylineTemplate.Page p = storyline.getTemplate().getPage(c); if (p == null) continue; String img = visualization.getStateUrl(p.getConcept(), VisualizationFactory.PLOT_GEOSURFACE_2D); if (img != null) { components.add(ZK.div(ZK.vbox(ZK.image(img).width(xy.getFirst()).height(xy.getSecond()) .listener("onClick", new EventListener() { @Override public void onEvent(Event arg0) throws Exception { // setup value chooser and filter editor } }), ZK.label(StringUtils.abbreviate(p.getName(), 24)).sclass(STYLE.TEXT_VERYSMALL) .align("center").fillx())) .align("center").width(120).tooltip(p.getRunningHead()).hand() .listener("onClick", new EventListener() { @Override public void onEvent(Event arg0) throws Exception { editLayer(c); } }).tmargin(64 - xy.getSecond())); } } return ZK.ribbon(rightW - 6, 64, 48, components.toArray(new ZK.ZKComponent[components.size()])) .id("layerselector"); }
From source file:org.integratedmodelling.aries.webapp.view.storyline.ModelStorylineView.java
@Override protected ZKComponent getRibbon(int width, int height) throws ThinklabException { ZKComponent ret = null;//from w w w . j a va2s .c om if (storyline.getStatus() == ModelStoryline.IDLE) { /* * TODO message, launch button */ ret = ZK.vbox(ZK.spacer(28), ZK.label("Click the play button in the sidebar to start computing this storyline.")) .align("center").sclass(STYLE.TEXT_LARGE_BOLD_GREY); } else if (storyline.getStatus() == ModelStoryline.COMPUTING) { /* * TODO icon, progress bar etc */ ret = ZK.vbox(ZK.spacer(28), ZK.label("The storyline is being computed. Results will appear in this area.")).align("center") .sclass(STYLE.TEXT_LARGE_BOLD_GREY); } else if (storyline.getStatus() == ModelStoryline.ERROR) { /* * TODO "more info" link, icons etc. */ ret = ZK.vbox(ZK.spacer(28), ZK.label("The computation ended with errors.")).align("center") .sclass(STYLE.TEXT_LARGE_BOLD_RED); } else if (storyline.getStatus() == ModelStoryline.DISABLED) { ret = ZK.vbox(ZK.spacer(28), ZK.label("Computation of this storyline is not possible in this region.")) .align("center").sclass(STYLE.TEXT_LARGE_BOLD_GREY); } else { /* * Make the ribbon for the result dataset corresponding to the various pages. * Call the vis first or we won't get our sequence right the first time. */ WebVisualization visualization = (WebZKVisualization) (storyline.getVisualization()); if (visualization == null) return null; Pair<Integer, Integer> xy = VisualizationFactory.get().getPlotSize(110, 64, storyline.getContext()); ArrayList<ZKComponent> components = new ArrayList<ZK.ZKComponent>(); for (int i = 0; i < getPageSequence().size(); i++) { Page p = getPageSequence().get(i); final int idx = i; String img = visualization.getStateUrl(p.getConcept(), VisualizationFactory.PLOT_GEOSURFACE_2D); if (img != null) { components.add(ZK .div(ZK.vbox( ZK.image(img).width(xy.getFirst()).height(xy.getSecond()) .sclass(currentPage == i ? STYLE.BRIGHT_BORDER : null), ZK.label(StringUtils.abbreviate(p.getName(), 24)).sclass(STYLE.TEXT_VERYSMALL) .align("center").fillx())) .align("center").width(120).tooltip(p.getRunningHead()).hand() .listener("onClick", new EventListener() { @Override public void onEvent(Event arg0) throws Exception { switchPage(idx); } }).tmargin(64 - xy.getSecond())); } } ret = ZK.ribbon(width, height, 120, components.toArray(new ZKComponent[components.size()])) .selected(currentPage); } return ret; }
From source file:org.jboss.tools.openshift.internal.ui.preferences.SSLCertificatesPreference.java
protected X509Certificate createCertificate(String certificateString) { try {/*from ww w . j a v a2 s .co m*/ return SSLCertificateUtils.createX509Certificate(certificateString); } catch (CertificateException e) { IStatus status = StatusFactory.errorStatus(OpenShiftUIActivator.PLUGIN_ID, NLS.bind("Could not read certificate for certificate {0}", StringUtils.abbreviate(certificateString, 50))); OpenShiftUIActivator.getDefault().getLogger().logStatus(status); } return null; }
From source file:org.jumpmind.metl.core.runtime.component.ModelAttributeScriptHelper.java
public String abbreviate(int maxwidth) { String text = value != null ? value.toString() : ""; return StringUtils.abbreviate(text, maxwidth); }
From source file:org.jumpmind.metl.core.runtime.flow.AsyncRecorder.java
@Override public void run() { running = true;// w ww .j av a2s .c om while (!stopping || inQueue.size() > 0) { try { AbstractObject object = inQueue.poll(100, TimeUnit.MILLISECONDS); if (object instanceof ExecutionStepLog) { ExecutionStepLog stepLog = (ExecutionStepLog) object; String executionStepId = stepLog.getExecutionStepId(); CsvWriter writer = logWriters.get(executionStepId); if (writer == null) { File logFile = new File(LogUtils.getLogDir(), executionStepId + ".log"); writer = new CsvWriter(logFile.getAbsolutePath()); writer.setTextQualifier('"'); logWriters.put(executionStepId, writer); } try { writer.writeRecord(new String[] { stepLog.getLevel(), FormatUtils.TIMESTAMP_FORMATTER.format(stepLog.getCreateTime()), StringUtils.abbreviate(stepLog.getLogText(), 100000) }); writer.flush(); } catch (IOException e) { writer.close(); logWriters.remove(executionStepId); log.error("", e); } // TODO log to file } else if (object != null) { executionService.save(object); } } catch (InterruptedException e) { } } running = false; }
From source file:org.jumpmind.symmetric.io.data.writer.DefaultDatabaseWriter.java
@Override protected void logFailureDetails(Throwable e, CsvData data, boolean logLastDmlDetails) { StringBuilder failureMessage = new StringBuilder(); failureMessage.append("Failed to process a "); failureMessage.append(data.getDataEventType().toString().toLowerCase()); failureMessage.append(" event in batch "); failureMessage.append(batch.getBatchId()); failureMessage.append(".\n"); if (logLastDmlDetails && this.currentDmlStatement != null) { failureMessage.append("Failed sql was: "); failureMessage.append(this.currentDmlStatement.getSql()); failureMessage.append("\n"); }//from w ww . jav a2 s .co m if (logLastDmlDetails && this.currentDmlValues != null) { failureMessage.append("Failed sql parameters: "); failureMessage.append(StringUtils.abbreviate(Arrays.toString(currentDmlValues), CsvData.MAX_DATA_SIZE_TO_PRINT_TO_LOG)); failureMessage.append("\n"); failureMessage.append("Failed sql parameters types: "); failureMessage.append(Arrays.toString(this.currentDmlStatement.getTypes())); failureMessage.append("\n"); } data.writeCsvDataDetails(failureMessage); log.info(failureMessage.toString()); }
From source file:org.jumpmind.symmetric.model.Grouplet.java
public void setDescription(String description) { this.description = StringUtils.abbreviate(description, 255); }
From source file:org.jumpmind.symmetric.model.Node.java
public void setSchemaVersion(String version) { // abbreviate because we do not control the version this.schemaVersion = StringUtils.abbreviate(version, MAX_VERSION_SIZE); }
From source file:org.jumpmind.util.FormatUtils.java
public static String abbreviateForLogging(String value) { if (value != null) { value = value.trim();// ww w. ja v a 2s . c om } return StringUtils.abbreviate(value, MAX_CHARS_TO_LOG); }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.QueryPanel.java
public void removeGeneralResultsTab() { if (generalResultsTab != null) { Component content = ((VerticalLayout) generalResultsTab.getComponent()).getComponent(0); if (content instanceof TabularResultLayout) { addResultsTab(((TabularResultLayout) content).refreshWithoutSaveButton(), StringUtils.abbreviate(((TabularResultLayout) content).getSql(), 20), generalResultsTab.getIcon(), 0); }/*w w w. j ava 2s. c om*/ resultsTabs.removeComponent(generalResultsTab.getComponent()); generalResultsTab = null; } }