org.eclipse.swt.widgets.Text#setBackground ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Text#setBackground ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tmxeditor8   文件: TextCellEditor.java
protected Text createTextControl(Composite parent) {
	IStyle cellStyle = getCellStyle();
	final Text textControl = new Text(parent, HorizontalAlignmentEnum.getSWTStyle(cellStyle));
	textControl.setBackground(cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
	textControl.setForeground(cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
	textControl.setFont(cellStyle.getAttributeValue(CellStyleAttributes.FONT));
	
	textControl.addKeyListener(new KeyAdapter() {
		private final Color originalColor = textControl.getForeground();
		@Override
		public void keyReleased(KeyEvent e) {
			if (!validateCanonicalValue()) {
				textControl.setForeground(GUIHelper.COLOR_RED);
			} else {
				textControl.setForeground(originalColor);
			}
		};
	});
	
	return textControl;
}
 
源代码2 项目: olca-app   文件: FileImportPage.java
private void mappingFileRow(Composite body) {
	if (!withMappingFile)
		return;
	Composite comp = new Composite(body, SWT.NONE);
	UI.gridLayout(comp, 3, 5, 0);
	UI.gridData(comp, true, false);
	new Label(comp, SWT.NONE).setText("Mapping file");
	Text text = new Text(comp, SWT.BORDER);
	UI.gridData(text, true, false);
	text.setEditable(false);
	text.setBackground(Colors.white());
	Button button = new Button(comp, SWT.NONE);
	button.setText(M.Browse);
	Controls.onSelect(button, e -> {
		mappingFile = FileChooser.open("*.csv");
		if (mappingFile == null) {
			text.setText("");
		} else {
			text.setText(mappingFile.getAbsolutePath());
		}
	});
}
 
源代码3 项目: MergeProcessor   文件: WorkspaceMergeDialog.java
/**
 * Creates the text field showing the established commands.
 * 
 * @param parent the parent composite of the text field
 * @return the text field
 */
private static Text createEstablishedCommandsText(final Composite parent) {
	final Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(new GridLayout(2, false));
	GridDataFactory.fillDefaults().span(2, 1).exclude(true).applyTo(composite);
	final Text text = new Text(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
	GridDataFactory.fillDefaults().grab(true, true).hint(0 /* Do not layout dependent to the content */, 100)
			.span(2, 1).applyTo(text);
	text.setEditable(false);
	text.setBackground(text.getDisplay().getSystemColor(SWT.COLOR_BLACK));
	text.setForeground(text.getDisplay().getSystemColor(SWT.COLOR_GRAY));
	text.setFont(JFaceResources.getFont(CONSOLE_FONT));
	return text;
}
 
源代码4 项目: birt   文件: ReportDocumentEditor.java
private void updateDetailsText( )
{
	if ( details != null )
	{
		details.dispose( );
		details = null;
	}

	if ( showingDetails )
	{
		detailsButton.setText( IDialogConstants.HIDE_DETAILS_LABEL );
		Text detailsText = new Text( detailsArea, SWT.BORDER
				| SWT.H_SCROLL
				| SWT.V_SCROLL
				| SWT.MULTI
				| SWT.READ_ONLY
				| SWT.LEFT_TO_RIGHT );
		detailsText.setText( getStackTrace( e ) );
		detailsText.setBackground( detailsText.getDisplay( )
				.getSystemColor( SWT.COLOR_LIST_BACKGROUND ) );
		details = detailsText;
		detailsArea.layout( true );
	}
	else
	{
		detailsButton.setText( IDialogConstants.SHOW_DETAILS_LABEL );
	}
}
 
源代码5 项目: ice   文件: ExtraInfoDialog.java
@Override
protected Control createDialogArea(Composite parent) {

	// Local Declarations
	Composite swtComposite = (Composite) super.createDialogArea(parent);
	GridLayout layout = (GridLayout) swtComposite.getLayout();
	Color backgroundColor = getParentShell().getDisplay()
			.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);

	// Set the column layout to one so that everything will stack
	layout.numColumns = 1;

	// Add the description as text
	Text text = new Text(swtComposite, SWT.FLAT);
	text.setToolTipText(dataComp.getDescription());
	text.setText(dataComp.getDescription());
	text.setLayoutData(new GridData(255, SWT.DEFAULT));
	text.setEditable(false);
	text.setBackground(backgroundColor);

	// Create the DataComponentComposite that will render the Entries
	dataComposite = new DataComponentComposite(dataComp, swtComposite,
			SWT.FLAT);

	// Set the data composite's layout. This arranges the composite to be a
	// tight column.
	GridLayout dataLayout = new GridLayout(1, true);
	GridData dataGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
	dataComposite.setLayout(dataLayout);
	dataComposite.setLayoutData(dataGridData);

	return swtComposite;
}
 
源代码6 项目: tracecompass   文件: DiagramToolTip.java
/**
 * Create a new tooltip for the given parent control
 *
 * @param parent the parent control.
 */
public DiagramToolTip(Control parent) {
    fParent = parent;
    fToolTipShell = new Shell(fParent.getShell(), SWT.MULTI);
    fToolTipShell.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    fTextBox = new Text(fToolTipShell, SWT.WRAP | SWT.MULTI);
    fTextBox.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
}
 
源代码7 项目: tracecompass   文件: ViewFilterDialog.java
private void handleEnterPressed(Composite parent, Composite labels, Text filterText) {
    String currentRegex = filterText.getText();
    if (currentRegex.isEmpty() || fFilterRegexes.size() == MAX_FILTER_REGEX_SIZE || fFilterRegexes.contains(currentRegex)) {
        filterText.setBackground(fColorScheme.getColor(TimeGraphColorScheme.TOOL_BACKGROUND));
        return;
    }
    boolean added = fFilterRegexes.add(currentRegex);
    if (added) {
        filterText.setText(EMPTY_STRING);
        fRegex = EMPTY_STRING;

        createCLabels(parent, labels, currentRegex);
    }
}
 
源代码8 项目: statecharts   文件: StatechartDefinitionSection.java
protected void createNameLabel(Composite labelComposite) {
	nameLabel = new Text(labelComposite, SWT.SINGLE | SWT.NORMAL);
	GridDataFactory.fillDefaults().indent(5, 1).grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(nameLabel);
	Optional<String> name = getStatechartName();
	if (name.isPresent()) {
		nameLabel.setText(name.get());
	}
	nameLabel.setEditable(isStatechart());
	nameLabel.setBackground(ColorConstants.white);
	nameModificationListener = new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent e) {
			Optional<Statechart> sct = getStatechart();
			if (sct.isPresent()) {
				if (Objects.equals(sct.get().getName(), nameLabel.getText())) {
					return;
				}
				getSash().setRedraw(false);
				TransactionalEditingDomain domain = getTransactionalEditingDomain();
				SetCommand command = new SetCommand(domain, sct.get(),
						BasePackage.Literals.NAMED_ELEMENT__NAME, nameLabel.getText());
				domain.getCommandStack().execute(command);
				refresh(nameLabel.getParent());
				getSash().setRedraw(true);
			}
		}
	};
	nameLabel.addModifyListener(nameModificationListener);
}
 
源代码9 项目: olca-app   文件: DbImportPage.java
private void createFileSection(Composite body) {
	Button fileCheck = new Button(body, SWT.RADIO);
	fileCheck.setText("From exported zolca-File");
	Controls.onSelect(fileCheck, (e) -> setSelection(config.FILE_MODE));
	Composite composite = UI.formComposite(body);
	UI.gridData(composite, true, false);
	fileText = new Text(composite, SWT.READ_ONLY | SWT.BORDER);
	fileText.setBackground(Colors.white());
	UI.gridData(fileText, true, false);
	browseButton = new Button(composite, SWT.NONE);
	browseButton.setText("Browse");
	Controls.onSelect(browseButton, (e) -> selectFile());
}
 
源代码10 项目: APICloud-Studio   文件: InputDialog.java
protected Control createDialogArea(Composite parent) {
    // create composite
    Composite composite = (Composite) super.createDialogArea(parent);
    // create message
    if (message != null) {
        Label label = new Label(composite, SWT.WRAP);
        label.setText(message);
        GridData data = new GridData(GridData.GRAB_HORIZONTAL
                | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL
                | GridData.VERTICAL_ALIGN_CENTER);
        data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
        label.setLayoutData(data);
        label.setFont(parent.getFont());
    }
    text = new Text(composite, SWT.PASSWORD);
    text.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
            | GridData.HORIZONTAL_ALIGN_FILL));
    text.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            validateInput();
        }
    });
    errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.WRAP);
    errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
            | GridData.HORIZONTAL_ALIGN_FILL));
    errorMessageText.setBackground(errorMessageText.getDisplay()
            .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    // Set the error message text
    // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=66292
    setErrorMessage(errorMessage);

    applyDialogFont(composite);
    return composite;
}
 
源代码11 项目: arx   文件: DialogComboSelection.java
@Override
protected Control createDialogArea(Composite parent) {
    // create composite
    Composite composite = (Composite) super.createDialogArea(parent);
    // create message
    if (message != null) {
        Label label = new Label(composite, SWT.WRAP);
        label.setText(message);
        GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL |
                                     GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
        data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
        label.setLayoutData(data);
        label.setFont(parent.getFont());
    }
    combo = new Combo(composite, SWT.NONE);
    combo.setItems(choices);
    combo.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    combo.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            validateInput();
        }
    });
    errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.WRAP);
    errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    // Set the error message text
    // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=66292
    setErrorMessage(errorMessage);

    applyDialogFont(composite);
    return composite;
}
 
源代码12 项目: translationstudio8   文件: UpdateDescriptionPage.java
public void createControl(Composite parent) {
	Text text = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
	Color color = text.getBackground();
	text.setEditable(false);
	text.setBackground(color);
	text.setText(getUpdateDescDetailText());
	setControl(text);
}
 
源代码13 项目: olca-app   文件: ModelSelectionPage.java
private void createChooseTargetComposite(final Composite body) {
	Composite composite = new Composite(body, SWT.NONE);
	GridLayout layout = UI.gridLayout(composite, 3);
	layout.marginHeight = 0;
	layout.marginWidth = 5;
	UI.gridData(composite, true, false);
	String label = targetIsDir ? M.ToDirectory : M.ToFile;
	new Label(composite, SWT.NONE).setText(label);
	Text text = createTargetText(composite);
	text.setEditable(false);
	text.setBackground(Colors.white());
	Button button = new Button(composite, SWT.NONE);
	button.setText(M.Browse);
	Controls.onSelect(button, (e) -> selectTarget(text));
}
 
private void addProperty(final Composite parent, final String labelText, final String value) {
	final Label label = new Label(parent, SWT.NONE);
	label.setText(labelText);
	final Text valueText = new Text(parent, SWT.WRAP | SWT.READ_ONLY);
	valueText.setText(value);
	valueText.setBackground(valueText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
}
 
源代码15 项目: hop   文件: RegexEvalHelperDialog.java
private void testValue( int index, boolean testRegEx, String regExString ) {
  String realScript = regExString;
  if ( realScript == null ) {
    realScript = transmeta.environmentSubstitute( wRegExScript.getText() );
  }
  if ( Utils.isEmpty( realScript ) ) {
    if ( testRegEx ) {
      MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
      mb.setMessage( BaseMessages.getString( PKG, "RegexEvalHelperDialog.EnterScript.Message" ) );
      mb.setText( BaseMessages.getString( PKG, "RegexEvalHelperDialog.EnterScript.Title" ) );
      mb.open();
    }
    return;
  }
  String realValue = null;
  Text control = null;
  switch ( index ) {
    case 1:
      realValue = Const.NVL( transmeta.environmentSubstitute( wValue1.getText() ), "" );
      control = wValue1;
      break;
    case 2:
      realValue = Const.NVL( transmeta.environmentSubstitute( wValue2.getText() ), "" );
      control = wValue2;
      break;
    case 3:
      realValue = Const.NVL( transmeta.environmentSubstitute( wValue3.getText() ), "" );
      control = wValue3;
      break;
    case 4:
      realValue = Const.NVL( transmeta.environmentSubstitute( wValueGroup.getText() ), "" );
      control = wValueGroup;
      break;
    default:
      break;
  }
  try {
    Pattern p;
    if ( isCanonicalEqualityFlagSet() ) {
      p = Pattern.compile( regexoptions + realScript, Pattern.CANON_EQ );
    } else {
      p = Pattern.compile( regexoptions + realScript );
    }
    Matcher m = p.matcher( realValue );
    boolean ismatch = m.matches();
    if ( ismatch ) {
      control.setBackground( guiresource.getColorGreen() );
    } else {
      control.setBackground( guiresource.getColorRed() );
    }

    if ( index == 4 ) {
      wGroups.removeAll();
      int nrFields = m.groupCount();
      int nr = 0;
      for ( int i = 1; i <= nrFields; i++ ) {
        if ( m.group( i ) == null ) {
          wGroups.add( "" );
        } else {
          wGroups.add( m.group( i ) );
        }
        nr++;
      }
      wlGroups.setText( BaseMessages.getString( PKG, "RegexEvalHelperDialog.FieldsGroup", nr ) );
    }
    wRegExScriptCompile.setForeground( guiresource.getColorBlue() );
    wRegExScriptCompile.setText( BaseMessages
      .getString( PKG, "RegexEvalHelperDialog.ScriptSuccessfullyCompiled" ) );
    wRegExScriptCompile.setToolTipText( "" );
  } catch ( Exception e ) {
    if ( !errorDisplayed ) {
      wRegExScriptCompile.setForeground( guiresource.getColorRed() );
      wRegExScriptCompile.setText( e.getMessage() );
      wRegExScriptCompile.setToolTipText( BaseMessages.getString(
        PKG, "RegexEvalHelperDialog.ErrorCompiling.Message" )
        + Const.CR + e.toString() );
      this.errorDisplayed = true;
    }
  }
}
 
源代码16 项目: AppleCommander   文件: ExportFileDestinationPane.java
/**
 * Create and display the wizard pane.
 * @see com.webcodepro.applecommander.ui.swt.wizard.WizardPane#open()
 */
public void open() {
	control = new Composite(parent, SWT.NULL);
	control.setLayoutData(layoutData);
	wizard.enableNextButton(false);
	wizard.enableFinishButton(true);
	RowLayout layout = new RowLayout(SWT.VERTICAL);
	layout.justify = true;
	layout.marginBottom = 5;
	layout.marginLeft = 5;
	layout.marginRight = 5;
	layout.marginTop = 5;
	layout.spacing = 3;
	control.setLayout(layout);
	Label label = new Label(control, SWT.WRAP);
	label.setText(textBundle.get("ExportFilePrompt")); //$NON-NLS-1$

	directoryText = new Text(control, SWT.WRAP | SWT.BORDER);
	if (wizard.getDirectory() != null) directoryText.setText(wizard.getDirectory());
	directoryText.setLayoutData(new RowData(parent.getSize().x - 30, -1));
	directoryText.setBackground(new Color(control.getDisplay(), 255,255,255));
	directoryText.setFocus();
	directoryText.addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent event) {
			Text text = (Text) event.getSource();
			getWizard().setDirectory(text.getText());
		}
	});
	
	Button button = new Button(control, SWT.PUSH);
	button.setText(textBundle.get("BrowseButton")); //$NON-NLS-1$
	button.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent e) {
			DirectoryDialog directoryDialog = new DirectoryDialog(getShell());
			directoryDialog.setFilterPath(getDirectoryText().getText());
			directoryDialog.setMessage(
				UiBundle.getInstance().get("ExportFileDirectoryPrompt")); //$NON-NLS-1$
			String directory = directoryDialog.open();
			if (directory != null) {
				getDirectoryText().setText(directory);
			}
		}
	});
}
 
源代码17 项目: pentaho-kettle   文件: RegexEvalHelperDialog.java
private void testValue( int index, boolean testRegEx, String regExString ) {
  String realScript = regExString;
  if ( realScript == null ) {
    realScript = transmeta.environmentSubstitute( wRegExScript.getText() );
  }
  if ( Utils.isEmpty( realScript ) ) {
    if ( testRegEx ) {
      MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
      mb.setMessage( BaseMessages.getString( PKG, "RegexEvalHelperDialog.EnterScript.Message" ) );
      mb.setText( BaseMessages.getString( PKG, "RegexEvalHelperDialog.EnterScript.Title" ) );
      mb.open();
    }
    return;
  }
  String realValue = null;
  Text control = null;
  switch ( index ) {
    case 1:
      realValue = Const.NVL( transmeta.environmentSubstitute( wValue1.getText() ), "" );
      control = wValue1;
      break;
    case 2:
      realValue = Const.NVL( transmeta.environmentSubstitute( wValue2.getText() ), "" );
      control = wValue2;
      break;
    case 3:
      realValue = Const.NVL( transmeta.environmentSubstitute( wValue3.getText() ), "" );
      control = wValue3;
      break;
    case 4:
      realValue = Const.NVL( transmeta.environmentSubstitute( wValueGroup.getText() ), "" );
      control = wValueGroup;
      break;
    default:
      break;
  }
  try {
    Pattern p;
    if ( isCanonicalEqualityFlagSet() ) {
      p = Pattern.compile( regexoptions + realScript, Pattern.CANON_EQ );
    } else {
      p = Pattern.compile( regexoptions + realScript );
    }
    Matcher m = p.matcher( realValue );
    boolean ismatch = m.matches();
    if ( ismatch ) {
      control.setBackground( guiresource.getColorGreen() );
    } else {
      control.setBackground( guiresource.getColorRed() );
    }

    if ( index == 4 ) {
      wGroups.removeAll();
      int nrFields = m.groupCount();
      int nr = 0;
      for ( int i = 1; i <= nrFields; i++ ) {
        if ( m.group( i ) == null ) {
          wGroups.add( "" );
        } else {
          wGroups.add( m.group( i ) );
        }
        nr++;
      }
      wlGroups.setText( BaseMessages.getString( PKG, "RegexEvalHelperDialog.FieldsGroup", nr ) );
    }
    wRegExScriptCompile.setForeground( guiresource.getColorBlue() );
    wRegExScriptCompile.setText( BaseMessages
      .getString( PKG, "RegexEvalHelperDialog.ScriptSuccessfullyCompiled" ) );
    wRegExScriptCompile.setToolTipText( "" );
  } catch ( Exception e ) {
    if ( !errorDisplayed ) {
      wRegExScriptCompile.setForeground( guiresource.getColorRed() );
      wRegExScriptCompile.setText( e.getMessage() );
      wRegExScriptCompile.setToolTipText( BaseMessages.getString(
        PKG, "RegexEvalHelperDialog.ErrorCompiling.Message" )
        + Const.CR + e.toString() );
      this.errorDisplayed = true;
    }
  }
}
 
源代码18 项目: birt   文件: ReportDocumentEditor.java
private void createErrorControl( Composite parent )
{
	Color bgColor = parent.getDisplay( )
			.getSystemColor( SWT.COLOR_LIST_BACKGROUND );
	Color fgColor = parent.getDisplay( )
			.getSystemColor( SWT.COLOR_LIST_FOREGROUND );

	parent.setBackground( bgColor );
	parent.setForeground( fgColor );

	GridLayout layout = new GridLayout( );

	layout.numColumns = 3;

	int spacing = 8;
	int margins = 8;
	layout.marginBottom = margins;
	layout.marginTop = margins;
	layout.marginLeft = margins;
	layout.marginRight = margins;
	layout.horizontalSpacing = spacing;
	layout.verticalSpacing = spacing;
	parent.setLayout( layout );

	Label imageLabel = new Label( parent, SWT.NONE );
	imageLabel.setBackground( bgColor );
	Image image = getImage( );
	if ( image != null )
	{
		image.setBackground( bgColor );
		imageLabel.setImage( image );
		imageLabel.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_CENTER
				| GridData.VERTICAL_ALIGN_BEGINNING ) );
	}

	Text text = new Text( parent, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP );
	text.setBackground( bgColor );
	text.setForeground( fgColor );

	// text.setForeground(JFaceColors.getErrorText(text.getDisplay()));
	text.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
	text.setText( Messages.getString("ReportDocumentEditor.errorMessage") ); //$NON-NLS-1$

	detailsButton = new Button( parent, SWT.PUSH );
	detailsButton.addSelectionListener( new SelectionAdapter( ) {

		public void widgetSelected( SelectionEvent e )
		{
			showDetails( !showingDetails );
		}
	} );

	detailsButton.setLayoutData( new GridData( SWT.BEGINNING,
			SWT.CENTER,
			false,
			false ) );
	detailsButton.setVisible( e != null );

	updateDetailsText( );

	detailsArea = new Composite( parent, SWT.NONE );
	detailsArea.setBackground( bgColor );
	detailsArea.setForeground( fgColor );
	GridData data = new GridData( GridData.FILL_BOTH );
	data.horizontalSpan = 3;
	data.verticalSpan = 1;
	detailsArea.setLayoutData( data );
	detailsArea.setLayout( new FillLayout( ) );
	parent.layout( true );
}
 
源代码19 项目: translationstudio8   文件: GetActiveKeyDialog.java
@Override
protected Control createDialogArea(Composite parent) {
	Composite tparent = (Composite) super.createDialogArea(parent);

	GridLayout layout = new GridLayout();
	layout.marginWidth = 10;
	layout.marginTop = 10;
	tparent.setLayout(layout);

	GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);

	Composite compNav = new Composite(tparent, SWT.NONE);
	GridLayout navLayout = new GridLayout();
	compNav.setLayout(navLayout);

	createNavigation(compNav);

	Group groupActivekey = new Group(tparent, SWT.NONE);
	groupActivekey.setText(Messages.getString("license.GetActiveKeyDialog.activekey"));
	GridDataFactory.fillDefaults().grab(true, true).applyTo(groupActivekey);
	GridLayout layoutGroup = new GridLayout(2, false);
	layoutGroup.marginWidth = 5;
	layoutGroup.marginHeight = 20;
	groupActivekey.setLayout(layoutGroup);

	StyledText text = new StyledText(groupActivekey, SWT.WRAP | SWT.READ_ONLY);
	text.setBackground(text.getParent().getBackground());
	text.setText(Messages.getString("license.GetActiveKeyDialog.activemessage"));
	GridData dataText = new GridData();
	dataText.horizontalSpan = 2;
	dataText.widthHint = 470;
	text.setLayoutData(dataText);
	int start = Messages.getString("license.GetActiveKeyDialog.activemessage").indexOf(
			Messages.getString("license.GetActiveKeyDialog.ts"));
	int length = Messages.getString("license.GetActiveKeyDialog.ts").length();
	StyleRange styleRange = new StyleRange();
	styleRange.start = start;
	styleRange.length = length;
	styleRange.fontStyle = SWT.BOLD;
	styleRange.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLUE);
	text.setStyleRange(styleRange);

	Label label = new Label(groupActivekey, SWT.WRAP | SWT.NONE);
	label.setText(Messages.getString("license.GetActiveKeyDialog.activemessage1"));
	GridDataFactory.fillDefaults().span(2, 1).applyTo(label);

	textActivekey = new Text(groupActivekey, SWT.MULTI | SWT.WRAP);
	textActivekey.setEditable(false);
	textActivekey.setText(activekey);
	textActivekey.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
	GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 150).applyTo(textActivekey);

	Button btnCopy = new Button(groupActivekey, SWT.NONE);
	GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.END).applyTo(btnCopy);
	btnCopy.setImage(Activator.getImageDescriptor("images/help/copy.png").createImage());
	btnCopy.setToolTipText(Messages.getString("license.GetActiveKeyDialog.copytoclipboard"));
	btnCopy.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent event) {
			Clipboard cb = new Clipboard(Display.getCurrent());
			String textData = textActivekey.getText();
			TextTransfer textTransfer = TextTransfer.getInstance();
			cb.setContents(new Object[] { textData }, new Transfer[] { textTransfer });
		}
	});

	return tparent;
}
 
源代码20 项目: Eclipse-Postfix-Code-Completion   文件: SWTUtil.java
/**
 * Fixes https://bugs.eclipse.org/71765 by setting the background
 * color to {@code SWT.COLOR_WIDGET_BACKGROUND}.
 * <p>
 * Should be applied to all SWT.READ_ONLY Texts in dialogs (or at least those which don't have an SWT.BORDER).
 * Search regex: {@code new Text\([^,]+,[^\)]+SWT\.READ_ONLY}
 * 
 * @param textField the text field
 */
public static void fixReadonlyTextBackground(Text textField) {
	textField.setBackground(textField.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
}