Java Code Examples for org.eclipse.swt.widgets.Text#setBackground()

The following examples show how to use org.eclipse.swt.widgets.Text#setBackground() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextCellEditor.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: FileImportPage.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
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());
		}
	});
}
 
Example 3
Source File: DbImportPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
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());
}
 
Example 4
Source File: EditorConfigPropertyPage.java    From editorconfig-eclipse with Apache License 2.0 5 votes vote down vote up
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));
}
 
Example 5
Source File: ModelSelectionPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
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));
}
 
Example 6
Source File: UpdateDescriptionPage.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 7
Source File: DialogComboSelection.java    From arx with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 8
Source File: InputDialog.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 9
Source File: WorkspaceMergeDialog.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 10
Source File: StatechartDefinitionSection.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
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);
}
 
Example 11
Source File: ViewFilterDialog.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 12
Source File: DiagramToolTip.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * 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));
}
 
Example 13
Source File: ExtraInfoDialog.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
@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;
}
 
Example 14
Source File: ReportDocumentEditor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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 );
	}
}
 
Example 15
Source File: RegexEvalHelperDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
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;
    }
  }
}
 
Example 16
Source File: ExportFileDestinationPane.java    From AppleCommander with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
			}
		}
	});
}
 
Example 17
Source File: ReportDocumentEditor.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
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 );
}
 
Example 18
Source File: GetActiveKeyDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
@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;
}
 
Example 19
Source File: RegexEvalHelperDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
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;
    }
  }
}
 
Example 20
Source File: SWTUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * 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));
}