MultiPageEditor [message #445065] |
Mon, 25 October 2004 15:23 |
Eclipse User |
|
|
|
Originally posted by: miha_sarda.classys.net
Hello,
I do not know if this is a swt question but i hope some of you know an
answer to my question.
Well I am trying to make a MultiPageEditor. The problem is that I do not
know how to close a page that I have added to my MultipageEditor (I want a
context menu to appear when i right click on a page tab that has a menu
item with close).
Can anyone help me please!!!
Thanks,
Mihai
|
|
|
Re: MultiPageEditor [message #445083 is a reply to message #445065] |
Mon, 25 October 2004 18:24 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
You could create the CTabFolder with the style SWT.CLOSE and this would
place an X in the corner of each tab. Or for finer control, create each tab
item with the style SWT.CLOSE if you only want the user to be able to close
some tabs.
To have a menu with Close in it, you need to create a menu and set it on the
CTabFolder.
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final CTabFolder folder = new CTabFolder(shell, SWT.BORDER);
for (int i = 0; i < 10; i++) {
CTabItem item = new CTabItem(folder, SWT.CLOSE);
item.setText("Item "+i);
Text t = new Text(folder, SWT.MULTI);
item.setControl(t);
}
Menu menu = new Menu(folder);
MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText("Close");
folder.setMenu(menu);
menuItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
CTabItem item = folder.getSelection();
item.dispose();
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
"mihai sarda" <miha_sarda@classys.net> wrote in message
news:clj5pk$jdg$1@eclipse.org...
> Hello,
> I do not know if this is a swt question but i hope some of you know an
> answer to my question.
> Well I am trying to make a MultiPageEditor. The problem is that I do not
> know how to close a page that I have added to my MultipageEditor (I want a
> context menu to appear when i right click on a page tab that has a menu
> item with close).
> Can anyone help me please!!!
>
> Thanks,
> Mihai
>
|
|
|
Re: MultiPageEditor [message #445108 is a reply to message #445083] |
Tue, 26 October 2004 12:41 |
Eclipse User |
|
|
|
Originally posted by: miha_sarda.classys.net
Thanks Veronika,
But you see I have a problem with the fact that the MultipageEditor does
not grant me permission to the CTabFolder and especially its children
items because the function used in this class refering to this 2 objects
are private.
So I can not create a Tab Item using SWT.CLOSE because it is created with
SWT.NONE.
Anyway, I have rezolved my proble setting a menu to my CTablFolder that
contains only close.
I have another problem now:
In this menu there appears my Close Item and an Item that says Input
Methods that I did not create. Can you tell me how I could get rid of it?
I have to say that the first page of the multipage editor contains a text
editor.
Thanks very much for your time!
Mihai
Veronika Irvine wrote:
> You could create the CTabFolder with the style SWT.CLOSE and this would
> place an X in the corner of each tab. Or for finer control, create each tab
> item with the style SWT.CLOSE if you only want the user to be able to close
> some tabs.
> To have a menu with Close in it, you need to create a menu and set it on the
> CTabFolder.
> public static void main(String[] args) {
> Display display = new Display();
> Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
> final CTabFolder folder = new CTabFolder(shell, SWT.BORDER);
> for (int i = 0; i < 10; i++) {
> CTabItem item = new CTabItem(folder, SWT.CLOSE);
> item.setText("Item "+i);
> Text t = new Text(folder, SWT.MULTI);
> item.setControl(t);
> }
> Menu menu = new Menu(folder);
> MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
> menuItem.setText("Close");
> folder.setMenu(menu);
> menuItem.addListener(SWT.Selection, new Listener() {
> public void handleEvent(Event event) {
> CTabItem item = folder.getSelection();
> item.dispose();
> }
> });
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> display.dispose();
> }
> "mihai sarda" <miha_sarda@classys.net> wrote in message
> news:clj5pk$jdg$1@eclipse.org...
> > Hello,
> > I do not know if this is a swt question but i hope some of you know an
> > answer to my question.
> > Well I am trying to make a MultiPageEditor. The problem is that I do not
> > know how to close a page that I have added to my MultipageEditor (I want a
> > context menu to appear when i right click on a page tab that has a menu
> > item with close).
> > Can anyone help me please!!!
> >
> > Thanks,
> > Mihai
> >
|
|
|
Powered by
FUDForum. Page generated in 0.02876 seconds