Java Code Examples for com.intellij.ide.DataManager#getInstance()

The following examples show how to use com.intellij.ide.DataManager#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DiffHyperlink.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void navigate(@Nonnull Project project, @javax.annotation.Nullable RelativePoint hyperlinkLocationPoint) {
  final DataManager dataManager = DataManager.getInstance();
  final DataContext dataContext = hyperlinkLocationPoint != null ?
                                  dataManager.getDataContext(hyperlinkLocationPoint.getOriginalComponent()) : dataManager.getDataContext();
  ViewAssertEqualsDiffAction.openDiff(dataContext, DiffHyperlink.this);
}
 
Example 2
Source File: ButtonToolbarImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
ButtonToolbarImpl(@Nonnull String place, @Nonnull ActionGroup actionGroup) {
  super(new GridBagLayout());
  myPlace = place;
  myPresentationFactory = new PresentationFactory();
  myDataManager = DataManager.getInstance();

  initButtons(actionGroup);

  updateActions();
  ActionManagerEx.getInstanceEx().addTimerListener(500, new WeakTimerListener(new MyTimerListener()));
  enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK);
}
 
Example 3
Source File: ActionToolbarImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ActionToolbarImpl(@Nonnull String place, @Nonnull ActionGroup actionGroup, final boolean horizontal, final boolean decorateButtons, boolean updateActionsNow) {
  super(null);
  myActionManager = ActionManagerEx.getInstanceEx();
  myPlace = place;
  myActionGroup = actionGroup;
  myVisibleActions = new ArrayList<>();
  myDataManager = DataManager.getInstance();
  myDecorateButtons = decorateButtons;
  myUpdater = new ToolbarUpdater(KeymapManagerEx.getInstanceEx(), this) {
    @Override
    protected void updateActionsImpl(boolean transparentOnly, boolean forced) {
      if (!ApplicationManager.getApplication().isDisposedOrDisposeInProgress()) {
        ActionToolbarImpl.this.updateActionsImpl(transparentOnly, forced);
      }
    }
  };

  setOrientation(horizontal ? ActionToolbar.HORIZONTAL_ORIENTATION : ActionToolbar.VERTICAL_ORIENTATION);

  mySecondaryActions.getTemplatePresentation().setIcon(AllIcons.General.GearPlain);
  mySecondaryActions.setPopup(true);

  myUpdater.updateActions(updateActionsNow, false);

  // If the panel doesn't handle mouse event then it will be passed to its parent.
  // It means that if the panel is in sliding mode then the focus goes to the editor
  // and panel will be automatically hidden.
  enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.COMPONENT_EVENT_MASK | AWTEvent.CONTAINER_EVENT_MASK);
  setMiniMode(false);
}
 
Example 4
Source File: ConfigurationContext.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@RequiredUIAccess
public static ConfigurationContext getFromContext(DataContext dataContext) {
  final ConfigurationContext context = new ConfigurationContext(dataContext);
  final DataManager dataManager = DataManager.getInstance();
  ConfigurationContext sharedContext = dataManager.loadFromDataContext(dataContext, SHARED_CONTEXT);
  if (sharedContext == null ||
      sharedContext.getLocation() == null ||
      context.getLocation() == null ||
      !Comparing.equal(sharedContext.getLocation().getPsiElement(), context.getLocation().getPsiElement())) {
    sharedContext = context;
    dataManager.saveInDataContext(dataContext, SHARED_CONTEXT, sharedContext);
  }
  return sharedContext;
}
 
Example 5
Source File: RunConfigurationsSEContributor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean processSelectedItem(@Nonnull ChooseRunConfigurationPopup.ItemWrapper selected, int modifiers, @Nonnull String searchText) {
  RunnerAndConfigurationSettings settings = ObjectUtils.tryCast(selected.getValue(), RunnerAndConfigurationSettings.class);
  if (settings != null) {
    int mode = getMode(searchText, modifiers);
    Executor executor = findExecutor(settings, mode);
    if (executor != null) {
      DataManager dataManager = DataManager.getInstance();
      selected.perform(myProject, executor, dataManager.getDataContext(myContextComponent));
    }
  }

  return true;
}
 
Example 6
Source File: UpdateProject.java    From GitToolBox with Apache License 2.0 4 votes vote down vote up
private Promise<AnActionEvent> synthesiseEvent(@NotNull AnAction action, @Nullable InputEvent inputEvent) {
  DataManager dataManager = DataManager.getInstance();
  return dataManager.getDataContextFromFocusAsync()
      .then(dataContext -> AnActionEvent.createFromAnAction(action, inputEvent, ActionPlaces.UNKNOWN, dataContext));
}
 
Example 7
Source File: ActionManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static DataContext getContextBy(Component contextComponent) {
  final DataManager dataManager = DataManager.getInstance();
  return contextComponent != null ? dataManager.getDataContext(contextComponent) : dataManager.getDataContext();
}