?? sdimgr.java
字號:
current_shell.setText("TigerBox BY CSK");
current_shell.setImage(SWTResourceManager.getImage("/res/img/usecasediagram.png"));
OnInitMenu();
OnInitMainCnt();
Output("=======Xiger Box======",true);
LoadConf();
OnNewDocument();
}
protected void OnInitMenu()
{
mainMenu = new Menu(current_shell,SWT.BAR);
current_shell.setMenuBar(mainMenu);
final MenuItem menu_file = new MenuItem(mainMenu, SWT.CASCADE);
menu_file.setText("&File");
final Menu filemenu = new Menu(current_shell, SWT.DROP_DOWN);
menu_file.setMenu(filemenu);
final MenuItem filemenu_new = new MenuItem(filemenu, SWT.PUSH);
filemenu_new.setText("&New...");
filemenu_new.setImage(SWTResourceManager.getImage("/res/img/bar_new.png"));
final MenuItem filemenu_open = new MenuItem(filemenu, SWT.PUSH);
filemenu_open.setText("&Open...");
filemenu_open.setImage(SWTResourceManager.getImage("/res/img/bar_open.png"));
new MenuItem(filemenu, SWT.SEPARATOR);
final MenuItem filemenu_save = new MenuItem(filemenu, SWT.PUSH);
filemenu_save.setText("&Save...");
filemenu_save.setImage(SWTResourceManager.getImage("/res/img/bar_save.png"));
final MenuItem filemenu_saveas = new MenuItem(filemenu, SWT.PUSH);
filemenu_saveas.setText("Save as...");
filemenu_saveas.setImage(SWTResourceManager.getImage("/res/img/SaveAllHS.png"));
new MenuItem(filemenu, SWT.SEPARATOR);
final MenuItem filemenu_close = new MenuItem(filemenu, SWT.PUSH);
filemenu_close.setText("E&xit");
final MenuItem menu_Compile = new MenuItem(mainMenu, SWT.CASCADE);
menu_Compile.setText("&Compile");
final Menu editmenu = new Menu(current_shell, SWT.DROP_DOWN);
menu_Compile.setMenu(editmenu);
final MenuItem editmenu_compile = new MenuItem(editmenu, SWT.PUSH);
editmenu_compile.setText("&Compile Src");
editmenu_compile.setImage(SWTResourceManager.getImage("/res/img/document.png"));
new MenuItem(editmenu, SWT.SEPARATOR);
final MenuItem editmenu_view_tree = new MenuItem(editmenu, SWT.PUSH);
editmenu_view_tree.setText("&View Trees");
editmenu_view_tree.setImage(SWTResourceManager.getImage("/res/img/shape_move_backwards.png"));
//editmenu_undo.setEnabled(false);
new MenuItem(editmenu, SWT.SEPARATOR);
final MenuItem editmenu_setting = new MenuItem(editmenu, SWT.PUSH);
editmenu_setting.setText("Preference...");
final MenuItem menu_help = new MenuItem(mainMenu, SWT.CASCADE);
menu_help.setText("&Help");
final Menu helpmenu = new Menu(current_shell, SWT.DROP_DOWN);
menu_help.setMenu(helpmenu);
final MenuItem helpmenu_About = new MenuItem(helpmenu, SWT.PUSH);
helpmenu_About.setText("&About");
helpmenu_About.setImage(SWTResourceManager.getImage("/res/img/bar_help.png"));
class popCmdListener implements SelectionListener
{
public void widgetDefaultSelected(SelectionEvent e)
{
}
public void widgetSelected(SelectionEvent e)
{
if (e.getSource() == filemenu_new)
{
OnNewDocument();
return;
}
if (e.getSource() == filemenu_open)
{
OnOpenDocument();
return;
}
if (e.getSource() == filemenu_save)
{
OnSaveDocument(false);
return;
}
if (e.getSource() == filemenu_saveas)
{
OnSaveDocument(true);
return;
}
if (e.getSource() == filemenu_close)
{
current_shell.close();
return;
}
if (e.getSource() == editmenu_compile)
{
OnCompile();
return;
}
if (e.getSource() == editmenu_view_tree)
{
OnExportTree();
return;
}
if (e.getSource() == helpmenu_About)
{
AboutDlg aaadialog=new AboutDlg(SDIMgr.current_shell,0);
aaadialog.open();
return;
}
}
}
popCmdListener cmdlistener = new popCmdListener();
filemenu_new.addSelectionListener(cmdlistener);
filemenu_open.addSelectionListener(cmdlistener);
filemenu_save.addSelectionListener(cmdlistener);
filemenu_saveas.addSelectionListener(cmdlistener);
filemenu_close.addSelectionListener(cmdlistener);
editmenu_compile.addSelectionListener(cmdlistener);
editmenu_view_tree.addSelectionListener(cmdlistener);
helpmenu_About.addSelectionListener(cmdlistener);
}
protected void OnInitMainCnt()
{
FormLayout layout = new FormLayout();
layout.marginWidth=3;
layout.marginBottom=3;
current_shell.setLayout(layout);
InitCoolBar();
InitSashBar();
InitViewSys();
InitOutPut();
}
private void InitSashBar()
{
FormData data = new FormData();
SashBar = new Sash(current_shell, SWT.HORIZONTAL|SWT.SMOOTH);
data.top = new FormAttachment(80, 0);
// data.bottom = new FormAttachment(80, 3);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
data.height = 3;
SashBar.setLayoutData(data);
SashBar.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if ( event.y<output.getLocation().y+output.getSize().y-20 && event.y>main_editor.getLocation().y+20)
{
((FormData) SashBar.getLayoutData()).top = new FormAttachment(0, event.y);
}
else
{
event.doit=false;
}
SashBar.getParent().layout();
}
});
}
private void InitOutPut()
{
FormData data = new FormData();
data.top = new FormAttachment(SashBar, 0);
data.bottom = new FormAttachment(100, 0);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
output = new Text(current_shell, SWT.V_SCROLL |SWT.MULTI| SWT.READ_ONLY|SWT.WRAP| SWT.BORDER);
output.setFont(SWTResourceManager.getFont("宋體", 9, SWT.NORMAL));
output.setLayoutData(data);
current_shell.layout();
}
private void InitViewSys()
{
FormData data = new FormData();
data.top = new FormAttachment(coolbar, 0);
data.bottom = new FormAttachment(SashBar, 0);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
main_editor = new StyledText(current_shell, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
main_editor.setFont(SWTResourceManager.getFont("宋體", 9, SWT.NORMAL));
main_editor.setLayoutData(data);
main_editor.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if(e.keyCode == SWT.F5) {
OnCompile();
}
}
});
main_editor.addModifyListener(new ModifyListener()
{
public void modifyText(ModifyEvent e)
{
m_bIsChg = true;
UpdateTitle();
}
});
main_editor.addLineStyleListener(new TigerLineStyler());
current_shell.layout();
}
private void InitCoolBar()
{
FormData data = new FormData();
data.top = new FormAttachment(0, 0);
data.bottom = new FormAttachment(0, 23);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
coolbarmgr = new CoolbarMgr();
coolbar=coolbarmgr.CreateCoolBar();
coolbar.setLayoutData(data);
//mainCoolBar.setSize(500, 420);
}
public void widgetDisposed(DisposeEvent e)
{
coolbarmgr.dispose();
mainMenu.dispose();
SashBar.dispose();
main_editor.dispose();
output.dispose();
SWTResourceManager.dispose();
}
private class myShellListener extends ShellAdapter
{
public void shellClosed(ShellEvent e) {
if (OnCloseDocument() == SWT.CANCEL)
{
e.doit = false;
}
if (e.doit)
{
ct.stop();
ct.setRun(false);
}
}
}
private class CoolbarMgr
{
public CoolBar cbar;
public ToolBar tools_1;
public void dispose()
{
tools_1.dispose();
cbar.dispose();
}
public CoolBar CreateCoolBar()
{
cbar = new CoolBar(SDIMgr.current_shell,SWT.FLAT | SWT.BAR | SWT.HORIZONTAL);
tools_1 = new ToolBar(cbar, SWT.NONE);
final ToolItem ToolNew = new ToolItem(tools_1, SWT.HORIZONTAL);
ToolNew.setToolTipText("New");
ToolNew.setImage(SWTResourceManager.getImage("/res/img/bar_new.png"));
final ToolItem ToolOpen = new ToolItem(tools_1, SWT.HORIZONTAL);
ToolOpen.setToolTipText("Open");
ToolOpen.setImage(SWTResourceManager.getImage("/res/img/bar_open.png"));
final ToolItem ToolSave = new ToolItem(tools_1, SWT.HORIZONTAL);
ToolSave.setToolTipText("Save");
ToolSave.setImage(SWTResourceManager.getImage("/res/img/bar_save.png"));
final ToolItem Toolseparator = new ToolItem(tools_1, SWT.SEPARATOR);
Toolseparator.setText("|");
final ToolItem Complie_c = new ToolItem(tools_1, SWT.HORIZONTAL);
Complie_c.setToolTipText("Compile");
Complie_c.setImage(SWTResourceManager.getImage("/res/img/document.png"));
final ToolItem ViewTrees_c = new ToolItem(tools_1, SWT.HORIZONTAL);
ViewTrees_c.setToolTipText("ViewTree");
ViewTrees_c.setImage(SWTResourceManager.getImage("/res/img/shape_move_backwards.png"));
final ToolItem Toolseparator2 = new ToolItem(tools_1, SWT.SEPARATOR);
Toolseparator2.setText("|");
final ToolItem tool_about = new ToolItem(tools_1, SWT.HORIZONTAL);
tool_about.setToolTipText("About");
tool_about.setImage(SWTResourceManager.getImage("/res/img/bar_help.png"));
tools_1.pack();
final SelectionListener l = new SelectionAdapter(){
public void widgetSelected(SelectionEvent e) {
if (e.getSource() == ToolNew)
{
OnNewDocument();
return;
}
if (e.getSource() == ToolOpen)
{
OnOpenDocument();
return;
}
if (e.getSource() == ToolSave)
{
OnSaveDocument(false);
return;
}
if (e.getSource() == Complie_c)
{
OnCompile();
return;
}
if (e.getSource() == ViewTrees_c)
{
OnExportTree();
return;
}
if (e.getSource() == tool_about)
{
AboutDlg adialog=new AboutDlg(SDIMgr.current_shell,0);
adialog.open();
return;
}
}
public void widgetDefaultSelected(SelectionEvent event) {
}
};
ToolNew.addSelectionListener(l);
ToolOpen.addSelectionListener(l);
ToolSave.addSelectionListener(l);
Complie_c.addSelectionListener(l);
ViewTrees_c.addSelectionListener(l);
tool_about.addSelectionListener(l);
/*
ToolPrintPrview.addSelectionListener(l);
ToolUndo.addSelectionListener(l);
*/
return cbar;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -