List of usage examples for org.apache.commons.io FileUtils byteCountToDisplaySize
public static String byteCountToDisplaySize(long size)
From source file:org.magdaaproject.analysis.rhizome.tasks.StatisticalAnalysis.java
private String getTotalUniqueDataSize() throws TaskException { String totalFileSize = executeSql("SELECT SUM(file_size) FROM (SELECT file_id, file_size FROM " + tableName + " GROUP BY file_id) as TABLE_01"); totalFileSize = FileUtils.byteCountToDisplaySize(Long.parseLong(totalFileSize)); return totalFileSize + "\n"; }
From source file:org.magdaaproject.analysis.rhizome.tasks.StatisticalAnalysis.java
private String getTotalDataSize() throws TaskException { String totalFileSize = executeSql("SELECT SUM(file_size) FROM " + tableName); totalFileSize = FileUtils.byteCountToDisplaySize(Long.parseLong(totalFileSize)); return totalFileSize + "\n"; }
From source file:org.magdaaproject.analysis.rhizome.tasks.StatisticalAnalysis.java
private String getAverageFileSize() throws TaskException { String averageFileSize = executeSql("SELECT AVG(file_size) FROM (SELECT file_id, file_size FROM " + tableName + " GROUP BY file_id) AS table_01"); averageFileSize = FileUtils.byteCountToDisplaySize(Math.round(Double.parseDouble(averageFileSize))); return averageFileSize + "\n"; }
From source file:org.n52.iceland.statistics.impl.handlers.CountingOutputStreamEventHandler.java
@Override public Map<String, Object> resolveAsMap(CountingOutputStreamEvent event) { Map<String, Object> data = new HashMap<>(); data.put(ObjectEsParameterFactory.BYTES.getName(), event.getBytesWritten()); data.put(ObjectEsParameterFactory.DISPLAY_BYTES.getName(), FileUtils.byteCountToDisplaySize(event.getBytesWritten())); put(ServiceEventDataMapping.ORE_BYTES_WRITTEN, data); return dataMap; }
From source file:org.obm.push.mail.MailErrorsMessages.java
public String mailTooLargeBodyStructure(int maxSize, String previousMessageReferenceText) { String humanReadableSize = FileUtils.byteCountToDisplaySize(maxSize); return getString("MailTooLargeBodyStructure", humanReadableSize, previousMessageReferenceText); }
From source file:org.openmicroscopy.shoola.agents.fsimporter.util.FileImportComponent.java
/** * Formats the tool tip of a successful import. * /*w ww. ja v a 2 s . c o m*/ * @return See above. */ private void formatResultTooltip() { StringBuffer buf = new StringBuffer(); buf.append("<html><body>"); buf.append("<b>Date Uploaded: </b>"); buf.append(UIUtilities.formatShortDateTime(null)); buf.append("<br>"); if (image instanceof PlateData) { PlateData p = (PlateData) image; buf.append("<b>Plate ID: </b>"); buf.append(p.getId()); buf.append("<br>"); } if (!statusLabel.isHCS()) { Object o = statusLabel.getImportResult(); if (o instanceof Set) { Set<PixelsData> list = (Set<PixelsData>) o; int n = list.size(); if (n == 1) { buf.append("<b>Image ID: </b>"); Iterator<PixelsData> i = list.iterator(); while (i.hasNext()) { buf.append(i.next().getImage().getId()); buf.append("<br>"); } } else if (n > 1) { buf.append("<b>Number of Images: </b>"); buf.append(n); buf.append("<br>"); } } } buf.append("<b>Size: </b>"); buf.append(FileUtils.byteCountToDisplaySize(statusLabel.getFileSize())); buf.append("<br>"); buf.append("<b>Group: </b>"); buf.append(importable.getGroup().getName()); buf.append("<br>"); buf.append("<b>Owner: </b>"); buf.append(EditorUtil.formatExperimenter(importable.getUser())); buf.append("<br>"); if (containerObject instanceof ProjectData) { buf.append("<b>Project: </b>"); buf.append(((ProjectData) containerObject).getName()); buf.append("<br>"); } else if (containerObject instanceof ScreenData) { buf.append("<b>Screen: </b>"); buf.append(((ScreenData) containerObject).getName()); buf.append("<br>"); } else if (containerObject instanceof DatasetData) { buf.append("<b>Dataset: </b>"); buf.append(((DatasetData) containerObject).getName()); buf.append("<br>"); } else if (dataset != null) { buf.append("<b>Dataset: </b>"); buf.append(dataset.getName()); buf.append("<br>"); } if (!CollectionUtils.isEmpty(tags)) { buf.append("<b>Tags: </b>"); Iterator<TagAnnotationData> i = tags.iterator(); while (i.hasNext()) { buf.append(i.next().getTagValue()); buf.append(" "); } } buf.append("</body></html>"); String tip = buf.toString(); fileNameLabel.setToolTipText(tip); resultLabel.setToolTipText(tip); }
From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUIElement.java
/** * Builds and lays out the header.//ww w . j a va2 s . c om * * @return See above. */ private JPanel buildHeader() { sizeLabel = UIUtilities.createComponent(null); sizeLabel.setText(FileUtils.byteCountToDisplaySize(sizeImport)); reportLabel = UIUtilities.setTextFont("Report:", Font.BOLD); importSizeLabel = UIUtilities.setTextFont("Import Size:", Font.BOLD); double[][] design = new double[][] { { TableLayout.PREFERRED }, { TableLayout.PREFERRED, TableLayout.PREFERRED } }; TableLayout layout = new TableLayout(design); JPanel detailsPanel = new JPanel(layout); detailsPanel.setBackground(UIUtilities.BACKGROUND_COLOR); JPanel p = createRow(); p.add(reportLabel); p.add(numberOfImportLabel); detailsPanel.add(p, "0, 0"); p = createRow(); p.add(importSizeLabel); p.add(sizeLabel); detailsPanel.add(p, "0, 1"); JPanel middlePanel = new JPanel(); middlePanel.setBackground(UIUtilities.BACKGROUND_COLOR); middlePanel.add(filterButton); JTextArea description = new JTextArea(MESSAGE); makeLabelStyle(description); description.setBackground(UIUtilities.BACKGROUND_COLOR); JPanel descriptionPanel = new JPanel(); descriptionPanel.setBackground(UIUtilities.BACKGROUND_COLOR); descriptionPanel.add(description); JPanel header = new JPanel(); header.setBackground(UIUtilities.BACKGROUND_COLOR); header.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); header.setLayout(new BorderLayout()); header.add(Box.createVerticalStrut(10), BorderLayout.NORTH); header.add(detailsPanel, BorderLayout.WEST); header.add(middlePanel, BorderLayout.CENTER); header.add(descriptionPanel, BorderLayout.EAST); header.add(Box.createVerticalStrut(10), BorderLayout.SOUTH); return header; }
From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUIElement.java
/** * Sets the result of the import for the specified file. * //from w w w.j a v a 2 s . c o m * @param f The imported file. * @param result The result. * @param index The index corresponding to the component * @result Returns the formatted result or <code>null</code>. */ Object uploadComplete(FileImportComponent c, Object result) { if (c == null) return null; c.uploadComplete(result); File file = c.getFile(); Object r = null; if (file.isFile()) { countUploaded++; sizeImport += c.getImportSize(); sizeLabel.setText(FileUtils.byteCountToDisplaySize(sizeImport)); //handle error that occurred during the scanning or upload. //Check that the result has not been set. //if (!c.hasResult()) { if (result instanceof Exception) { r = new ImportErrorObject(file, (Exception) result, c.getGroupID()); if (c.hasResult()) return null; setImportResult(c, result); } else if (result instanceof Boolean) { Boolean b = (Boolean) result; if (!b && c.isCancelled()) { countUploaded--; if (isDone() && rotationIcon != null) rotationIcon.stopRotation(); } else setImportResult(c, result); } else { if (c.isCancelled()) { if (result == null) { countCancelled++; countImported++; if (isDone() && rotationIcon != null) rotationIcon.stopRotation(); } else { countCancelled--; countUploaded--; } } } //} } else {//empty folder if (result instanceof Exception) { countUploaded++; //Check if no files if (!c.hasComponents()) { countImported++; countUploadFailure++; c.setStatus(result); } if (isDone() && rotationIcon != null) rotationIcon.stopRotation(); } else if (result instanceof Boolean) { Boolean b = (Boolean) result; if (!b && c.isCancelled()) { countUploaded++; countCancelled++; countImported++; if (isDone() && rotationIcon != null) rotationIcon.stopRotation(); } } } setNumberOfImport(); setClosable(isUploadComplete()); return r; }
From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUIElement.java
/** * Sets the result of the import for the specified file. * //from ww w . jav a2 s . c o m * @param fc The component hosting the file to import. * @param result The result. * @result Returns the formatted result or <code>null</code>. */ void setImportResult(FileImportComponent fc, Object result) { if (fc == null) return; File file = fc.getFile(); if (file.isFile()) { fc.setStatus(result); countImported++; if (fc.isCancelled() && result != null && !(result instanceof Boolean)) countImported--; if (isDone() && rotationIcon != null) rotationIcon.stopRotation(); if (fc.hasUploadFailed()) { countUploadFailure++; sizeImport -= fc.getImportSize(); sizeLabel.setText(FileUtils.byteCountToDisplaySize(sizeImport)); } if (fc.hasImportFailed()) countFailure++; setNumberOfImport(); setClosable(isDone()); filterButton.setEnabled(countFailure > 0 && countFailure != totalToImport); } else { //empty folder if (result instanceof Exception) { fc.setStatus(result); countImported++; countFailure++; countUploadFailure++; if (isDone() && rotationIcon != null) rotationIcon.stopRotation(); setNumberOfImport(); setClosable(isDone()); } } }
From source file:org.openmicroscopy.shoola.env.data.util.StatusLabel.java
/** * Formats the size of the uploaded data. * // w ww . j av a 2s .c om * @param value The value to display. * @return See above. */ private String formatUpload(long value) { StringBuffer buffer = new StringBuffer(); String v = FileUtils.byteCountToDisplaySize(value); String[] values = v.split(" "); if (values.length > 1) { String u = values[1]; if (units.equals(u)) buffer.append(values[0]); else buffer.append(v); } else buffer.append(v); buffer.append("/"); buffer.append(fileSize); return buffer.toString(); }