private void updateInput() { if (this.infoText == null || !this.inputChanged) { return; } if (this.labelProvider == null) { this.labelProvider = new RLabelProvider( RLabelProvider.LONG | RLabelProvider.HEADER | RLabelProvider.NAMESPACE); } if (this.input != null) { final Image image = this.labelProvider.getImage(this.input.getElement()); this.titleImage.setImage( (image != null) ? image : SharedUIResources.getImages().get(SharedUIResources.PLACEHOLDER_IMAGE_ID)); final StyledString styleString = this.labelProvider.getStyledText( this.input.getElement(), this.input.getElementName(), this.input.getElementAttr()); if (this.input.isElementOfActiveBinding()) { styleString.append(" (active binding)", StyledString.QUALIFIER_STYLER); } this.titleText.setText(styleString.getString()); this.titleText.setStyleRanges(styleString.getStyleRanges()); if (this.input.hasDetail()) { this.infoText.setText( this.input.getDetailTitle() + '\n' + ((this.input.getDetailInfo() != null) ? this.input.getDetailInfo() : "")); //$NON-NLS-1$ final StyleRange title = new StyleRange(0, this.input.getDetailTitle().length(), null, null); title.underline = true; this.infoText.setStyleRange(title); } else { this.infoText.setText(""); // $NON-NLS-1$ } } else { this.titleImage.setImage( SharedUIResources.getImages().get(SharedUIResources.PLACEHOLDER_IMAGE_ID)); this.titleText.setText(""); // $NON-NLS-1$ this.infoText.setText(""); // $NON-NLS-1$ } if ((this.mode & MODE_FOCUS) != 0) { getToolBarManager().update(true); } else { setStatusText( (this.input.getControl() != null && this.input.getControl().isFocusControl()) ? InformationDispatchHandler.getTooltipAffordanceString() : ""); //$NON-NLS-1$ } this.inputChanged = false; }
@Override protected SourceEditorViewerConfigurator createConfigurator(final SourceViewer sourceViewer) { final RSourceViewerConfigurator viewerConfigurator = new RSourceViewerConfigurator( RCore.getWorkbenchAccess(), new RSourceViewerConfiguration(null, SharedUIResources.getColors())); return viewerConfigurator; }
private void updateInput() { if (fInfoText == null || !fInputChanged) { return; } if (fLabelProvider == null) { fLabelProvider = new RLabelProvider( RLabelProvider.LONG | RLabelProvider.HEADER | RLabelProvider.NAMESPACE); } if (fInput != null) { final Image image = fLabelProvider.getImage(fInput.element); fTitleImage.setImage( (image != null) ? image : SharedUIResources.getImages().get(SharedUIResources.PLACEHOLDER_IMAGE_ID)); final StyledString styleString = fLabelProvider.getStyledText( fInput.element, fInput.element.getElementName(), fInput.elementAttr); fTitleText.setText(styleString.getString()); fTitleText.setStyleRanges(styleString.getStyleRanges()); if (fInput.detailTitle != null) { fInfoText.setText( fInput.detailTitle + '\n' + ((fInput.detailInfo != null) ? fInput.detailInfo : "")); // $NON-NLS-1$ final StyleRange title = new StyleRange(0, fInput.detailTitle.length(), null, null); title.underline = true; fInfoText.setStyleRange(title); } else { fInfoText.setText(""); // $NON-NLS-1$ } } else { fTitleImage.setImage( SharedUIResources.getImages().get(SharedUIResources.PLACEHOLDER_IMAGE_ID)); fTitleText.setText(""); // $NON-NLS-1$ fInfoText.setText(""); // $NON-NLS-1$ } if (fMode == MODE_SIMPLE) { setStatusText( (fInput.control != null && fInput.control.isFocusControl()) ? InformationDispatchHandler.getTooltipAffordanceString() : ""); //$NON-NLS-1$ } fInputChanged = false; }
private void createImages() { final Image baseImage = PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJS_TASK_TSK); this.taskIcon = new DecorationOverlayIcon( baseImage, new ImageDescriptor[] {null, null, null, null, null}, new Point(baseImage.getBounds().width + 4, baseImage.getBounds().height)) .createImage(); this.taskDefaultIcon = new DecorationOverlayIcon( baseImage, new ImageDescriptor[] { null, null, null, SharedUIResources.getImages() .getDescriptor(SharedUIResources.OVR_DEFAULT_MARKER_IMAGE_ID), null }, new Point(baseImage.getBounds().width + 4, baseImage.getBounds().height)) .createImage(); }
@Override protected void createContent(final Composite parent) { fContentComposite = new Composite(parent, SWT.NONE) { @Override public Point computeSize(final int width, final int height, final boolean changed) { return super.computeSize(width, height, changed || width != getSize().x); } }; fContentComposite.setBackgroundMode(SWT.INHERIT_FORCE); final GridLayout gridLayout = LayoutUtil.applyCompositeDefaults(new GridLayout(), 2); gridLayout.horizontalSpacing = (int) ((gridLayout.horizontalSpacing) / 1.5); fContentComposite.setLayout(gridLayout); final int vIndent = Math.max(1, LayoutUtil.defaultVSpacing() / 4); final int hIndent = Math.max(2, LayoutUtil.defaultHSpacing() / 3); { // Title image fTitleImage = new Label(fContentComposite, SWT.NULL); final Image image = SharedUIResources.getImages().get(SharedUIResources.PLACEHOLDER_IMAGE_ID); fTitleImage.setImage(image); final GridData textGd = new GridData(SWT.FILL, SWT.TOP, false, false); fTitleText = new StyledText(fContentComposite, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP) { @Override public Point computeSize(int width, final int height, final boolean changed) { if (!fLayoutHint && width <= 0 && fContentComposite.getSize().x > 0) { width = fContentComposite.getSize().x - LayoutUtil.defaultHMargin() - fTitleImage.getSize().x - LayoutUtil.defaultHSpacing() - 10; } final Point size = super.computeSize(width, -1, true); // if (width >= 0) { // size.x = Math.min(size.x, width); // } return size; } }; fTitleText.setFont(JFaceResources.getDialogFont()); final GC gc = new GC(fTitleText); final FontMetrics fontMetrics = gc.getFontMetrics(); final GridData imageGd = new GridData(SWT.FILL, SWT.TOP, false, false); imageGd.horizontalIndent = hIndent; final int textHeight = fontMetrics.getAscent() + fontMetrics.getLeading(); final int imageHeight = image.getBounds().height; final int shift = Math.max(3, (int) ((fontMetrics.getDescent()) / 1.5)); if (textHeight + shift < imageHeight) { imageGd.verticalIndent = vIndent + shift; textGd.verticalIndent = vIndent + (imageHeight - textHeight); } else { imageGd.verticalIndent = vIndent + (textHeight - imageHeight) + shift; textGd.verticalIndent = vIndent; } fTitleImage.setLayoutData(imageGd); fTitleText.setLayoutData(textGd); fLayoutWorkaround = true; gc.dispose(); } fInfoText = new StyledText( fContentComposite, fMode == MODE_FOCUS ? (SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL) : (SWT.MULTI | SWT.READ_ONLY)); fInfoText.setIndent(hIndent); fInfoText.setFont(JFaceResources.getFont(PREF_DETAIL_PANE_FONT)); final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); // gd.widthHint = LayoutUtil.hintWidth(fInfoText, INFO_FONT, 50); fInfoText.setLayoutData(gd); setBackgroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); setForegroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); updateInput(); }