/** * Add image to a widget or window * * @param parent * @param image * @throws JellyTagException */ protected void setImage(Object parent, Image image) throws GroovyException { if (parent instanceof Label) { Label label = (Label) parent; label.setImage(image); } else if (parent instanceof Button) { Button button = (Button) parent; button.setImage(image); } else if (parent instanceof Item) { Item item = (Item) parent; item.setImage(image); } else if (parent instanceof Decorations) { Decorations item = (Decorations) parent; item.setImage(image); } else if (parent instanceof Form) { Form form = (Form) parent; form.setBackgroundImage(image); } else if (parent instanceof ScrolledForm) { ScrolledForm form = (ScrolledForm) parent; form.setBackgroundImage(image); } else if (parent instanceof Window) { Window window = (Window) parent; window.getShell().setImage(image); } else { throw new GroovyException("This tag must be nested inside a <label>, <button> or <item> tag"); } }
@Override public void doSetValue(Object value) { final Object oldValue = doGetValue(); if (attribute.equals(Constants.ATTR_IMAGE)) { item.setImage((Image) value); } else if (attribute.equals(Constants.ATTR_TEXT)) { item.setText((String) value); } else if (attribute.equals(Constants.ATTR_TOOLTIP)) { if (item instanceof TableColumn) { ((TableColumn) item).setToolTipText((String) value); } if (item instanceof TreeColumn) { ((TreeColumn) item).setToolTipText((String) value); } if (item instanceof ToolItem) { ((ToolItem) item).setToolTipText((String) value); } if (item instanceof TabItem) { ((TabItem) item).setToolTipText((String) value); } } else if (attribute.equals(Constants.ATTR_ALIGNMENT)) { if (item instanceof TableColumn) { ((TableColumn) item).setAlignment((Integer) value); } if (item instanceof TreeColumn) { ((TreeColumn) item).setAlignment((Integer) value); } } else if (attribute.equals(Constants.ATTR_WIDTH)) { if (item instanceof TableColumn) { ((TableColumn) item).setWidth((Integer) value); } if (item instanceof TreeColumn) { ((TreeColumn) item).setWidth((Integer) value); } if (item instanceof ToolItem) { ((ToolItem) item).setWidth((Integer) value); } } else if (attribute.equals(Constants.ATTR_ENABLED)) { if (item instanceof ToolItem) { ((ToolItem) item).setEnabled(value == Boolean.TRUE); } } fireValueChange(Diffs.createValueDiff(oldValue, value)); }
private void updateItem(Item item) { if (!item.isDisposed()) { // defensive code ILabelProvider lprovider = (ILabelProvider) fContentViewer.getLabelProvider(); Object data = item.getData(); String oldText = item.getText(); String text = lprovider.getText(data); if (text != null && !text.equals(oldText)) { item.setText(text); } Image oldImage = item.getImage(); Image image = lprovider.getImage(data); if (image != null && !image.equals(oldImage)) { item.setImage(image); } } }
private void loadCommon(Item column) { column.setData(DescriptorKey, this); if (imagePath != null) column.setImage(ResourceManager.imageFor(imagePath)); }
/* * @see org.eclipse.swt.widgets.Item#setImage(org.eclipse.swt.graphics.Image) */ @Override public void setImage(Image image) { super.setImage(image); fDetailsBlock.setImage(image); }