@SuppressWarnings("deprecation")
  private void launch(IContainer basecon, String mode) {
    if (basecon == null) {
      return;
    }

    IContainer basedir = findPomXmlBasedir(basecon);

    ILaunchConfiguration launchConfiguration = getLaunchConfiguration(basedir, mode);
    if (launchConfiguration == null) {
      return;
    }

    boolean openDialog = showDialog;
    if (!openDialog) {
      try {
        // if no goals specified
        String goals =
            launchConfiguration.getAttribute(MavenLaunchConstants.ATTR_GOALS, (String) null);
        openDialog = goals == null || goals.trim().length() == 0;
      } catch (CoreException ex) {
        log.error(ex.getMessage(), ex);
      }
    }

    if (openDialog) {
      DebugUITools.saveBeforeLaunch();
      // ILaunchGroup group = DebugUITools.getLaunchGroup(launchConfiguration, mode);
      DebugUITools.openLaunchConfigurationDialog(
          getShell(), launchConfiguration, MavenLaunchMainTab.ID_EXTERNAL_TOOLS_LAUNCH_GROUP, null);
    } else {
      DebugUITools.launch(launchConfiguration, mode);
    }
  }
  @Override
  public void createPartControl(Composite parent) {

    // create viewer
    graphViewer = new VisualisationGraphViewer(parent, SWT.NONE);
    graphViewer.setLayoutAlgorithm(layout.getDefault());
    graphViewer.setLabelProvider(labelprovider);
    graphViewer.setContentProvider(contentprovider);
    if (VisualisationSettings.filterPrimitiveTypes) {
      graphViewer.addFilter(VisualisationSettings.primitiveTypeFilter);
    }
    if (VisualisationSettings.filterUndefinedValues) {
      graphViewer.addFilter(VisualisationSettings.undefinedValuesFilter);
    }
    graphViewer.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);
    // TODO why is this needed for selection synchronizing?
    graphViewer.setUseHashlookup(false);

    initializeActions();
    createToolbar();
    createMenu();

    // double click on nodes
    graphViewer
        .getGraphControl()
        .addMouseListener(
            new MouseAdapter() {

              @Override
              public void mouseDoubleClick(MouseEvent e) {
                toggleOpen.run();
              }
            });

    // graphViewer.getGraphControl().addKeyListener(new KeyAdapter() {
    //
    // @Override
    // public void keyReleased(KeyEvent e) {
    // if (e.keyCode == SWT.DEL || e.character == 8) {
    // hideNode.run();
    // }
    //
    // }
    //
    // });

    // listener for debug context
    listener = new DebugContextListener(this);
    DebugUITools.getDebugContextManager().addDebugContextListener(listener);

    // Check if there is an already started debug context
    IAdaptable dc = DebugUITools.getDebugContext();
    if (dc != null) {
      Object o = dc.getAdapter(IStackFrame.class);
      if (o instanceof IStackFrame) setStackFrame((IStackFrame) o);
    }

    getSite().setSelectionProvider(graphViewer);
    selectionSynchronizer = new VariableSelectionSynchronizer(getSite());
  }
 protected void launch(IFile file, String mode) {
   final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
   final ILaunchConfigurationType configType =
       launchManager.getLaunchConfigurationType(getConfigType());
   ILaunchConfiguration launchConfig = findLaunchConfiguration(configType, file);
   if (launchConfig != null) {
     DebugUITools.launch(launchConfig, mode);
   } else {
     ILaunchConfiguration launchConfiguration = createNewLaunchConfiguration(file);
     DebugUITools.launch(launchConfiguration, mode);
   }
 }
Ejemplo n.º 4
0
    /*
     * (non-Javadoc)
     * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime .IProgressMonitor)
     */
    public IStatus runInUIThread(IProgressMonitor monitor) {
      ISourceLookupResult result = null;
      IWorkbenchPage page = null;
      synchronized (this) {
        result = fResult;
        page = fPage;
        setDisplayInfo(null, null);
      }
      if (!monitor.isCanceled() && result != null && page != null) {
        if (result.getEditorInput() == null) {
          MessageDialog.openError(
              page.getWorkbenchWindow().getShell(),
              Messages.getString("SourceDisplayAdapter.Error_Opening_Source"), // $NON-NLS-1$
              MessageFormat.format(
                  Messages.getString("SourceDisplayAdapter.Source_Not_Located"), // $NON-NLS-1$
                  JSDebugUIPlugin.getDefault()
                      .getModelPresentation()
                      .getText(result.getArtifact())));
          return Status.CANCEL_STATUS;
        }
        // Workaround for http://support.aptana.com/asap/browse/STU-3818
        if (result.getArtifact() instanceof ISourceLink) {
          boolean oldReuseValue =
              DebugUIPlugin.getDefault()
                  .getPreferenceStore()
                  .getBoolean(IDebugUIConstants.PREF_REUSE_EDITOR);
          DebugUIPlugin.getDefault()
              .getPreferenceStore()
              .setValue(IDebugUIConstants.PREF_REUSE_EDITOR, false);
          DebugUITools.displaySource(result, page);
          DebugUIPlugin.getDefault()
              .getPreferenceStore()
              .setValue(IDebugUIConstants.PREF_REUSE_EDITOR, oldReuseValue);
        } else {
          DebugUITools.displaySource(result, page);
        }
        if (result.getArtifact() instanceof IJSScriptElement) {
          int lineNumber = ((IJSScriptElement) result.getArtifact()).getBaseLine();
          IEditorInput editorInput = result.getEditorInput();
          if (editorInput != null && lineNumber > 0) {
            IEditorPart editorPart = SourceDisplayUtil.findEditor(editorInput);
            if (editorPart != null) {
              SourceDisplayUtil.revealLineInEditor(editorPart, lineNumber);
            }
          }
        }
      }

      return Status.OK_STATUS;
    }
 /**
  * Returns the launch to which the current selection belongs.
  *
  * @return the launch to which the current selection belongs.
  */
 protected ILaunch getCurrentLaunch() {
   IAdaptable context = DebugUITools.getDebugContext();
   if (context != null) {
     return context.getAdapter(ILaunch.class);
   }
   return null;
 }
Ejemplo n.º 6
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.ui.console.IConsolePageParticipant#init(IPageBookViewPage,
   * IConsole)
   */
  public void init(final IPageBookViewPage page, final IConsole console) {
    fPage = page;
    fConsole = (ErlangConsole) console;

    fRemoveTerminated = new ConsoleRemoveLaunchAction(fConsole.getBackend());
    fRemoveAllTerminated = new ConsoleRemoveAllTerminatedAction();
    fTerminate = new ConsoleTerminateAction(fConsole);
    fStdOut = new ShowStandardOutAction();

    fView = (IConsoleView) fPage.getSite().getPage().findView(IConsoleConstants.ID_CONSOLE_VIEW);

    DebugPlugin.getDefault().addDebugEventListener(this);
    DebugUITools.getDebugContextManager()
        .getContextService(fPage.getSite().getWorkbenchWindow())
        .addDebugContextListener(this);

    // contribute to toolbar
    IActionBars actionBars = fPage.getSite().getActionBars();
    configureToolBar(actionBars.getToolBarManager());

    // create handler and submissions for EOF
    fEOFHandler = new EOFHandler();

    // set global ref, used by the SendToConsole action
    // FIXME global is bad, use project's page (keyed by backend?)
    ErlideUIPlugin.getDefault().setConsolePage((ErlangConsolePage) fPage);
  }
  @Override
  protected Viewer createViewer(final Composite parent) {
    listViewer = new ListViewer(parent, SWT.BORDER);
    listViewer.setLabelProvider(new ModuleItemLabelProvider());
    contentProvider = new InterpretedModuleListContentProvider();
    listViewer.setContentProvider(contentProvider);
    getSite().setSelectionProvider(listViewer);
    listViewer.addDoubleClickListener(
        new IDoubleClickListener() {

          @Override
          public void doubleClick(final DoubleClickEvent event) {
            final IStructuredSelection ss = (IStructuredSelection) event.getSelection();
            for (final Object o : ss.toArray()) {
              try {
                EditorUtility.openInEditor(o);
              } catch (final PartInitException e) {
                ErlLogger.warn(e);
              }
            }
          }
        });
    DebugUITools.getDebugContextManager().addDebugContextListener(this);
    DebugPlugin.getDefault().addDebugEventListener(this);
    return listViewer;
  }
Ejemplo n.º 8
0
 public SimulationView() {
   DebugUITools.getDebugContextManager().addDebugContextListener(this);
   DebugPlugin.getDefault().addDebugEventListener(this);
   kit = new FormToolkit(Display.getDefault());
   font = new Font(Display.getDefault(), new FontData("Courier", 10, SWT.BOLD));
   clockUpdater = new ClockUpdater();
 }
Ejemplo n.º 9
0
  public ILaunchConfiguration getSelectedLaunchConfiguration() {
    if (!fLaunchConfigButton.getSelection()) return null;

    String configName = fLaunchConfigCombo.getText();
    try {
      ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
      ILaunchConfigurationType type =
          manager.getLaunchConfigurationType(EclipseLaunchShortcut.CONFIGURATION_TYPE);
      ILaunchConfigurationType type2 =
          manager.getLaunchConfigurationType(IPDELauncherConstants.OSGI_CONFIGURATION_TYPE);
      ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
      ILaunchConfiguration[] configs2 = manager.getLaunchConfigurations(type2);
      ILaunchConfiguration[] configurations =
          new ILaunchConfiguration[configs.length + configs2.length];
      System.arraycopy(configs, 0, configurations, 0, configs.length);
      System.arraycopy(configs2, 0, configurations, configs.length, configs2.length);
      for (int i = 0; i < configurations.length; i++) {
        if (configurations[i].getName().equals(configName)
            && !DebugUITools.isPrivate(configurations[i])) return configurations[i];
      }
    } catch (CoreException e) {
      PDEPlugin.logException(e);
    }
    return null;
  }
Ejemplo n.º 10
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ui.console.IConsolePageParticipant#dispose()
  */
 public void dispose() {
   DebugUITools.getDebugContextManager()
       .getContextService(fPage.getSite().getWorkbenchWindow())
       .removeDebugContextListener(this);
   DebugPlugin.getDefault().removeDebugEventListener(this);
   if (fRemoveTerminated != null) {
     fRemoveTerminated.dispose();
     fRemoveTerminated = null;
   }
   if (fRemoveAllTerminated != null) {
     fRemoveAllTerminated.dispose();
     fRemoveAllTerminated = null;
   }
   if (fTerminate != null) {
     fTerminate.dispose();
     fTerminate = null;
   }
   if (fStdOut != null) {
     fStdOut.dispose();
     fStdOut = null;
   }
   fConsole = null;
   if (ErlideUIPlugin.getDefault().getConsolePage() == fPage) {
     ErlideUIPlugin.getDefault().setConsolePage(null);
   }
 }
  /* (non-Javadoc)
   * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
   */
  public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection)
      throws CoreException {
    IEditorPart editorPart = (IEditorPart) part;
    IEditorInput editorInput = editorPart.getEditorInput();
    IResource resource = null;
    if (editorInput instanceof IFileEditorInput) {
      resource = ((IFileEditorInput) editorInput).getFile();
    }
    if (resource == null) {
      Display.getCurrent().beep();
      return;
    }

    ITextSelection textSelection = (ITextSelection) selection;
    int lineNumber = textSelection.getStartLine();
    IBreakpoint[] breakpoints =
        DebugPlugin.getDefault()
            .getBreakpointManager()
            .getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL);
    for (int i = 0; i < breakpoints.length; i++) {
      IBreakpoint breakpoint = breakpoints[i];
      if (resource.equals(breakpoint.getMarker().getResource())) {
        if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber + 1)) {
          DebugUITools.deleteBreakpoints(
              new IBreakpoint[] {breakpoint}, part.getSite().getShell(), null);
          return;
        }
      }
    }
    // create line breakpoint (doc line numbers start at 0)
    new AntLineBreakpoint(resource, lineNumber + 1);
  }
Ejemplo n.º 12
0
 public static String trimDisplayResult(String result) {
   int max = DebugUITools.getPreferenceStore().getInt(IDebugUIConstants.PREF_MAX_DETAIL_LENGTH);
   if (max > 0 && result.length() > max) {
     result = result.substring(0, max) + "..."; // $NON-NLS-1$
   }
   return result;
 }
Ejemplo n.º 13
0
  protected String computeName() {
    String label = fLabel;

    ILaunchConfiguration config = fLaunch.getLaunchConfiguration();
    if (config != null && !DebugUITools.isPrivate(config)) {
      String type = null;
      try {
        type = config.getType().getName();
      } catch (CoreException e) {
      }
      StringBuilder buffer = new StringBuilder();
      buffer.append(config.getName());
      if (type != null) {
        buffer.append(" ["); // $NON-NLS-1$
        buffer.append(type);
        buffer.append("] "); // $NON-NLS-1$
      }
      buffer.append(label);
      label = buffer.toString();
    }

    if (fLaunch.isTerminated()) {
      return ConsoleMessages.ConsoleMessages_console_terminated + label;
    }

    return label;
  }
Ejemplo n.º 14
0
 private ScriptStackFrame getFrame() {
   IAdaptable adaptable = DebugUITools.getDebugContext();
   if (adaptable != null) {
     return (ScriptStackFrame) adaptable.getAdapter(ScriptStackFrame.class);
   }
   return null;
 }
Ejemplo n.º 15
0
 @Override
 public void dispose() {
   clockUpdater.setTerminated(true);
   super.dispose();
   DebugUITools.getDebugContextManager().removeDebugContextListener(this);
   DebugPlugin.getDefault().removeDebugEventListener(this);
   font.dispose();
 }
Ejemplo n.º 16
0
 protected void becomesVisible() {
   super.becomesVisible();
   ISelection selection =
       DebugUITools.getDebugContextManager()
           .getContextService(getSite().getWorkbenchWindow())
           .getActiveContext();
   contextActivated(selection);
 }
Ejemplo n.º 17
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener
  * #contextEvent
  * (org.eclipse.debug.internal.ui.contexts.provisional.DebugContextEvent)
  */
 public void debugContextChanged(final DebugContextEvent event) {
   if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) {
     IProcess process = getProcess();
     if (fView != null && process != null && process.equals(DebugUITools.getCurrentProcess())) {
       fView.display(fConsole);
     }
   }
 }
Ejemplo n.º 18
0
 /**
  * Returns the currently active stack frame, or <code>null</code> if none.
  *
  * @return the currently active stack frame, or <code>null</code>
  */
 protected IJavaStackFrame getStackFrame() {
   IAdaptable debugContext = DebugUITools.getDebugContext();
   IJavaStackFrame frame = null;
   if (debugContext != null) {
     frame = (IJavaStackFrame) debugContext.getAdapter(IJavaStackFrame.class);
   }
   return frame;
 }
 /** Add any overlays to the image as specified in the flags. */
 protected void drawOverlays() {
   int flags = getFlags();
   ImageData data = null;
   if ((flags & ERROR) != 0) {
     data = DebugUITools.getImage(IDebugUIConstants.IMG_OVR_ERROR).getImageData();
     drawImage(data, 0, 0);
   }
 }
 @Override
 public void dispose() {
   super.dispose();
   DebugUITools.getDebugContextManager()
       .getContextService(getSite().getWorkbenchWindow())
       .removeDebugContextListener(this);
   fTerminalControl.disposeTerminal();
   fMenuManager.dispose();
   GdbUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener);
 }
Ejemplo n.º 21
0
 private ISteppingModeTarget getSteppingModeTarget(IWorkbenchWindow window) {
   ISelection selection =
       DebugUITools.getDebugContextManager().getContextService(window).getActiveContext();
   if (selection instanceof IStructuredSelection) {
     Object element = ((IStructuredSelection) selection).getFirstElement();
     if (element instanceof IAdaptable)
       return ((IAdaptable) element).getAdapter(ISteppingModeTarget.class);
   }
   return null;
 }
 @Override
 public void dispose() {
   super.dispose();
   if (listener != null)
     DebugUITools.getDebugContextManager().removeDebugContextListener(listener);
   /* getState().removeListener(stateListener); */
   if (selectionSynchronizer != null) {
     selectionSynchronizer.dispose();
   }
 }
 /**
  * Finds the currently selected context in the UI.
  *
  * @return the current debug context
  */
 protected IDebugElement getContext() {
   IAdaptable object = DebugUITools.getDebugContext();
   IDebugElement context = null;
   if (object instanceof IDebugElement) {
     context = (IDebugElement) object;
   } else if (object instanceof ILaunch) {
     context = ((ILaunch) object).getDebugTarget();
   }
   return context;
 }
  /**
   * Launch a config for the specified project.
   *
   * @param project The project to launch
   * @param mode The launch mode ("debug", "run" or "profile")
   */
  private void launch(IProject project, String mode) {
    // get an existing or new launch configuration
    ILaunchConfiguration config =
        AndroidLaunchController.getLaunchConfig(
            project, LaunchConfigDelegate.ANDROID_LAUNCH_TYPE_ID);

    if (config != null) {
      // and launch!
      DebugUITools.launch(config, mode);
    }
  }
Ejemplo n.º 25
0
 private String[] getLaunchConfigurations() {
   ArrayList list = new ArrayList();
   try {
     ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
     ILaunchConfigurationType type =
         manager.getLaunchConfigurationType(EclipseLaunchShortcut.CONFIGURATION_TYPE);
     ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
     for (int i = 0; i < configs.length; i++) {
       if (!DebugUITools.isPrivate(configs[i])) list.add(configs[i].getName());
     }
     // add osgi launch configs to the list
     type = manager.getLaunchConfigurationType(IPDELauncherConstants.OSGI_CONFIGURATION_TYPE);
     configs = manager.getLaunchConfigurations(type);
     for (int i = 0; i < configs.length; i++) {
       if (!DebugUITools.isPrivate(configs[i])) list.add(configs[i].getName());
     }
   } catch (CoreException e) {
     PDEPlugin.logException(e);
   }
   return (String[]) list.toArray(new String[list.size()]);
 }
  /**
   * @return the currently selected / suspended frame. If the console is passed, it will only return
   *     a frame that matches the passed console. If no selected / suspended frame is found or the
   *     console doesn't match, null is returned.
   */
  protected static PyStackFrame getCurrentSuspendedPyStackFrame(IConsole console) {
    IAdaptable context = DebugUITools.getDebugContext();

    if (context instanceof PyStackFrame) {
      PyStackFrame stackFrame = (PyStackFrame) context;
      if (!stackFrame.isTerminated() && stackFrame.isSuspended()) {
        if (console != null) {
          // If a console is passed, we must check if it matches the console from the selected
          // frame.
          AbstractDebugTarget target =
              (AbstractDebugTarget) stackFrame.getAdapter(IDebugTarget.class);
          if (DebugUITools.getConsole(target.getProcess()) != console) {
            return null;
          }
        }

        return stackFrame;
      }
    }
    return null;
  }
Ejemplo n.º 27
0
  @Override
  public void init(IViewPart view) {
    fView = view;

    // Get the current selection from the DebugView so we can determine if we want this menu action
    // to be live or not.
    IDebugContextService debugContextService =
        DebugUITools.getDebugContextManager()
            .getContextService(view.getSite().getWorkbenchWindow());
    debugContextService.addPostDebugContextListener(this);
    fDebugContext = debugContextService.getActiveContext();
  }
Ejemplo n.º 28
0
  /** Create a new CreateLaunchAction. */
  public CreateLaunchAction(
      ManageLaunchesDialog launchConfigurationDialog, ILaunchConfigurationType configType) {
    super("Create a new " + configType.getName());

    this.launchConfigurationDialog = launchConfigurationDialog;
    this.configType = configType;

    setImageDescriptor(
        new DecorationOverlayIcon(
            SDBGDebugUIPlugin.getImage(DebugUITools.getDefaultImageDescriptor(configType)),
            SDBGDebugUIPlugin.getImageDescriptor("ovr16/new.png"),
            IDecoration.TOP_RIGHT));
  }
Ejemplo n.º 29
0
 void launch(IPath targetPath, String mode) {
   targetPath = targetPath.makeRelative();
   try {
     ILaunchConfiguration config = findLaunchConfig(targetPath);
     if (config == null) {
       ILaunchConfigurationWorkingCopy wc = createConfiguration(targetPath);
       config = wc.doSave();
     }
     DebugUITools.launch(config, mode);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 /**
  * Creates a new watch expression from a string using the default expression manager.
  *
  * @param exp the string to use to create the expression
  */
 private IExpression createExpression(String exp) {
   IWatchExpression expression =
       DebugPlugin.getDefault().getExpressionManager().newWatchExpression(exp);
   IAdaptable object = DebugUITools.getPartDebugContext(fSite);
   IDebugElement context = null;
   if (object instanceof IDebugElement) {
     context = (IDebugElement) object;
   } else if (object instanceof ILaunch) {
     context = ((ILaunch) object).getDebugTarget();
   }
   expression.setExpressionContext(context);
   return expression;
 }