Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » org.eclipse.swt.custom.ViewForm , ToolBar and JFace Action
org.eclipse.swt.custom.ViewForm , ToolBar and JFace Action [message #443849] Sun, 03 October 2004 21:06 Go to next message
jmi is currently offline jmiFriend
Messages: 84
Registered: July 2009
Member
Hi,

I try to put a ToolBar on a ViewForm that react to Action. Unfortunatelly
the ToolBar is empty, no button. So, is it possible?

Here is a few code (easier than a big explanation)

In the VeiwForm, i have the next code:

// Create the ViewForm
ViewForm vf = new ViewForm(this, SWT.BORDER);
// Add the view toolBar
ToolBar tb = new ToolBar(vf, SWT.HORIZONTAL | SWT.FLAT);
ToolBarManager tbManager = createToolBarManager(tb);
vf.setTopLeft(tb);


WITH
====
protected ToolBarManager createToolBarManager(ToolBar argToolBar) {
// Create the manager
ToolBarManager manager = new ToolBarManager(argToolBar);
// Add an Action
manager.add(_testAction);
// Return the manager
return manager;
}

AND
===
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;

public class TestAction extends Action implements ISelectionChangedListener,
IDoubleClickListener {

MyComposite myComposite;
public TestAction(final MyComposite argMyComposite) {
super();
myComposite = argMyComposite;
setText("Test Action");
setToolTipText("Run the test action...");
setEnabled(true);
setImageDescriptor(ImageDescriptor.createFromURL(Util
.newURL("file:icons/folder.gif")));
}

public void run() {
myComposite.setMyLabel("Action Test OK");
}

public void selectionChanged(SelectionChangedEvent arg0) {
setText("Test Action");
setToolTipText("Run the test action...");
setEnabled(true);
}

public void doubleClick(DoubleClickEvent arg0) {
run();
}

}

Is it possible to do that????

Thanks

JMi
Re: org.eclipse.swt.custom.ViewForm , ToolBar and JFace Action [message #443856 is a reply to message #443849] Mon, 04 October 2004 06:32 Go to previous messageGo to next message
jmi is currently offline jmiFriend
Messages: 84
Registered: July 2009
Member
... and of course, i would like to use shortcut key...


JM Delsaux wrote:

> Hi,

> I try to put a ToolBar on a ViewForm that react to Action. Unfortunatelly
> the ToolBar is empty, no button. So, is it possible?

> Here is a few code (easier than a big explanation)

> In the VeiwForm, i have the next code:

> // Create the ViewForm
> ViewForm vf = new ViewForm(this, SWT.BORDER);
> // Add the view toolBar
> ToolBar tb = new ToolBar(vf, SWT.HORIZONTAL | SWT.FLAT);
> ToolBarManager tbManager = createToolBarManager(tb);
> vf.setTopLeft(tb);


> WITH
> ====
> protected ToolBarManager createToolBarManager(ToolBar argToolBar) {
> // Create the manager
> ToolBarManager manager = new ToolBarManager(argToolBar);
> // Add an Action
> manager.add(_testAction);
> // Return the manager
> return manager;
> }

> AND
> ===
> import org.eclipse.jface.action.Action;
> import org.eclipse.jface.resource.ImageDescriptor;
> import org.eclipse.jface.viewers.DoubleClickEvent;
> import org.eclipse.jface.viewers.IDoubleClickListener;
> import org.eclipse.jface.viewers.ISelectionChangedListener;
> import org.eclipse.jface.viewers.SelectionChangedEvent;

> public class TestAction extends Action implements ISelectionChangedListener,
> IDoubleClickListener {

> MyComposite myComposite;
> public TestAction(final MyComposite argMyComposite) {
> super();
> myComposite = argMyComposite;
> setText("Test Action");
> setToolTipText("Run the test action...");
> setEnabled(true);
> setImageDescriptor(ImageDescriptor.createFromURL(Util
> .newURL("file:icons/folder.gif")));
> }

> public void run() {
> myComposite.setMyLabel("Action Test OK");
> }

> public void selectionChanged(SelectionChangedEvent arg0) {
> setText("Test Action");
> setToolTipText("Run the test action...");
> setEnabled(true);
> }

> public void doubleClick(DoubleClickEvent arg0) {
> run();
> }

> }

> Is it possible to do that????

> Thanks

> JMi
Re: org.eclipse.swt.custom.ViewForm , ToolBar and JFace Action [message #443940 is a reply to message #443856] Mon, 04 October 2004 19:28 Go to previous messageGo to next message
jmi is currently offline jmiFriend
Messages: 84
Registered: July 2009
Member
I've done it with

ToolBarManager tbManager = createToolBarManager(SWT.HORIZONTAL |
SWT.FLAT);
ToolBar tb = tbManager.createControl(_vf);
vf.setTopLeft(tb);

and

protected ToolBarManager createToolBarManager(final int style) {
System.out.println("createToolBarManager(...) - START");
// Create the manager
ToolBarManager manager = new ToolBarManager(style);
ActionContributionItem actionItem = new
ActionContributionItem(_testAction);
//actionItem.setMode(ActionContributionItem.MODE_FORCE_TEXT) ;
// Add an ActionContributionItem
manager.add(actionItem);

actionItem = new ActionContributionItem(_exitAction);
manager.add(actionItem);
// Return the manager
System.out.println("createToolBarManager(...) - END");
return manager;
}

Now, i would like to set ACCELERATOR KEY

Any idea????


"JM Delsaux" <JMDelsaux@skynet.be> wrote in message
news:cjqqp2$mr8$1@eclipse.org...
> .. and of course, i would like to use shortcut key...
>
>
> JM Delsaux wrote:
>
> > Hi,
>
> > I try to put a ToolBar on a ViewForm that react to Action.
Unfortunatelly
> > the ToolBar is empty, no button. So, is it possible?
>
> > Here is a few code (easier than a big explanation)
>
> > In the VeiwForm, i have the next code:
>
> > // Create the ViewForm
> > ViewForm vf = new ViewForm(this, SWT.BORDER);
> > // Add the view toolBar
> > ToolBar tb = new ToolBar(vf, SWT.HORIZONTAL | SWT.FLAT);
> > ToolBarManager tbManager = createToolBarManager(tb);
> > vf.setTopLeft(tb);
>
>
> > WITH
> > ====
> > protected ToolBarManager createToolBarManager(ToolBar argToolBar) {
> > // Create the manager
> > ToolBarManager manager = new ToolBarManager(argToolBar);
> > // Add an Action
> > manager.add(_testAction);
> > // Return the manager
> > return manager;
> > }
>
> > AND
> > ===
> > import org.eclipse.jface.action.Action;
> > import org.eclipse.jface.resource.ImageDescriptor;
> > import org.eclipse.jface.viewers.DoubleClickEvent;
> > import org.eclipse.jface.viewers.IDoubleClickListener;
> > import org.eclipse.jface.viewers.ISelectionChangedListener;
> > import org.eclipse.jface.viewers.SelectionChangedEvent;
>
> > public class TestAction extends Action implements
ISelectionChangedListener,
> > IDoubleClickListener {
>
> > MyComposite myComposite;
> > public TestAction(final MyComposite argMyComposite) {
> > super();
> > myComposite = argMyComposite;
> > setText("Test Action");
> > setToolTipText("Run the test action...");
> > setEnabled(true);
> > setImageDescriptor(ImageDescriptor.createFromURL(Util
> > .newURL("file:icons/folder.gif")));
> > }
>
> > public void run() {
> > myComposite.setMyLabel("Action Test OK");
> > }
>
> > public void selectionChanged(SelectionChangedEvent arg0) {
> > setText("Test Action");
> > setToolTipText("Run the test action...");
> > setEnabled(true);
> > }
>
> > public void doubleClick(DoubleClickEvent arg0) {
> > run();
> > }
>
> > }
>
> > Is it possible to do that????
>
> > Thanks
>
> > JMi
>
>
Re: org.eclipse.swt.custom.ViewForm , ToolBar and JFace Action [message #443943 is a reply to message #443940] Mon, 04 October 2004 20:18 Go to previous message
jmi is currently offline jmiFriend
Messages: 84
Registered: July 2009
Member
Is there a way for key binding???

For the moment, if i do setAccelerator(SWT.CTRL | 'C') in the Action class
nothing happen.

What's wrong.

[my toolbar is contained in a ViewForm]

"JM Delsaux" <JMDelsaux@skynet.be> wrote in message
news:cjs7v4$ojs$1@eclipse.org...
> I've done it with
>
> ToolBarManager tbManager = createToolBarManager(SWT.HORIZONTAL |
> SWT.FLAT);
> ToolBar tb = tbManager.createControl(_vf);
> vf.setTopLeft(tb);
>
> and
>
> protected ToolBarManager createToolBarManager(final int style) {
> System.out.println("createToolBarManager(...) - START");
> // Create the manager
> ToolBarManager manager = new ToolBarManager(style);
> ActionContributionItem actionItem = new
> ActionContributionItem(_testAction);
> //actionItem.setMode(ActionContributionItem.MODE_FORCE_TEXT) ;
> // Add an ActionContributionItem
> manager.add(actionItem);
>
> actionItem = new ActionContributionItem(_exitAction);
> manager.add(actionItem);
> // Return the manager
> System.out.println("createToolBarManager(...) - END");
> return manager;
> }
>
> Now, i would like to set ACCELERATOR KEY
>
> Any idea????
>
>
> "JM Delsaux" <JMDelsaux@skynet.be> wrote in message
> news:cjqqp2$mr8$1@eclipse.org...
> > .. and of course, i would like to use shortcut key...
> >
> >
> > JM Delsaux wrote:
> >
> > > Hi,
> >
> > > I try to put a ToolBar on a ViewForm that react to Action.
> Unfortunatelly
> > > the ToolBar is empty, no button. So, is it possible?
> >
> > > Here is a few code (easier than a big explanation)
> >
> > > In the VeiwForm, i have the next code:
> >
> > > // Create the ViewForm
> > > ViewForm vf = new ViewForm(this, SWT.BORDER);
> > > // Add the view toolBar
> > > ToolBar tb = new ToolBar(vf, SWT.HORIZONTAL | SWT.FLAT);
> > > ToolBarManager tbManager = createToolBarManager(tb);
> > > vf.setTopLeft(tb);
> >
> >
> > > WITH
> > > ====
> > > protected ToolBarManager createToolBarManager(ToolBar argToolBar) {
> > > // Create the manager
> > > ToolBarManager manager = new ToolBarManager(argToolBar);
> > > // Add an Action
> > > manager.add(_testAction);
> > > // Return the manager
> > > return manager;
> > > }
> >
> > > AND
> > > ===
> > > import org.eclipse.jface.action.Action;
> > > import org.eclipse.jface.resource.ImageDescriptor;
> > > import org.eclipse.jface.viewers.DoubleClickEvent;
> > > import org.eclipse.jface.viewers.IDoubleClickListener;
> > > import org.eclipse.jface.viewers.ISelectionChangedListener;
> > > import org.eclipse.jface.viewers.SelectionChangedEvent;
> >
> > > public class TestAction extends Action implements
> ISelectionChangedListener,
> > > IDoubleClickListener {
> >
> > > MyComposite myComposite;
> > > public TestAction(final MyComposite argMyComposite) {
> > > super();
> > > myComposite = argMyComposite;
> > > setText("Test Action");
> > > setToolTipText("Run the test action...");
> > > setEnabled(true);
> > > setImageDescriptor(ImageDescriptor.createFromURL(Util
> > > .newURL("file:icons/folder.gif")));
> > > }
> >
> > > public void run() {
> > > myComposite.setMyLabel("Action Test OK");
> > > }
> >
> > > public void selectionChanged(SelectionChangedEvent arg0) {
> > > setText("Test Action");
> > > setToolTipText("Run the test action...");
> > > setEnabled(true);
> > > }
> >
> > > public void doubleClick(DoubleClickEvent arg0) {
> > > run();
> > > }
> >
> > > }
> >
> > > Is it possible to do that????
> >
> > > Thanks
> >
> > > JMi
> >
> >
>
>
Previous Topic:[Key Bindings] Howto to avoid accelerators stealing keys from Text?
Next Topic:How do I remove a TableColumn from a table
Goto Forum:
  


Current Time: Thu Apr 25 02:14:43 GMT 2024

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

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

Back to the top