01 package org.jpn.xucker.rcp.optipngwrapper;
02
03
04 import org.eclipse.core.runtime.Path;
05 import org.eclipse.jface.action.IMenuManager;
06 import org.eclipse.jface.action.MenuManager;
07 import org.eclipse.jface.resource.ImageDescriptor;
08 import org.eclipse.swt.graphics.Image;
09 import org.eclipse.swt.graphics.Point;
10 import org.eclipse.ui.IWorkbenchActionConstants;
11 import org.eclipse.ui.IWorkbenchWindow;
12 import org.eclipse.ui.actions.ActionFactory;
13 import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
14 import org.eclipse.ui.application.IActionBarConfigurer;
15 import org.eclipse.ui.application.IWorkbenchConfigurer;
16 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
17 import org.eclipse.ui.application.WorkbenchAdvisor;
18
19 public class OptipngWrapperWorkbenchAdvisor extends WorkbenchAdvisor {
20
21 public void initialize(IWorkbenchConfigurer configurer) {
22
23 }
24
25 public String getInitialWindowPerspectiveId() {
26 return OptipngWrapperPerspective.ID;
27 }
28
29 public void preWindowOpen(IWorkbenchWindowConfigurer configurer) {
30
31
32 super.preWindowOpen(configurer);
33
34 configurer.setInitialSize(new Point(640, 520));
35 configurer.setShowCoolBar(false);
36 configurer.setShowStatusLine(true);
37 configurer.setShowPerspectiveBar(false);
38 configurer.setShowFastViewBars(true);
39 configurer.setShowMenuBar(true);
40 configurer.setTitle(Messages.getString("optipng_title")); //$NON-NLS-1$
41
42 }
43
44
45 public void postWindowOpen(IWorkbenchWindowConfigurer configurer) {
46 Image logoImage=ImageDescriptor.createFromURL(OptipngWrapperPlugin.getDefault().find(new Path("icons/akj_eclipse.png"))).createImage(); //$NON-NLS-1$
47
48
49 configurer.getWindow().getShell().setImage(logoImage);
50
51
52 //set share values.
53
54 OptipngWrapperPlugin.getDefault().getFileListImage().getFileListTable().addFileListChangeListener(OptipngWrapperPlugin.getDefault().getWrapperView());
55
56 }
57
58
59 public void fillActionBars(
60 IWorkbenchWindow window,
61 IActionBarConfigurer configurer,
62 int flags) {
63 super.fillActionBars(window, configurer, flags);
64 if ((flags & FILL_MENU_BAR) != 0) {
65 fillMenuBar(window, configurer);
66 }
67 }
68
69
70 private void fillMenuBar(
71 IWorkbenchWindow window,
72 IActionBarConfigurer configurer) {
73 IMenuManager menuBar = configurer.getMenuManager();
74
75 menuBar.add(createFileMenu(window));
76
77
78 }
79
80 private MenuManager createFileMenu(IWorkbenchWindow window) {
81
82
83 MenuManager menu = new MenuManager(Messages.getString("file"), //$NON-NLS-1$
84 IWorkbenchActionConstants.M_FILE);
85
86 IWorkbenchAction action=
87 ActionFactory.QUIT.create(window);
88 action.setText(Messages.getString("quit")); //$NON-NLS-1$
89 menu.add(action);
90
91
92
93 return menu;
94 }
95
96
97 }
|