SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.
Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg
by nocomm » Fri Sep 19, 2003 12:08 am
Hi there!
First of all I have to say that I really like your tool - it makes it even more fun, programming with Eclipse, now!
My question concerns the TabItem handling:
In my application I use a TabFolder, where on the first Tab the user is asked to login. At this moment the other TabItems should not be accessible! I already read in another post, that it is not possible yet to disable a TabItem, so my idea was, to catch the users mouseclick on another TabItem and to disallow the access somehow (does not really matter how). But the problem is, that I did not find any method that helps me to get the event when the selected TabItem changes!
Am I blind? Is there a way to recognize this?
Thanx
nocomm
-
nocomm
-
- Posts: 9
- Joined: Thu Sep 18, 2003 11:53 pm
by admin » Fri Sep 19, 2003 2:13 am
Here is small code that does what you want.
- Code: Select all
private static Text m_UserText;
private static TabItem m_InfoTabItem;
private static TabItem m_LoginTabItem;
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell();
shell.setLayout(new FillLayout());
shell.setText("SWT Application");
{
final TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
tabFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if ((e.item != m_LoginTabItem) && (m_UserText != null) && (m_UserText.getText().length() == 0)) {
tabFolder.setSelection(0);
}
}
});
{
m_LoginTabItem = new TabItem(tabFolder, SWT.NONE);
m_LoginTabItem.setText("Login");
{
final Composite composite = new Composite(tabFolder, SWT.NONE);
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
composite.setLayout(gridLayout);
m_LoginTabItem.setControl(composite);
{
final Label label = new Label(composite, SWT.NONE);
label.setText("User:");
}
{
m_UserText = new Text(composite, SWT.BORDER);
m_UserText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
}
}
{
m_InfoTabItem = new TabItem(tabFolder, SWT.NONE);
m_InfoTabItem.setText("Information");
}
}
// DESIGNER: Add controls before this line.
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
-
admin
- Moderator
-
- Posts: 166
- Joined: Thu Jul 24, 2003 12:25 am
-
by nocomm » Fri Sep 19, 2003 3:39 am
wow, that was really a fast solution!!!!!
i am totally impressed by your service!!!!
thanx
nocomm
-
nocomm
-
- Posts: 9
- Joined: Thu Sep 18, 2003 11:53 pm
by admin » Fri Sep 19, 2003 3:43 am
If we are online, we monitor our forum.
-
admin
- Moderator
-
- Posts: 166
- Joined: Thu Jul 24, 2003 12:25 am
-
Return to SWT Designer
Who is online
Users browsing this forum: Google [Bot], Yahoo [Bot] and 1 guest