List of usage examples for org.apache.commons.lang3 StringUtils abbreviateMiddle
public static String abbreviateMiddle(final String str, final String middle, final int length)
Abbreviates a String to the length passed, replacing the middle characters with the supplied replacement String.
This abbreviation only occurs if the following criteria is met:
Otherwise, the returned String will be the same as the supplied String for abbreviation.
From source file:org.sleuthkit.autopsy.timeline.ShowInTimelineDialog.java
/** * Constructor for file based dialog. Allows the user to choose an event * (MAC time) derived from the given file * * @param controller The controller for this Dialog. * @param file The AbstractFile to configure this dialog for. *//*from w ww.ja v a2 s . c o m*/ @NbBundle.Messages({ "# {0} - file path", "ShowInTimelineDialog.fileTitle=View {0} in timeline.", "ShowInTimelineDialog.eventSelectionValidator.message=You must select an event." }) ShowInTimelineDialog(TimeLineController controller, AbstractFile file) { this(controller, controller.getEventsModel().getEventIDsForFile(file, false)); /* * since ValidationSupport does not support list selection, we will * manually apply and remove decoration in response to selection * property changes. */ eventTable.getSelectionModel().selectedItemProperty().isNull() .addListener((selectedItemNullProperty, wasNull, isNull) -> { if (isNull) { validationSupport.getValidationDecorator().applyValidationDecoration(ValidationMessage .error(eventTable, Bundle.ShowInTimelineDialog_eventSelectionValidator_message())); } else { validationSupport.getValidationDecorator().removeDecorations(eventTable); } }); //require selection and validation of ammount spinner to enable show button getDialogPane().lookupButton(SHOW).disableProperty().bind(Bindings.or(validationSupport.invalidProperty(), eventTable.getSelectionModel().selectedItemProperty().isNull())); //set result converter that uses selection. setResultConverter(buttonType -> (buttonType == SHOW) ? makeEventInTimeRange(eventTable.getSelectionModel().getSelectedItem()) : null); setTitle(Bundle.ShowInTimelineDialog_fileTitle( StringUtils.abbreviateMiddle(getContentPathSafe(file), " ... ", 50))); }