jace & toolbars / coolbars [message #287267] |
Tue, 28 June 2005 11:42  |
Eclipse User |
|
|
|
Originally posted by: mailinglists.nick-wyatt.de
hi,
i'm currently just getting started with jface. and i do
have a small problem!
how do i create several toolbars/coolbars with jface?
or isn't this possible? do i have to use swt instead?
thanks in advance,
cheers, nick
|
|
|
Re: jace & toolbars / coolbars [message #287352 is a reply to message #287267] |
Wed, 29 June 2005 00:51  |
Eclipse User |
|
|
|
Originally posted by: scheglov_ke.nlmk.ru
Nick:
> i'm currently just getting started with jface. and i do
> have a small problem!
>
> how do i create several toolbars/coolbars with jface?
> or isn't this possible? do i have to use swt instead?
You can use CoolBarManager.
Here is small example.
Created in 2 minutes. :-)
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.CoolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.StatusLineManager;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
public class ApplicationWindowWithCoolbars extends ApplicationWindow {
private Action m_SecondAction;
private Action m_FirstAction;
public ApplicationWindowWithCoolbars() {
super(null);
createActions();
addCoolBar(SWT.FLAT);
addMenuBar();
addStatusLine();
}
protected Control createContents(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new GridLayout());
{
final Group group = new Group(container, SWT.NONE);
group.setLayoutData(new GridData(GridData.FILL_BOTH));
group.setLayout(new GridLayout());
}
return container;
}
private void createActions() {
{
m_FirstAction = new Action("Action 1") {
public void run() {
}
};
}
{
m_SecondAction = new Action("Action 2") {
public void run() {
}
};
}
}
protected MenuManager createMenuManager() {
MenuManager result = new MenuManager("menu");
{
final MenuManager menuManager = new MenuManager("&File");
result.add(menuManager);
menuManager.add(m_FirstAction);
menuManager.add(m_SecondAction);
}
return result;
}
protected CoolBarManager createCoolBarManager(int style) {
CoolBarManager coolBarManager = new CoolBarManager(style);
{
final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
coolBarManager.add(toolBarManager);
toolBarManager.add(m_FirstAction);
toolBarManager.add(m_SecondAction);
}
{
final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
coolBarManager.add(toolBarManager);
toolBarManager.add(m_FirstAction);
}
return coolBarManager;
}
protected StatusLineManager createStatusLineManager() {
StatusLineManager statusLineManager = new StatusLineManager();
statusLineManager.setMessage(null, "Some status text...");
return statusLineManager;
}
public static void main(String args[]) {
try {
ApplicationWindowWithCoolbars window = new
ApplicationWindowWithCoolbars();
window.setBlockOnOpen(true);
window.open();
Display.getCurrent().dispose();
} catch (Exception e) {
e.printStackTrace();
}
}
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("New Application");
}
protected Point getInitialSize() {
return new Point(425, 350);
}
}
--
SY, Konstantin.
Advanced Eclipse SWT Designer (http://www.swt-designer.com)
|
|
|
Powered by
FUDForum. Page generated in 0.03629 seconds