Added by Tony Lam, last edited by Tony Lam on Aug 22, 2007  (view change)

Labels

 

Available pages on Eclipse

Eclipse Programming Tips

How to hide the sash form separator from form?

SashForm sashForm = new SashForm(parent, SWT.NONE);
getToolkit().adapt(sashForm);

How to change drag and drop icon?

http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet257.java

How to load an editor input into an EMF object

Resource resource = SDOUtil.createResourceSet().createResource(EditUIUtil.getURI(getEditorInput()));
resource.load(null);
Object content = resource.getContents().get(0);

How to hide SWT widget using GridLayout

Set data height or width to 0 (-1 is reserved as default size) and run layout()

this.setLayout(new GridLayout());
title = new Label(this, SWT.NONE);
title.setText("Title");
titleData = new GridData(SWT.CENTER, SWT.CENTER, true, false);
title.setLayoutData(titleData);
composite = new Composite(this, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
render(composite);
		
b = new Button(this, SWT.CHECK);
b.setText("hide");
b.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
b.setSelection(false);
b.addListener(SWT.Selection, new Listener() {
	public void handleEvent(Event e) {
		if(b.getSelection()) {
			titleData.heightHint = 0;
		} else {
			titleData.heightHint = -1;
		}
		layout();
	}
});