Hi,
weiß jemand wie ich Scrollleisten in eine View von einem Plugin bekomme?
weiß jemand wie ich Scrollleisten in eine View von einem Plugin bekomme?
@Override
public void createPartControl(final Composite parent) {
final ScrolledComposite com = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
final Composite composite = new Composite(com, SWT.None);
composite.setLayout(new FillLayout());
ScrolledComposite sc = new ScrolledComposite(com, SWT.H_SCROLL | SWT.V_SCROLL);
TabFolder tabFolder = new TabFolder(sc, SWT.H_SCROLL | SWT.V_SCROLL);
Button b = new Button(tabFolder, SWT.NULL);
b.setText("this is a Button");
TabItem tabItem1 = new TabItem(tabFolder, SWT.NULL);
tabItem1.setText("item #1");
tabItem1.setControl(b);
Text t = new Text(tabFolder, SWT.MULTI);
t.setText("this is a control.");
TabItem tabItem2 = new TabItem(tabFolder, SWT.NULL);
tabItem2.setText("item #2");
tabItem2.setControl(t);
final ScrollBar hBar = com.getHorizontalBar();
hBar.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
Point location = composite.getLocation();
location.x = -hBar.getSelection();
composite.setLocation(location);
}
});
final ScrollBar vBar = com.getVerticalBar();
vBar.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
Point location = composite.getLocation();
location.y = -vBar.getSelection();
composite.setLocation(location);
}
});
com.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event e) {
Point size = composite.getSize();
Rectangle rect = com.getClientArea();
hBar.setMaximum(size.x);
vBar.setMaximum(size.y);
hBar.setThumb(Math.min(size.x, rect.width));
vBar.setThumb(Math.min(size.y, rect.height));
int hPage = size.x - rect.width;
int vPage = size.y - rect.height;
int hSelection = hBar.getSelection();
int vSelection = vBar.getSelection();
Point location = composite.getLocation();
if (hSelection >= hPage) {
if (hPage <= 0)
hSelection = 0;
location.x = -hSelection;
}
if (vSelection >= vPage) {
if (vPage <= 0)
vSelection = 0;
location.y = -vSelection;
}
composite.setLocation(location);
}
});
}