MenuItem fileNew = new MenuItem(fileMenu, SWT.PUSH);
fileNew.setText(MenuBarLabels.FILE_NEW);
// fileNew.setAccelerator(SWT.MOD1 + 'A');
- fileNew.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
- }
+ fileNew.addSelectionListener(fileMenuListener);
+
+ MenuItem fileLoad = new MenuItem(fileMenu, SWT.PUSH);
+ fileLoad.setText(MenuBarLabels.FILE_LOAD);
+ fileLoad.addSelectionListener(fileMenuListener);
- @Override
- public void widgetSelected(SelectionEvent arg0) {
+ MenuItem fileSave = new MenuItem(fileMenu, SWT.PUSH);
+ fileSave.setText(MenuBarLabels.FILE_SAVE);
+ fileSave.setEnabled(false);
+ fileSave.addSelectionListener(fileMenuListener);
+
+ MenuItem fileExit = new MenuItem(fileMenu, SWT.PUSH);
+ fileExit.setText(MenuBarLabels.FILE_EXIT);
+ fileExit.addSelectionListener(fileMenuListener);
+
+ //analyze menu
+ Menu analyzeMenu = new Menu(currentShell, SWT.DROP_DOWN);
+ analyzeItem.setMenu(analyzeMenu);
+
+ MenuItem analyzeSearchItem = new MenuItem(analyzeMenu, SWT.PUSH);
+ analyzeSearchItem.setText(MenuBarLabels.ANALYZE_SEARCH);
+ analyzeSearchItem.addSelectionListener(anlysisMenuListener);
+
+ MenuItem analyzeTarget = new MenuItem(analyzeMenu, SWT.PUSH);
+ analyzeTarget.setText(MenuBarLabels.ANALYZE_TARGET);
+ analyzeTarget.addSelectionListener(anlysisMenuListener);
+
+ MenuItem analyzeScreenshot = new MenuItem(analyzeMenu, SWT.PUSH);
+ analyzeScreenshot.setText(MenuBarLabels.ANALYZE_SCREENSHOT);
+ analyzeScreenshot.addSelectionListener(anlysisMenuListener);
+
+ MenuItem analyzePreferences = new MenuItem(analyzeMenu, SWT.PUSH);
+ analyzePreferences.setText(MenuBarLabels.ANALYZE_PREFENCES);
+ analyzePreferences.addSelectionListener(anlysisMenuListener);
+
+ MenuItem analyzeDefault = new MenuItem(analyzeMenu, SWT.PUSH);
+ analyzeDefault.setText(MenuBarLabels.ANALYZE_SET_AS_DEFAULT);
+ analyzeDefault.addSelectionListener(anlysisMenuListener);
+
+ //view menu
+ Menu viewMenu = new Menu(currentShell, SWT.DROP_DOWN);
+ viewItem.setMenu(viewMenu);
+
+ MenuItem viewDetail = new MenuItem(viewMenu, SWT.CHECK);
+ viewDetail.setText(MenuBarLabels.VIEW_DETAIL);
+ viewDetail.addSelectionListener(viewMenuListener);
+
+ MenuItem viewReport = new MenuItem(viewMenu, SWT.CASCADE);
+ viewReport.setText(MenuBarLabels.VIEW_REPORT);
+
+ Menu viewReportMenu = new Menu(currentShell, SWT.DROP_DOWN);
+ viewReport.setMenu(viewReportMenu);
+
+ MenuItem viewReportStatistics = new MenuItem(viewReportMenu, SWT.CHECK);
+ viewReportStatistics.setText(MenuBarLabels.VIEW_STATISTICS);
+ viewReportStatistics.addSelectionListener(viewReportMenuListener);
+
+ MenuItem viewReportTrace = new MenuItem(viewReportMenu, SWT.CHECK);
+ viewReportTrace.setText(MenuBarLabels.VIEW_TRACE);
+ viewReportTrace.addSelectionListener(viewReportMenuListener);
+
+ MenuItem viewReportFunctionprofiling = new MenuItem(viewReportMenu, SWT.CHECK);
+ viewReportFunctionprofiling.setText(MenuBarLabels.VIEW_FUNCTION_PROFILING);
+ viewReportFunctionprofiling.addSelectionListener(viewReportMenuListener);
+
+ MenuItem viewNavigate = new MenuItem(viewMenu, SWT.CASCADE);
+ viewNavigate.setText(MenuBarLabels.VIEW_NAVIGATE);
+
+ Menu viewNavigateMenu = new Menu(currentShell, SWT.DROP_DOWN);
+ viewNavigate.setMenu(viewNavigateMenu);
+
+ MenuItem viewNavigateZoomin = new MenuItem(viewNavigateMenu, SWT.PUSH);
+ viewNavigateZoomin.setText(MenuBarLabels.VIEW_ZOOM_IN);
+ viewNavigateZoomin.addSelectionListener(viewNavigateMenuListener);
+
+ MenuItem viewNavigateZoomout = new MenuItem(viewNavigateMenu, SWT.PUSH);
+ viewNavigateZoomout.setText(MenuBarLabels.VIEW_ZOOM_OUT);
+ viewNavigateZoomout.addSelectionListener(viewNavigateMenuListener);
+
+ MenuItem viewNavigateMoveleft = new MenuItem(viewNavigateMenu, SWT.PUSH);
+ viewNavigateMoveleft.setText(MenuBarLabels.VIEW_MOVE_LEFT);
+ viewNavigateMoveleft.addSelectionListener(viewNavigateMenuListener);
+
+ MenuItem viewNavigateMoveright = new MenuItem(viewNavigateMenu, SWT.PUSH);
+ viewNavigateMoveright.setText(MenuBarLabels.VIEW_MOVE_RIGHT);
+ viewNavigateMoveright.addSelectionListener(viewNavigateMenuListener);
+
+ MenuItem viewNavigateMovefirst = new MenuItem(viewNavigateMenu, SWT.PUSH);
+ viewNavigateMovefirst.setText(MenuBarLabels.VIEW_MOVE_FIRST);
+ viewNavigateMovefirst.addSelectionListener(viewNavigateMenuListener);
+
+ MenuItem viewNavigateMoveend = new MenuItem(viewNavigateMenu, SWT.PUSH);
+ viewNavigateMoveend.setText(MenuBarLabels.VIEW_MOVE_END);
+ viewNavigateMoveend.addSelectionListener(viewNavigateMenuListener);
+
+ //help menu
+ Menu helpMenu = new Menu(currentShell, SWT.DROP_DOWN);
+ helpItem.setMenu(helpMenu);
+
+ MenuItem helpHowto = new MenuItem(helpMenu, SWT.PUSH);
+ helpHowto.setText(MenuBarLabels.HELP_HOWTO);
+ helpHowto.addSelectionListener(helpMenuListener);
+
+ MenuItem helpBugreport = new MenuItem(helpMenu, SWT.PUSH);
+ helpBugreport.setText(MenuBarLabels.HELP_BUGREPORT);
+ helpBugreport.addSelectionListener(helpMenuListener);
+
+ MenuItem helpAbout = new MenuItem(helpMenu, SWT.PUSH);
+ helpAbout.setText(MenuBarLabels.HELP_ABOUT);
+ helpAbout.addSelectionListener(helpMenuListener);
+ }
+
+ private SelectionListener fileMenuListener = new SelectionListener () {
+ @Override
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent arg0) {
+ String menuName = null;
+ if (arg0.getSource() != null && arg0.getSource() instanceof MenuItem) {
+ menuName = ((MenuItem)arg0.getSource()).getText();
+ }
+ else {
+ return;
+ }
+
+ if(menuName.equals(MenuBarLabels.FILE_NEW)) {
// change UI state
Toolbar.INSTANCE.resetProcessCombo();
Toolbar.INSTANCE.changeUIState(DAState.PREPARE_START);
FlatFeatureDialog featureDialog = new FlatFeatureDialog(currentShell);
featureDialog.open();
}
- });
-
- MenuItem fileLoad = new MenuItem(fileMenu, SWT.PUSH);
- fileLoad.setText(MenuBarLabels.FILE_LOAD);
- fileLoad.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
- }
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
+ else if(menuName.equals(MenuBarLabels.FILE_LOAD)) {
FileDialog dialog = new FileDialog(currentShell, SWT.OPEN);
dialog.setFilterNames(new String[] {"Zip file"});
dialog.setFilterExtensions(new String[] {"*.zip"});
}
}
}
- });
-
- MenuItem fileSave = new MenuItem(fileMenu, SWT.PUSH);
- fileSave.setText(MenuBarLabels.FILE_SAVE);
- fileSave.setEnabled(false);
- fileSave.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
- }
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
+ else if(menuName.equals(MenuBarLabels.FILE_SAVE)) {
Project project = Global.getProject();
if(project == null) {
return;
}
}
}
- });
-
- MenuItem fileExit = new MenuItem(fileMenu, SWT.PUSH);
- fileExit.setText(MenuBarLabels.FILE_EXIT);
- fileExit.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
- }
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
+ else if(menuName.equals(MenuBarLabels.FILE_EXIT)) {
currentShell.close();
}
- });
-
- //analyze menu
- Menu analyzeMenu = new Menu(currentShell, SWT.DROP_DOWN);
- analyzeItem.setMenu(analyzeMenu);
-
- MenuItem analyzeSearchItem = new MenuItem(analyzeMenu, SWT.PUSH);
- analyzeSearchItem.setText(MenuBarLabels.ANALYZE_SEARCH);
- analyzeSearchItem.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
- }
+ }
+ };
+
+ private SelectionListener anlysisMenuListener = new SelectionListener () {
+ @Override
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+
+ }
- @Override
- public void widgetSelected(SelectionEvent arg0) {
-
+ @Override
+ public void widgetSelected(SelectionEvent arg0) {
+ String menuName = null;
+ if (arg0.getSource() != null && arg0.getSource() instanceof MenuItem) {
+ menuName = ((MenuItem)arg0.getSource()).getText();
+ }
+ else {
+ return;
}
- });
-
- MenuItem analyzeTarget = new MenuItem(analyzeMenu, SWT.PUSH);
- analyzeTarget.setText(MenuBarLabels.ANALYZE_TARGET);
- analyzeTarget.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
+
+ if(menuName.equals(MenuBarLabels.ANALYZE_SEARCH)) {
}
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
+ else if(menuName.equals(MenuBarLabels.ANALYZE_TARGET)) {
TargetDialog targetDialog = new TargetDialog(currentShell);
targetDialog.open();
}
- });
-
- MenuItem analyzeScreenshot = new MenuItem(analyzeMenu, SWT.PUSH);
- analyzeScreenshot.setText(MenuBarLabels.ANALYZE_SCREENSHOT);
- analyzeScreenshot.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
- }
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
+ else if(menuName.equals(MenuBarLabels.ANALYZE_SCREENSHOT)) {
}
- });
-
- MenuItem analyzePreferences = new MenuItem(analyzeMenu, SWT.PUSH);
- analyzePreferences.setText(MenuBarLabels.ANALYZE_PREFENCES);
- analyzePreferences.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
- }
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
+ else if(menuName.equals(MenuBarLabels.ANALYZE_PREFENCES)) {
PreferencesDialog preferencesDialog = new PreferencesDialog(currentShell);
preferencesDialog.open();
}
- });
-
- MenuItem analyzeDefault = new MenuItem(analyzeMenu, SWT.PUSH);
- analyzeDefault.setText(MenuBarLabels.ANALYZE_SET_AS_DEFAULT);
- analyzeDefault.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
- }
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
-
- }
- });
-
-
- //view menu
- Menu viewMenu = new Menu(currentShell, SWT.DROP_DOWN);
- viewItem.setMenu(viewMenu);
-
- MenuItem viewDetail = new MenuItem(viewMenu, SWT.CHECK);
- viewDetail.setText(MenuBarLabels.VIEW_DETAIL);
- viewDetail.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
- }
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
-
- }
- });
-
- MenuItem viewReport = new MenuItem(viewMenu, SWT.CASCADE);
- viewReport.setText(MenuBarLabels.VIEW_REPORT);
-
- Menu viewReportMenu = new Menu(currentShell, SWT.DROP_DOWN);
- viewReport.setMenu(viewReportMenu);
-
- MenuItem viewReportStatistics = new MenuItem(viewReportMenu, SWT.CHECK);
- viewReportStatistics.setText(MenuBarLabels.VIEW_STATISTICS);
- viewReportStatistics.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
- }
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
-
- }
- });
-
- MenuItem viewReportTrace = new MenuItem(viewReportMenu, SWT.CHECK);
- viewReportTrace.setText(MenuBarLabels.VIEW_TRACE);
- viewReportTrace.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
- }
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
-
- }
- });
-
- MenuItem viewReportFunctionprofiling = new MenuItem(viewReportMenu, SWT.CHECK);
- viewReportFunctionprofiling.setText(MenuBarLabels.VIEW_FUNCTION_PROFILING);
- viewReportFunctionprofiling.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
+ else if(menuName.equals(MenuBarLabels.ANALYZE_SET_AS_DEFAULT)) {
+
}
+ }
+ };
+
+ private SelectionListener viewMenuListener = new SelectionListener () {
+ @Override
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+
+ }
- @Override
- public void widgetSelected(SelectionEvent arg0) {
-
+ @Override
+ public void widgetSelected(SelectionEvent arg0) {
+ String menuName = null;
+ if (arg0.getSource() != null && arg0.getSource() instanceof MenuItem) {
+ menuName = ((MenuItem)arg0.getSource()).getText();
+ }
+ else {
+ return;
}
- });
-
- MenuItem viewNavigate = new MenuItem(viewMenu, SWT.CASCADE);
- viewNavigate.setText(MenuBarLabels.VIEW_NAVIGATE);
-
- Menu viewNavigateMenu = new Menu(currentShell, SWT.DROP_DOWN);
- viewNavigate.setMenu(viewNavigateMenu);
-
- MenuItem viewNavigateZoomin = new MenuItem(viewNavigateMenu, SWT.PUSH);
- viewNavigateZoomin.setText(MenuBarLabels.VIEW_ZOOM_IN);
- viewNavigateZoomin.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
+
+ if(menuName.equals(MenuBarLabels.VIEW_DETAIL)) {
}
+ }
+ };
+
+ private SelectionListener viewReportMenuListener = new SelectionListener () {
+ @Override
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+
+ }
- @Override
- public void widgetSelected(SelectionEvent arg0) {
-
+ @Override
+ public void widgetSelected(SelectionEvent arg0) {
+ String menuName = null;
+ if (arg0.getSource() != null && arg0.getSource() instanceof MenuItem) {
+ menuName = ((MenuItem)arg0.getSource()).getText();
+ }
+ else {
+ return;
}
- });
-
- MenuItem viewNavigateZoomout = new MenuItem(viewNavigateMenu, SWT.PUSH);
- viewNavigateZoomout.setText(MenuBarLabels.VIEW_ZOOM_OUT);
- viewNavigateZoomout.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
+
+ if(menuName.equals(MenuBarLabels.VIEW_STATISTICS)) {
}
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
+ else if(menuName.equals(MenuBarLabels.VIEW_FUNCTION_PROFILING)) {
}
- });
-
- MenuItem viewNavigateMoveleft = new MenuItem(viewNavigateMenu, SWT.PUSH);
- viewNavigateMoveleft.setText(MenuBarLabels.VIEW_MOVE_LEFT);
- viewNavigateMoveleft.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
+ else if(menuName.equals(MenuBarLabels.VIEW_TRACE)) {
}
+ }
+ };
+
+ private SelectionListener viewNavigateMenuListener = new SelectionListener () {
+ @Override
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+
+ }
- @Override
- public void widgetSelected(SelectionEvent arg0) {
-
- }
- });
-
- MenuItem viewNavigateMoveright = new MenuItem(viewNavigateMenu, SWT.PUSH);
- viewNavigateMoveright.setText(MenuBarLabels.VIEW_MOVE_RIGHT);
- viewNavigateMoveright.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
+ @Override
+ public void widgetSelected(SelectionEvent arg0) {
+ String menuName = null;
+ if (arg0.getSource() != null && arg0.getSource() instanceof MenuItem) {
+ menuName = ((MenuItem)arg0.getSource()).getText();
+ }
+ else {
+ return;
}
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
+
+ if(menuName.equals(MenuBarLabels.VIEW_ZOOM_IN)) {
}
- });
-
- MenuItem viewNavigateMovefirst = new MenuItem(viewNavigateMenu, SWT.PUSH);
- viewNavigateMovefirst.setText(MenuBarLabels.VIEW_MOVE_FIRST);
- viewNavigateMovefirst.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
+ else if(menuName.equals(MenuBarLabels.VIEW_ZOOM_OUT)) {
}
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
+ else if(menuName.equals(MenuBarLabels.VIEW_MOVE_LEFT)) {
}
- });
-
- MenuItem viewNavigateMoveend = new MenuItem(viewNavigateMenu, SWT.PUSH);
- viewNavigateMoveend.setText(MenuBarLabels.VIEW_MOVE_END);
- viewNavigateMoveend.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
+ else if(menuName.equals(MenuBarLabels.VIEW_MOVE_RIGHT)) {
+
}
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
-
+ else if(menuName.equals(MenuBarLabels.VIEW_MOVE_FIRST)) {
+
}
- });
-
- //help menu
- Menu helpMenu = new Menu(currentShell, SWT.DROP_DOWN);
- helpItem.setMenu(helpMenu);
-
- MenuItem helpHowto = new MenuItem(helpMenu, SWT.PUSH);
- helpHowto.setText(MenuBarLabels.HELP_HOWTO);
- helpHowto.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
+ else if(menuName.equals(MenuBarLabels.VIEW_MOVE_END)) {
+
}
+ }
+ };
+
+ private SelectionListener helpMenuListener = new SelectionListener () {
+ @Override
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+
+ }
- @Override
- public void widgetSelected(SelectionEvent arg0) {
-
+ @Override
+ public void widgetSelected(SelectionEvent arg0) {
+ String menuName = null;
+ if (arg0.getSource() != null && arg0.getSource() instanceof MenuItem) {
+ menuName = ((MenuItem)arg0.getSource()).getText();
+ }
+ else {
+ return;
}
- });
-
- MenuItem helpBugreport = new MenuItem(helpMenu, SWT.PUSH);
- helpBugreport.setText(MenuBarLabels.HELP_BUGREPORT);
- helpBugreport.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
+
+ if(menuName.equals(MenuBarLabels.HELP_ABOUT)) {
}
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
+ else if(menuName.equals(MenuBarLabels.HELP_BUGREPORT)) {
}
- });
-
- MenuItem helpAbout = new MenuItem(helpMenu, SWT.PUSH);
- helpAbout.setText(MenuBarLabels.HELP_ABOUT);
- helpAbout.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
-
- }
-
- @Override
- public void widgetSelected(SelectionEvent arg0) {
+ else if(menuName.equals(MenuBarLabels.HELP_HOWTO)) {
}
- });
- }
+ }
+ };
public boolean setMenuItemEnable(String menuName, boolean enable) {
int menulength = menubar.getItems().length;