private void setPrologInterface(PrologInterface newPif, boolean updateActivePif) { if (currentPif == newPif) { return; } if (currentPif != null) { viewerStates.put(currentPif, viewer.saveState()); } currentPif = newPif; if (currentPif != null) { addHooks(currentPif); try { connect(currentPif); } catch (PrologInterfaceException e) { Debug.report(e); } reconfigureViewer(currentPif); getDefaultPrologConsoleService().fireActivePrologInterfaceChanged(this); if (updateActivePif) { PrologRuntimeUIPlugin.getDefault() .getPrologInterfaceService() .setActivePrologInterface(currentPif); } } else { Debug.debug("no pif (yet)."); } if (automatedSelector != null) { automatedSelector.update(); } writeCurrentProcessPortToFile(); }
private void startServer(PrologInterface pif, PrologSession session) { try { String queryString = bT( PDTConsolePredicates.PDT_START_CONSOLE_SERVER, "Port", Util.quoteAtom( PrologRuntimePlugin.getDefault().getPrologInterfaceRegistry().getKey(pif))); Debug.info("starting console server using: " + queryString); Map<String, ?> result = session.queryOnce(queryString); if (result == null) { Debug.info("starting server failed, which may mean that it is actualy running already."); result = session.queryOnce(bT(PDTConsolePredicates.PDT_CURRENT_CONSOLE_SERVER, "Port")); if (result == null) { throw new RuntimeException("No Server running."); } } int port = Integer.parseInt((String) result.get("Port")); Debug.debug("A server thread seems to be listinging at port " + port); } catch (Throwable e) { Debug.report(e); throw new RuntimeException(e); } }