📄 applicationworkbenchwindowadvisor.java
字号:
package com.niis.myprice.frame;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
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 com.niis.myprice.domain.DataTree;
import com.niis.myprice.util.message.Messages;
public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
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(860, 660));
configurer.setShowCoolBar(true);
configurer.setShowStatusLine(true);
configurer.setTitle(Messages
.getString("ApplicationWorkbenchWindowAdvisor.title")); //$NON-NLS-1$
}
public boolean preWindowShellClose() {
if (DataTree.getDt().isModified()) {
IWorkbenchWindow window =getWindowConfigurer().getWindow();
Shell shell = window.getShell();
String title = Messages.getString("common.promptmessage");
String msg =Messages.getString("ApplicationWorkbenchWindowAdvisor.prompt");
MessageDialog dialog = new MessageDialog(shell, title, null, // accept
msg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
IDialogConstants.NO_LABEL,IDialogConstants.CANCEL_LABEL }, 0); // yes is the default
int result = dialog.open();
switch(result){
case 0://yes
DataTree.getDt().save();
break;
case 1://no
break;
case 2://cancel
return false;
default:break;
}
}
return super.preWindowShellClose();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -