- toolBarManager.add(new Action("Refresh modules",
- Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/arrow_refresh.png")) {
+ toolBarManager.add(new Action("Refresh modules", IAction.AS_DROP_DOWN_MENU) {
+ {
+ setImageDescriptor(Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/arrow_refresh.png"));
+ setMenuCreator(new IMenuCreator() {
+ Menu menu;
+ @Override
+ public Menu getMenu(Menu parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Menu getMenu(Control parent) {
+ if(menu == null) {
+ menu = new Menu(parent);
+ refreshAutomaticallyItem = new MenuItem(menu, SWT.CHECK);
+ refreshAutomaticallyItem.setText("Refresh automatically");
+ refreshAutomaticallyItem.setSelection(refreshAutomatically);
+ refreshAutomaticallyItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setRefreshAutomatically(!refreshAutomatically, true);
+ }
+ });
+ }
+ return menu;
+ }
+
+ @Override
+ public void dispose() {
+ if(menu != null)
+ menu.dispose();
+ }
+ });
+ }