@Override protected String retrieveCSSProperty( Control control, String property, String pseudo, CSSEngine engine) throws Exception { if (control instanceof ToolBar) { if (ICathyConstants.PROPERTY_TOOL_ITEM_COLOR.equals(property)) { Color fgColor = ((ToolBar) control).getForeground(); return engine.convert(fgColor, Color.class, null); } } return null; }
@Override protected void applyCSSProperty( Control control, String property, CSSValue value, String pseudo, CSSEngine engine) throws Exception { if (!(control instanceof ToolBar)) return; ToolBar toolBar = (ToolBar) control; if (ICathyConstants.PROPERTY_TOOL_ITEM_COLOR.equals(property)) { Color color = (Color) engine.convert(value, Color.class, toolBar.getDisplay()); toolBar.setForeground(color); ToolItem[] items = toolBar.getItems(); for (ToolItem each : items) { String text = each.getText(); each.setText(text); } } else if (ICathyConstants.PROPERTY_VIEW_MENU.equals(property)) { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { if (((CSSPrimitiveValue) value).getPrimitiveType() == CSSPrimitiveValue.CSS_URI) { String imageUrl = ((CSSPrimitiveValue) value).getStringValue(); ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(new URL(imageUrl.toString())); Image image = JFaceResources.getResources().createImage(imageDescriptor); if (TOOLBAR_TAG_VIEW_MENU.equals(toolBar.getData())) { toolBar.getItem(0).setImage(image); } } } } // else if ("xswt-view-properties-pin".equals(property)) { // ToolItem[] items = toolBar.getItems(); // for (ToolItem each : items) { // Object data = each.getData(); // if (data instanceof ActionContributionItem) { // String id = ((ActionContributionItem) data).getId(); // if (id.contains("org.eclipse.ui.views.properties.PinPropertySheetAction")) // { // // } // } // } // } }