ApplicationWorkbenchWindowAdvisor.java
01 /*
02  *
03  * Licensed to the Apache Software Foundation (ASF) under one
04  * or more contributor license agreements.  See the NOTICE file
05  * distributed with this work for additional information
06  * regarding copyright ownership.  The ASF licenses this file
07  * to you under the Apache License, Version 2.0 (the
08  * "License"); you may not use this file except in compliance
09  * with the License.  You may obtain a copy of the License at
10  
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  */
21 package org.apache.qpid.management.ui;
22 
23 import org.eclipse.swt.graphics.Point;
24 import org.eclipse.swt.widgets.Display;
25 import org.eclipse.swt.widgets.Shell;
26 import org.eclipse.ui.application.ActionBarAdvisor;
27 import org.eclipse.ui.application.IActionBarConfigurer;
28 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
29 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
30 
31 /**
32  
33  @author Bhupendra Bhardwaj
34  */
35 public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor
36 {
37     public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer)
38     {
39         super(configurer);
40     }
41     
42     public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer)
43     {
44         return new ApplicationActionBarAdvisor(configurer);
45     }
46     
47     public void preWindowOpen()
48     {
49         IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
50         int x = Display.getDefault().getBounds().width;
51         int y = Display.getDefault().getBounds().height;
52         configurer.setInitialSize(new Point(9*x/108*y/10));
53         configurer.setShowCoolBar(true);
54         configurer.setShowStatusLine(false);
55         
56         configurer.setTitle(Constants.APPLICATION_NAME);
57     }  
58     
59     public void postWindowCreate()
60     {
61         IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
62         Shell shell = configurer.getWindow().getShell();
63         shell.setImage(ApplicationRegistry.getImage(Constants.CONSOLE_IMAGE));
64     }
65 }