`
louisling
  • 浏览: 145308 次
  • 性别: Icon_minigender_1
  • 来自: ZhuHai
社区版块
存档分类
最新评论

JFace Snippets

    博客分类:
  • RCP
 
阅读更多
Color COLOR_RED = Display.getDefault().getSystemColor(SWT.COLOR_RED);
Color COLOR_GREEN = Display.getDefault().getSystemColor(SWT.COLOR_GREEN);
Color COLOR_BLUE = Display.getDefault().getSystemColor(SWT.COLOR_BLUE);
Color COLOR_YELLOW = Display.getDefault().getSystemColor(SWT.COLOR_YELLOW);

/** @param color Color constant in SWT, eg. SWT.COLOR_RED */
public static Color getColor(int color) {
    return Display.getDefault().getSystemColor(color);
}

public static Image createImage(Display display, int red, int green, int blue) {
    Color color = new Color(display, red, green, blue);
    return createImage(display, color);
}

public static Image createImage(Display display, Color color) {
    Image image = new Image(display, 10, 10);
    GC gc = new GC(image);
    gc.setBackground(color);
    gc.fillRectangle(0, 0, 10, 10);
    gc.dispose();

    return image;
}

//LabelProvider
Image getColumnImage(Object element, int columnIndex) {
    Person p = (Person) element;
    if (columnIndex == 1) {
        if ("Alice".equals(p.getName()))
            return images[0];
        else if ("Bob".equals(p.getName()))
            return images[1];
        else if ("Mike".equals(p.getName()))
            return images[2];
    }
    return null;
}


//Change row background or foreground
LabelProvider implements ITableColorProvider {
    public Color getBackground(Object element, int columnIndex) {
        Person p = (Person) element;

        if (p.getId() <= 3)
            return RcpUI.COLOR_BLUE;

        else if (p.getId() > 5)
            return RcpUI.COLOR_YELLOW;

        return null;
    }

    public Color getForeground(Object element, int columnIndex) {
        return null;
    }
}
分享到:
评论

相关推荐

    org.eclipse.jface.snippets

    《Eclipse JFace Snippets深度解析》 在Java开发领域,Eclipse是一个广泛使用的集成开发环境(IDE),而JFace是Eclipse平台的一部分,提供了一种高级的用户界面(UI)构建工具。"org.eclipse.jface.snippets"是...

    org.eclipse.swt.snippets

    src1可能包含了基础的SWT代码片段,而Eclipse JFace Snippets则可能涉及到Eclipse JFace库的使用。JFace是建立在SWT之上的一个抽象层,它提供了高级的GUI组件和数据绑定功能,简化了SWT的使用。 以下是一些可能包含...

    SWT-resource address

    - JFace Snippets提供了JFace相关的代码示例,帮助开发者了解如何使用JFace构建应用程序。 - 示例包括数据绑定、表单编辑器等实用功能的实现。 - 这些示例有助于加深对JFace框架的理解,提高开发效率。 3. **...

    eclipse-snippets.rar

    "eclipse-snippets.rar"是一个压缩包,其中包含了与Eclipse相关的各种代码片段、教程文档以及一些插件资源,对于学习和提升Eclipse的使用技巧具有重要意义。 首先,我们来看《Understanding Layouts in SWT.doc》这...

    SWT基础代码涵盖其所有控件

    SWT(Standard Widget ...这个名为"snippets"的压缩包文件很可能是包含了一系列示例代码片段,演示了如何在SWT中使用各种控件和功能。通过学习这些代码,开发者可以快速掌握SWT的用法,解决实际开发中遇到的问题。

    Setting focus cell in TableViewer

    5. "[Eclipse_Project] View of -org_eclipse_swt_snippets-src-org-eclipse-swt-snippets-Snippet96_java.mht" 可能是Eclipse SWT Snippets项目的一部分,其中Snippet96可能是一个关于TableViewer的例子。...

Global site tag (gtag.js) - Google Analytics