Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to hide the context menu in a customized viewer?
How to hide the context menu in a customized viewer? [message #519247] Mon, 08 March 2010 09:34 Go to next message
tingel christian is currently offline tingel christianFriend
Messages: 46
Registered: December 2009
Member
Hi, All experts:

Long time no see and Long time no questions Smile

I created a new RAP project based on the mail template existing in the new project wizard and had some modification on it and it's now something like this:

public class View extends ViewPart {

public static final String ID = "org.eclipse.rap.sample.view";

MenuManager menuManager = new MenuManager();

public void createPartControl(Composite parent) {
MailViewer viewer = new MailViewer(parent);
this.getSite().registerContextMenu(menuManager, viewer);
this.getSite().setSelectionProvider(viewer);
}

public void setFocus() {
}

private class MailViewer extends Viewer
{
Composite topComposite;

MailViewer(Composite parent)
{
topComposite = new Composite(parent, SWT.None);
topComposite.setLayout(new FillLayout());

Composite top = new Composite(topComposite, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
top.setLayout(layout);
// top banner
Composite banner = new Composite(top, SWT.NONE);
banner.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_BEGINNING, true, false));
layout = new GridLayout();
layout.marginHeight = 5;
layout.marginWidth = 10;
layout.numColumns = 2;
banner.setLayout(layout);

// setup bold font
Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFA ULT_FONT);

Label l = new Label(banner, SWT.WRAP);
l.setText("Subject:");
l.setFont(boldFont);
l = new Label(banner, SWT.WRAP);
l.setText("This is a message about the cool Eclipse RCP!");

l = new Label(banner, SWT.WRAP);
l.setText("From:");
l.setFont(boldFont);

final Link link = new Link(banner, SWT.NONE);
link.setText("<a>nicole@mail.org</a>");

l = new Label(banner, SWT.WRAP);
l.setText("Date:");
l.setFont(boldFont);
l = new Label(banner, SWT.WRAP);
l.setText("10:34 am");
// message contents
Text text = new Text(top, SWT.MULTI | SWT.WRAP);
text.setText("This RCP Application was generated from the PDE Plug-in Project wizard. This sample shows how to:\n");
text.setLayoutData(new GridData(GridData.FILL_BOTH));

banner.setMenu(menuManager.createContextMenu(banner));
}

public Control getControl()
{
return this.topComposite;
}

public Object getInput()
{
return null;
}

public ISelection getSelection()
{
return new StructuredSelection(new Object());
}

public void refresh()
{

}

public void setInput(Object input)
{

}

public void setSelection(ISelection selection, boolean reveal)
{

}
}
}

(Sorry for my stupid-looking modification but actually my purpose is just to simplify the question)

As you see, I added a context menu to the banner composite.

When I start a new session, the context menu poped up as I had experted, but when I clicked at somewhere else that was blank on the banner composite, the context menu did not get hiden.

So, could you please tell me how to hide the context menu by clicking elsewhere on the parent control as Table does(We can hide the context menu of a Table by clicking anywhere else except the point where the context menu starts)?

Great thanks and Best Regards!

Tingel Christian

[Updated on: Mon, 08 March 2010 09:36]

Report message to a moderator

Re: How to hide the context menu in a customized viewer? [message #519376 is a reply to message #519247] Mon, 08 March 2010 16:26 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Christian,

I've just checked your code with RAP from CVS HEAD and it's working as
expected - context menu gets hidden when I click somewhere in the banner
composite. Maybe you run into this bug:
287314: [Menu] Context-menu does not always close on click
https://bugs.eclipse.org/bugs/show_bug.cgi?id=287314
which has been fixed in 1.3M3. Which version of RAP are you using?

Best,
Ivan

On 03/08/2010 11:34 AM, tingel christian wrote:
> Hi, All experts:
>
> Long time no see and Long time no questions :)
> I created a new RAP project based on the mail template existing in the
> new project wizard and had some modification on it and it's now
> something like this:
>
> public class View extends ViewPart {
>
> public static final String ID = "org.eclipse.rap.sample.view";
>
> MenuManager menuManager = new MenuManager();
>
> public void createPartControl(Composite parent) {
> MailViewer viewer = new MailViewer(parent);
> this.getSite().registerContextMenu(menuManager, viewer);
> this.getSite().setSelectionProvider(viewer);
> }
>
> public void setFocus() {
> }
>
> private class MailViewer extends Viewer
> {
> Composite topComposite;
> MailViewer(Composite parent)
> {
> topComposite = new Composite(parent, SWT.None);
> topComposite.setLayout(new FillLayout());
> Composite top = new Composite(topComposite,
> SWT.NONE);
> GridLayout layout = new GridLayout();
> layout.marginHeight = 0;
> layout.marginWidth = 0;
> top.setLayout(layout);
> // top banner
> Composite banner = new Composite(top, SWT.NONE);
> banner.setLayoutData(new
> GridData(GridData.HORIZONTAL_ALIGN_FILL,
> GridData.VERTICAL_ALIGN_BEGINNING, true, false));
> layout = new GridLayout();
> layout.marginHeight = 5;
> layout.marginWidth = 10;
> layout.numColumns = 2;
> banner.setLayout(layout);
> // setup bold font
> Font boldFont =
> JFaceResources.getFontRegistry().getBold(JFaceResources.DEFA
> ULT_FONT); Label l = new Label(banner,
> SWT.WRAP);
> l.setText("Subject:");
> l.setFont(boldFont);
> l = new Label(banner, SWT.WRAP);
> l.setText("This is a message about the cool Eclipse RCP!");
> l = new Label(banner, SWT.WRAP);
> l.setText("From:");
> l.setFont(boldFont);
> final Link link = new Link(banner, SWT.NONE);
> link.setText("<a>mailto:nicole@mail.org</a>");
> l = new Label(banner, SWT.WRAP);
> l.setText("Date:");
> l.setFont(boldFont);
> l = new Label(banner, SWT.WRAP);
> l.setText("10:34 am");
> // message contents
> Text text = new Text(top, SWT.MULTI | SWT.WRAP);
> text.setText("This RCP Application was generated from the
> PDE Plug-in Project wizard. This sample shows how to:\n");
> text.setLayoutData(new GridData(GridData.FILL_BOTH));
>
> banner.setMenu(menuManager.createContextMenu(banner));
> }
> public Control getControl()
> {
> return this.topComposite;
> }
>
> public Object getInput()
> {
> return null;
> }
>
> public ISelection getSelection()
> {
> return new StructuredSelection(new Object());
> }
>
> public void refresh()
> {
> }
>
> public void setInput(Object input)
> {
> }
>
> public void setSelection(ISelection selection, boolean reveal)
> {
> }
> }
> }
>
> (Sorry for the stupid-looking code)
>
> As you see, I added a context menu to the banner composite.
>
> When I start a new session, the context menu poped up as I had
> experted, but when I clicked at somewhere else that was blank on the
> banner composite, the context menu did not get hiden.
>
> So, could you please tell me how to hide the context menu by clicking
> elsewhere on the parent control as Table does(We can hide the context
> menu of a Table by clicking anywhere else except the point where the
> context menu starts)?
>
> Great thanks and Best Regards!
>
> Tingel Christian
Re: How to hide the context menu in a customized viewer? [message #519494 is a reply to message #519376] Tue, 09 March 2010 02:01 Go to previous messageGo to next message
tingel christian is currently offline tingel christianFriend
Messages: 46
Registered: December 2009
Member
Thanks a lot Ivan.

I forgot to tell that I was using RAP 1.2(.0). Terribly sorry for that:(

I followed your direction and That's the problem.But I am afraid we can not upgrade our product to RAP 1.3 at this moment. I tried to synchronize the changes you had made to 1.3 with the RAP base line we are using, but found that there was no file named menu.js existing.So I can only turn back to you again now, could you please give me some suggestion on how to solve this problem in RAP 1.2?

Great thanks!

Best Regards

Tingel Christian
Re: How to hide the context menu in a customized viewer? [message #519520 is a reply to message #519494] Tue, 09 March 2010 08:09 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Christian,

due to some unresolvable problems with qooxdoo menu/menu manager
implementation we decided to completely re-write the menu related code.
Unfortunately, it is not possible to backport these changes in 1.2 branch.

Best,
Ivan

On 03/09/2010 4:01 AM, tingel christian wrote:
> Thanks a lot Ivan.
>
> I forgot to tell that I was using RAP 1.2(.0). Terribly sorry for that:(
>
> I followed your direction and That's the problem.But I am afraid we
> can not upgrade our product to RAP 1.3 at this moment. I tried to
> synchronize the changes you had made to 1.3 with the RAP base line we
> are using, but found that there was no file named menu.js existing.So
> I can only turn back to you again now, could you please give me some
> suggestion on how to solve this problem in RAP 1.2?
>
> Great thanks!
>
> Best Regards
>
> Tingel Christian
Re: How to hide the context menu in a customized viewer? [message #519840 is a reply to message #519520] Wed, 10 March 2010 07:42 Go to previous message
tingel christian is currently offline tingel christianFriend
Messages: 46
Registered: December 2009
Member
Hi Ivan

I rogered that~~~

It seems that I've got to find another way to solve my problem now:(

Anyway, thanks a lot for the information:)

Best Regards

Tingel Christian

Ivan Furnadjiev wrote on Tue, 09 March 2010 03:09
Hi Christian,

due to some unresolvable problems with qooxdoo menu/menu manager
implementation we decided to completely re-write the menu related code.
Unfortunately, it is not possible to backport these changes in 1.2 branch.

Best,
Ivan

On 03/09/2010 4:01 AM, tingel christian wrote:
> Thanks a lot Ivan.
>
> I forgot to tell that I was using RAP 1.2(.0). Terribly sorry for that:(
>
> I followed your direction and That's the problem.But I am afraid we
> can not upgrade our product to RAP 1.3 at this moment. I tried to
> synchronize the changes you had made to 1.3 with the RAP base line we
> are using, but found that there was no file named menu.js existing.So
> I can only turn back to you again now, could you please give me some
> suggestion on how to solve this problem in RAP 1.2?
>
> Great thanks!
>
> Best Regards
>
> Tingel Christian

Previous Topic:[ANN] Google Visualizations Available for RAP
Next Topic:Broken image in RAP 1.3.0M5
Goto Forum:
  


Current Time: Thu Apr 25 10:03:49 GMT 2024

Powered by FUDForum. Page generated in 0.03400 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top