[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[platform-swt-dev] composite and H/V_SCROLL
|
Hello to all,
Hope someone of you can point me to the right direction.
I'm quite new to swt/jface and probably I'm doing wrong keeping thinking in
Swing.
What I'm trying to create is a tabbed pane with few editor components (using
a FormLayout) inside.
It looks ok but I'm not able to bring the form to be scrollable inside the
tab area.
Note: the tab viewport (sorry for the swing terminology) need to be
scrollable because one of the "editors" need to displays a lot of fields and
the only thing I can able to get is some fake scrollbar that doesn't scroll
the view port at all.
Here is the code I'm using.
java -classpath
c:\eclipse\swt\swt.jar;.;c:\eclipse\plugins\org.eclipse.jface_3.0.0\jface.jar;c:\eclipse\plugins\org.eclipse.core.runtime_3.0.1\runtime.jar
WidgetWindow
Thanks in advance.
Kar
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
public class MethodEditor extends Composite
{
private Text identifierText;
private Text methodText;
private Text interfaceText;
private Button testStatus;
private Text toUseText, toCreateText;
private Text statusText;
private Combo repetition;
private Text mPortText;
private Text mPortNameText;
private Text iorText;
private Combo projectType;
private Button browseButton;
private Shell shell_main;
private Button[] radios;
public MethodEditor (Composite parent)
{
super (parent, SWT.V_SCROLL | SWT.H_SCROLL);
FormData data = null;
FormLayout layout= new FormLayout();
layout.marginWidth = 11;
layout.marginHeight = 10;
this.setLayout(layout);
// -----------------------
Label header = new Label (this, SWT.NONE);
data = new FormData (630, 0);
data.top = new FormAttachment (0,0);
data.left = new FormAttachment (0,0);
header.setLayoutData(data);
// -----------------------
Label description = new Label (this, SWT.NONE);
description.setText("Test Unit Info");
data = new FormData ();
data.left = new FormAttachment (0, 0);
data.top = new FormAttachment (header, 10);
description.setLayoutData(data);
Label separator = new Label (this, SWT.SEPARATOR | SWT.HORIZONTAL);
data = new FormData ();
data.left = new FormAttachment (description, 7);
data.top = new FormAttachment (description, 0, SWT.CENTER);
data.right = new FormAttachment (header, 0, SWT.RIGHT);
separator.setLayoutData(data);
// -----------------------------------
Label identifierLabel = new Label(this, SWT.NULL);
identifierLabel.setText("Identifier");
identifierLabel.setAlignment(SWT.RIGHT);
data = new FormData(80, 13);
data.top = new FormAttachment (description, 15);
data.left = new FormAttachment (0,0);
identifierLabel.setLayoutData(data);
identifierText = new Text(this, SWT.SINGLE | SWT.BORDER);
data = new FormData(200, 13);
data.left = new FormAttachment (identifierLabel, 7);
data.top = new FormAttachment (identifierLabel,0,SWT.CENTER);
identifierText.setLayoutData(data);
// -----------------------------------
Label interfaceLabel = new Label(this, SWT.PUSH);
interfaceLabel.setText("Interface");
interfaceLabel.setAlignment(SWT.RIGHT);
data = new FormData(80, 13);
data.top = new FormAttachment (identifierLabel, 15);
data.left = new FormAttachment (0,0);
interfaceLabel.setLayoutData(data);
interfaceText = new Text(this, SWT.SINGLE | SWT.BORDER);
data = new FormData(200, 13);
data.left = new FormAttachment (interfaceLabel, 7);
data.top = new FormAttachment (interfaceLabel, 0, SWT.CENTER);
interfaceText.setLayoutData(data);
Label methodLabel = new Label (this, SWT.NULL);
methodLabel.setText("Method");
methodLabel.setAlignment(SWT.RIGHT);
data = new FormData (80, 13);
data.left = new FormAttachment (identifierText, 10);
data.top = new FormAttachment (interfaceLabel,0,SWT.CENTER);
methodLabel.setLayoutData(data);
methodText = new Text(this, SWT.SINGLE | SWT.BORDER);
data = new FormData (200, 13);
data.left = new FormAttachment (methodLabel, 7);
data.top = new FormAttachment (interfaceLabel,0,SWT.CENTER);
methodText.setLayoutData(data);
Label testResponseLabel = new Label (this, SWT.NONE);
testResponseLabel.setText("Test");
testResponseLabel.setAlignment(SWT.RIGHT);
data = new FormData (80, 13);
data.top = new FormAttachment (interfaceLabel, 15);
data.left = new FormAttachment (0,0);
testResponseLabel.setLayoutData(data);
testStatus = new Button(this, SWT.CHECK);
testStatus.setSelection(true);
data = new FormData ();
data.left = new FormAttachment (testResponseLabel, 7);
data.top = new FormAttachment (testResponseLabel,0,SWT.CENTER);
testStatus.setLayoutData(data);
Label testResponseLabel2 = new Label (this, SWT.NONE);
testResponseLabel2.setText("must be positive!");
testResponseLabel2.setAlignment(SWT.RIGHT);
data = new FormData ();
data.left = new FormAttachment (testStatus, 7);
data.top = new FormAttachment (testResponseLabel,0,SWT.CENTER);
testResponseLabel2.setLayoutData(data);
// ----------------------------
// REFERENCES
// ----------------------------
Label referencesInfo = new Label (this, SWT.NULL);
referencesInfo.setText("References");
data = new FormData ();
data.left = new FormAttachment (0, 0);
data.top = new FormAttachment (testResponseLabel, 28);
referencesInfo.setLayoutData(data);
separator = new Label (this, SWT.SEPARATOR | SWT.LINE_SOLID | SWT.HORIZONTAL);
data = new FormData ();
data.left = new FormAttachment (referencesInfo, 7);
data.right = new FormAttachment (header, 0, SWT.RIGHT);
data.top = new FormAttachment (referencesInfo,0,SWT.CENTER);
separator.setLayoutData(data);
// -----------------------------
/// to use -------- to create
// -----------------------------
Label toUseLabel = new Label(this, SWT.PUSH);
toUseLabel.setText("Interface");
toUseLabel.setAlignment(SWT.RIGHT);
data = new FormData(80, 13);
data.top = new FormAttachment (referencesInfo, 15);
data.left = new FormAttachment (0,0);
toUseLabel.setLayoutData(data);
toUseText = new Text(this, SWT.SINGLE | SWT.BORDER);
data = new FormData(200, 13);
data.left = new FormAttachment (toUseLabel, 7);
data.top = new FormAttachment (toUseLabel, 0, SWT.CENTER);
toUseText.setLayoutData(data);
Label toCreateLabel = new Label (this, SWT.NULL);
toCreateLabel.setText("Method");
toCreateLabel.setAlignment(SWT.RIGHT);
data = new FormData (80, 13);
data.left = new FormAttachment (toUseText, 10);
data.top = new FormAttachment (toUseLabel,0,SWT.CENTER);
toCreateLabel.setLayoutData(data);
toCreateText = new Text(this, SWT.SINGLE | SWT.BORDER);
data = new FormData (200, 13);
data.left = new FormAttachment (toCreateLabel, 7);
data.top = new FormAttachment (toUseLabel,0,SWT.CENTER);
toCreateText.setLayoutData(data);
// -----------------------------
/// Save status as
// -----------------------------
Label statusLabel = new Label(this, SWT.PUSH);
statusLabel.setText("Save status");
statusLabel.setAlignment(SWT.RIGHT);
data = new FormData(80, 13);
data.top = new FormAttachment (toCreateLabel, 15);
data.left = new FormAttachment (0,0);
statusLabel.setLayoutData(data);
statusText = new Text(this, SWT.SINGLE | SWT.BORDER);
data = new FormData(200, 13);
data.left = new FormAttachment (statusLabel, 7);
data.top = new FormAttachment (statusLabel, 0, SWT.CENTER);
statusText.setLayoutData(data);
// -----------------------------
/// repetition
// -----------------------------
Label repetitionLabel = new Label(this, SWT.PUSH);
repetitionLabel.setText("Repeat");
repetitionLabel.setAlignment(SWT.RIGHT);
data = new FormData(80, 13);
data.top = new FormAttachment (statusLabel, 15);
data.left = new FormAttachment (0,0);
repetitionLabel.setLayoutData(data);
repetition = new Combo (this, SWT.NONE);
repetition.setItems(new String[] {"1", "2", "3", "4", "5", "10", "20"});
repetition.setText("1");
data = new FormData (40,13);
data.top = new FormAttachment (repetitionLabel, 0, SWT.CENTER);
data.left = new FormAttachment (repetitionLabel, 7);
//data.right = new FormAttachment (mPortLabel, 0, SWT.RIGHT);
repetition.setLayoutData(data);
repetition.addTraverseListener(new TraverseListener ()
{
public void keyTraversed(org.eclipse.swt.events.TraverseEvent A)
{
System.out.println ("KEY repetition: " + repetition.getText ());
}
});
SelectionListener paramSelectionListener = new SelectionAdapter ()
{
public void widgetSelected(org.eclipse.swt.events.SelectionEvent A)
{
System.out.println ("repetition: " + repetition.getText ());
};
};
repetition.addSelectionListener(paramSelectionListener);
// ----------------------------
// PARAMETERS
// ----------------------------
Label parmsInfo = new Label (this, SWT.NULL);
parmsInfo.setText("Test Parameters");
data = new FormData ();
data.left = new FormAttachment (0, 0);
data.top = new FormAttachment (repetitionLabel, 28);
parmsInfo.setLayoutData(data);
separator = new Label (this, SWT.SEPARATOR | SWT.LINE_SOLID | SWT.HORIZONTAL);
data = new FormData ();
data.left = new FormAttachment (parmsInfo, 7);
data.right = new FormAttachment (header, 0, SWT.RIGHT);
data.top = new FormAttachment (parmsInfo,0,SWT.CENTER);
separator.setLayoutData(data);
}
}
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
public class WidgetWindow extends ApplicationWindow
{
/**
* @param arg0
*/
public WidgetWindow()
{
super(null);
// TODO Auto-generated constructor stub
}
protected Control createContents(Composite parent)
{
TabFolder tf = new TabFolder(parent, SWT.V_SCROLL | SWT.H_SCROLL);
TabItem editor1 = new TabItem (tf, SWT.NONE);
editor1.setText("Editor 1");
editor1.setControl(new MethodEditor (tf));
return parent;
}
public static void main(String[] args)
{
WidgetWindow wwin = new WidgetWindow ();
wwin.setBlockOnOpen(true);
wwin.open();
Display.getCurrent().dispose ();
}
}