package org.jampa;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
import org.jampa.controllers.Controller;
import org.jampa.preferences.PreferenceConstants;
import org.jampa.utils.Constants;
public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
/*
private Composite _toolBar;
private Control _dummyToolbar;
private Control _applicationPage;
private Control _applicationStatusline;
private ProgressRegion _applicationProgressRegion;
private boolean _newMode = false;
*/
public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
super(configurer);
}
public ActionBarAdvisor createActionBarAdvisor(
IActionBarConfigurer configurer) {
return new ApplicationActionBarAdvisor(configurer);
}
public void preWindowOpen() {
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
configurer.setInitialSize(new Point(1024, 650));
configurer.setShowCoolBar(Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PLAYERVIEW_SHOW_IN_TOOLBAR));
configurer.setShowStatusLine(true);
configurer.setShowProgressIndicator(true);
configurer.setTitle(Constants.APP_NAME);
}
public void postWindowOpen() {
Controller.getInstance().getTrayController().setShell(getWindowConfigurer().getWindow().getShell());
IPreferenceStore store = Controller.getInstance().getPreferenceStore();
if (store.getBoolean(PreferenceConstants.TRAY_SHOW_IN_TRAY)) {
Controller.getInstance().getTrayController().showTrayItems();
}
Controller.getInstance().setStatusLineManager(getWindowConfigurer().getActionBarConfigurer().getStatusLineManager());
}
public boolean preWindowShellClose() {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
if (store.getBoolean(PreferenceConstants.TRAY_SHOW_IN_TRAY)) {
Controller.getInstance().getTrayController().hideApplication();
return false;
} else {
return true;
}
}
/*
public void createWindowContents(Shell shell) {
if (!_newMode) {
super.createWindowContents(shell);
} else {
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
Menu menu = configurer.createMenuBar();
shell.setMenuBar(menu);
FormLayout layout = new FormLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
shell.setLayout(layout);
_toolBar = new Composite(getWindowConfigurer().getWindow().getShell(), SWT.NONE);
final GridLayout gLayout = new GridLayout(3,false);
gLayout.horizontalSpacing = 0;
gLayout.marginHeight = 0;
gLayout.marginWidth = 0;
gLayout.verticalSpacing = 0;
this._toolBar.setLayout(gLayout);
_dummyToolbar = configurer.createCoolBarControl(shell);
((CoolBar) _dummyToolbar).setLocked(true);
_applicationPage = configurer.createPageComposite(shell);
_applicationStatusline = configurer.createStatusLineControl(shell);
createProgressIndicator(shell);
final Composite _toolBarComposite = new Composite(_toolBar, SWT.NONE);
//CoolBarManager test = new CoolBarManager(SWT.NONE);
//CoolBar _toolBarComposite = new CoolBar(_toolBar, SWT.FLAT);
//CoolBar _toolBarComposite = (CoolBar) configurer.createCoolBarControl(_toolBar);
//CoolBar _toolBarComposite = test.createControl(_toolBar);
//CoolBarManager test = new CoolBarManager(_toolBarComposite);
//fill.setBackgroundImage(bannerfill);
GridLayout gl = new GridLayout(1, false);
gl.horizontalSpacing = 0;
gl.marginHeight = 2;
gl.marginWidth = 2;
gl.verticalSpacing = 0;
_toolBarComposite.setLayout(gl);
//Controller.getInstance().getToolbarController().fillToolbar(test);
//test.update(true);
Controller.getInstance().getToolbarController().fillCustomToolbar(_toolBarComposite);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
_toolBarComposite.setLayoutData(gd);
// The layout method does the work of connecting the
// controls together.
layoutNormal();
}
}
private void layoutNormal() {
// Toolbar
FormData data = new FormData();
data.top = new FormAttachment(0, 0);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
data.height = 34; // Current Toolbar height
_toolBar.setLayoutData(data);
// Dummy Toolbar
data = new FormData();
data.top = new FormAttachment(_toolBar, 5, SWT.BOTTOM);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(_applicationPage, 0, SWT.LEFT);
_dummyToolbar.setLayoutData(data);
// Status line
data = new FormData();
data.bottom = new FormAttachment(100, 0);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(75, 0);
_applicationStatusline.setLayoutData(data);
// Progress region
data = new FormData();
data.bottom = new FormAttachment(100, 0);
data.right = new FormAttachment(100, 0);
_applicationProgressRegion.getControl().setLayoutData(data);
// Page
data = new FormData();
data.top = new FormAttachment(_toolBar, 5, SWT.BOTTOM);
data.left = new FormAttachment(0, 5);
data.right = new FormAttachment(100, -5);
data.bottom = new FormAttachment(_applicationStatusline);
_applicationPage.setLayoutData(data);
layout();
}
private void layout() {
if (!_newMode) {
super.l
} else {
getWindowConfigurer().getWindow().getShell().layout(true);
if (_applicationPage != null) {
((Composite) _applicationPage).layout(true);
}
}
}
private void createProgressIndicator(Shell shell) {
if (getWindowConfigurer().getShowProgressIndicator()) {
WorkbenchWindow window = (WorkbenchWindow) getWindowConfigurer().getWindow();
_applicationProgressRegion = new ProgressRegion();
_applicationProgressRegion.createContents(shell, window);
_applicationProgressRegion.getControl().setVisible(true);
}
}
*/
}