package org.craftyourmod.mineclipse.ui;
import org.craftyourmod.mineclipse.ui.wizards.AddBinaryWizard;
import org.eclipse.jface.action.Action;
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.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class TestUI extends ApplicationWindow {
private Action action;
/**
* Create the application window.
*/
public TestUI() {
super(null);
createActions();
addToolBar(SWT.FLAT | SWT.WRAP);
addMenuBar();
addStatusLine();
}
/**
* Create contents of the application window.
*
* @param parent
*/
@Override
protected Control createContents(final Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
{
Button btnBin = new Button(container, SWT.NONE);
btnBin.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
WizardDialog wiz = new WizardDialog(getShell(),
new AddBinaryWizard());
wiz.open();
}
});
btnBin.setBounds(42, 38, 75, 25);
btnBin.setText("Bin");
}
Button btnSrc = new Button(container, SWT.NONE);
btnSrc.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
// Not working
/*
* WizardDialog wiz = new WizardDialog(getShell(), new
* AddSourceWizard()); wiz.open();
*/
}
});
btnSrc.setBounds(42, 74, 75, 25);
btnSrc.setText("Src");
return container;
}
/**
* Create the actions.
*/
private void createActions() {
// Create the actions
{
action = new Action("Run bin") {
};
}
}
/**
* Create the menu manager.
*
* @return the menu manager
*/
@Override
protected MenuManager createMenuManager() {
MenuManager menuManager = new MenuManager("menu");
return menuManager;
}
/**
* Create the toolbar manager.
*
* @return the toolbar manager
*/
@Override
protected ToolBarManager createToolBarManager(final int style) {
ToolBarManager toolBarManager = new ToolBarManager(style);
toolBarManager.add(action);
return toolBarManager;
}
/**
* Create the status line manager.
*
* @return the status line manager
*/
@Override
protected StatusLineManager createStatusLineManager() {
StatusLineManager statusLineManager = new StatusLineManager();
return statusLineManager;
}
/**
* Launch the application.
*
* @param args
*/
public static void main(final String args[]) {
try {
TestUI window = new TestUI();
window.setBlockOnOpen(true);
window.open();
Display.getCurrent().dispose();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Configure the shell.
*
* @param newShell
*/
@Override
protected void configureShell(final Shell newShell) {
super.configureShell(newShell);
newShell.setText("New Application");
}
/**
* Return the initial size of the window.
*/
@Override
protected Point getInitialSize() {
return new Point(450, 300);
}
}