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:com.sfs.captor.model.Iteration.java
/** * @return the abbreviated objective */ public String getObjectiveAbbrv() { return StringUtils.abbreviate(objective, 80); }
From source file:com.sfs.captor.model.Risk.java
/** * @return the mitigation */ public String getMitigationAbbrv() { return StringUtils.abbreviate(this.mitigation, Constants.ABBRV_DESC_LEN); }
From source file:mobi.chouette.model.Company.java
/** * set registration number <br/>//from w ww .j a v a 2s.c o m * truncated to 255 characters if too long * * @param value * New value */ public void setRegistrationNumber(String value) { registrationNumber = StringUtils.abbreviate(value, 255); }
From source file:mobi.chouette.model.Route.java
/** * set wayBack <br/>//w w w .j a va 2s. c om * truncated to 255 characters if too long * * @param value * New value */ public void setWayBack(String value) { wayBack = StringUtils.abbreviate(value, 255); }
From source file:com.ruesga.gerrit.plugins.fcm.handlers.EventHandler.java
protected Notification createNotification(ChangeEvent event) { Notification notification = new Notification(); notification.event = getEventType(); notification.when = event.getWhen().getTime() / 1000L; notification.who = event.getWho();//from w w w .ja v a2s . c om notification.change = event.getChange().changeId; notification.legacyChangeId = event.getChange()._number; notification.project = event.getChange().project; notification.branch = event.getChange().branch; notification.topic = event.getChange().topic; notification.subject = StringUtils.abbreviate(event.getChange().subject, 100); if (event instanceof RevisionEvent) { notification.revision = ((RevisionEvent) event).getRevision().commit.commit; } return notification; }
From source file:net.sf.zekr.ui.splash.AdvancedSplashScreen.java
public AdvancedSplashScreen(Display disp) { super(disp);/*from ww w . java2s . c o m*/ shell = new Shell(display, SWT.NO_TRIM | SWT.DOUBLE_BUFFERED); shell.setText("Starting Zekr..."); shell.setImages(new Image[] { new Image(display, resource.getString("icon.form16")), new Image(display, resource.getString("icon.form32")), new Image(display, resource.getString("icon.form48")), new Image(display, resource.getString("icon.form128")), new Image(display, resource.getString("icon.form256")) }); final TaskItem tbi = getTaskBarItem(); if (tbi != null) { tbi.setProgressState(SWT.NORMAL); } shell.addListener(EventProtocol.CUSTOM_ZEKR_EVENT, new Listener() { public void handleEvent(Event e) { if (e.data != null) { if (((String) e.data).startsWith(EventProtocol.SPLASH_PROGRESS_FULLY)) { progressMsg = ((String) e.data).substring(EventProtocol.SPLASH_PROGRESS_FULLY.length() + 1); progBar.setSelection(progressCount = 100); if (tbi != null) { tbi.setProgress(progressCount); } shell.redraw(); shell.update(); } else if (((String) e.data).startsWith(EventProtocol.SPLASH_PROGRESS)) { progressMsg = ((String) e.data).substring(EventProtocol.SPLASH_PROGRESS.length() + 1); progBar.setSelection(progressCount += 7); if (tbi != null) { tbi.setProgress(progressCount); tbi.reskin(SWT.ALL); } shell.redraw(); shell.update(); } } } }); final Point centerPoint = FormUtils.getScreenCenter(display, splashImage.getBounds()); GC gc = new GC(display); Rectangle rect = display.getBounds(); rect = splashImage.getBounds(); final Image bgImage = new Image(display, rect); gc.copyArea(bgImage, centerPoint.x, centerPoint.y); gc.dispose(); region = new Region(); imageData = splashImage.getImageData(); if (imageData.alphaData != null) { Rectangle pixel = new Rectangle(0, 0, 1, 1); for (int y = 0; y < imageData.height; y++) { for (int x = 0; x < imageData.width; x++) { if (imageData.getAlpha(x, y) >= ALPHA_LIMIT) { pixel.x = imageData.x + x; pixel.y = imageData.y + y; region.add(pixel); } } } } else { ImageData mask = imageData.getTransparencyMask(); Rectangle pixel = new Rectangle(0, 0, 1, 1); for (int y = 0; y < mask.height; y++) { for (int x = 0; x < mask.width; x++) { if (mask.getPixel(x, y) != 0) { pixel.x = imageData.x + x; pixel.y = imageData.y + y; region.add(pixel); } } } } Rectangle regBound; regBound = region.getBounds(); int y1 = regBound.height + regBound.y; region.add(0, y1, regBound.width, PROGRESS_BAR_HEIGHT); shell.setRegion(region); shell.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { e.gc.drawImage(bgImage, 0, 0); int height = imageData.height; e.gc.drawImage(splashImage, 0, 0); e.gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); e.gc.setAlpha(200); e.gc.drawText(StringUtils.abbreviate(progressMsg, 40), 40, height - 30, true); } }); regBound = region.getBounds(); shell.setSize(regBound.width, regBound.height); shell.setLocation(centerPoint); progBar = new ProgressBar(shell, SWT.SMOOTH | SWT.HORIZONTAL); progBar.setSelection(progressCount); Point shellSize = shell.getSize(); progBar.setBounds(0, shellSize.y - PROGRESS_BAR_HEIGHT, shellSize.x, PROGRESS_BAR_HEIGHT); }
From source file:gov.nih.nci.caarray.web.action.project.ProjectTabAction.java
/** * Helper method for creating and saving appropriate error message when experiment creation fails due to any reason * other than an InconsistentStateError and/or a WorkflowError. * @param e the exception containing information about the error. *//* w ww . ja v a 2 s .c om*/ protected void handleSaveError(Exception e) { ActionHelper.saveMessage(getText("project.saveError", new String[] { StringUtils.abbreviate(getProject().getExperiment().getTitle(), TRUNCATED_TITLE_WIDTH) })); }
From source file:com.google.ie.common.builder.ProjectBuilder.java
/** * Shortens the length of title and description fields * /*from www . j av a 2 s.co m*/ * @param project */ private void shortenFields(Project project) { if (null != project) { /* 50 chars for title */ project.setName(StringUtils.abbreviate(project.getName(), 50)); /* 150 chars for description */ project.setDescription(StringUtils.abbreviate(project.getDescription(), 150)); } }
From source file:com.perceptive.epm.perkolcentral.bl.LicensesBL.java
public String getLicenseSummaryChartData() throws ExceptionWrapper { String chartData = ""; try {/* w w w.j a v a 2 s.c o m*/ HashMap<String, ArrayList<String>> licenseInfoKeyedByLicenseName = getLicenseRelatedInfo(); String categories = ""; for (String licenseTypeName : licenseInfoKeyedByLicenseName.keySet()) { categories = categories + "<category name='" + StringUtils.abbreviate(licenseTypeName, 15) + "' hoverText='" + licenseTypeName + "'/>"; } String licensePurchased = ""; String licenseUsedUp = ""; /*for (Object obj : licenseInfoKeyedByLicenseName.values()) { ArrayList<String> values = (ArrayList<String>) obj; licensePurchased = licensePurchased + "<set value='" + values.get(0) + "'/>"; licenseUsedUp = licenseUsedUp + "<set value='" + values.get(1) + "' link='JavaScript: isJavaScriptCall=true;$('#id_selectedLicenseTypeId').val('');'/>"; } */ for (Map.Entry<String, ArrayList<String>> obj : licenseInfoKeyedByLicenseName.entrySet()) { ArrayList<String> values = obj.getValue(); licensePurchased = licensePurchased + "<set value='" + values.get(0) + "'/>"; licenseUsedUp = licenseUsedUp + "<set value='" + values.get(1) + "' link='JavaScript:populateTheDetails(%26apos;" + obj.getKey() + "%26apos;)'/>"; } chartData = "<graph xaxisname='License Type' yaxisname='Number Of Licenses' hovercapbg='DEDEBE' hovercapborder='889E6D' rotateNames='0' yAxisMaxValue='100' numdivlines='9' divLineColor='CCCCCC' divLineAlpha='80' decimalPrecision='0' showAlternateHGridColor='1' AlternateHGridAlpha='30' AlternateHGridColor='CCCCCC' caption='Perceptive Software Kolkata' subcaption='License purchase/distribution summary'>" + "<categories font='Arial' fontSize='11' fontColor='000000'>" + categories + "</categories>" + "<dataset seriesname='Total License Purchased' color='FDC12E'>" + licensePurchased + "</dataset>" + "<dataset seriesname='Total License Used Up' color='56B9F9'>" + licenseUsedUp + "</dataset>" + "</graph>"; } catch (Exception ex) { throw new ExceptionWrapper(ex); } return chartData; }
From source file:com.sfs.ucm.model.Help.java
@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Help [id="); builder.append(id);/*from www. j av a2s .c o m*/ builder.append(", keyword="); builder.append(keyword); builder.append(", content="); builder.append(StringUtils.abbreviate(content, 60)); builder.append("]"); return builder.toString(); }