/*
  * @see org.eclipse.jface.action.Action#run()
  */
 @Override
 public void run() {
   ErlBrowserInformationControlInput input = null;
   if (fInfoControl != null) {
     input = (ErlBrowserInformationControlInput) fInfoControl.getInput();
     fInfoControl.notifyDelayedInputChange(null);
     fInfoControl.dispose();
   } else if (edocView != null) {
     input = edocView.getInput();
   }
   if (input != null) {
     // TODO: add hover location to editor navigation history?
     try {
       final Object element = input.getInputElement();
       if (element instanceof IErlElement) {
         EditorUtility.openElementInEditor(element, true);
       } else if (element instanceof OpenResult) {
         final OpenResult or = (OpenResult) element;
         try {
           final AbstractErlangEditor editor = input.getEditor();
           new OpenUtils().openOpenResult(editor, editor.getModule(), -1, null, or, null);
         } catch (final Exception e) {
           ErlLogger.error(e);
         }
       }
     } catch (final PartInitException e) {
       ErlLogger.error(e);
     }
   }
 }
示例#2
0
  /**
   * This method is called upon plug-in activation
   *
   * @param context The context
   * @throws Exception if a problem occurs
   */
  @Override
  public void start(final BundleContext context) throws Exception {
    ErlLogger.debug("Starting UI " + Thread.currentThread());
    super.start(context);

    if (SystemConfiguration.getInstance().isDeveloper()) {
      BackendManagerPopup.init();
    }

    loadDefaultEditorColors();

    ErlLogger.debug("Started UI");

    erlConsoleManager = new ErlConsoleManager();
    if (SystemConfiguration.getInstance().isDeveloper()) {
      try {
        final IBackend ideBackend = BackendCore.getBackendManager().getIdeBackend();
        if (!ideBackend.getData().hasConsole()) {
          erlConsoleManager.runtimeAdded(ideBackend);
        }
      } catch (final Exception e) {
        ErlLogger.warn(e);
      }
    }

    erlangDebuggerBackendListener = new ErlangDebuggerBackendListener();
    BackendCore.getBackendManager().addBackendListener(erlangDebuggerBackendListener);

    startPeriodicCacheCleaner();
  }
示例#3
0
 @Override
 protected void terminated() {
   ErlLogger.debug("ErtsProcess terminated: %s", getLabel());
   try {
     getLaunch().terminate();
   } catch (final DebugException e) {
     ErlLogger.error(e);
   }
   super.terminated();
 }
示例#4
0
 @Override
 public void terminate() throws DebugException {
   ErlLogger.debug(
       "ErtsProcess will be terminated: %s, called from: %s",
       getLabel(), new Throwable().getStackTrace()[1]);
   try {
     super.terminate();
   } finally {
     if (!isTerminated()) {
       ErlLogger.debug("Could not terminate process %s", getLabel());
     }
   }
 }
示例#5
0
 private void autoIndentAfterNewLine(final IDocument d, final DocumentCommand c) {
   try {
     indentAfterNewLine(d, c);
   } catch (final BadLocationException e) {
     ErlLogger.warn(e);
   }
 }
 public SearchPatternData tryErlangTextSelection(
     final SearchPatternData initData0, final IEditorPart activePart) throws ErlModelException {
   final AbstractErlangEditor erlangEditor = (AbstractErlangEditor) activePart;
   final IErlModule module = erlangEditor.getModule();
   SearchPatternData initData = initData0;
   if (module != null) {
     final ISelection ssel = erlangEditor.getSite().getSelectionProvider().getSelection();
     final ITextSelection textSel = (ITextSelection) ssel;
     final int offset = textSel.getOffset();
     OpenResult res;
     try {
       res =
           ErlangEngine.getInstance()
               .getService(OpenService.class)
               .open(
                   module.getScannerName(),
                   offset,
                   ErlangEngine.getInstance().getModelUtilService().getImportsAsList(module),
                   "",
                   ErlangEngine.getInstance().getModel().getPathVars());
     } catch (final RpcException e) {
       res = null;
     }
     ErlLogger.debug("searchPage(open) " + res);
     initData = determineInitValuesFrom(module, offset, res);
   }
   return initData;
 }
 @Override
 public void moduleLoaded(
     final IBackend backend, final IProject project, final String moduleName) {
   try {
     final ErlangDebugTarget erlangDebugTarget = debugTargetOfBackend(backend.getOtpRpc());
     if (erlangDebugTarget != null
         && erlangDebugTarget.getInterpretedModules().contains(moduleName)) {
       if (isModuleRunningInInterpreter(erlangDebugTarget, backend.getOtpRpc(), moduleName)) {
         abortContinueDialog(erlangDebugTarget);
       } else {
         final ILaunchConfiguration launchConfiguration =
             erlangDebugTarget.getLaunch().getLaunchConfiguration();
         final EnumSet<ErlDebugFlags> debugFlags =
             ErlDebugFlags.makeSet(
                 launchConfiguration.getAttribute(
                     ErlRuntimeAttributes.DEBUG_FLAGS,
                     ErlDebugFlags.getFlag(ErlDebugFlags.DEFAULT_DEBUG_FLAGS)));
         final boolean distributed = debugFlags.contains(ErlDebugFlags.DISTRIBUTED_DEBUG);
         erlangDebugTarget.interpret(project, moduleName, distributed, true);
       }
     }
   } catch (final CoreException e) {
     ErlLogger.error(e);
   }
 }
示例#8
0
 @Override
 protected void waitForExit() throws ErlRuntimeException {
   if (process != null) {
     int i = 500;
     // may have to wait for crash dump to be written
     while (i-- > 0 && exitCode < 0) {
       exitCode = -1;
       try {
         Thread.sleep(POLL_INTERVAL * 2);
         exitCode = process.exitValue();
       } catch (final IllegalThreadStateException e) {
       } catch (final InterruptedException e) {
       }
       if (exitCode > 0) {
         throw new ErlRuntimeException(
             String.format("Runtime %s died with exit code %d", getNodeName(), exitCode));
       }
     }
     if (exitCode < 0) {
       ErlLogger.warn("Runtime %s died, but process is still running; killing it", getNodeName());
       throw new ErlRuntimeException(
           String.format("Runtime %s died with exit code unknown", getNodeName()));
     }
   }
 }
示例#9
0
 /** Selects and reveals the given offset and length in the given editor part. */
 public static void revealInEditor(final IEditorPart editor, final int offset, final int length) {
   if (editor instanceof ITextEditor) {
     ((ITextEditor) editor).selectAndReveal(offset, length);
     return;
   }
   ErlLogger.warn(
       "EditorUtility.revealInEditor should only be called on an ErlangEditor; it was an %s",
       editor.getClass().getName());
 }
示例#10
0
 public static String getFilteredStackTrace(final Throwable t, final boolean shouldFilter) {
   try {
     final StringWriter sw = new StringWriter();
     final PrintWriter pw = new PrintWriter(sw);
     writeCleanStackTrace(t, pw, shouldFilter);
     return sw.getBuffer().toString();
   } catch (final Exception e) {
     ErlLogger.error(e);
     return e.toString();
   }
 }
示例#11
0
  public void start() throws CoreException {
    final String version = getFeatureVersionImpl();

    ErlLogger.debug("Starting CORE " + Thread.currentThread());
    String dev = "(" + EncodingUtils.getEncoding() + ") ";
    if (SystemConfiguration.getInstance().isDeveloper()) {
      dev += " developer version ***";
    }
    if (SystemConfiguration.getInstance().isTest()) {
      dev += " test ***";
    }
    final String versionBanner = "*** starting Erlide v" + version + " *** " + dev;
    logger.log(Level.INFO, versionBanner);
    featureVersion = version;

    workspace.addSaveParticipant(plugin.getBundle().getSymbolicName(), getSaveParticipant());

    ErlangDebugOptionsManager.getDefault().start();
    ErlLogger.debug("Started CORE");
  }
  /**
   * Run code inspection function, and shows the result in the workbench
   *
   * @param viewtTitle title of the view
   * @param noResultMessage if there is no result, this message will be displayed
   * @param tmpFile temp .dot file
   * @param functionName function to call
   * @param signature parameters signature
   * @param parameters function parameters
   */
  protected void runInspection(
      final String viewtTitle,
      final String secondaryID,
      final String noResultMessage,
      final File tmpFile,
      final String functionName,
      final String signature,
      final Object... parameters) {
    try {
      CodeInspectionViewsManager.hideView(CodeInspectionViewsManager.GRAPH_VIEW, secondaryID);
      final Boolean b =
          WranglerBackendManager.getRefactoringBackend()
              .callSimpleInspection(functionName, signature, parameters);
      if (b) {
        final FileInputStream fis = new FileInputStream(tmpFile);
        try {
          if (fis.available() > 0) {

            final Image img = GraphViz.load(fis, "png", new Point(0, 0));
            CodeInspectionViewsManager.showDotImage(img, viewtTitle, secondaryID, tmpFile);
          } else {
            MessageDialog.openInformation(
                GlobalParameters.getEditor().getSite().getShell(), viewtTitle, noResultMessage);
          }
        } finally {
          fis.close();
        }
      } else {
        MessageDialog.openError(
            GlobalParameters.getEditor().getSite().getShell(),
            "Internal error",
            "Internal error occured. Please report it!");
      }
    } catch (final IOException e) {
      ErlLogger.error(e);
    } catch (final CoreException e) {
      ErlLogger.error(e);
    } catch (final Exception e) {
      ErlLogger.error(e);
    }
  }
示例#13
0
  /** Hide the duplicates view. */
  public static void closeDuplicatesView() {
    final IWorkbench workbench = PlatformUI.getWorkbench();

    final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    IViewPart view;
    try {
      view = window.getActivePage().showView(duplicatedView);
      window.getActivePage().hideView(view);
    } catch (final PartInitException e) {
      ErlLogger.error(e);
    }
  }
示例#14
0
  /** Shows the duplicates view. */
  public static void showDuplicatesView() {
    final IWorkbench workbench = PlatformUI.getWorkbench();

    final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    try {

      @SuppressWarnings("unused")
      final IViewPart view = window.getActivePage().showView(duplicatedView);

    } catch (final PartInitException e) {
      ErlLogger.error(e);
    }
  }
示例#15
0
 /*
  * @see org.eclipse.jface.action.Action#run()
  */
 @Override
 public void run() {
   final BrowserInformationControlInput input = fInfoControl.getInput();
   fInfoControl.notifyDelayedInputChange(null);
   fInfoControl.dispose();
   try {
     final EdocView view = (EdocView) ErlideUIPlugin.getActivePage().showView(EdocView.ID);
     // TODO view.setInput(infoInput);
     view.setText(input.getHtml());
   } catch (final PartInitException e) {
     ErlLogger.error(e);
   }
 }
  private void contextActivated(final ISelection selection) {
    if (!isAvailable() || !isVisible()) {
      return;
    }
    erlangDebugTarget = null;
    if (selection instanceof IStructuredSelection) {
      final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
      final Object o = structuredSelection.getFirstElement();
      if (o instanceof ErlangDebugElement) {
        final ErlangDebugElement e = (ErlangDebugElement) o;
        erlangDebugTarget = e.getErlangDebugTarget();
      } else if (o instanceof ILaunch) {
        final ILaunch launch = (ILaunch) o;
        final IDebugTarget target = launch.getDebugTarget();
        if (target instanceof IErlangDebugNode) {
          final IErlangDebugNode edn = (IErlangDebugNode) target;
          erlangDebugTarget = edn.getErlangDebugTarget();
        }
      } else if (o instanceof RuntimeProcess) {
        final RuntimeProcess ep = (RuntimeProcess) o;
        final ILaunch launch = ep.getLaunch();
        final IDebugTarget target = launch.getDebugTarget();
        if (target instanceof IErlangDebugNode) {
          final IErlangDebugNode edn = (IErlangDebugNode) target;
          erlangDebugTarget = edn.getErlangDebugTarget();
        }
      }
      if (erlangDebugTarget == null) {
        ErlLogger.debug("no debug target found for " + selection);
        return;
      }
      final ILaunchConfiguration launchConfiguration =
          erlangDebugTarget.getLaunch().getLaunchConfiguration();
      setViewerInput(launchConfiguration);
      try {
        final EnumSet<ErlDebugFlags> debugFlags =
            ErlDebugFlags.makeSet(
                launchConfiguration.getAttribute(
                    ErlRuntimeAttributes.DEBUG_FLAGS,
                    ErlDebugFlags.getFlag(ErlDebugFlags.DEFAULT_DEBUG_FLAGS)));
        distributed = debugFlags.contains(ErlDebugFlags.DISTRIBUTED_DEBUG);
      } catch (final CoreException e1) {
        distributed = false;
      }
    }
    listViewer.refresh();
    showViewer();

    // updateAction(VARIABLES_FIND_ELEMENT_ACTION);
    // updateAction(FIND_ACTION);
  }
示例#17
0
  private Process startRuntimeProcess(final RuntimeData rtData) {
    final String[] cmds = rtData.getCmdLine();
    final File workingDirectory = new File(rtData.getWorkingDir());

    try {
      ErlLogger.debug(
          "START node :> " + Arrays.toString(cmds) + " *** " + workingDirectory.getCanonicalPath());
    } catch (final IOException e1) {
      ErlLogger.error("START ERROR node :> " + e1.getMessage());
    }

    final ProcessBuilder builder = new ProcessBuilder(cmds);
    builder.directory(workingDirectory);
    setEnvironment(rtData, builder);
    try {
      final Process aProcess = builder.start();
      return aProcess;
    } catch (final IOException e) {
      ErlLogger.error("Could not create runtime: %s", Arrays.toString(cmds));
      ErlLogger.error(e);
      return null;
    }
  }
 private Template indentTemplatePattern(final Template template, final boolean indentFrom0) {
   String pattern = template.getPattern();
   final String whiteSpacePrefix = indentFrom0 ? "" : getWhiteSpacePrefix();
   try {
     pattern = IndentAction.indentLines(0, 0, pattern, true, whiteSpacePrefix);
   } catch (final RpcException e) {
     ErlLogger.error(e);
   }
   return new Template(
       template.getName(),
       template.getDescription(),
       template.getContextTypeId(),
       pattern,
       template.isAutoInsertable());
 }
示例#19
0
 private String getFeatureVersionImpl() {
   String version = "?";
   try {
     final IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
     if (providers != null) {
       version = findErlideFeatureVersion(providers);
     } else {
       ErlLogger.debug("***: no bundle group providers");
     }
   } catch (final Throwable e) {
     // ignore
   }
   final Version coreVersion = getBundle().getVersion();
   version = version + " (core=" + coreVersion.toString() + ")";
   return version;
 }
  public void interpretOrDeinterpret(final IErlModule module, final boolean checked) {
    if (erlangDebugTarget == null) {
      ErlLogger.warn("erlangDebugTarget is null ?!?!");
      return;
    }
    final String moduleWoExtension = module.getModuleName();
    final IProject project =
        ErlangEngine.getInstance().getModelUtilService().getProject(module).getWorkspaceProject();
    final boolean interpret = checked;

    if (erlangDebugTarget.getInterpretedModules().contains(moduleWoExtension) != interpret) {
      // FIXME this isn't correct!!!
      erlangDebugTarget.interpret(project, moduleWoExtension, distributed, interpret);
    }
    addRemove(module, checked);
  }
 private String getWhiteSpacePrefix() {
   final int start = getStart();
   final IDocument document = getDocument();
   int line;
   try {
     line = document.getLineOfOffset(start);
     final int lineStart = document.getLineOffset(line);
     for (int i = 0; lineStart + i <= start; ++i) {
       final char c = document.getChar(lineStart + i);
       if (c != ' ' && c != '\t') {
         return document.get(lineStart, i);
       }
     }
   } catch (final BadLocationException e) {
     ErlLogger.error(e);
   }
   return "";
 }
 @Override
 public void handleDebugEvents(final DebugEvent[] events) {
   boolean changed = false;
   for (final DebugEvent debugEvent : events) {
     if (debugEvent.getKind() == DebugEvent.MODEL_SPECIFIC
         && debugEvent.getDetail() == ErlangDebugTarget.INTERPRETED_MODULES_CHANGED) {
       changed = true;
       break;
     }
   }
   if (changed) {
     if (erlangDebugTarget == null) {
       ErlLogger.warn("erlangDebugTarget is null ?!?!");
       return;
     }
     final Set<String> interpret = erlangDebugTarget.getInterpretedModules();
     contentProvider.setModules(interpret);
     refreshList();
   }
 }
示例#23
0
 private static IFile resolveFile(final IFile file) {
   IFile result = file;
   if (file.getResourceAttributes().isSymbolicLink()) {
     try {
       final File f = new File(file.getLocation().toString());
       final IFileInfo info = EFS.getFileSystem(EFS.SCHEME_FILE).fromLocalFile(f).fetchInfo();
       final String target = info.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET);
       if (target != null) {
         // FIXME this is wrong in the general case
         // find the file in the externals!
         result = (IFile) file.getParent().findMember(target);
         if (result == null) {
           result = file;
         }
       }
     } catch (final Exception e) {
       ErlLogger.warn(e);
     }
   }
   return result;
 }
示例#24
0
  protected void indentAfterNewLine(final IDocument d, final DocumentCommand c)
      throws BadLocationException {
    final int offset = c.offset;
    String txt = null;
    editor.reconcileNow();
    final IErlElement element = editor.getElementAt(offset, false);
    final IErlMember member = (IErlMember) element;
    if (member != null) {
      final int start = member.getSourceRange().getOffset();
      if (offset >= start) {
        txt = d.get(start, offset - start);
      }
    }
    if (txt == null) {
      txt = "";
    }
    final int lineN = d.getLineOfOffset(offset);
    final int lineOffset = d.getLineOffset(lineN);
    final int lineLength = d.getLineLength(lineN);
    final String oldLine = d.get(offset, lineLength + lineOffset - offset);
    try {
      final IRpcSite b = BackendCore.getBackendManager().getIdeBackend().getRpcSite();
      final int tabw = getTabWidthFromPreferences();

      final Map<String, String> prefs = new TreeMap<String, String>();
      IndentationPreferencePage.addKeysAndPrefs(prefs);
      SmartTypingPreferencePage.addAutoNLKeysAndPrefs(prefs);
      final boolean useTabs = getUseTabsFromPreferences();
      final IndentResult res =
          ErlideIndent.indentLine(b, oldLine, txt, c.text, tabw, useTabs, prefs);

      if (res.isAddNewLine()) {
        c.text += "\n";
      }
      c.text += res.getText();
      c.length += res.getRemoveNext();
    } catch (final Exception e) {
      ErlLogger.warn(e);
    }
  }
 public static String loadPreviewContentFromFile(final Class<?> clazz, final String filename) {
   String line;
   final String separator = System.getProperty("line.separator"); // $NON-NLS-1$
   final StringBuilder buffer = new StringBuilder(512);
   BufferedReader reader = null;
   try {
     reader = new BufferedReader(new InputStreamReader(clazz.getResourceAsStream(filename)));
     while ((line = reader.readLine()) != null) {
       buffer.append(line);
       buffer.append(separator);
     }
   } catch (final IOException io) {
     ErlLogger.error(io);
   } finally {
     if (reader != null) {
       try {
         reader.close();
       } catch (final IOException e) {
       }
     }
   }
   return buffer.toString();
 }
  @Override
  public Object execute(final ExecutionEvent event) throws ExecutionException {
    final String actionId = event.getCommand().getId();
    PlatformUI.getWorkbench()
        .getActiveWorkbenchWindow()
        .getActivePage()
        .getActiveEditor()
        .setFocus();
    try {
      GlobalParameters.setSelection(
          PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection());
    } catch (final WranglerException e1) {
      MessageDialog.openError(
          PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
          "Error",
          e1.getMessage());
      return null;
    }
    try {
      final File tmpFile = File.createTempFile("wrangler_graph_", ".dot");
      tmpFile.deleteOnExit();

      final IErlSelection wranglerSelection = GlobalParameters.getWranglerSelection();

      if (actionId.equals("org.erlide.wrangler.refactoring.codeinspection.cyclicdependencies")) {
        final Boolean answer =
            MessageDialog.openQuestion(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                "Labels",
                "Label edges with function names called?");
        runInspection(
            "Cyclic module dependency",
            CYCLYC_VIEW_ID,
            "There is no cyclic dependent modules in the project!",
            tmpFile,
            "cyclic_dependent_modules",
            "ssx",
            tmpFile.getAbsolutePath(),
            wranglerSelection.getSearchPath(),
            new OtpErlangBoolean(answer));
      } else if (actionId.equals(
          "org.erlide.wrangler.refactoring.codeinspection.generatefunctioncallgraph")) {
        runInspection(
            "Function callgraph",
            FUNCTION_CALL_GRAPH_VIEW_ID,
            "There is no dependent functions in the module!",
            tmpFile,
            "gen_function_callgraph",
            "sss",
            tmpFile.getAbsolutePath(),
            wranglerSelection.getFilePath(),
            wranglerSelection.getSearchPath());

      } else if (actionId.equals(
          "org.erlide.wrangler.refactoring.codeinspection.generatemodulegraph")) {
        final Boolean answer =
            MessageDialog.openQuestion(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                "Labels",
                "Label edges with function names called?");
        runInspection(
            "Module dependency graph",
            MODULE_GRAPH_VIEW_ID,
            "There is no dependent modules in the project!",
            tmpFile,
            "gen_module_graph",
            "ssx",
            tmpFile.getAbsolutePath(),
            wranglerSelection.getSearchPath(),
            new OtpErlangBoolean(answer));

      } else if (actionId.equals(
          "org.erlide.wrangler.refactoring.codeinspection.improperdependecies")) {
        runInspection(
            "Improper module dependencies",
            IMPROPER_DEPENDECIES_VIEW_ID,
            "There is no improper module dependecies!",
            tmpFile,
            "improper_inter_module_calls",
            "ss",
            tmpFile.getAbsolutePath(),
            wranglerSelection.getSearchPath());
      }

    } catch (final Exception e) {
      ErlLogger.error(e);
    }
    return event;
  }
  @Override
  protected Control createDialogArea(final Composite parent) {

    final Composite composite = (Composite) super.createDialogArea(parent);
    final Tree functionClausesTree;

    final Label label = new Label(composite, SWT.WRAP);
    label.setText("Please select the function clause which against should fold!");
    final GridData minToksData =
        new GridData(
            GridData.GRAB_HORIZONTAL
                | GridData.GRAB_VERTICAL
                | GridData.HORIZONTAL_ALIGN_FILL
                | GridData.VERTICAL_ALIGN_CENTER);
    minToksData.widthHint =
        convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    label.setLayoutData(minToksData);
    label.setFont(parent.getFont());

    functionClausesTree = new Tree(composite, SWT.BORDER);
    final GridData treeData =
        new GridData(
            GridData.GRAB_HORIZONTAL
                | GridData.GRAB_VERTICAL
                | GridData.HORIZONTAL_ALIGN_FILL
                | GridData.VERTICAL_ALIGN_CENTER);
    treeData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    functionClausesTree.setLayoutData(treeData);

    try {
      final Collection<IErlModule> erlmodules =
          ErlangEngine.getInstance()
              .getModelUtilService()
              .getProject(GlobalParameters.getWranglerSelection().getErlElement())
              .getModules();

      for (final IErlModule m : erlmodules) {
        // must refresh the scanner!
        if (
        /* !m.isStructureKnown() */ true) {
          // FIXME: not permitted operation
          m.open(null);
        }

        final TreeItem moduleName = new TreeItem(functionClausesTree, 0);
        moduleName.setText(m.getModuleName());
        moduleName.setData(m);
        final List<IErlFunction> functions = filterFunctions(m.getChildren());
        for (final IErlFunction f : functions) {
          final TreeItem functionName = new TreeItem(moduleName, 0);
          functionName.setText(f.getNameWithArity());
          final List<IErlFunctionClause> clauses = filterClauses(f.getChildren());
          functionName.setData(f);
          for (final IErlFunctionClause c : clauses) {
            final TreeItem clauseName = new TreeItem(functionName, 0);
            clauseName.setText(String.valueOf(c.getName()));
            clauseName.setData(c);
          }
        }
      }

      // listen to treeitem selection
      functionClausesTree.addSelectionListener(
          new SelectionListener() {

            @Override
            public void widgetDefaultSelected(final SelectionEvent e) {}

            // if a function or a function clause is selected, then
            // highlight it
            // and store the selection
            @Override
            public void widgetSelected(final SelectionEvent e) {

              final TreeItem[] selectedItems = functionClausesTree.getSelection();

              if (selectedItems.length > 0) {
                final TreeItem treeItem = selectedItems[0];
                final Object data = treeItem.getData();
                if (data instanceof IErlFunctionClause) {
                  // enable the ok button
                  okButton.setEnabled(true);

                  // highlight
                  WranglerUtils.highlightSelection((IErlFunctionClause) data);

                  // store
                  functionClause = (IErlFunctionClause) data;
                } else {
                  okButton.setEnabled(false);
                }
              }
            }
          });
    } catch (final ErlModelException e) {
      ErlLogger.error(e);
    }

    applyDialogFont(composite);
    return composite;
  }
示例#28
0
 public ErtsProcess(
     final ILaunch launch, final Process process, final String nodeName, final String workingDir) {
   super(launch, process, nodeName, null);
   ErlLogger.debug("# create ErtsProcess: " + nodeName);
 }
示例#29
0
 public static void debug(final String message) {
   if (getDefault().isDebugging()) {
     ErlLogger.debug(message);
   }
 }