@Override public void setEnabled( boolean enabled ) { styledText.setEnabled( enabled ); // StyledText component does not get the "disabled" look, so it needs to be applied explicitly // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=4745 if ( Display.getDefault() != null ) { Color foreground = Display.getDefault().getSystemColor( enabled ? SWT.COLOR_BLACK : SWT.COLOR_DARK_GRAY ); Color background = Display.getDefault().getSystemColor( enabled ? SWT.COLOR_WHITE : SWT.COLOR_WIDGET_BACKGROUND ); styledText.setForeground( foreground ); styledText.setBackground( background ); } } }
public void setEnabled (boolean enabled) { edit.setEnabled(enabled); }
public void setText (TextContainer oriCont) { modified = false; textFrag = null; textCont = oriCont; edit.setEnabled(oriCont != null); if ( oriCont == null ) { edit.setText(""); return; } // Otherwise: set the content createFragmentFromContainer(); updateText(null); }
public void setText (TextFragment oriFrag) { modified = false; textCont = null; textFrag = oriFrag; edit.setEnabled(oriFrag != null); if ( oriFrag == null ) { edit.setText(""); } else { codedText = textFrag.getCodedText(); // Make a copy of the list, as getCodes() gives an un-modifiable list codes = new ArrayList<Code>(textFrag.getCodes()); updateText(null); } }
public void setEnabled(boolean enabled) { if (enabled != fEnabled) { fEnabled= enabled; StyledText c= getTextWidget(); if (c != null) { c.setEnabled(enabled); Display d= c.getDisplay(); c.setBackground(enabled ? d.getSystemColor(SWT.COLOR_LIST_BACKGROUND) : null); } } }
@Override protected Control createMessageArea(Composite composite) { Composite main = new Composite(composite, SWT.NONE); main.setLayout(new GridLayout(2, false)); GridDataFactory.fillDefaults().indent(0, 0).grab(true, true).applyTo( main); // add error image super.createMessageArea(main); StyledText text = new StyledText(main, SWT.FULL_SELECTION | SWT.WRAP); text.setEnabled(false); text.setBackground(main.getBackground()); String messageText = NLS.bind(UIText.CloneFailureDialog_checkList, cause); int newLinesCount = messageText.split("\n").length; //$NON-NLS-1$ Bullet bullet = createBullet(main); text.setText(messageText); text.setLineBullet(newLinesCount - 4, 2, bullet); return main; }
public static StyledText createStyledText(final Composite parent, final String text, final int color, final boolean grabExcessHorizontalSpace) { final StyledText styledText = new StyledText(parent, SWT.WRAP); styledText.setEnabled(false); styledText.setDoubleClickEnabled(false); styledText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, grabExcessHorizontalSpace, false)); styledText.setEditable(false); styledText.setText(text); styledText.setForeground(createColor(color)); return styledText; }
/** * Create the error page of this rendering * * @param parent the parent to add the page to */ private void createMessagePage(Composite parent) { if (fTextViewer == null) { fTextViewer = new TextViewer(parent, SWT.WRAP); fTextViewer.setDocument(new Document()); StyledText styleText = fTextViewer.getTextWidget(); styleText.setEditable(false); styleText.setEnabled(false); } }
public void setEnabled(boolean enabled) { if (enabled != fEnabled) { fEnabled= enabled; StyledText c= getSourceViewer().getTextWidget(); if (c != null) { c.setEnabled(enabled); Display d= c.getDisplay(); if (enabled) { c.setBackground(d.getSystemColor(SWT.COLOR_LIST_BACKGROUND)); } } } }
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); StyledText text = new StyledText(shell, SWT.NONE); text.setEditable(false); text.setEnabled(false); text.setText("Blue and not blue"); Color blue = display.getSystemColor(SWT.COLOR_BLUE); StyleRange range = new StyleRange(0, 4, blue, null); text.setStyleRange(range); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
/** * Create the error page for this rendering. * The error page is used to report any error resulted from * getting memory from a memory block. * @param parent the parent composite */ private void createErrorPage(Composite parent) { if (fTextViewer == null) { fTextViewer = new TextViewer(parent, SWT.WRAP); fTextViewer.setDocument(new Document()); StyledText styleText = fTextViewer.getTextWidget(); styleText.setEditable(false); styleText.setEnabled(false); } }
protected void createContent(Composite parent) { Display display = parent.getDisplay(); Color foreground = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND); Color background = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND); StyledText hint = new StyledText(popup, SWT.READ_ONLY | SWT.SINGLE); String enterKeyName = getEnterBinding(); String hintTemplate = "Enter new name, press {0} to refactor"; hint.setText(Messages.format(hintTemplate, enterKeyName)); hint.setForeground(foreground); hint.setStyleRange(new StyleRange(hintTemplate.indexOf("{0}"), enterKeyName.length(), null, null, SWT.BOLD)); //$NON-NLS-1$ hint.setEnabled(false); // text must not be selectable addViewMenu(parent); recursiveSetBackgroundColor(parent, background); }
errorText.setEnabled(false); errorText.setText(""); //$NON-NLS-1$
private void createContent(Composite parent) { Display display= parent.getDisplay(); Color foreground= display.getSystemColor(SWT.COLOR_INFO_FOREGROUND); Color background= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND); addMoveSupport(fPopup, parent); StyledText hint= new StyledText(fPopup, SWT.READ_ONLY | SWT.SINGLE); hint.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); String enterKeyName= getEnterBinding(); String hintTemplate= ReorgMessages.RenameInformationPopup_EnterNewName; hint.setText(Messages.format(hintTemplate, enterKeyName)); hint.setForeground(foreground); hint.setStyleRange(new StyleRange(hintTemplate.indexOf("{0}"), enterKeyName.length(), null, null, SWT.BOLD)); //$NON-NLS-1$ hint.setEnabled(false); // text must not be selectable addMoveSupport(fPopup, hint); addLink(parent); addViewMenu(parent); recursiveSetBackgroundColor(parent, background); }
private void createContent(Composite parent) { Display display= parent.getDisplay(); Color foreground= getInformationForegroundColor(display); Color background= getInformationBackgroundColor(display); addMoveSupport(fPopup, parent); StyledText hint= new StyledText(fPopup, SWT.READ_ONLY | SWT.SINGLE); hint.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); String enterKeyName= getEnterBinding(); String hintTemplate= ReorgMessages.RenameInformationPopup_EnterNewName; hint.setText(Messages.format(hintTemplate, enterKeyName)); hint.setForeground(foreground); hint.setStyleRange(new StyleRange(hintTemplate.indexOf("{0}"), enterKeyName.length(), null, null, SWT.BOLD)); //$NON-NLS-1$ hint.setEnabled(false); // text must not be selectable addMoveSupport(fPopup, hint); addLink(parent); addViewMenu(parent); recursiveSetBackgroundColor(parent, background); }
private void createContent(Composite parent) { Display display= parent.getDisplay(); Color foreground= display.getSystemColor(SWT.COLOR_INFO_FOREGROUND); Color background= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND); addMoveSupport(fPopup, parent); StyledText hint= new StyledText(fPopup, SWT.READ_ONLY | SWT.SINGLE); String enterKeyName= getEnterBinding(); String hintTemplate= ReorgMessages.RenameInformationPopup_EnterNewName; hint.setText(Messages.format(hintTemplate, enterKeyName)); hint.setForeground(foreground); hint.setStyleRange(new StyleRange(hintTemplate.indexOf("{0}"), enterKeyName.length(), null, null, SWT.BOLD)); //$NON-NLS-1$ hint.setEnabled(false); // text must not be selectable addMoveSupport(fPopup, hint); addViewMenu(parent); recursiveSetBackgroundColor(parent, background); }
private void configureStyledText(String text, boolean enabled) { if (fStyledText == null) return; fStyledText.setText(text); int count= fStyledText.getCharCount(); if (count == 0) return; Color foreground= enabled ? null : Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY); fStyledText.setStyleRange(new StyleRange(0, count, foreground, null)); StyleRange styleRange= new StyleRange(0, count, foreground, null); styleRange.metrics= new GlyphMetrics(0, 0, 20); fStyledText.setLineBullet(0, fStyledText.getLineCount(), new Bullet(styleRange)); fStyledText.setEnabled(enabled); } }
private void configureStyledText(String text, boolean enabled) { if (fStyledText == null) return; fStyledText.setText(text); int count= fStyledText.getCharCount(); if (count == 0) return; Color foreground= enabled ? null : Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY); fStyledText.setStyleRange(new StyleRange(0, count, foreground, null)); StyleRange styleRange= new StyleRange(0, count, foreground, null); styleRange.metrics= new GlyphMetrics(0, 0, 20); fStyledText.setLineBullet(0, fStyledText.getLineCount(), new Bullet(styleRange)); fStyledText.setEnabled(enabled); } }
private void configureStyledText(String text, boolean enabled) { if (fStyledText == null) return; fStyledText.setText(text); int count= fStyledText.getCharCount(); if (count == 0) return; Color foreground= enabled ? null : Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY); fStyledText.setStyleRange(new StyleRange(0, count, foreground, null)); StyleRange styleRange= new StyleRange(0, count, foreground, null); styleRange.metrics= new GlyphMetrics(0, 0, 20); fStyledText.setLineBullet(0, fStyledText.getLineCount(), new Bullet(styleRange)); fStyledText.setEnabled(enabled); } }
/** * @see org.eclipse.jface.preference.FieldEditor#setEnabled(boolean, org.eclipse.swt.widgets.Composite) */ public void setEnabled(boolean enabled) { fViewer.setEditable(enabled); fViewer.getTextWidget().setEnabled(enabled); if (enabled) { fViewer.updateViewerColors(); fViewer.getTextWidget().setFocus(); fActivation = fHandlerService.activateHandler(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, fHandler); } else { Color color = fViewer.getControl().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); fViewer.getTextWidget().setBackground(color); if(fActivation != null) { fHandlerService.deactivateHandler(fActivation); } } valueChanged(); }