org.eclipse.jface.resource.JFaceColors Java Examples

The following examples show how to use org.eclipse.jface.resource.JFaceColors. 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: QueryDataView.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void createPartControl ( final Composite parent )
{
    addListener ();

    parent.setLayout ( new FillLayout () );
    this.table = new Table ( parent, SWT.FULL_SELECTION );
    this.table.setHeaderVisible ( true );

    this.indexCol = new TableColumn ( this.table, SWT.NONE );
    this.indexCol.setText ( Messages.QueryDataView_ColIndex );
    this.indexCol.setWidth ( 50 );

    this.qualityCol = new TableColumn ( this.table, SWT.NONE );
    this.qualityCol.setText ( Messages.QueryDataView_ColQuality );
    this.qualityCol.setWidth ( 75 );

    this.manualCol = new TableColumn ( this.table, SWT.NONE );
    this.manualCol.setText ( Messages.QueryDataView_ColManual );
    this.manualCol.setWidth ( 75 );

    this.invalidColor = JFaceColors.getErrorBackground ( getDisplay () );
}
 
Example #2
Source File: MessageLine.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Sets the message and image to the given status. <code>null</code> is a
 * valid argument and will set the empty text and no image
 */
public void setErrorStatus( IStatus status )
{
	if ( status != null && !status.isOK( ) )
	{
		String message = status.getMessage( );
		if ( message != null && message.length( ) > 0 )
		{
			setText( message );
			setImage( findImage( status ) );
			setBackground( JFaceColors.getErrorBackground( getDisplay( ) ) );
			return;
		}
	}
	setText( "" ); //$NON-NLS-1$	
	setImage( null );
	setBackground( fNormalMsgAreaBackground );
}
 
Example #3
Source File: PyUnitView.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void addLink(IHyperlink link, int offset, int length) {
    if (testOutputText == null) {
        return;
    }
    StyleRangeWithCustomData range = new StyleRangeWithCustomData();
    range.underline = true;
    try {
        range.underlineStyle = SWT.UNDERLINE_LINK;
    } catch (Throwable e) {
        //Ignore (not available on earlier versions of eclipse)
    }

    //Set the proper color if it's available.
    TextAttribute textAttribute = ColorManager.getDefault().getHyperlinkTextAttribute();
    if (textAttribute != null) {
        range.foreground = textAttribute.getForeground();
    } else {
        range.foreground = JFaceColors.getHyperlinkText(Display.getDefault());
    }
    range.start = offset;
    range.length = length + 1;
    range.customData = link;
    testOutputText.setStyleRange(range);
}
 
Example #4
Source File: IgnoreResourcesDialog.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void setError(String text) {
	if (text == null) {
		statusMessageLabel.setText(""); //$NON-NLS-1$
		getButton(IDialogConstants.OK_ID).setEnabled(true);
	} else {
		statusMessageLabel.setText(text);
		statusMessageLabel.setForeground(JFaceColors.getErrorText(getShell().getDisplay()));
		getButton(IDialogConstants.OK_ID).setEnabled(false);
	}
}
 
Example #5
Source File: CommitCommentArea.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private Color getSpellingErrorColor(Composite composite) {
	AnnotationPreference pref = EditorsUI
			.getAnnotationPreferenceLookup().getAnnotationPreference(
					"org.eclipse.ui.workbench.texteditor.spelling"); // $NON-NLS-1$
	String preferenceKey = pref.getColorPreferenceKey();
	try {
		return fResources.createColor(PreferenceConverter.getColor(EditorsUI.getPreferenceStore(), preferenceKey));
	} catch (DeviceResourceException e) {
		SVNUIPlugin.log(IStatus.ERROR, Policy.bind("internal"), e); //$NON-NLS-1$
		return JFaceColors.getErrorText(composite.getDisplay());
	}
}
 
Example #6
Source File: SvnWizardSetPropertyPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void setError(String text) {
	if (text == null) {
		statusMessageLabel.setText(""); //$NON-NLS-1$
		setPageComplete(true);
	} else {
		statusMessageLabel.setText(text);
		statusMessageLabel.setForeground(JFaceColors.getErrorText(getShell().getDisplay()));
		setPageComplete(false);
	}
}
 
Example #7
Source File: CrosstabGrandTotalDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private Composite createTitleArea( Composite parent )
{
	int heightMargins = 3;
	int widthMargins = 8;
	final Composite titleArea = new Composite( parent, SWT.NONE );
	FormLayout layout = new FormLayout( );
	layout.marginHeight = heightMargins;
	layout.marginWidth = widthMargins;
	titleArea.setLayout( layout );

	Display display = parent.getDisplay( );
	Color background = JFaceColors.getBannerBackground( display );
	GridData layoutData = new GridData( GridData.FILL_HORIZONTAL );
	layoutData.heightHint = 20 + ( heightMargins * 2 );
	titleArea.setLayoutData( layoutData );
	titleArea.setBackground( background );

	titleArea.addPaintListener( new PaintListener( ) {

		public void paintControl( PaintEvent e )
		{
			e.gc.setForeground( titleArea.getDisplay( )
					.getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
			Rectangle bounds = titleArea.getClientArea( );
			bounds.height = bounds.height - 2;
			bounds.width = bounds.width - 1;
			e.gc.drawRectangle( bounds );
		}
	} );

	Label label = new Label( titleArea, SWT.NONE );
	label.setBackground( background );
	label.setFont( FontManager.getFont( label.getFont( ).toString( ),
			10,
			SWT.BOLD ) );
	label.setText( getTitle( ) );
	UIUtil.bindHelp( parent,
			IHelpContextIds.INSERT_EDIT_GRAND_TOTAL_DIALOG_ID );
	return titleArea;
}
 
Example #8
Source File: CrosstabPageBreakDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private Composite createTitleArea( Composite parent )
{
	int heightMargins = 3;
	int widthMargins = 8;
	final Composite titleArea = new Composite( parent, SWT.NONE );
	FormLayout layout = new FormLayout( );
	layout.marginHeight = heightMargins;
	layout.marginWidth = widthMargins;
	titleArea.setLayout( layout );

	Display display = parent.getDisplay( );
	Color background = JFaceColors.getBannerBackground( display );
	GridData layoutData = new GridData( GridData.FILL_HORIZONTAL );
	layoutData.heightHint = 20 + ( heightMargins * 2 );
	titleArea.setLayoutData( layoutData );
	titleArea.setBackground( background );

	titleArea.addPaintListener( new PaintListener( ) {

		public void paintControl( PaintEvent e )
		{
			e.gc.setForeground( titleArea.getDisplay( )
					.getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
			Rectangle bounds = titleArea.getClientArea( );
			bounds.height = bounds.height - 2;
			bounds.width = bounds.width - 1;
			e.gc.drawRectangle( bounds );
		}
	} );

	Label label = new Label( titleArea, SWT.NONE );
	label.setBackground( background );
	label.setFont( FontManager.getFont( label.getFont( ).toString( ),
			10,
			SWT.BOLD ) );
	label.setText( getTitle( ) );

	return titleArea;
}
 
Example #9
Source File: CrosstabSubTotalDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private Composite createTitleArea( Composite parent )
{
	int heightMargins = 3;
	int widthMargins = 8;
	final Composite titleArea = new Composite( parent, SWT.NONE );
	FormLayout layout = new FormLayout( );
	layout.marginHeight = heightMargins;
	layout.marginWidth = widthMargins;
	titleArea.setLayout( layout );

	Display display = parent.getDisplay( );
	Color background = JFaceColors.getBannerBackground( display );
	GridData layoutData = new GridData( GridData.FILL_HORIZONTAL );
	layoutData.heightHint = 20 + ( heightMargins * 2 );
	titleArea.setLayoutData( layoutData );
	titleArea.setBackground( background );

	titleArea.addPaintListener( new PaintListener( ) {

		public void paintControl( PaintEvent e )
		{
			e.gc.setForeground( titleArea.getDisplay( )
					.getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
			Rectangle bounds = titleArea.getClientArea( );
			bounds.height = bounds.height - 2;
			bounds.width = bounds.width - 1;
			e.gc.drawRectangle( bounds );
		}
	} );

	Label label = new Label( titleArea, SWT.NONE );
	label.setBackground( background );
	label.setFont( FontManager.getFont( label.getFont( ).toString( ),
			10,
			SWT.BOLD ) );
	label.setText( getTitle( ) );

	return titleArea;
}
 
Example #10
Source File: GroupDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the title area
 * 
 * @param parent
 *            the parent composite
 */
private void createTitleArea( Composite parent )
{
	int heightMargins = 3;
	int widthMargins = 8;
	final Composite titleArea = new Composite( parent, SWT.NONE );
	FormLayout layout = new FormLayout( );
	layout.marginHeight = heightMargins;
	layout.marginWidth = widthMargins;
	titleArea.setLayout( layout );

	Display display = parent.getDisplay( );
	Color background = JFaceColors.getBannerBackground( display );
	GridData layoutData = new GridData( GridData.FILL_HORIZONTAL );
	layoutData.heightHint = 20 + ( heightMargins * 2 );
	titleArea.setLayoutData( layoutData );
	titleArea.setBackground( background );

	titleArea.addPaintListener( new PaintListener( ) {

		public void paintControl( PaintEvent e )
		{
			e.gc.setForeground( titleArea.getDisplay( )
					.getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
			Rectangle bounds = titleArea.getClientArea( );
			bounds.height = bounds.height - 2;
			bounds.width = bounds.width - 1;
			e.gc.drawRectangle( bounds );
		}
	} );

	Label label = new Label( titleArea, SWT.NONE );
	label.setBackground( background );
	label.setFont( FontManager.getFont( label.getFont( ).toString( ),
			10,
			SWT.BOLD ) );
	label.setText( GROUP_DLG_AREA_MSG );
}
 
Example #11
Source File: GoSearchPage.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
private void statusMessage(boolean error, String message) {
  fStatusLabel.setText(message);
  if (error) {
    fStatusLabel.setForeground(JFaceColors.getErrorText(fStatusLabel.getDisplay()));
  } else {
    fStatusLabel.setForeground(null);
  }
}
 
Example #12
Source File: CustomTextEMFObservableValueEditingSupport.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void updateTextEditorFeedback(final IStatus status) {
    if (cellEditor != null && cellEditor.getControl() != null && !cellEditor.getControl().isDisposed()) {
        final Control control = cellEditor.getControl();
        if (status.getSeverity() == IStatus.ERROR) {
            control.setBackground(JFaceColors.getErrorBackground(control.getDisplay()));
            control.setForeground(JFaceColors.getErrorText(control.getDisplay()));
        } else {
            control.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_WHITE));
            control.setForeground(control.getDisplay().getSystemColor(SWT.COLOR_BLACK));
        }
    }
}
 
Example #13
Source File: SVNHistoryPage.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
void updatePanels(ISelection selection) {
  if(selection == null || !(selection instanceof IStructuredSelection)) {
    textViewer.setDocument(new Document("")); //$NON-NLS-1$
    changePathsViewer.setInput(null);
    return;
  }
  IStructuredSelection ss = (IStructuredSelection) selection;
  if(ss.size() != 1) {
    textViewer.setDocument(new Document("")); //$NON-NLS-1$
    changePathsViewer.setInput(null);
    return;
  }
  LogEntry entry = (LogEntry) ss.getFirstElement();
  textViewer.setDocument(new Document(entry.getComment()));
  StyledText text = textViewer.getTextWidget();
  
  // TODO move this logic into the hyperlink detector created in createText()
  if(projectProperties == null) {
    linkList = ProjectProperties.getUrls(entry.getComment());
  } else {
    linkList = projectProperties.getLinkList(entry.getComment());
  }
  if(linkList != null) {
    int[][] linkRanges = linkList.getLinkRanges();
    // String[] urls = linkList.getUrls();
    for(int i = 0; i < linkRanges.length; i++) {
      text.setStyleRange(new StyleRange(linkRanges[ i][ 0], linkRanges[ i][ 1], 
          JFaceColors.getHyperlinkText(Display.getCurrent()), null));
    }
  }
  if (changePathsViewer instanceof ChangePathsTreeViewer) {
  	((ChangePathsTreeViewer)changePathsViewer).setCurrentLogEntry(entry);
  }
  if (changePathsViewer instanceof ChangePathsFlatViewer) {
  	((ChangePathsFlatViewer)changePathsViewer).setCurrentLogEntry(entry);
  }
  if (changePathsViewer instanceof ChangePathsTableProvider) {
  	((ChangePathsTableProvider)changePathsViewer).setCurrentLogEntry(entry);
  }      
  changePathsViewer.setInput(entry);
}
 
Example #14
Source File: PyInformationPresenter.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
private String handleLinks(List<PyStyleRange> lst, String str, FastStringBuffer buf, String tag,
        boolean addLinkUnderline) {
    int lastIndex = 0;

    String startTag = "<" + tag;

    String endTag = "</" + tag + ">";
    int endTagLen = endTag.length();

    while (true) {
        int start = str.indexOf(startTag, lastIndex);
        if (start == -1) {
            break;
        }
        int startTagLen = str.indexOf(">", start) - start + 1;
        int end = str.indexOf(endTag, start + startTagLen);
        if (end == -1 || end == start) {
            break;
        }
        int initialIndex = lastIndex;
        lastIndex = end + endTagLen;

        buf.append(str.substring(initialIndex, start));
        int startRange = buf.length();

        buf.append(str.substring(start + startTagLen, end));
        int endRange = buf.length();

        PyStyleRange styleRange = new PyStyleRange(startRange, endRange - startRange,
                JFaceColors.getHyperlinkText(Display.getDefault()), null, SWT.BOLD);
        styleRange.tagReplaced = str.substring(start, start + startTagLen);
        if (addLinkUnderline) {
            styleRange.underline = true;
            try {
                styleRange.underlineStyle = SWT.UNDERLINE_LINK;
            } catch (Throwable e) {
                //Ignore (not available on earlier versions of eclipse)
            }
        }
        lst.add(styleRange);
    }

    buf.append(str.substring(lastIndex, str.length()));
    String newString = buf.toString();
    return newString;
}