示例#1
0
 @Override
 public Menu getMenu(Control parent) {
   if (menu != null) {
     menu.dispose();
   }
   Menu newMenu = new Menu(parent);
   List<String> preferenceConfigurations =
       PrologRuntimeUIPlugin.getDefault().getPreferenceConfigurations();
   String defaultConfiguration =
       PrologRuntimeUIPlugin.getDefault()
           .getPreferenceStore()
           .getString(PrologRuntimeUI.PREF_CONFIGURATION);
   for (String preferenceConfiguration : preferenceConfigurations) {
     MenuItem item = new MenuItem(newMenu, SWT.NONE);
     item.setText(preferenceConfiguration.replaceAll("&", "&&"));
     if (preferenceConfiguration.equals(defaultConfiguration)) {
       item.setImage(ImageRepository.getImage(ImageRepository.NEW_PROCESS));
     }
     final String configuration = preferenceConfiguration;
     item.addSelectionListener(
         new SelectionAdapter() {
           @Override
           public void widgetSelected(SelectionEvent e) {
             askForNameAndCreateProcess(configuration);
           }
         });
   }
   menu = newMenu;
   return menu;
 }
示例#2
0
  public PrologInterface activateNewPrologProcess(
      PrologInterfaceRegistry registry, String pifKey, String configuration) {
    DefaultSubscription subscription =
        new DefaultSubscription(
            pifKey + "_indepent", pifKey, "Independent prolog process", "Prolog");
    registry.addSubscription(subscription);
    PrologInterface pif =
        PrologRuntimeUIPlugin.getDefault().getPrologInterface(subscription, configuration);

    if (automatedSelector.getActiveTrackers().isEmpty()) {
      setPrologInterface(pif);
      automatedSelector.setImageDescriptor(
          ImageRepository.getImageDescriptor(ImageRepository.MANUAL_MODE));
    }
    return pif;
  }
示例#3
0
  private void createAutomatedSelector(IToolBarManager toolBarManager) {

    automatedSelector =
        new SelectContextPIFAutomatedAction() {

          @Override
          protected PrologInterface getPrologInterface() {
            return PrologConsoleView.this.getPrologInterface();
          }

          @Override
          protected void setPrologInterface(PrologInterface prologInterface) {
            PrologConsoleView.this.setPrologInterface(prologInterface);
          }

          @Override
          protected void trackerActivated(PrologContextTracker tracker) {
            setPrologInterface(automatedSelector.getCurrentPrologInterface());
          }

          @Override
          protected void trackerDeactivated(PrologContextTracker tracker) {
            setPrologInterface(automatedSelector.getCurrentPrologInterface());
          }

          @Override
          public void contextChanged(PrologContextTrackerEvent e) {
            PrologContextTracker tracker = (PrologContextTracker) e.getSource();
            Debug.info("context changed for tracker " + tracker.getLabel());
            setPrologInterface(e.getPrologInterface());
          }
        };
    toolBarManager.add(automatedSelector);

    //		pifSelector = new SelectPifAction() {
    //
    //			protected void setPrologInterface(PrologInterface prologInterface) {
    //				PrologConsoleView.this.setPrologInterface(prologInterface);
    //
    //			}
    //
    //			protected PrologInterface getPrologInterface() {
    //				return PrologConsoleView.this.getPrologInterface();
    //			}
    //
    //		};
    //		toolBarManager.add(pifSelector);

    //		contextSelector = new SelectContextsAction() {
    //
    //			public void contextChanged(PrologContextTrackerEvent e) {
    //				PrologContextTracker tracker = (PrologContextTracker) e
    //						.getSource();
    //				Debug.info("context changed for tracker " + tracker.getLabel());
    //				setPrologInterface(e.getPrologInterface());
    //
    //			}
    //
    //			protected void trackerActivated(PrologContextTracker tracker) {
    //				setPrologInterface(contextSelector.getCurrentPrologInterface());
    //
    //			}
    //
    //			protected void trackerDeactivated(PrologContextTracker tracker) {
    //				setPrologInterface(contextSelector.getCurrentPrologInterface());
    //
    //			}
    //		};

    //		toolBarManager.add(contextSelector);
    //		setPrologInterface(contextSelector.getCurrentPrologInterface());
    setPrologInterface(
        PrologRuntimeUIPlugin.getDefault().getPrologInterfaceService().getActivePrologInterface());
    automatedSelector.setImageDescriptor(
        ImageRepository.getImageDescriptor(ImageRepository.MANUAL_MODE));
  }
示例#4
0
  private void createActions() {
    cutAction =
        new Action() {
          @Override
          public void run() {
            viewer.cut();
          }
        };

    copyAction =
        new Action() {
          @Override
          public void run() {
            viewer.copy();
          }
        };
    pasteAction =
        new Action() {
          @Override
          public void run() {
            viewer.paste();
          }
        };
    selectAllAction =
        new Action() {
          @Override
          public void run() {
            viewer.selectAll();
          }
        };
    clearAction =
        new ClearAction(
            "Clear",
            "Clear console output",
            ImageRepository.getImageDescriptor(ImageRepository.CLEAR));
    searchAction =
        new Action("Open Search Dialog") {
          @Override
          public void run() {
            NewSearchUI.openSearchDialog(
                getSite().getWorkbenchWindow(), PrologSearchPage.EXTENSION_POINT_ID);
          }
        };
    //		guiTracerAction = new GuiTracerAction(new String[] {"guitracer", "noguitracer"},
    //				new String[] {"activate guitracer", "deactivate guitracer"},
    //				new String[] {"activate GUI tracer", "deactivate GUI tracer"},
    //				new ImageDescriptor[] {
    //				ImageRepository.getImageDescriptor(ImageRepository.GUITRACER),
    //				ImageRepository.getImageDescriptor(ImageRepository.NOGUITRACER)});
    activateGuiTracerAction =
        new ConsoleQueryAction(
            "Activate GUI tracer",
            ImageRepository.getImageDescriptor(ImageRepository.GUITRACER),
            "guitracer");
    deactivateGuiTracerAction =
        new ConsoleQueryAction(
            "Deactivate GUI tracer",
            ImageRepository.getImageDescriptor(ImageRepository.NOGUITRACER),
            "noguitracer");
    threadMonitorAction =
        new ConsoleQueryAction(
            "Show SWI thread monitor",
            ImageRepository.getImageDescriptor(ImageRepository.THREAD_MONITOR),
            "user:prolog_ide(thread_monitor)");
    debugMonitorAction =
        new ConsoleQueryAction(
            "Show SWI debug message monitor",
            ImageRepository.getImageDescriptor(ImageRepository.DEBUG_MONITOR),
            "user:prolog_ide(debug_monitor)");
    abortAction =
        new PifQueryAction(
            "Abort running query",
            ImageRepository.getImageDescriptor(ImageRepository.ABORT),
            bT(PDTConsolePredicates.CONSOLE_THREAD_NAME, "ID")
                + ", catch(thread_signal(ID, abort),_,fail)") {
          @Override
          public void run() {
            super.run();
            if (!getModel().isConnected()) {
              new Thread(
                      new Runnable() {
                        @Override
                        public void run() {
                          try {
                            Thread.sleep(500);
                          } catch (InterruptedException e) {
                          }
                          try {
                            connect(currentPif);
                          } catch (PrologInterfaceException e) {
                          }
                        }
                      })
                  .start();
            }
          }
        };
    traceAction =
        new PifQueryAction(
            "Interrupt running query and start tracing",
            ImageRepository.getImageDescriptor(ImageRepository.TRACE),
            bT(PDTConsolePredicates.CONSOLE_THREAD_NAME, "ID")
                + ", catch(thread_signal(ID, trace),_,fail)");

    pasteFileNameAction =
        new PasteAction(
            "Paste filename",
            "Paste the name of the current editor file",
            ImageRepository.getImageDescriptor(ImageRepository.PASTE_FILENAME)) {

          @Override
          protected String getTextToInsert() {
            String fileName = UIUtils.getFileFromActiveEditor();
            if (fileName == null) {
              return null;
            }
            return Util.quoteAtom(Util.prologFileName(new File(fileName)));
          }
        };
    pasteFileNameAction.setActionDefinitionId(PDTConsole.COMMAND_PASTE_FILENAME);

    IKeyBindingService keyBindingService = getSite().getKeyBindingService();
    keyBindingService.setScopes(new String[] {PDTConsole.CONTEXT_USING_CONSOLE_VIEW});
    keyBindingService.registerAction(pasteFileNameAction);
    restartAction = new RestartAction();
    killAction = new KillAction();
    genLoadFileAction = new GenLoadFileAction();
    createProcessAction = new CreateNamedProcessAction();
    helpAction =
        new Action(
            "SWI-Prolog Documentation", ImageRepository.getImageDescriptor(ImageRepository.HELP)) {
          @Override
          public void run() {
            try {
              PlatformUI.getWorkbench()
                  .getBrowserSupport()
                  .getExternalBrowser()
                  .openURL(new URL("http://www.swi-prolog.org/pldoc/index.html"));
            } catch (Exception e) {
            }
          }
        };

    configAction =
        new Action(
            "Console preferences",
            ImageRepository.getImageDescriptor(ImageRepository.PREFERENCES)) {
          @Override
          public void run() {
            PreferenceManager mgr = new PreferenceManager();

            IPreferencePage page = new PreferencePageMain();
            page.setTitle("PDT Console");

            IPreferenceNode node = new PreferenceNode("PreferencePage", page);
            mgr.addToRoot(node);

            PreferenceDialog dialog = new PreferenceDialog(getSite().getShell(), mgr);
            dialog.create();
            dialog.setMessage(page.getTitle());
            dialog.open();
          }
        };
  }
示例#5
0
 @Override
 public ImageDescriptor getImageDescriptor() {
   return ImageRepository.getImageDescriptor(ImageRepository.NEW_PROCESS);
 }
示例#6
0
 @Override
 public ImageDescriptor getImageDescriptor() {
   return ImageRepository.getImageDescriptor(ImageRepository.GEN_LOAD_FILE);
 }
示例#7
0
 @Override
 public ImageDescriptor getImageDescriptor() {
   return ImageRepository.getImageDescriptor(ImageRepository.STOP);
 }
示例#8
0
 @Override
 public ImageDescriptor getImageDescriptor() {
   return ImageRepository.getImageDescriptor(ImageRepository.RESTART);
 }