Java 类org.eclipse.jface.resource.JFaceColors 实例源码

项目:neoscada    文件:QueryDataView.java   
@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 () );
}
项目:Hydrograph    文件:CustomAboutDialog.java   
void configureText(final Composite parent) {
    // Don't set caret to 'null' as this causes
    // https://bugs.eclipse.org/293263.
    // text.setCaret(null);
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());

    text.setFont(parent.getFont());
    text.setText(item.getText());

    text.setBackground(background);
    text.setForeground(foreground);
    text.setMargins(TEXT_MARGIN, TEXT_MARGIN, TEXT_MARGIN, 0);

    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    text.setLayoutData(gd);

    aboutTextManager = new AboutTextManager(text);
    aboutTextManager.setItem(item);

    createTextMenu();

}
项目:yamcs-studio    文件:StatusLineContributionItem.java   
private void updateMessageLabel() {
    if (label != null && !label.isDisposed()) {
        Display display = label.getDisplay();
        if (errorText != null && errorText.length() > 0) {
            label.setForeground(JFaceColors.getErrorText(display));
            label.setText(escape(errorText));
            label.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
            if (errorDetail != null)
                label.setToolTipText(escape(errorDetail));
            else if (tooltip != null)
                label.setToolTipText(escape(tooltip));
            else
                label.setToolTipText(null);

        } else {
            label.setForeground(label.getParent().getForeground());
            label.setText(escape(text));
            label.setImage(image);
            if (tooltip != null)
                label.setToolTipText(escape(tooltip));
            else
                label.setToolTipText(null);
        }
    }
}
项目:gef-gwt    文件:FieldAssistColors.java   
/**
 * Compute the RGB of the color that should be used for the background of a
 * control to indicate that the control has an error. Because the color
 * suitable for indicating an error depends on the colors set into the
 * control, this color is always computed dynamically and provided as an RGB
 * value. Clients who use this RGB to create a Color resource are
 * responsible for managing the life cycle of the color.
 * <p>
 * This color is computed dynamically each time that it is queried. Clients
 * should typically call this method once, create a color from the RGB
 * provided, and dispose of the color when finished using it.
 * 
 * @param control
 *            the control for which the background color should be computed.
 * @return the RGB value indicating a background color appropriate for
 *         indicating an error in the control.
 */
public static RGB computeErrorFieldBackgroundRGB(Control control) {
    /*
     * Use a 10% alpha of the error color applied on top of the widget
     * background color.
     */
    Color dest = control.getBackground();
    Color src = JFaceColors.getErrorText(control.getDisplay());
    int destRed = dest.getRed();
    int destGreen = dest.getGreen();
    int destBlue = dest.getBlue();

    // 10% alpha
    int alpha = (int) (0xFF * 0.10f);
    // Alpha blending math
    destRed += (src.getRed() - destRed) * alpha / 0xFF;
    destGreen += (src.getGreen() - destGreen) * alpha / 0xFF;
    destBlue += (src.getBlue() - destBlue) * alpha / 0xFF;

    return new RGB(destRed, destGreen, destBlue);
}
项目:gef-gwt    文件:StatusDialog.java   
/**
 * Sets the message and image to the given status.
 * 
 * @param status
 *            IStatus or <code>null</code>. <code>null</code> 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);
            // unqualified call of setImage is too ambiguous for
            // Foundation 1.0 compiler
            // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=140576
            MessageLine.this.setImage(findImage(status));
            setBackground(JFaceColors.getErrorBackground(getDisplay()));
            return;
        }
    }
    setText(""); //$NON-NLS-1$  
    // unqualified call of setImage is too ambiguous for Foundation 1.0
    // compiler
    // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=140576
    MessageLine.this.setImage(null);
    setBackground(fNormalMsgAreaBackground);
}
项目:gef-gwt    文件:StatusLine.java   
/**
 * Updates the message label widget.
 */
protected void updateMessageLabel() {
    if (fMessageLabel != null && !fMessageLabel.isDisposed()) {
        Display display = fMessageLabel.getDisplay();
        if ((fErrorText != null && fErrorText.length() > 0)
                || fErrorImage != null) {
            fMessageLabel.setForeground(JFaceColors.getErrorText(display));
            fMessageLabel.setText(fErrorText);
            fMessageLabel.setImage(fErrorImage);
        } else {
            fMessageLabel.setForeground(display
                    .getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
            fMessageLabel.setText(fMessageText == null ? "" : fMessageText); //$NON-NLS-1$
            fMessageLabel.setImage(fMessageImage);
        }
        if (copyMenuItem != null && !copyMenuItem.isDisposed()) {
            String text = fMessageLabel.getText();
            copyMenuItem.setEnabled(text != null && text.length() > 0);
        }
    }
}
项目:birt    文件:MessageLine.java   
/**
 * 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 );
}
项目:Pydev    文件:PyUnitView.java   
@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);
}
项目:subclipse    文件:IgnoreResourcesDialog.java   
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);
    }
}
项目:subclipse    文件:CommitCommentArea.java   
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());
    }
}
项目:subclipse    文件:SvnWizardSetPropertyPage.java   
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);
    }
}
项目:APICloud-Studio    文件:IgnoreResourcesDialog.java   
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);
    }
}
项目:APICloud-Studio    文件:CommitCommentArea.java   
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());
    }
}
项目:APICloud-Studio    文件:SvnWizardSetPropertyPage.java   
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);
    }
}
项目:mytourbook    文件:MessageRegion.java   
/**
 * Show the new message in the message text and update the image. Base the background color on
 * whether or not there are errors.
 * 
 * @param newMessage
 *            The new value for the message
 * @param newType
 *            One of the IMessageProvider constants. If newType is IMessageProvider.NONE show
 *            the title.
 * @see IMessageProvider
 */
public void updateText(final String newMessage, final int newType) {
    Image newImage = null;
    boolean showingError = false;
    switch (newType) {
    case IMessageProvider.NONE:
        hideRegion();
        return;
    case IMessageProvider.INFORMATION:
        newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
        break;
    case IMessageProvider.WARNING:
        newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
        break;
    case IMessageProvider.ERROR:
        newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
        showingError = true;
        break;
    }

    if (newMessage == null) {//No message so clear the area
        hideRegion();
        return;
    }
    showRegion();
    // Any more updates required
    if (newMessage.equals(messageText.getText()) && newImage == messageImageLabel.getImage()) {
        return;
    }
    messageImageLabel.setImage(newImage);
    messageText.setText(newMessage);
    if (showingError) {
        setMessageColors(JFaceColors.getErrorBackground(messageComposite.getDisplay()));
    } else {
        lastMessageText = newMessage;
        setMessageColors(JFaceColors.getBannerBackground(messageComposite.getDisplay()));
    }

}
项目:gef-gwt    文件:PaletteCustomizerDialog.java   
/**
 * A convenient method to create CLabel titles (like the ones used in the
 * Preferences dialog in the Eclipse workbench) throughout the dialog.
 * 
 * @param composite
 *            The composite in which the title is to be created (it must
 *            have a GridLayout with two columns).
 * @param text
 *            The title to be displayed
 * @return The newly created CLabel for convenience
 */
protected CLabel createSectionTitle(Composite composite, String text) {
    CLabel cTitle = new CLabel(composite, SWT.LEFT);
    Color background = JFaceColors.getBannerBackground(composite
            .getDisplay());
    Color foreground = JFaceColors.getBannerForeground(composite
            .getDisplay());
    JFaceColors.setColors(cTitle, foreground, background);
    cTitle.setFont(JFaceResources.getBannerFont());
    cTitle.setText(text);
    cTitle.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
            | GridData.VERTICAL_ALIGN_FILL));

    if (titleImage == null) {
        titleImage = new Image(composite.getDisplay(), ImageDescriptor
                .createFromFile(Internal.class,
                        "icons/customizer_dialog_title.gif").getImageData()); //$NON-NLS-1$
        composite.addDisposeListener(new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {
                titleImage.dispose();
                titleImage = null;
            }
        });
    }

    Label imageLabel = new Label(composite, SWT.LEFT);
    imageLabel.setBackground(background);
    imageLabel.setImage(titleImage);
    imageLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
            | GridData.VERTICAL_ALIGN_FILL));

    Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.horizontalSpan = 2;
    separator.setLayoutData(data);

    return cTitle;
}
项目:birt    文件:CrosstabGrandTotalDialog.java   
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;
}
项目:birt    文件:CrosstabPageBreakDialog.java   
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;
}
项目:birt    文件:CrosstabSubTotalDialog.java   
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;
}
项目:birt    文件:GroupDialog.java   
/**
 * 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 );
}
项目:Pydev    文件:ProjectFolderSelectionDialog.java   
@Override
protected Control createDialogArea(Composite parent) {
    // create composite
    Composite area = (Composite) super.createDialogArea(parent);

    Listener listener = new Listener() {
        @Override
        public void handleEvent(Event event) {
            if (statusMessage != null && validator != null) {
                String errorMsg = validator.isValid(group.getContainerFullPath());
                if (errorMsg == null || errorMsg.equals("")) { //$NON-NLS-1$
                    statusMessage.setText(""); //$NON-NLS-1$
                    getOkButton().setEnabled(true);
                } else {
                    statusMessage.setForeground(JFaceColors.getErrorText(statusMessage.getDisplay()));
                    statusMessage.setText(errorMsg);
                    getOkButton().setEnabled(false);
                }
            }
        }
    };

    // container selection group
    group = new ProjectFolderSelectionGroup(area, listener, allowNewContainerName, getMessage(),
            showClosedProjects, initialSelection);
    if (initialSelection != null) {
        group.setSelectedContainer(initialSelection);
    }

    statusMessage = new Label(parent, SWT.NONE);
    statusMessage.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    statusMessage.setFont(parent.getFont());

    return dialogArea;
}
项目:seg.jUCMNav    文件:UrnSearchPage.java   
private void statusMessage(boolean error, String message) {
    fStatusLabel.setText(message);
    if (error)
        fStatusLabel.setForeground(JFaceColors.getErrorText(fStatusLabel.getDisplay()));
    else
        fStatusLabel.setForeground(null);
}
项目:goclipse    文件:GoSearchPage.java   
private void statusMessage(boolean error, String message) {
  fStatusLabel.setText(message);
  if (error) {
    fStatusLabel.setForeground(JFaceColors.getErrorText(fStatusLabel.getDisplay()));
  } else {
    fStatusLabel.setForeground(null);
  }
}
项目:subclipse    文件:SVNHistoryPage.java   
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);
}
项目:mesfavoris    文件:HyperlinkTokenScanner.java   
@Override
public void setRange(IDocument document, int offset, int length) {
    Assert.isNotNull(document);
    setRangeAndColor(document, offset, length, JFaceColors
            .getHyperlinkText(viewer.getTextWidget().getDisplay()));
}
项目:APICloud-Studio    文件:SVNHistoryPage.java   
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);
}
项目:gef-gwt    文件:TitleAreaDialog.java   
/**
 * Creates the dialog's title area.
 * 
 * @param parent
 *            the SWT parent for the title area widgets
 * @return Control with the highest x axis value.
 */
private Control createTitleArea(Composite parent) {

    // add a dispose listener
    parent.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            if (titleAreaColor != null) {
                titleAreaColor.dispose();
            }
        }
    });
    // Determine the background color of the title bar
    Display display = parent.getDisplay();
    Color background;
    Color foreground;
    if (titleAreaRGB != null) {
        titleAreaColor = new Color(display, titleAreaRGB);
        background = titleAreaColor;
        foreground = null;
    } else {
        background = JFaceColors.getBannerBackground(display);
        foreground = JFaceColors.getBannerForeground(display);
    }

    parent.setBackground(background);
    int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    // Dialog image @ right
    titleImageLabel = new Label(parent, SWT.CENTER);
    titleImageLabel.setBackground(background);
    if (titleAreaImage == null)
        titleImageLabel.setImage(JFaceResources
                .getImage(DLG_IMG_TITLE_BANNER));
    else
        titleImageLabel.setImage(titleAreaImage);

    FormData imageData = new FormData();
    imageData.top = new FormAttachment(0, 0);
    // Note: do not use horizontalSpacing on the right as that would be a
    // regression from
    // the R2.x style where there was no margin on the right and images are
    // flush to the right
    // hand side. see reopened comments in 41172
    imageData.right = new FormAttachment(100, 0); // horizontalSpacing
    titleImageLabel.setLayoutData(imageData);
    // Title label @ top, left
    titleLabel = new Label(parent, SWT.LEFT);
    JFaceColors.setColors(titleLabel, foreground, background);
    titleLabel.setFont(JFaceResources.getBannerFont());
    titleLabel.setText(" ");//$NON-NLS-1$
    FormData titleData = new FormData();
    titleData.top = new FormAttachment(0, verticalSpacing);
    titleData.right = new FormAttachment(titleImageLabel);
    titleData.left = new FormAttachment(0, horizontalSpacing);
    titleLabel.setLayoutData(titleData);
    // Message image @ bottom, left
    messageImageLabel = new Label(parent, SWT.CENTER);
    messageImageLabel.setBackground(background);
    // Message label @ bottom, center
    messageLabel = new Text(parent, SWT.WRAP | SWT.READ_ONLY);
    JFaceColors.setColors(messageLabel, foreground, background);
    messageLabel.setText(" \n "); // two lines//$NON-NLS-1$
    messageLabel.setFont(JFaceResources.getDialogFont());
    messageLabelHeight = messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
    // Filler labels
    leftFillerLabel = new Label(parent, SWT.CENTER);
    leftFillerLabel.setBackground(background);
    bottomFillerLabel = new Label(parent, SWT.CENTER);
    bottomFillerLabel.setBackground(background);
    setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing);
    determineTitleImageLargest();
    if (titleImageLargest)
        return titleImageLabel;
    return messageLabel;
}
项目:Pydev    文件:PyInformationPresenter.java   
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;
}