📄 helpbrowserdialog.java
字号:
package com.galaxyworkstation.view;
import java.io.File;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
import com.galaxyworkstation.model.SWTResourceManager;
public class HelpBrowserDialog extends Dialog {
private Browser browser;
protected Object result;
protected Shell shell;
/**
* Create the dialog
* @param parent
* @param style
*/
public HelpBrowserDialog(Shell parent, int style) {
super(parent, style);
}
/**
* Create the dialog
* @param parent
*/
public HelpBrowserDialog(Shell parent) {
this(parent, SWT.NONE);
}
/**
* Open the dialog
* @return the result
*/
public Object open() {
createContents();
shell.open();
shell.layout();
Display display = getParent().getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
return result;
}
/**
* Create contents of the dialog
*/
protected void createContents() {
shell = new Shell(getParent(), SWT.SHELL_TRIM);
shell.setLayout(new FormLayout());
shell.setSize(640, 480);
shell.setLocation((shell.getDisplay().getClientArea().width - shell.getClientArea().width) / 2,
(shell.getDisplay().getClientArea().height - shell.getClientArea().height) / 2);
shell.setText("帮助 - CD Manager");
shell.setImage(SWTResourceManager.getImage(MainGUI.class, "../../../image/help2.png"));
final Group group = new Group(shell, SWT.NONE);
group.setLayout(new FillLayout());
final FormData fd_group = new FormData();
fd_group.top = new FormAttachment(0, 0);
fd_group.left = new FormAttachment(0, 5);
fd_group.bottom = new FormAttachment(100, -5);
fd_group.right = new FormAttachment(100, -5);
group.setLayoutData(fd_group);
final SashForm sashForm = new SashForm(group, SWT.NONE);
sashForm.setLayout(new FormLayout());
browser = new Browser(sashForm, SWT.NONE);
sashForm.setWeights(new int[] {4 });
File file = new File("help" + File.separator + "index.html");
browser.setUrl(file.getAbsolutePath());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -