jface

How best to use ViewerFilter on a TreeViewer?

[亡魂溺海] 提交于 2019-12-06 21:22:41
问题 I am applying a ViewerFilter to a tree of a few branches, but mostly leaves. The filter really applies to the leaves, using properties within the leaf. All branches are left untouched so that their leaves can appear. However I would like to filter out branches that contain no selected leaves, and I can see no mechanism within ViewerFilter that allows this. Is this possible at all? For example, given the notional tree below (where b is a branch, a L is a leaf) b0 b1 L2 L4 L8 b2 L1 L3 L5 I

SWT/JFace: remove widgets

非 Y 不嫁゛ 提交于 2019-12-06 18:19:53
问题 Group group = new Group(parent, SWT.NONE); StyledText comment = new StyledText(group, SWT.BORDER_DASH); This creates a group with a text area inside. How can I later delete the text (remove it from the screen so that I can replace it with something else)? 回答1: Use Widget.dispose. public class DisposeDemo { private static void addControls(final Shell shell) { shell.setLayout(new GridLayout()); Button button = new Button(shell, SWT.PUSH); button.setText("Click to remove all controls from shell"

How do you utilize SWT's Hi-DPI support for icons?

痴心易碎 提交于 2019-12-06 15:05:29
According to Eclipse Project Neon - New and Noteworthy , SWT supports auto-scaling for Hi-DPI monitors. Does SWT only support "auto-scaling", or does it provide additional features such as defining different images for various DPIs or zoom levels? If so, what are the classes I need to be looking into? SWT's Image has a new constructor that accepts an ImageDataProvider in order to provide image data for different zoom levels. if the application is moved to a monitor with different DPI or the zoom level is changed, the provider will be asked to return an image for the new zoom level (e.g. 150 or

Updating the JFace TreeViewer after the underlying model changes

前提是你 提交于 2019-12-06 13:47:51
问题 I have a tree viewer in my view, which listens to EMF models from the standard Ecore editor and does further things with it. I have already registered a selection listener, which checks whether the selected elements are the types the tree viewer needs as input. So the problem is that if there any changes in the model (e.g. adding a new element or new information to an existing element etc.) the tree viewer shows the changed model only if the user changes the selection, i.e. clicks to any

Background color of widgets in JFace PopupDialog

元气小坏坏 提交于 2019-12-06 13:43:25
问题 I want to use the JFace PopupDialog as lightweight dialog for user input. But I have some problems with the background color of text widgets. As you can see below in 1, a SWT.MULTI text widget has no background and border, a SWT.SINGLE text widget has no background. I tried to override the background color with: Text comment = new Text(composite, SWT.MULTI|SWT.BORDER); comment.setFocus(); comment.setBackground(new Color(Display.getDefault(), new RGB(000, 000, 000))); // method of PopupDialog

Non resizable window with JFace

荒凉一梦 提交于 2019-12-06 09:30:02
I how it's possible to setup non resizable window with JFace API. Consider code below that creates application window. I can't find any methods to setup window as not resizable on shell object or application window parent. Is there something I'm missing? public class Application extends ApplicationWindow { public Application() { super(null); } protected Control createContents(Composite parent) { prepareShell(); return parent; } protected void prepareShell() { Shell shell = getShell(); shell.setSize(450, 300); } public static void main(String[] args) { Application app = new Application(); app

JFace dialog button translation

巧了我就是萌 提交于 2019-12-06 05:20:41
问题 I am creating a standalone SWT/JFace application. I used to use plain old SWT MessageBox: int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO; MessageBox messageBox = new MessageBox (getShell(), style); messageBox.setText ("Question"); messageBox.setMessage ("So?"); boolean result = messageBox.open() == SWT.YES; I try to switch to JFace MessageDialog boolean result = MessageDialog.openQuestion(getShell(), "Question", "So?"); The problem I have is that in SWT, the Yes and No button labels are

Draggable toolbar

假装没事ソ 提交于 2019-12-06 04:33:41
how to make draggable/dockable toolbar with JFace/SWT like Eclipse has? Could you post a simple example of ApplicationWindow or link good source of how to make it. Thanks. SWT has a component called CoolBar, You can create CoolBars fairly easily by using CoolBarManager , or you can manually use just them ( API Doc ) In case that someone found this question I have prepared small example. My problem was in incorrect use of add method. You have to use add(IToolBarManager toolBarManager) method from CoolBarManager not one of from base class ContributionManager . import org.eclipse.jface.action

How do I change the background selection color for a jface table

核能气质少年 提交于 2019-12-06 04:06:05
问题 In a elipse-rcp application I am setting the background color for a row in a jface table but I don't want the selection to change this color. I want to be able to specify the color change for a selected row. 回答1: According to this thread, for JFace Viewers ( ListViewer , Table , Tree ) by means of using EraseItem and MeasureItem events General principle detailed in the article "Custom Drawing Table and Tree Items" SWT.EraseItem : allows a client to custom draw a cell's background and/or

Changing labels in a JFace TreeViewer on node expansion/collapse

喜欢而已 提交于 2019-12-06 02:04:00
I have a TreeViewer where some nodes represent folders, so I wanted to show the icon of an open folder when the node is expanded and a closed folder when it is collapsed. Sounds easy, I just need to add a tree listener (the code is in Scala, but Java equivalent should be easy to imagine): val tree = new TreeViewer(contents) tree.addTreeListener(folderIconFixingListener) private def folderIconFixingListener = new ITreeViewerListener { def treeCollapsed(event: TreeExpansionEvent) { tree.update(event.getElement, null) } def treeExpanded(event: TreeExpansionEvent) { tree.update(event.getElement,