/** * {@inheritDoc} */ @Override protected String valueToHumanReadableImpl(double value) { return NumberFormatter.formatDoubleToPercent(value / 100D); }
/** * {@inheritDoc} */ @Override protected String valueToHumanReadableImpl(double value) { return NumberFormatter.humanReadableByteCount((long) (value * MEGABYTE_BYTE_COUNT)); }
/** * Returns string representation of count and percentage. * * @param count * Count. * @param totalCount * Total count. * @return {@link String} representation. */ private String getCountAndPercentage(int count, int totalCount) { if (0 == totalCount) { return "0(0%)"; } return count + "(" + NumberFormatter.formatDouble(((double) count / totalCount) * 100, 0) + "%)"; }
/** * Updates title based on the sensor configuration class. * * @param sensorConfigClass * Sensor configuration class. */ private void updateTitle(Class<? extends ISensorConfig> sensorConfigClass) { String titleText = TextFormatter.getSensorConfigName(sensorConfigClass); Image titleImage = ImageFormatter.getSensorConfigImage(sensorConfigClass); title.setText("<form><p> <img href=\"titleImage\"/> <span color=\"header\" font=\"header\">" + titleText + "</span></p></form>", true, false); title.setImage("titleImage", titleImage); }
/** * Returns styled text for {@link Span} based on the column. * * @param span * span * @param enumId * column * @return string */ public StyledString getStyledTextForColumn(Span span, Column enumId) { switch (enumId) { case ELEMENT: return TextFormatter.getSpanDetailsFull(span, cachedDataService); case DURATION: return new StyledString(NumberFormatter.formatDouble(span.getDuration())); default: return new StyledString(); } }
/** * Sets the agent name. * * @param agentName * Agent name. * @param agentImg * Image to go next to the agent name. If <code>null</code> is passed no changed to * the current image will be done. */ public void setAgent(String agentName, Image agentImg) { agentLabel.setText(TextFormatter.clearLineBreaks(TextFormatter.crop(agentName, MAX_TEXT_LENGTH))); agentLabel.setToolTipText(agentName); if (null != agentImg) { agentLabel.setImage(agentImg); } }
/** * Updates the form title. Sub-classes can extend if needed. */ protected void updateFormTitle() { if (null != displayedCmrRepositoryDefinition) { mainForm.setImage(ImageFormatter.getCmrRepositoryImage(displayedCmrRepositoryDefinition, true)); mainForm.setText(displayedCmrRepositoryDefinition.getName()); mainForm.setToolTipText(TextFormatter.getCmrRepositoryDescription(displayedCmrRepositoryDefinition)); mainForm.setMessage(null); } else { mainForm.setImage(null); mainForm.setText("No repository exists"); mainForm.setMessage("Repositories can be added from the Repository Manager", IMessageProvider.WARNING); mainForm.setToolTipText(null); } }
/** * Returns the {@link ImageDescriptor} for the composite that represents a label. * * @param labelType * Label type. * @return {@link ImageDescriptor} for {@link Composite}. */ public static ImageDescriptor getImageDescriptorForLabel(AbstractStorageLabelType<?> labelType) { return InspectIT.getDefault().getImageDescriptor(getImageKeyForLabel(labelType)); }
/** * Returns the combined image for given array of descriptors. Orientation can be vertical or * horizontal. * * @param resourceManager * {@link ResourceManager}. * @param orientation * SWT#Vertical or SWT#Horizontal. Descriptors will be passed in given order. * @param descriptors * Array of descriptors. * * @return Combined {@link Image}. */ public static Image getCombinedImage(ResourceManager resourceManager, int orientation, ImageDescriptor... descriptors) { return getCombinedImage(resourceManager, orientation, 0, 0, descriptors); }
/** * Formats the time to a String value with milliseconds. * * @param time * The time as long value. * @return The formatted string. */ public static String formatTimeWithMillis(long time) { return formatTimeWithMillis(new Date(time)); }
/** * Formats the time to a String value. * * @param time * The time as long value. * @return The formatted string. */ public static String formatTime(long time) { return formatTime(new Date(time)); }
/** * Returns image for the {@link ISensorConfig}. * * @param sensorConfig * {@link ISensorConfig} * @return Image or <code>null</code> if one can not be resolved for given sensor configuration. */ public static Image getSensorConfigImage(ISensorConfig sensorConfig) { return getSensorConfigImage(sensorConfig.getClass()); }
/** * Returns name of the {@link ISensorConfig}. * * @param sensorConfig * {@link ISensorConfig}. * @return Name or empty string if sensor name can be resolved. */ public static String getSensorConfigName(ISensorConfig sensorConfig) { return getSensorConfigName(sensorConfig.getClass()); }
/** * Returns a String out of the {@link MethodIdent} objects which looks like: 'name'('parameter') * - 'package'.'class'. * * @param methodIdent * The object which contains the information to create the method string. * @return The created method string. */ public static String getMethodString(MethodIdent methodIdent) { return getStyledMethodString(methodIdent).getString(); }
@Override public ImageDescriptor getImageDescriptor() { return ImageDescriptor.createFromImage(ImageFormatter.getApplicationDefinitionImage(application)); }
/** * Returns the name of the label, based on it's type. If label is <code>null</code>, string * "null" will be returned. * * @param label * Label to get name for. * @return Returns the name of the label, based on it's class. */ public static String getLabelName(AbstractStorageLabel<?> label) { if (null == label) { return "null"; } else { return getLabelName(label.getStorageLabelType()); } }
/** * {@inheritDoc} */ @Override protected Comparable<?> getSeriesKey(TimerData template) { MethodIdent methodIdent = cachedDataService.getMethodIdentForId(template.getMethodIdent()); return TextFormatter.getMethodString(methodIdent); }
/** * Description of the agent with the connection information. * * @param agent * {@link PlatformIdent} * @param agentStatusData * {@link AgentStatusData}. * @return Description of the agent. */ public static String getAgentDescription(PlatformIdent agent, AgentStatusData agentStatusData) { return agent.getAgentName() + getStyledAgentDescription(agent, agentStatusData).getString(); }
/** * Returns the human readable bytes number with one decimal place. * * @param bytes * Bytes to transform. * @return Human readable string. */ public static String humanReadableByteCount(long bytes) { return humanReadableByteCount(bytes, 1); }
/** * Returns the {@link Image} for the composite that represents a label. * * @param labelType * Label type. * @return {@link Image} for Composite. */ public static Image getImageForLabel(AbstractStorageLabelType<?> labelType) { return InspectIT.getDefault().getImage(getImageKeyForLabel(labelType)); }