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); } } } }
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); } } } }
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); } } } }
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);
private static Image getDecorationImage(final String key) { return FieldDecorationRegistry.getDefault().getFieldDecoration(key) .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(); } }
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(); } }
Composite composite = new Composite( shell, SWT.NONE ); composite.setLayout( new GridLayout( 2, false ) ); composite.setBackground( composite.getDisplay().getSystemColor( SWT.COLOR_GREEN ) ); Label label = new Label( composite, SWT.NONE ); label.setText( "MyLabel" ); Text text = new Text( composite, SWT.BORDER ); text.setText( "my text" ); ControlDecoration decoration = new ControlDecoration( text, SWT.TOP | SWT.LEFT ); FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); FieldDecoration fieldDecoration = registry.getFieldDecoration( DEC_CONTENT_PROPOSAL ); decoration.setImage( fieldDecoration.getImage() ); label.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false ) ); GridData gridData = new GridData( SWT.BEGINNING, SWT.CENTER, false, false ); gridData.horizontalIndent = 10; text.setLayoutData( gridData );
protected void createProductSection(Composite parent) { fProductButton = new Button(parent, SWT.RADIO); fProductButton.setText(PDEUIMessages.ProgramBlock_runProduct); fProductButton.addSelectionListener(fListener); fProductCombo = SWTFactory.createCombo(parent, SWT.DROP_DOWN, 1, TargetPlatform.getProducts()); fProductCombo.addSelectionListener(fListener); fProductCombo.addModifyListener(fListener); fProductComboDecoration = new ControlDecoration(fProductCombo, SWT.TOP | SWT.LEFT); FieldDecoration warningDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_WARNING); fProductComboDecoration.setDescriptionText(PDEUIMessages.ProgramBlock_productDecorationWarning0); fProductComboDecoration.setImage(warningDecoration.getImage()); }
/** * Adds enough space in the control's layout data margin for the content assist * decoration. * @param control the control that needs a margin * @since 3.3 */ private void addDecorationMargin(Control control) { Object layoutData= control.getLayoutData(); if (!(layoutData instanceof GridData)) return; GridData gd= (GridData)layoutData; FieldDecoration dec= FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); gd.horizontalIndent= dec.getImage().getBounds().width; }
/** * Adds enough space in the control's layout data margin for the content assist * decoration. * @param control the control that needs a margin * @since 3.3 */ private void addDecorationMargin(Control control) { Object layoutData= control.getLayoutData(); if (!(layoutData instanceof GridData)) return; GridData gd= (GridData)layoutData; FieldDecoration dec= FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); gd.horizontalIndent= dec.getImage().getBounds().width; }
/** * Adds enough space in the control's layout data margin for the content assist * decoration. * @param control the control that needs a margin * @since 3.3 */ private void addDecorationMargin(Control control) { Object layoutData= control.getLayoutData(); if (!(layoutData instanceof GridData)) return; GridData gd= (GridData)layoutData; FieldDecoration dec= FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); gd.horizontalIndent= dec.getImage().getBounds().width; }
/** * Initializes the control editor. * * @param itemEditor * the editor to initialize */ protected void initItemEditor(C itemEditor) { this.setItemEditor(itemEditor); setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); hide(); }
protected void updateDecoration(ControlDecoration decoration, RefactoringStatus status) { RefactoringStatusEntry highestSeverity= status.getEntryWithHighestSeverity(); if (highestSeverity != null) { Image newImage= null; FieldDecorationRegistry registry= FieldDecorationRegistry.getDefault(); switch (highestSeverity.getSeverity()) { case RefactoringStatus.INFO: newImage= registry.getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage(); break; case RefactoringStatus.WARNING: newImage= registry.getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage(); break; case RefactoringStatus.FATAL: case RefactoringStatus.ERROR: newImage= registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage(); } decoration.setDescriptionText(highestSeverity.getMessage()); decoration.setImage(newImage); decoration.show(); } else { decoration.setDescriptionText(null); decoration.hide(); } }
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()); } }
/** * 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); } } }
/** * 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); } } }
protected Control createDialogArea(Composite parent) { Control createDialogArea = super.createDialogArea(parent); decorator = new ControlDecoration(getText(), SWT.TOP | SWT.LEFT); decorator.setDescriptionText(NetUIMessages.NonProxyHostsComposite_0); decorator.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration( FieldDecorationRegistry.DEC_INFORMATION).getImage()); return createDialogArea; } public boolean close() {
/** * Adds little bulb decoration to given control. Bulb will appear in top * left corner of control after giving focus for this control. * * After clicking on bulb image text from <code>tooltip</code> will appear. * * @param control * instance of {@link Control} object with should be decorated * @param tooltip * text value which should appear after clicking on bulb image. */ public static void addBulbDecorator(final Control control, final String tooltip) { ControlDecoration dec = new ControlDecoration(control, SWT.TOP | SWT.LEFT); dec.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration( FieldDecorationRegistry.DEC_CONTENT_PROPOSAL).getImage()); dec.setShowOnlyOnFocus(true); dec.setShowHover(true); dec.setDescriptionText(tooltip); }
private void createUIFieldDecorationTemplate() { // Decorate the combo with the info image int bits = SWT.TOP | SWT.LEFT; fControlDecoration = new ControlDecoration(fFieldTemplateCombo.getControl(), bits); // Configure decoration // No margin fControlDecoration.setMarginWidth(0); // Custom hover tip text fControlDecoration.setDescriptionText(PDEUIMessages.SplashConfigurationSection_msgDecorationTemplateSupport); // Custom hover properties fControlDecoration.setShowHover(true); // Hover image to use FieldDecoration contentProposalImage = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION); fControlDecoration.setImage(contentProposalImage.getImage()); // Hide the decoration initially fControlDecoration.hide(); }