📄 securityworkbenchadvisor.java
字号:
/*
* Created on 2004-9-11
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.hnjchina;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.Assert;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.internal.UIPlugin;
/**
* @author limeiyong
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class SecurityWorkbenchAdvisor extends WorkbenchAdvisor{
private ActionFactory.IWorkbenchAction quitAction,aboutAction,closeAction,closeAllAction;
public String getInitialWindowPerspectiveId() {
// 向新的工作台窗口返回初始透视图的标识符
return SecurityApplication.SECURITY_PERSPECTIVE_ID;
}
public void preWindowOpen(IWorkbenchWindowConfigurer configurer){
// 设置工作台的窗口标题和尺寸
super.preWindowOpen(configurer);
// 设置工作台的tab 的弧度
UIPlugin.getDefault().getPreferenceStore().setDefault(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, false);
configurer.setTitle("security");
configurer.setInitialSize(new Point(800,600));
configurer.setShowMenuBar(true);
configurer.setShowStatusLine(true);
configurer.setShowCoolBar(false);
}
public void fillActionBars(final IWorkbenchWindow window, IActionBarConfigurer configurer, int flags) {
Assert.isTrue((flags & WorkbenchAdvisor.FILL_PROXY) == 0);
if ((flags & WorkbenchAdvisor.FILL_MENU_BAR) != 0){
IMenuManager menuBar=configurer.getMenuManager();
IMenuManager fileMenu = new MenuManager("&File", "file"); //$NON-NLS-2$
menuBar.add(fileMenu);
closeAction=ActionFactory.CLOSE.create(window);
fileMenu.add(closeAction);
closeAllAction = ActionFactory.CLOSE_ALL.create(window);
fileMenu.add(closeAllAction);
fileMenu.add(new Separator()); //$NON-NLS-1$
ActionFactory.IWorkbenchAction saveAction=ActionFactory.SAVE.create(window);
fileMenu.add(saveAction);
ActionFactory.IWorkbenchAction saveAsAction=ActionFactory.SAVE_AS.create(window);
fileMenu.add(saveAsAction);
ActionFactory.IWorkbenchAction saveAllAction=ActionFactory.SAVE_ALL.create(window);
fileMenu.add(saveAllAction);
ActionFactory.IWorkbenchAction printAction=ActionFactory.PRINT.create(window);
fileMenu.add(printAction);
fileMenu.add(new Separator()); //$NON-NLS-1$
quitAction = ActionFactory.QUIT.create(window);
fileMenu.add(quitAction);
IMenuManager editMenu = new MenuManager("&Edit", "edit"); //$NON-NLS-2$
menuBar.add(editMenu);
ActionFactory.IWorkbenchAction undoAction=ActionFactory.UNDO.create(window);
editMenu.add(undoAction);
ActionFactory.IWorkbenchAction redoAction=ActionFactory.REDO.create(window);
editMenu.add(redoAction);
editMenu.add(new Separator()); //$NON-NLS-1$
ActionFactory.IWorkbenchAction cutAction=ActionFactory.CUT.create(window);
editMenu.add(cutAction);
ActionFactory.IWorkbenchAction copyAction=ActionFactory.COPY.create(window);
editMenu.add(copyAction);
ActionFactory.IWorkbenchAction pasteAction=ActionFactory.PASTE.create(window);
editMenu.add(pasteAction);
editMenu.add(new Separator()); //$NON-NLS-1$
ActionFactory.IWorkbenchAction findAction=ActionFactory.FIND.create(window);
editMenu.add(findAction);
ActionFactory.IWorkbenchAction deleteAction=ActionFactory.DELETE.create(window);
editMenu.add(deleteAction);
ActionFactory.IWorkbenchAction selectAllAction=ActionFactory.SELECT_ALL.create(window);
editMenu.add(selectAllAction);
IMenuManager applicatMenu = new MenuManager("&Applicat", "applicat");
menuBar.add(applicatMenu);
IAction tableAciton=new Action("TableView"){
public void run(){
try {
IWorkbenchPage page=window.getActivePage();
page.showView(SecurityApplication.SECURITY_TABLEVIEW_VIEW_ID);
} catch (PartInitException e) {
e.printStackTrace();
}
}
};
applicatMenu.add(tableAciton);
IAction jfaceAciton=new Action("jface"){
public void run(){
try {
IWorkbenchPage page=window.getActivePage();
page.showView(SecurityApplication.SECURITY_JFACE_VIEW_ID);
} catch (PartInitException e) {
e.printStackTrace();
}
}
};
applicatMenu.add(jfaceAciton);
IAction jtreeAction=new Action("Jtree"){
public void run(){
IWorkbenchPage page=window.getActivePage();
try {
page.showView(SecurityApplication.SECURITY_JTREE_VIEW_ID);
} catch (PartInitException e) {
e.printStackTrace();
}
}
};
applicatMenu.add(jtreeAction);
IAction treeViewerAction=new Action("TreeViewer"){
public void run(){
IWorkbenchPage page=window.getActivePage();
try {
page.showView(SecurityApplication.SECURITY_TREEVIEWER_VIEW_ID);
} catch (PartInitException e) {
e.printStackTrace();
}
}
};
applicatMenu.add(treeViewerAction);
IAction historyAction = new Action("History") {
public void run() {
try {
IWorkbenchPage page=window.getActivePage();
page.showView(SecurityApplication.HISTORY_VIEW_ID);
} catch (PartInitException e) {
e.printStackTrace();
}
}
};
applicatMenu.add(historyAction);
IAction objectsAction=new Action("Security Object"){
public void run(){
try{
IWorkbenchPage page=window.getActivePage();
page.showView(SecurityApplication.SECURITY_OBJECTS_VIEW_ID);
}catch (PartInitException e) {
e.printStackTrace();
}
}
};
applicatMenu.add(objectsAction);
IAction priorityAction=new Action("PrioritySet"){
public void run(){
try{
IWorkbenchPage page=window.getActivePage();
page.showView(SecurityApplication.SECURITY_PRIORITY_SET_VIEW_ID);
}catch (PartInitException e) {
e.printStackTrace();
}
}
};
applicatMenu.add(priorityAction);
IAction reportAction=new Action("Report"){
public void run(){
try{
IWorkbenchPage page=window.getActivePage();
page.showView(SecurityApplication.SECURITY_REPORT_VIEW_ID);
}catch (PartInitException e) {
e.printStackTrace();
}
}
};
applicatMenu.add(reportAction);
IMenuManager createviewers = new MenuManager("&CreateViewers","createviewers");
menuBar.add(createviewers);
IAction treeviewer=new Action("TreeViewers"){
public void run(){
try{
IWorkbenchPage page=window.getActivePage();
page.showView(SecurityApplication.TREEVIEWERS_ID);
}catch (PartInitException e) {
e.printStackTrace();
}
}
};
createviewers.add(treeviewer);
IAction celleditors=new Action("CellEditors"){
public void run(){
try{
IWorkbenchPage page=window.getActivePage();
page.showView(SecurityApplication.CELLEDITORS_ID);
}catch (PartInitException e) {
e.printStackTrace();
}
}
};
createviewers.add(celleditors);
IAction listviewers=new Action("ListViewers"){
public void run(){
try{
IWorkbenchPage page=window.getActivePage();
page.showView(SecurityApplication.LISTVIEWERS_ID);
}catch (PartInitException e) {
e.printStackTrace();
}
}
};
createviewers.add(listviewers);
IAction tableviewers=new Action("TableViewers"){
public void run(){
try{
IWorkbenchPage page=window.getActivePage();
page.showView(SecurityApplication.TABLEVIEWERS_ID);
}catch (PartInitException e) {
e.printStackTrace();
}
}
};
createviewers.add(tableviewers);
IAction sampletableviewers=new Action("SampleTableViewers"){
public void run(){
try{
IWorkbenchPage page=window.getActivePage();
page.showView(SecurityApplication.SAMPLETABLEVIEW_ID);
}catch (PartInitException e) {
e.printStackTrace();
}
}
};
createviewers.add(sampletableviewers);
IAction sampletreeviewers=new Action("SampleTreeViewers"){
public void run(){
try{
IWorkbenchPage page=window.getActivePage();
page.showView(SecurityApplication.SAMPLETREEVIEWERMOVINGBOXVIEW_ID);
}catch (PartInitException e) {
e.printStackTrace();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -