@Override
        public void changeEvent(DebuggerContextImpl newContext, DebuggerSession.Event event) {

          final DebuggerSession session = newContext.getDebuggerSession();
          if (event == DebuggerSession.Event.PAUSE
              && myDebuggerStateManager.myDebuggerSession != session) {
            // if paused in non-active session; switch current session
            myDebuggerStateManager.setState(
                newContext,
                session != null ? session.getState() : DebuggerSession.State.DISPOSED,
                event,
                null);
            return;
          }

          if (myDebuggerStateManager.myDebuggerSession == session) {
            myDebuggerStateManager.fireStateChanged(newContext, event);
          }
          if (event == DebuggerSession.Event.ATTACHED) {
            myDispatcher.getMulticaster().sessionAttached(session);
          } else if (event == DebuggerSession.Event.DETACHED) {
            myDispatcher.getMulticaster().sessionDetached(session);
          } else if (event == DebuggerSession.Event.DISPOSE) {
            dispose(session);
            if (myDebuggerStateManager.myDebuggerSession == session) {
              myDebuggerStateManager.setState(
                  DebuggerContextImpl.EMPTY_CONTEXT,
                  DebuggerSession.State.DISPOSED,
                  DebuggerSession.Event.DISPOSE,
                  null);
            }
          }
        }
  private LocalTask doActivate(Task origin, boolean explicitly) {
    final LocalTaskImpl task =
        origin instanceof LocalTaskImpl ? (LocalTaskImpl) origin : new LocalTaskImpl(origin);
    if (explicitly) {
      task.setUpdated(new Date());
    }
    myActiveTask.setActive(false);
    task.setActive(true);
    addTask(task);
    if (task.isIssue()) {
      StartupManager.getInstance(myProject)
          .runWhenProjectIsInitialized(
              new Runnable() {
                public void run() {
                  ProgressManager.getInstance()
                      .run(
                          new com.intellij.openapi.progress.Task.Backgroundable(
                              myProject, "Updating " + task.getId()) {

                            public void run(@NotNull ProgressIndicator indicator) {
                              updateIssue(task.getId());
                            }
                          });
                }
              });
    }
    LocalTask oldActiveTask = myActiveTask;
    boolean isChanged = !task.equals(oldActiveTask);
    myActiveTask = task;
    if (isChanged) {
      myDispatcher.getMulticaster().taskDeactivated(oldActiveTask);
      myDispatcher.getMulticaster().taskActivated(task);
    }
    return task;
  }
Ejemplo n.º 3
0
 private void moveSelectedRows(int increment) {
   if (increment == 0) {
     return;
   }
   if (myEntryTable.isEditing()) {
     myEntryTable.getCellEditor().stopCellEditing();
   }
   final ListSelectionModel selectionModel = myEntryTable.getSelectionModel();
   for (int row = increment < 0 ? 0 : myModel.getRowCount() - 1;
       increment < 0 ? row < myModel.getRowCount() : row >= 0;
       row += increment < 0 ? +1 : -1) {
     if (selectionModel.isSelectedIndex(row)) {
       final int newRow = moveRow(row, increment);
       selectionModel.removeSelectionInterval(row, row);
       selectionModel.addSelectionInterval(newRow, newRow);
     }
   }
   myModel.fireTableRowsUpdated(0, myModel.getRowCount() - 1);
   Rectangle cellRect = myEntryTable.getCellRect(selectionModel.getMinSelectionIndex(), 0, true);
   if (cellRect != null) {
     myEntryTable.scrollRectToVisible(cellRect);
   }
   myEntryTable.repaint();
   myListeners.getMulticaster().entryMoved();
 }
  public final IdeFrameImpl allocateFrame(final Project project) {
    LOG.assertTrue(!myProject2Frame.containsKey(project));

    final IdeFrameImpl frame;
    if (myProject2Frame.containsKey(null)) {
      frame = myProject2Frame.get(null);
      myProject2Frame.remove(null);
      myProject2Frame.put(project, frame);
      frame.setProject(project);
    } else {
      frame =
          new IdeFrameImpl(
              (ApplicationInfoEx) ApplicationInfo.getInstance(),
              ActionManagerEx.getInstanceEx(),
              UISettings.getInstance(),
              DataManager.getInstance(),
              ApplicationManager.getApplication());
      final Rectangle bounds = ProjectFrameBounds.getInstance(project).getBounds();
      if (bounds != null) {
        frame.setBounds(bounds);
      } else if (myFrameBounds != null) {
        frame.setBounds(myFrameBounds);
      }
      frame.setExtendedState(myFrameExtendedState);
      frame.setProject(project);
      myProject2Frame.put(project, frame);
      frame.setVisible(true);
    }

    frame.addWindowListener(myActivationListener);

    myEventDispatcher.getMulticaster().frameCreated(frame);

    return frame;
  }
  private void refreshPointers(@NotNull final Module module) {
    // todo[nik] refresh only pointers related to renamed module/facet?
    List<Pair<FacetPointerImpl, String>> changed = new ArrayList<Pair<FacetPointerImpl, String>>();

    for (FacetPointerImpl pointer : myPointers.values()) {
      final String oldId = pointer.getId();
      pointer.refresh();
      if (!oldId.equals(pointer.getId())) {
        changed.add(Pair.create(pointer, oldId));
      }
    }

    for (Pair<FacetPointerImpl, String> pair : changed) {
      FacetPointerImpl pointer = pair.getFirst();
      final Facet facet = pointer.getFacet();
      Class facetClass = facet != null ? facet.getClass() : Facet.class;
      while (facetClass != Object.class) {
        final EventDispatcher<FacetPointerListener> dispatcher = myDispatchers.get(facetClass);
        if (dispatcher != null) {
          //noinspection unchecked
          dispatcher.getMulticaster().pointerIdChanged(pointer, pair.getSecond());
        }
        facetClass = facetClass.getSuperclass();
      }
    }
  }
 private void dispose(DebuggerSession session) {
   ProcessHandler processHandler = session.getProcess().getProcessHandler();
   synchronized (mySessions) {
     DebuggerSession removed = mySessions.remove(processHandler);
     LOG.assertTrue(removed != null);
     myDispatcher.getMulticaster().sessionRemoved(session);
   }
 }
Ejemplo n.º 7
0
 /** Notifies all registered listeners that UI settings has been changed. */
 public void fireUISettingsChanged() {
   incModificationCount();
   myDispatcher.getMulticaster().uiSettingsChanged(this);
   ApplicationManager.getApplication()
       .getMessageBus()
       .syncPublisher(UISettingsListener.TOPIC)
       .uiSettingsChanged(this);
 }
 public void setDefaultManifestFileLocation(@NotNull String defaultManifestFileLocation) {
   _defaultManifestFileLocation = defaultManifestFileLocation;
   if (_defaultManifestFileLocation.equals("META-INF")) {
     // we specify full names, so to work with older projects, we have to convert this
     _defaultManifestFileLocation = "META-INF/MANIFEST.MF";
   }
   dispatcher.getMulticaster().projectSettingsChanged();
 }
Ejemplo n.º 9
0
 private void updateOrderEntriesInEditors() {
   if (getModule() != null) { // module with attached module libraries was deleted
     getPanel(); // init editor if needed
     for (final ModuleConfigurationEditor myEditor : myEditors) {
       myEditor.moduleStateChanged();
     }
     myEventDispatcher.getMulticaster().moduleStateChanged(getModifiableRootModelProxy());
   }
 }
 @Override
 public void removeTask(LocalTask task) {
   if (task.isDefault()) return;
   if (myActiveTask.equals(task)) {
     activateTask(myTasks.get(LocalTaskImpl.DEFAULT_TASK_ID), true);
   }
   myTasks.remove(task.getId());
   myDispatcher.getMulticaster().taskRemoved(task);
   myContextManager.removeContext(task);
 }
Ejemplo n.º 11
0
  public boolean tryToApplyActivationState(boolean active, Window window) {
    final Component frame = UIUtil.findUltimateParent(window);

    if (frame instanceof IdeFrame) {
      final IdeFrame ideFrame = (IdeFrame) frame;
      if (isActive() != active) {
        myActive = Boolean.valueOf(active);
        System.setProperty("idea.active", Boolean.valueOf(myActive).toString());
        if (active) {
          myDispatcher.getMulticaster().applicationActivated(ideFrame);
        } else {
          myDispatcher.getMulticaster().applicationDeactivated(ideFrame);
        }
        return true;
      }
    }

    return false;
  }
  public static void enterModal(@NotNull Object modalEntity) {
    LOG.assertTrue(isDispatchThread(), "enterModal() should be invoked in event-dispatch thread");

    if (LOG.isDebugEnabled()) {
      LOG.debug("enterModal:" + modalEntity);
    }

    ourModalityStateMulticaster.getMulticaster().beforeModalityStateChanged(true);

    ourModalEntities.add(modalEntity);
  }
Ejemplo n.º 13
0
 /**
  * Notify single line
  *
  * @param line a line to notify
  * @param outputType output type
  */
 private void notifyLine(final String line, final Key outputType) {
   String trimmed = trimLineSeparator(line);
   // if line ends with return, then it is a progress line, ignore it
   if (myVcs != null && !"\r".equals(line.substring(trimmed.length()))) {
     if (outputType == ProcessOutputTypes.STDOUT && !isStdoutSuppressed()) {
       myVcs.showMessages(trimmed);
     } else if (outputType == ProcessOutputTypes.STDERR && !isStderrSuppressed()) {
       myVcs.showErrorMessages(trimmed);
     }
   }
   myLineListeners.getMulticaster().onLineAvailable(trimmed, outputType);
 }
 // used in Fabrique
 public synchronized void addBreakpoint(@NotNull Breakpoint breakpoint) {
   myBreakpoints.put(breakpoint.myXBreakpoint, breakpoint);
   myBreakpointsListForIteration = null;
   breakpoint.updateUI();
   RequestManagerImpl.createRequests(breakpoint);
   myDispatcher.getMulticaster().breakpointsChanged();
   if (breakpoint instanceof MethodBreakpoint || breakpoint instanceof WildcardMethodBreakpoint) {
     XDebugSessionImpl.NOTIFICATION_GROUP
         .createNotification(
             "Method breakpoints may dramatically slow down debugging", MessageType.WARNING)
         .notify(myProject);
   }
 }
Ejemplo n.º 15
0
  public boolean updateDescription(boolean modified) {
    EditorColorsScheme scheme = myOptions.getSelectedScheme();

    if (modified
        && (ColorAndFontOptions.isReadOnly(scheme) || ColorSettingsUtil.isSharedScheme(scheme))) {
      showReadOnlyMessage(this, ColorSettingsUtil.isSharedScheme(scheme));
      return false;
    }

    myDispatcher.getMulticaster().fontChanged();

    return true;
  }
  public void initComponent() {
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
      myCacheRefreshTimer =
          UIUtil.createNamedTimer(
              "TaskManager refresh",
              myConfig.updateInterval * 60 * 1000,
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  if (myConfig.updateEnabled && !myUpdating) {
                    updateIssues(null);
                  }
                }
              });
      myCacheRefreshTimer.setInitialDelay(0);
      StartupManager.getInstance(myProject)
          .registerPostStartupActivity(
              new Runnable() {
                public void run() {
                  myCacheRefreshTimer.start();
                }
              });
    }

    // make sure that the default task is exist
    LocalTask defaultTask = findTask(LocalTaskImpl.DEFAULT_TASK_ID);
    if (defaultTask == null) {
      defaultTask = createDefaultTask();
      addTask(defaultTask);
    }

    // search for active task
    LocalTask activeTask = null;
    final List<LocalTask> tasks = getLocalTasks();
    Collections.sort(tasks, TASK_UPDATE_COMPARATOR);
    for (LocalTask task : tasks) {
      if (activeTask == null) {
        if (task.isActive()) {
          activeTask = task;
        }
      } else {
        task.setActive(false);
      }
    }
    if (activeTask == null) {
      activeTask = defaultTask;
    }

    myActiveTask = activeTask;
    doActivate(myActiveTask, false);
    myDispatcher.getMulticaster().taskActivated(myActiveTask);
  }
Ejemplo n.º 17
0
  public void start() {
    synchronized (myLock) {
      checkNotStarted();

      try {
        myProcess = myCommandLine.createProcess();
        if (LOG.isDebugEnabled()) {
          LOG.debug(myCommandLine.toString());
        }
        myHandler = new OSProcessHandler(myProcess, myCommandLine.getCommandLineString());
        startHandlingStreams();
      } catch (Throwable t) {
        myListeners.getMulticaster().startFailed(t);
      }
    }
  }
  private synchronized void onBreakpointRemoved(@Nullable final XBreakpoint xBreakpoint) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    if (xBreakpoint == null) {
      return;
    }

    Breakpoint breakpoint = myBreakpoints.remove(xBreakpoint);
    if (breakpoint != null) {
      // updateBreakpointRules(breakpoint);
      myBreakpointsListForIteration = null;
      // we delete breakpoints inside release, so gutter will not fire events to deleted breakpoints
      breakpoint.delete();

      RequestManagerImpl.deleteRequests(breakpoint);
      myDispatcher.getMulticaster().breakpointsChanged();
    }
  }
  public static void leaveModal(@NotNull Object modalEntity) {
    LOG.assertTrue(isDispatchThread(), "leaveModal() should be invoked in event-dispatch thread");

    if (LOG.isDebugEnabled()) {
      LOG.debug("leaveModal:" + modalEntity);
    }

    //noinspection StatementWithEmptyBody
    while (ourFlushQueueRunnable.runNextEvent()) ;

    ourModalityStateMulticaster.getMulticaster().beforeModalityStateChanged(false);

    boolean removed = ourModalEntities.remove(modalEntity);
    LOG.assertTrue(removed, modalEntity);
    cleanupQueueForModal(modalEntity);
    ourQueueSkipCount = 0;
    requestFlush();
  }
  public final void releaseFrame(final IdeFrameImpl frame) {

    myEventDispatcher.getMulticaster().beforeFrameReleased(frame);

    final Project project = frame.getProject();
    LOG.assertTrue(project != null);

    frame.removeWindowListener(myActivationListener);
    proceedDialogDisposalQueue(project);

    frame.setProject(null);
    frame.setTitle(null);
    frame.setFileTitle(null, null);

    myProject2Frame.remove(project);
    Disposer.dispose(frame.getStatusBar());
    frame.dispose();
  }
 private void fireWriteActionStarted(Class action) {
   myDispatcher.getMulticaster().writeActionStarted(action);
 }
 public void fireUpdate() {
   myEventDispatcher.getMulticaster().stateChanged(new ChangeEvent(this));
   update();
 }
 public void setCreateFrameworkInstanceModule(boolean selected) {
   _createFrameworkInstanceModule = selected;
   dispatcher.getMulticaster().projectSettingsChanged();
 }
 public void setFrameworkInstanceName(@Nullable String frameworkInstanceName) {
   _frameworkInstanceName = frameworkInstanceName;
   dispatcher.getMulticaster().projectSettingsChanged();
 }
Ejemplo n.º 25
0
 private void fireWriteActionFinished(Runnable action) {
   myDispatcher.getMulticaster().writeActionFinished(action);
 }
Ejemplo n.º 26
0
 private void fireBeforeWriteActionStart(Runnable action) {
   myDispatcher.getMulticaster().beforeWriteActionStart(action);
 }
Ejemplo n.º 27
0
 private void fireApplicationExiting() {
   myDispatcher.getMulticaster().applicationExiting();
 }
  @Override
  @Nullable
  public DebuggerSession attachVirtualMachine(@NotNull DebugEnvironment environment)
      throws ExecutionException {
    ApplicationManager.getApplication().assertIsDispatchThread();
    final DebugProcessEvents debugProcess = new DebugProcessEvents(myProject);
    debugProcess.addDebugProcessListener(
        new DebugProcessAdapter() {
          @Override
          public void processAttached(final DebugProcess process) {
            process.removeDebugProcessListener(this);
            for (Function<DebugProcess, PositionManager> factory :
                myCustomPositionManagerFactories) {
              final PositionManager positionManager = factory.fun(process);
              if (positionManager != null) {
                process.appendPositionManager(positionManager);
              }
            }
            for (PositionManagerFactory factory :
                Extensions.getExtensions(PositionManagerFactory.EP_NAME, myProject)) {
              final PositionManager manager = factory.createPositionManager(debugProcess);
              if (manager != null) {
                process.appendPositionManager(manager);
              }
            }
          }

          @Override
          public void processDetached(final DebugProcess process, final boolean closedByUser) {
            debugProcess.removeDebugProcessListener(this);
          }

          @Override
          public void attachException(
              final RunProfileState state,
              final ExecutionException exception,
              final RemoteConnection remoteConnection) {
            debugProcess.removeDebugProcessListener(this);
          }
        });
    DebuggerSession session =
        DebuggerSession.create(environment.getSessionName(), debugProcess, environment);
    ExecutionResult executionResult = session.getProcess().getExecutionResult();
    if (executionResult == null) {
      return null;
    }
    session.getContextManager().addListener(mySessionListener);
    getContextManager()
        .setState(
            DebuggerContextUtil.createDebuggerContext(
                session, session.getContextManager().getContext().getSuspendContext()),
            session.getState(),
            DebuggerSession.Event.CONTEXT,
            null);

    final ProcessHandler processHandler = executionResult.getProcessHandler();

    synchronized (mySessions) {
      mySessions.put(processHandler, session);
    }

    if (!(processHandler instanceof RemoteDebugProcessHandler)) {
      // add listener only to non-remote process handler:
      // on Unix systems destroying process does not cause VMDeathEvent to be generated,
      // so we need to call debugProcess.stop() explicitly for graceful termination.
      // RemoteProcessHandler on the other hand will call debugProcess.stop() as a part of
      // destroyProcess() and detachProcess() implementation,
      // so we shouldn't add the listener to avoid calling stop() twice
      processHandler.addProcessListener(
          new ProcessAdapter() {
            @Override
            public void processWillTerminate(ProcessEvent event, boolean willBeDestroyed) {
              final DebugProcessImpl debugProcess = getDebugProcess(event.getProcessHandler());
              if (debugProcess != null) {
                // if current thread is a "debugger manager thread", stop will execute synchronously
                // it is KillableColoredProcessHandler responsibility to terminate VM
                debugProcess.stop(
                    willBeDestroyed
                        && !(event.getProcessHandler() instanceof KillableColoredProcessHandler));

                // wait at most 10 seconds: the problem is that debugProcess.stop() can hang if
                // there are troubles in the debuggee
                // if processWillTerminate() is called from AWT thread debugProcess.waitFor() will
                // block it and the whole app will hang
                if (!DebuggerManagerThreadImpl.isManagerThread()) {
                  if (SwingUtilities.isEventDispatchThread()) {
                    ProgressManager.getInstance()
                        .runProcessWithProgressSynchronously(
                            new Runnable() {
                              @Override
                              public void run() {
                                ProgressManager.getInstance()
                                    .getProgressIndicator()
                                    .setIndeterminate(true);
                                debugProcess.waitFor(10000);
                              }
                            },
                            "Waiting For Debugger Response",
                            false,
                            debugProcess.getProject());
                  } else {
                    debugProcess.waitFor(10000);
                  }
                }
              }
            }
          });
    }
    myDispatcher.getMulticaster().sessionCreated(session);
    return session;
  }
 private void setSelectedList(final ChangeList list) {
   mySelectedChangeList = list;
   rebuildList();
   myDispatcher.getMulticaster().selectedListChanged();
 }
Ejemplo n.º 30
0
 private void notifyLine(final String line, final Key outputType) {
   String trimmed = LineHandlerHelper.trimLineSeparator(line);
   myLineListeners.getMulticaster().onLineAvailable(trimmed, outputType);
 }