Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Creating a view that shows a list of images from ISharedImages
//Config:UIThread__False
import org.eclipse.jface.dialogs.*
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.events.*;
def panel = eclipseUI.new_Panel("view images").clear()
def container = panel.composite;
container.setLayout(new FormLayout());
Label lblNewLabel = new Label(container, SWT.NONE);
FormData fd_lblNewLabel = new FormData();
fd_lblNewLabel.top = new FormAttachment(0, 10);
fd_lblNewLabel.left = new FormAttachment(0, 0);
lblNewLabel.setLayoutData(fd_lblNewLabel);
lblNewLabel.setText("Selected Image");
Text text = new Text(container, SWT.BORDER);
FormData fd_text = new FormData();
fd_text.right = new FormAttachment(100,0);
fd_text.top = new FormAttachment(lblNewLabel, -3, SWT.TOP);
fd_text.left = new FormAttachment(lblNewLabel, 6);
text.setLayoutData(fd_text);
composite = new Composite(container, SWT.NONE);
FormData fd_composite = new FormData();
fd_composite.top = new FormAttachment(text, 4);
fd_composite.left = new FormAttachment(0);
fd_composite.bottom = new FormAttachment(100, 0);
fd_composite.right = new FormAttachment(100,0);
composite.setLayoutData(fd_composite);
composite.setLayout(new FillLayout());
Group grpText = new Group(composite, SWT.NONE);
grpText.setText("Images from ISharedImages (click to see name)");
grpText.setLayout(new RowLayout(SWT.HORIZONTAL));
def image = images.get(images.names().first());
for(final String name : images.names())
{
def label = new Label(grpText,SWT.NONE);
label.setImage(images.get(name));
label.addMouseListener( new MouseAdapter() {
def pinnedName = name;
public void mouseUp(MouseEvent e)
{
text.setText(pinnedName);
}});
}
//new Label(grpText,SWT.NONE).setImage(images.get(1));
//new Label(grpText,SWT.NONE).setImage(images.get(20));
//new Label(grpText,SWT.NONE).setImage(images.get(10));
panel.refresh();
return "done";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.