private void recomputeMaximums() { Iterator entries = decorations.values().iterator(); maxDecorationHeight = 0; maxDecorationWidth = 0; while (entries.hasNext()) { Image image = ((Entry)entries.next()).getDecoration().getImage(); if (image != null) { maxDecorationHeight = Math.max(maxDecorationHeight, image.getBounds().height); maxDecorationWidth = Math.max(maxDecorationWidth, image.getBounds().width); } } } }
public static void addRequiredDecoration(Control control) { FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration( FieldDecorationRegistry.DEC_REQUIRED); ControlDecoration controlDecoration = new ControlDecoration(control, SWT.LEFT | SWT.CENTER); controlDecoration.setDescriptionText(fieldDecoration.getDescription()); controlDecoration.setImage(fieldDecoration.getImage()); } }
FieldDecoration getDecoration() { if (decoration == null) { if (image == null) { if (imageRegistry == null) { imageRegistry = JFaceResources.getImageRegistry(); } image = imageRegistry.get(imageId); } decoration = new FieldDecoration(image, description); } // Null out all other fields now that the decoration has an image description = null; imageId = null; imageRegistry = null; image = null; return decoration; } }
private FieldDecoration getFieldDecoration() { FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); // Look for a decoration installed for this particular command id. String decId = CONTENT_ASSIST_DECORATION_ID + adapter.getCommandId(); FieldDecoration dec = registry.getFieldDecoration(decId); // If there is not one, base ours on the standard JFace one. if (dec == null) { FieldDecoration originalDec = registry .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); registry.registerFieldDecoration(decId, null, originalDec .getImage()); dec = registry.getFieldDecoration(decId); } // Always update the decoration text since the key binding may // have changed since it was last retrieved. IBindingService bindingService = PlatformUI .getWorkbench().getService(IBindingService.class); dec.setDescription(NLS.bind( WorkbenchMessages.ContentAssist_Cue_Description_Key, bindingService.getBestActiveBindingFormattedFor(adapter .getCommandId()))); // Now return the field decoration return dec; }
@Override public void mouseHover(MouseEvent event) { FieldDecorationData decData = (FieldDecorationData) event.widget .getData(); String desc = decData.decoration.getDescription(); if (desc != null) { showHoverText(desc, label); } }
private FieldDecoration getContentAssistFieldDecoration() { FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); // Look for a decoration installed for this particular command id. String decId = CONTENT_ASSIST_DECORATION_ID + getCommandId(); FieldDecoration dec = registry.getFieldDecoration(decId); // If there is not one, base ours on the standard JFace one. if (dec == null) { FieldDecoration originalDec = registry .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); registry.registerFieldDecoration(decId, null, originalDec .getImage()); dec = registry.getFieldDecoration(decId); } // Always update the decoration text since the key binding may // have changed since it was last retrieved. IBindingService bindingService = PlatformUI .getWorkbench().getService(IBindingService.class); dec .setDescription(NLS .bind( WorkbenchMessages.ContentAssist_Cue_Description_Key, bindingService .getBestActiveBindingFormattedFor(getCommandId()))); // Now return the field decoration return dec; }
@Override public void mouseHover(MouseEvent event) { FieldDecorationData decData = (FieldDecorationData) event.widget .getData(); String desc = decData.decoration.getDescription(); if (desc != null) { showHoverText(desc, label); } }
private void recomputeMaximums() { Iterator<Entry> entries = decorations.values().iterator(); maxDecorationHeight = 0; maxDecorationWidth = 0; while (entries.hasNext()) { Image image = entries.next().getDecoration().getImage(); if (image != null) { maxDecorationHeight = Math.max(maxDecorationHeight, image.getBounds().height); maxDecorationWidth = Math.max(maxDecorationWidth, image.getBounds().width); } } } }
/** * Update the specified decoration. This message should be used if the image * or description in the decoration have changed. This message has no * immediate effect if the decoration is not visible, and no effect at all * if the decoration was not previously added to the field. * * @param decoration * the decoration to be hidden. */ public void updateDecoration(FieldDecoration decoration) { FieldDecorationData data = getDecorationData(decoration); if (data == null) { return; } if (data.label != null) { data.label.setImage(decoration.getImage()); // If the decoration is being shown, and a hover is active, // update the hover text to display the new description. if (data.label.getVisible() == true && hover != null) { showHoverText(decoration.getDescription(), data.label); } } }
FieldDecoration getDecoration() { if (decoration == null) { if (image == null) { if (imageRegistry == null) { imageRegistry = JFaceResources.getImageRegistry(); } image = imageRegistry.get(imageId); } decoration = new FieldDecoration(image, description); } // Null out all other fields now that the decoration has an image description = null; imageId = null; imageRegistry = null; image = null; return decoration; } }
private void recomputeMaximums() { Iterator<Entry> entries = decorations.values().iterator(); maxDecorationHeight = 0; maxDecorationWidth = 0; while (entries.hasNext()) { Image image = entries.next().getDecoration().getImage(); if (image != null) { maxDecorationHeight = Math.max(maxDecorationHeight, image.getBounds().height); maxDecorationWidth = Math.max(maxDecorationWidth, image.getBounds().width); } } } }
/** * Update the specified decoration. This message should be used if the image * or description in the decoration have changed. This message has no * immediate effect if the decoration is not visible, and no effect at all * if the decoration was not previously added to the field. * * @param decoration * the decoration to be hidden. */ public void updateDecoration(FieldDecoration decoration) { FieldDecorationData data = getDecorationData(decoration); if (data == null) { return; } if (data.label != null) { data.label.setImage(decoration.getImage()); // If the decoration is being shown, and a hover is active, // update the hover text to display the new description. if (data.label.getVisible() == true && hover != null) { showHoverText(decoration.getDescription(), data.label); } } }
FieldDecoration getDecoration() { if (decoration == null) { if (image == null) { if (imageRegistry == null) { imageRegistry = JFaceResources.getImageRegistry(); } image = imageRegistry.get(imageId); } decoration = new FieldDecoration(image, description); } // Null out all other fields now that the decoration has an image description = null; imageId = null; imageRegistry = null; image = null; return decoration; } }
Text text = new Text(composite, SWT.BORDER); FieldDecorationRegistry decRegistry = FieldDecorationRegistry.getDefault(); FieldDecoration infoField = decRegistry.getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION); ControlDecoration decoration = new ControlDecoration(text, SWT.TOP | SWT.LEFT); decoration.setImage(infoField.getImage()); decoration.setDescriptionText("Info decoration text"); GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); // Space for decoration image gridData.horizontalIndent = decRegistry.getMaximumDecorationWidth(); text.setLayoutData(gridData);
/** * Update the specified decoration. This message should be used if the image * or description in the decoration have changed. This message has no * immediate effect if the decoration is not visible, and no effect at all * if the decoration was not previously added to the field. * * @param decoration * the decoration to be hidden. */ public void updateDecoration(FieldDecoration decoration) { FieldDecorationData data = getDecorationData(decoration); if (data == null) { return; } if (data.label != null) { data.label.setImage(decoration.getImage()); // If the decoration is being shown, and a hover is active, // update the hover text to display the new description. if (data.label.getVisible() == true && hover != null) { showHoverText(decoration.getDescription(), data.label); } } }
private static Image getDecorationImage(final String key) { return FieldDecorationRegistry.getDefault().getFieldDecoration(key) .getImage(); }
int i = indexForPosition(position); if (decDatas[i] == null) { formData = createFormDataForIndex(i, decoration.getImage()); label = new Label(form, SWT.HORIZONTAL | SWT.VERTICAL | SWT.CENTER); decDatas[i].showOnFocus = showOnFocus; label.setImage(decDatas[i].decoration.getImage()); showHoverText( decDatas[i].decoration.getDescription(), label );
Image img = fieldDecoration.getImage(); txtDecorator.setImage(img); txtDecorator.setDescriptionText("Pls enter only numeric fields");
ControlDecoration decoration = new ControlDecoration(control, SWT.LEFT | SWT.TOP); decoration.setShowOnlyOnFocus(true); decoration.setDescriptionText(fieldDecoration.getDescription()); decoration.setImage(fieldDecoration.getImage());
public void update() { if (controlMessages.isEmpty()) { decoration.setDescriptionText(null); decoration.hide(); } else { ArrayList<Message> peers = createPeers(controlMessages); int type = peers.get(0).getMessageType(); String description = createDetails(createPeers(peers), true); if (type == IMessageProvider.ERROR) decoration.setImage(standardError.getImage()); else if (type == IMessageProvider.WARNING) decoration.setImage(standardWarning.getImage()); else if (type == IMessageProvider.INFORMATION) decoration.setImage(standardInformation.getImage()); decoration.setDescriptionText(description); decoration.show(); } }