swt

SWT Invalid Thread Access on Mac OSX (Eclipse Helios)

偶尔善良 提交于 2019-11-30 14:54:05
问题 I have the simplest of all simple SWT programs (it doesn't even display hello world yet): package com.samples.swt.first; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class Main { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } } When I run this on Mac OSX from Eclipse Helios,

Eclipse RCP - ILazyTreeContentProvider implementation is unexpectedly eager

社会主义新天地 提交于 2019-11-30 14:11:37
I am developing an Eclipse RCP application, and am trying to use a ILazyTreeContentProvider implementation in order to show only the visible items at a certain time. The code: Inside the class extending ViewPart: public void createPartControl(Composite parent) { viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.VIRTUAL); drillDownAdapter = new DrillDownAdapter(viewer); viewer.setContentProvider(new ViewContentProvider()); viewer.setLabelProvider(new ViewLabelProvider()); //viewer.setSorter(new NameSorter()); viewer.setInput(getViewSite()); // Create the help context

Setting Colors in SWT

吃可爱长大的小学妹 提交于 2019-11-30 13:07:17
问题 This is pretty simple, I come from a swing/awt background. I'm just wondering what the proper way to set the background color for a SWT widget is? I've been trying: widget.setBackground( ); Except I have no idea how to create the color Object in SWT? 回答1: To create a color, try this: Device device = Display.getCurrent (); Color red = new Color (device, 255, 0, 0); 回答2: For standard colors (including common colors and default colors used by the operating system) Use Display.getSystemColor(int)

How to display system icon for a file in SWT?

╄→гoц情女王★ 提交于 2019-11-30 13:06:52
I want to display a file tree similarly to java2s.com 'Create a lazy file tree' , but include the actual system icons - especially for folders. SWT does not seem to offer this (Program API does not support folders), so I came up with the following: public Image getImage(File file) { ImageIcon systemIcon = (ImageIcon) FileSystemView.getFileSystemView().getSystemIcon(file); java.awt.Image image = systemIcon.getImage(); int width = image.getWidth(null); int height = image.getHeight(null); BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g2d =

how to dynamically add swt widgets to a composite?

≡放荡痞女 提交于 2019-11-30 12:56:36
问题 I'm trying to add widgets like text boxes, buttons to a composite on click of a button. I've tried , but i could only add these widgets dynamically only up to the size of the composite. My jface dialog is such that, it has a scrolled composite in which it holds a composite. In the main composite i have 3 other composites where i have to achieve this functionality, so if i add dynamic widgets to a composite it might expand, but it should not overlap existing composites down to it, rather it

SWT Invalid Thread Access on Mac OSX (Eclipse Helios)

余生颓废 提交于 2019-11-30 12:18:42
I have the simplest of all simple SWT programs (it doesn't even display hello world yet): package com.samples.swt.first; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class Main { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } } When I run this on Mac OSX from Eclipse Helios, I get the following error: ***WARNING: Display must be created on main thread due to Cocoa restrictions

RCP with SWT.Browser and XULRunner

ε祈祈猫儿з 提交于 2019-11-30 12:17:18
问题 I'm developing an RCP application (Windows) with SWT.Browser ( SWT.MOZILLA ): Browser browser = new Browser(parent, SWT.MOZILLA); It's working fine with the old XULRunner 3.6.23 and the installation described here: xulrunner.exe --register-global I want to use the new XULRunner 8.x, but as mentioned here the old way to install XULRunner was removed. So I added the XULRunner-Path programmatically: System.setProperty("org.eclipse.swt.browser.XULRunnerPath", "Path\\To\\xulrunner_8.x"); But when

How to get Eclipse SWT Browser component running on Ubuntu 11.04 (Natty Narwhal) with Webkit?

点点圈 提交于 2019-11-30 11:39:55
问题 I use the SWT Browser control in my Eclipse RCP application. On Linux Ubuntu 10.10 this depends on the user having installed xulrunner-1.9.2. This works fine. However, on Ubuntu 11.04 I find that it ships by default with xulrunner-2.0. The SWT Browser does not support this. See http://bugs.eclipse.org/bugs/show_bug.cgi?id=327696 and http://bugs.eclipse.org/bugs/process_bug.cgi So rather than ask the user to install xulrunner-1.9.2 I want to get the SWT Browser to run with WebKitGTK as per the

Why does an SWT Composite sometimes require a call to resize() to layout correctly?

帅比萌擦擦* 提交于 2019-11-30 11:28:05
问题 Sometimes we encounter an SWT composite that absolutely refuses to lay itself out correctly. Often we encounter this when we have called dispose on a composite, and then replaced it with another; although it does not seem to be strictly limited to this case. When we run into this problem, about 50 % of the time, we can call pack() and layout() on the offending composite, and all will be well. About 50 % of the time, though, we have to do this: Point p = c.getSize(); c.setSize(p.x+1, p.y+1); c

Context menu for TreeViewer based on selected node - SWT

ⅰ亾dé卋堺 提交于 2019-11-30 09:19:07
I need to create a context menu for a TreeViewer in an Eclipse plugin project. But, the menu should not contain constant items, they should vary depending on the type of the node that is selected. For example, my treeViewer has the following hierarchy: Node A | --Node B | --Node C For node A - I want to show a menu with an action, but for nodes B and C I don't want to show anything (no menu). I managed to create the menu for node A, but then I can't get rid of it when some other type of node is selected. My code looks like: treeViewer.addSelectionChangedListener( new ISelectionChangedListener(