Java Code Examples for com.intellij.ide.DataManager

The following examples show how to use com.intellij.ide.DataManager. These examples are extracted from open source projects. 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 Project: consulo   Source File: BranchActionGroupPopup.java    License: Apache License 2.0 6 votes vote down vote up
public BranchActionGroupPopup(@Nonnull String title, @Nonnull Project project, @Nonnull Condition<AnAction> preselectActionCondition, @Nonnull ActionGroup actions, @Nullable String dimensionKey) {
  super(title, createBranchSpeedSearchActionGroup(actions), SimpleDataContext.getProjectContext(project), preselectActionCondition, true);
  myProject = project;
  DataManager.registerDataProvider(getList(), dataId -> POPUP_MODEL == dataId ? getListModel() : null);
  myKey = dimensionKey;
  if (myKey != null) {
    Dimension storedSize = WindowStateService.getInstance(myProject).getSizeFor(myProject, myKey);
    if (storedSize != null) {
      //set forced size before component is shown
      setSize(storedSize);
      myUserSizeChanged = true;
    }
    createTitlePanelToolbar(myKey);
  }
  myMeanRowHeight = getList().getCellBounds(0, 0).height + UIUtil.getListCellVPadding() * 2;
}
 
Example 2
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  final AnAction action = ActionManager.getInstance().getAction("Flutter.ExtractWidget");
  if (action != null) {
    TransactionGuard.submitTransaction(project, () -> {
      final Editor editor = getCurrentEditor();
      if (editor == null) {
        // It is a race condition if we hit this. Gracefully assume
        // the action has just been canceled.
        return;
      }
      final JComponent editorComponent = editor.getComponent();
      final DataContext editorContext = DataManager.getInstance().getDataContext(editorComponent);
      final AnActionEvent editorEvent = AnActionEvent.createFromDataContext(ActionPlaces.UNKNOWN, null, editorContext);

      action.actionPerformed(editorEvent);
    });
  }
}
 
Example 3
Source Project: consulo   Source File: PathEditor.java    License: Apache License 2.0 6 votes vote down vote up
private VirtualFile[] doAdd() {
  VirtualFile baseDir = myAddBaseDir;
  Project project = DataManager.getInstance().getDataContext(myComponent).getData(CommonDataKeys.PROJECT);
  if (baseDir == null && project != null) {
    baseDir = project.getBaseDir();
  }
  VirtualFile[] files = FileChooser.chooseFiles(myDescriptor, myComponent, project, baseDir);
  files = adjustAddedFileSet(myComponent, files);
  List<VirtualFile> added = new ArrayList<VirtualFile>(files.length);
  for (VirtualFile vFile : files) {
    if (addElement(vFile)) {
      added.add(vFile);
    }
  }
  return VfsUtil.toVirtualFileArray(added);
}
 
Example 4
Source Project: consulo   Source File: NavBarUpdateQueue.java    License: Apache License 2.0 6 votes vote down vote up
private void requestModelUpdateFromContextOrObject(DataContext dataContext, Object object) {
  try {
    final NavBarModel model = myPanel.getModel();
    if (dataContext != null) {
      if (dataContext.getData(CommonDataKeys.PROJECT) != myPanel.getProject() || myPanel.isNodePopupActive()) {
        requestModelUpdate(null, myPanel.getContextObject(), true);
        return;
      }
      final Window window = SwingUtilities.getWindowAncestor(myPanel);
      if (window != null && !window.isFocused()) {
        model.updateModel(DataManager.getInstance().getDataContext(myPanel));
      }
      else {
        model.updateModel(dataContext);
      }
    }
    else {
      model.updateModel(object);
    }

    queueRebuildUi();
  }
  finally {
    myModelUpdating.set(false);
  }
}
 
Example 5
Source Project: consulo   Source File: DesktopContentManagerImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@Nullable
public Object getData(@Nonnull @NonNls Key<?> dataId) {
  if (PlatformDataKeys.CONTENT_MANAGER == dataId || PlatformDataKeys.NONEMPTY_CONTENT_MANAGER == dataId && getContentCount() > 1) {
    return DesktopContentManagerImpl.this;
  }

  for (DataProvider dataProvider : myDataProviders) {
    Object data = dataProvider.getData(dataId);
    if (data != null) {
      return data;
    }
  }

  if (myUI instanceof DataProvider) {
    return ((DataProvider)myUI).getData(dataId);
  }

  DataProvider provider = DataManager.getDataProvider(this);
  return provider == null ? null : provider.getData(dataId);
}
 
Example 6
Source Project: consulo   Source File: ActionsTree.java    License: Apache License 2.0 6 votes vote down vote up
private void reset(final Keymap keymap, final QuickList[] allQuickLists, String filter, @Nullable KeyboardShortcut shortcut) {
  myKeymap = keymap;

  final PathsKeeper pathsKeeper = new PathsKeeper();
  pathsKeeper.storePaths();

  myRoot.removeAllChildren();

  ActionManager actionManager = ActionManager.getInstance();
  Project project = DataManager.getInstance().getDataContext(myComponent).getData(CommonDataKeys.PROJECT);
  Group mainGroup = ActionsTreeUtil.createMainGroup(project, myKeymap, allQuickLists, filter, true, filter != null && filter.length() > 0 ?
                                                                                                    ActionsTreeUtil.isActionFiltered(filter, true) :
                                                                                                    (shortcut != null ? ActionsTreeUtil.isActionFiltered(actionManager, myKeymap, shortcut) : null));
  if ((filter != null && filter.length() > 0 || shortcut != null) && mainGroup.initIds().isEmpty()){
    mainGroup = ActionsTreeUtil.createMainGroup(project, myKeymap, allQuickLists, filter, false, filter != null && filter.length() > 0 ?
                                                                                                 ActionsTreeUtil.isActionFiltered(filter, false) :
                                                                                                 ActionsTreeUtil.isActionFiltered(actionManager, myKeymap, shortcut));
  }
  myRoot = ActionsTreeUtil.createNode(mainGroup);
  myMainGroup = mainGroup;
  MyModel model = (MyModel)myTree.getModel();
  model.setRoot(myRoot);
  model.nodeStructureChanged(myRoot);

  pathsKeeper.restorePaths();
}
 
Example 7
Source Project: consulo   Source File: ButtonToolbarImpl.java    License: Apache License 2.0 6 votes vote down vote up
ActionJButton(final AnAction action) {
  super(action.getTemplatePresentation().getText());
  myAction = action;
  setMnemonic(action.getTemplatePresentation().getMnemonic());
  setDisplayedMnemonicIndex(action.getTemplatePresentation().getDisplayedMnemonicIndex());

  addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      AnActionEvent event = new AnActionEvent(null, ((BaseDataManager)DataManager.getInstance()).getDataContextTest(ButtonToolbarImpl.this), myPlace, myPresentationFactory.getPresentation(action),
                                              ActionManager.getInstance(), e.getModifiers());
      if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) {
        ActionUtil.performActionDumbAware(action, event);
      }
    }
  });

}
 
Example 8
Source Project: consulo   Source File: CloseActiveTabAction.java    License: Apache License 2.0 6 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
  ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(e.getDataContext(), true);
  boolean processed = false;
  if (contentManager != null && contentManager.canCloseContents()) {
    final Content selectedContent = contentManager.getSelectedContent();
    if (selectedContent != null && selectedContent.isCloseable()) {
      contentManager.removeContent(selectedContent, true);
      processed = true;
    }
  }

  if (!processed && contentManager != null) {
    final DataContext context = DataManager.getInstance().getDataContext(contentManager.getComponent());
    final ToolWindow tw = context.getData(PlatformDataKeys.TOOL_WINDOW);
    if (tw != null) {
      tw.hide(null);
    }
  }
}
 
Example 9
Source Project: consulo   Source File: MacOSDefaultMenuInitializer.java    License: Apache License 2.0 6 votes vote down vote up
@Inject
@ReviewAfterMigrationToJRE(9)
public MacOSDefaultMenuInitializer(AboutManager aboutManager, DataManager dataManager, WindowManager windowManager) {
  myAboutManager = aboutManager;
  myDataManager = dataManager;
  myWindowManager = windowManager;
  if (SystemInfo.isMac) {
    try {
      ThrowableRunnable<Throwable> task = SystemInfo.isJavaVersionAtLeast(9) ? new Java9Worker(this::showAbout) : new PreJava9Worker(this::showAbout);

      task.run();

      installAutoUpdateMenu();
    }
    catch (Throwable t) {
      LOGGER.warn(t);
    }
  }
}
 
Example 10
Source Project: consulo   Source File: XDebuggerEditorBase.java    License: Apache License 2.0 6 votes vote down vote up
private ListPopup createLanguagePopup() {
  DefaultActionGroup actions = new DefaultActionGroup();
  for (Language language : getSupportedLanguages()) {
    //noinspection ConstantConditions
    actions.add(new AnAction(language.getDisplayName(), null, language.getAssociatedFileType().getIcon()) {
      @RequiredUIAccess
      @Override
      public void actionPerformed(@Nonnull AnActionEvent e) {
        XExpression currentExpression = getExpression();
        setExpression(new XExpressionImpl(currentExpression.getExpression(), language, currentExpression.getCustomInfo()));
        requestFocusInEditor();
      }
    });
  }

  DataContext dataContext = DataManager.getInstance().getDataContext(getComponent());
  return JBPopupFactory.getInstance().createActionGroupPopup("Choose Language", actions, dataContext,
                                                             JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
                                                             false);
}
 
Example 11
Source Project: consulo   Source File: LightPlatformCodeInsightTestCase.java    License: Apache License 2.0 6 votes vote down vote up
protected static DataContext getCurrentEditorDataContext() {
  final DataContext defaultContext = DataManager.getInstance().getDataContext();
  return new DataContext() {
    @Override
    @javax.annotation.Nullable
    public Object getData(@NonNls Key dataId) {
      if (PlatformDataKeys.EDITOR == dataId) {
        return getEditor();
      }
      if (CommonDataKeys.PROJECT == dataId) {
        return getProject();
      }
      if (LangDataKeys.PSI_FILE == dataId) {
        return getFile();
      }
      if (LangDataKeys.PSI_ELEMENT == dataId) {
        PsiFile file = getFile();
        if (file == null) return null;
        Editor editor = getEditor();
        if (editor == null) return null;
        return file.findElementAt(editor.getCaretModel().getOffset());
      }
      return defaultContext.getData(dataId);
    }
  };
}
 
Example 12
/**
 * {@inheritDoc}
 */
@Override
public void remind() {
    DataManager.getInstance().getDataContextFromFocus()
        .doWhenDone((Consumer<DataContext>) (dataContext -> new OpenImageConsumer().accept(dataContext)))
        .doWhenRejected((Consumer<String>) LOG::error);
}
 
Example 13
Source Project: consulo   Source File: ActionPopupMenuImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void show(final Component component, int x, int y) {
  if (!component.isShowing()) {
    //noinspection HardCodedStringLiteral
    throw new IllegalArgumentException("component must be shown on the screen");
  }

  removeAll();

  // Fill menu. Only after filling menu has non zero size.

  int x2 = Math.max(0, Math.min(x, component.getWidth() - 1)); // fit x into [0, width-1]
  int y2 = Math.max(0, Math.min(y, component.getHeight() - 1)); // fit y into [0, height-1]

  myContext = myDataContextProvider != null ? myDataContextProvider.get() : DataManager.getInstance().getDataContext(component, x2, y2);
  Utils.fillMenu(myGroup, this, true, myPresentationFactory, myContext, myPlace, false, false, LaterInvocator.isInModalContext());
  if (getComponentCount() == 0) {
    return;
  }
  if (myApp != null) {
    if (myApp.isActive()) {
      Component frame = UIUtil.findUltimateParent(component);
      if (frame instanceof Window) {
        consulo.ui.Window uiWindow = TargetAWT.from((Window)frame);
        myFrame = uiWindow.getUserData(IdeFrame.KEY);
      }
      myConnection = myApp.getMessageBus().connect();
      myConnection.subscribe(ApplicationActivationListener.TOPIC, ActionPopupMenuImpl.this);
    }
  }

  super.show(component, x, y);
}
 
Example 14
Source Project: consulo   Source File: SelectWordHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void execute(@Nonnull Editor editor, DataContext dataContext) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("enter: execute(editor='" + editor + "')");
  }
  Project project = DataManager.getInstance().getDataContext(editor.getComponent()).getData(CommonDataKeys.PROJECT);
  if (project == null) {
    if (myOriginalHandler != null) {
      myOriginalHandler.execute(editor, dataContext);
    }
    return;
  }
  PsiDocumentManager.getInstance(project).commitAllDocuments();

  TextRange range = selectWord(editor, project);
  if (editor instanceof EditorWindow) {
    if (range == null || !isInsideEditableInjection((EditorWindow)editor, range, project) || TextRange.from(0, editor.getDocument().getTextLength()).equals(
            new TextRange(editor.getSelectionModel().getSelectionStart(), editor.getSelectionModel().getSelectionEnd()))) {
      editor = ((EditorWindow)editor).getDelegate();
      range = selectWord(editor, project);
    }
  }
  if (range == null) {
    if (myOriginalHandler != null) {
      myOriginalHandler.execute(editor, dataContext);
    }
  }
  else {
    editor.getSelectionModel().setSelection(range.getStartOffset(), range.getEndOffset());
  }
}
 
Example 15
Source Project: CppTools   Source File: ExtractFunctionDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void createUIComponents() {
  functionMethodNameTextField = new NameSuggestionsField(
    new String[] {"fun"},
    (Project) DataManager.getInstance().getDataContext().getData(DataConstants.PROJECT),
    CppSupportLoader.CPP_FILETYPE
  );
}
 
Example 16
Source Project: consulo   Source File: RunDashboardContent.java    License: Apache License 2.0 5 votes vote down vote up
private JComponent createToolbar() {
  JPanel toolBarPanel = new JPanel(new GridLayout());
  DefaultActionGroup leftGroup = new DefaultActionGroup();
  leftGroup.add(ActionManager.getInstance().getAction(RUN_DASHBOARD_TOOLBAR));
  // TODO [konstantin.aleev] provide context help ID
  //leftGroup.add(new Separator());
  //leftGroup.add(new ContextHelpAction(HELP_ID));

  ActionToolbar leftActionToolBar = ActionManager.getInstance().createActionToolbar(PLACE_TOOLBAR, leftGroup, false);
  toolBarPanel.add(leftActionToolBar.getComponent());

  myTree.putClientProperty(DataManager.CLIENT_PROPERTY_DATA_PROVIDER, new DataProvider() {
    @Override
    public Object getData(@Nonnull @NonNls Key dataId) {
      if (KEY == dataId) {
        return RunDashboardContent.this;
      }
      return null;
    }
  });
  leftActionToolBar.setTargetComponent(myTree);

  DefaultActionGroup rightGroup = new DefaultActionGroup();

  TreeExpander treeExpander = new DefaultTreeExpander(myTree);
  AnAction expandAllAction = CommonActionsManager.getInstance().createExpandAllAction(treeExpander, this);
  rightGroup.add(expandAllAction);

  AnAction collapseAllAction = CommonActionsManager.getInstance().createCollapseAllAction(treeExpander, this);
  rightGroup.add(collapseAllAction);

  rightGroup.add(new AnSeparator());
  myGroupers.stream().filter(grouper -> !grouper.getRule().isAlwaysEnabled()).forEach(grouper -> rightGroup.add(new GroupAction(grouper)));

  ActionToolbar rightActionToolBar = ActionManager.getInstance().createActionToolbar(PLACE_TOOLBAR, rightGroup, false);
  toolBarPanel.add(rightActionToolBar.getComponent());
  rightActionToolBar.setTargetComponent(myTree);
  return toolBarPanel;
}
 
Example 17
Source Project: consulo   Source File: DesktopWindowWatcher.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * This method should get notifications abount changes of focused window.
 * Only <code>focusedWindow</code> property is acceptable.
 *
 * @throws IllegalArgumentException if property name isn't <code>focusedWindow</code>.
 */
@Override
public final void propertyChange(final PropertyChangeEvent e) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("enter: propertyChange(" + e + ")");
  }
  if (!FOCUSED_WINDOW_PROPERTY.equals(e.getPropertyName())) {
    throw new IllegalArgumentException("unknown property name: " + e.getPropertyName());
  }
  synchronized (myLock) {
    final consulo.ui.Window window = TargetAWT.from((Window)e.getNewValue());
    if (window == null || myApplication.isDisposed()) {
      return;
    }
    if (!myWindow2Info.containsKey(window)) {
      myWindow2Info.put(window, new WindowInfo(window, true));
    }
    myFocusedWindow = window;
    final Project project = DataManager.getInstance().getDataContext(myFocusedWindow).getData(CommonDataKeys.PROJECT);
    for (Iterator<consulo.ui.Window> i = myFocusedWindows.iterator(); i.hasNext(); ) {
      final consulo.ui.Window w = i.next();
      final DataContext dataContext = DataManager.getInstance().getDataContext(TargetAWT.to(w));
      if (project == dataContext.getData(CommonDataKeys.PROJECT)) {
        i.remove();
      }
    }
    myFocusedWindows.add(myFocusedWindow);
    // Set new root frame
    final IdeFrame frame = IdeFrameUtil.findRootIdeFrame(window);

    if (frame != null) {
      JOptionPane.setRootFrame((Frame)TargetAWT.to(frame.getWindow()));
    }
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("exit: propertyChange()");
  }
}
 
Example 18
Source Project: consulo   Source File: BaseLabel.java    License: Apache License 2.0 5 votes vote down vote up
public BaseLabel(DesktopToolWindowContentUi ui, boolean bold) {
  myUi = ui;
  setOpaque(false);
  myBold = bold;

  DataManager.registerDataProvider(this, dataId -> {
    if (dataId == ToolWindowDataKeys.CONTENT) {
      return getContent();
    }

    return null;
  });
}
 
Example 19
Source Project: consulo   Source File: ConfigurationContext.java    License: 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 20
private Optional<DataContext> getDataContext() {
    try {
        return Optional.ofNullable(
                DataManager.getInstance()
                        .getDataContextFromFocusAsync()
                        .blockingGet(100, TimeUnit.MILLISECONDS));
    } catch (TimeoutException | ExecutionException e) {
        return Optional.empty();
    }

}
 
Example 21
Source Project: consulo   Source File: PopupPositionManager.java    License: Apache License 2.0 5 votes vote down vote up
private static Component discoverPopup(final Key<JBPopup> datakey, Component focusOwner) {
  if (focusOwner == null) {
    focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
  }

  if (focusOwner == null) return null;

  final DataContext dataContext = DataManager.getInstance().getDataContext(focusOwner);
  final JBPopup popup = dataContext.getData(datakey);
  if (popup != null && popup.isVisible() && !popup.isDisposed()) {
    return popup.getContent();
  }

  return null;
}
 
Example 22
Source Project: intellij   Source File: BlazeProblemsViewPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void scrollToSource(Component tree) {
  DataContext dataContext = DataManager.getInstance().getDataContext(tree);
  getReady(dataContext)
      .doWhenDone(
          () ->
              TransactionGuard.submitTransaction(
                  ApplicationManager.getApplication(),
                  () -> {
                    DataContext context = DataManager.getInstance().getDataContext(tree);
                    Navigatable navigatable = BLAZE_CONSOLE_NAVIGATABLE_DATA_KEY.getData(context);
                    if (navigatable != null) {
                      OpenSourceUtil.navigate(false, true, navigatable);
                    }
                  }));
}
 
Example 23
Source Project: intellij   Source File: ProjectViewEnterHandler.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean isApplicable(PsiFile file, DataContext dataContext) {
  if (!(file instanceof ProjectViewPsiFile)) {
    return false;
  }
  Boolean isSplitLine =
      DataManager.getInstance().loadFromDataContext(dataContext, SplitLineAction.SPLIT_LINE_KEY);
  if (isSplitLine != null) {
    return false;
  }
  return true;
}
 
Example 24
Source Project: intellij   Source File: BuildEnterHandler.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean isApplicable(PsiFile file, DataContext dataContext) {
  if (!(file instanceof BuildFile)) {
    return false;
  }
  Boolean isSplitLine =
      DataManager.getInstance().loadFromDataContext(dataContext, SplitLineAction.SPLIT_LINE_KEY);
  if (isSplitLine != null) {
    return false;
  }
  return true;
}
 
Example 25
Source Project: consulo   Source File: StructureViewWrapperImpl.java    License: Apache License 2.0 5 votes vote down vote up
private void checkUpdate() {
  if (myProject.isDisposed()) return;

  final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
  final boolean insideToolwindow = SwingUtilities.isDescendingFrom(myToolWindow.getComponent(), owner);
  if (!myFirstRun && (insideToolwindow || JBPopupFactory.getInstance().isPopupActive())) {
    return;
  }

  final DataContext dataContext = DataManager.getInstance().getDataContext(owner);
  if (dataContext.getData(ourDataSelectorKey) == this) return;
  if (dataContext.getData(CommonDataKeys.PROJECT) != myProject) return;

  final VirtualFile[] files = hasFocus() ? null : dataContext.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
  if (!myToolWindow.isVisible()) {
    if (files != null && files.length > 0) {
      myFile = files[0];
    }
    return;
  }

  if (files != null && files.length == 1) {
    setFile(files[0]);
  }
  else if (files != null && files.length > 1) {
    setFile(null);
  } else if (myFirstRun) {
    final FileEditorManagerImpl editorManager = (FileEditorManagerImpl)FileEditorManager.getInstance(myProject);
    final List<Pair<VirtualFile, EditorWindow>> history = editorManager.getSelectionHistory();
    if (! history.isEmpty()) {
      setFile(history.get(0).getFirst());
    }
  }

  myFirstRun = false;
}
 
Example 26
Source Project: intellij   Source File: ProjectViewUi.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * To support the custom language features, we need a ProjectImpl, and it's not desirable to
 * create one from scratch.<br>
 *
 * @return the current, non-default project, if one exists, else the default project.
 */
public static Project getProject() {
  Project project = (Project) DataManager.getInstance().getDataContext().getData("project");
  if (project != null && project instanceof ProjectImpl) {
    return project;
  }
  return ProjectManager.getInstance().getDefaultProject();
}
 
Example 27
@Override
@Nonnull
protected JComponent createEditor() {
  JPanel wholePanel = new JPanel(new BorderLayout());

  wholePanel.add(myEditor.getComponent(), BorderLayout.NORTH);
  wholePanel.add(myBeforeLaunchContainer, BorderLayout.SOUTH);

  DataManager.registerDataProvider(wholePanel, new TypeSafeDataProviderAdapter(new MyDataProvider()));
  return wholePanel;
}
 
Example 28
Source Project: consulo   Source File: BranchActionGroupPopup.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  setExpanded(!myIsExpanded);
  InputEvent event = e.getInputEvent();
  if (event != null && event.getSource() instanceof JComponent) {
    DataProvider dataProvider = DataManager.getDataProvider((JComponent)event.getSource());
    if (dataProvider != null) {
      assertNotNull(dataProvider.getDataUnchecked(POPUP_MODEL)).refilter();
    }
  }
}
 
Example 29
Source Project: consulo   Source File: KeyboardShortcutDialog.java    License: Apache License 2.0 5 votes vote down vote up
public KeyboardShortcutDialog(Component component, String actionId, final QuickList[] quickLists) {
  super(component, true);
  setTitle(KeyMapBundle.message("keyboard.shortcut.dialog.title"));
  myActionId = actionId;
  final Project project = DataManager.getInstance().getDataContext(component).getData(CommonDataKeys.PROJECT);
  myMainGroup = ActionsTreeUtil.createMainGroup(project, myKeymap, quickLists, null, false, null); //without current filter
  myEnableSecondKeystroke = new JCheckBox();
  UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, myEnableSecondKeystroke);
  myEnableSecondKeystroke.setBorder(new EmptyBorder(4, 0, 0, 2));
  myEnableSecondKeystroke.setFocusable(false);
  myKeystrokePreview = new JLabel(" ");
  myConflictInfoArea = new JTextArea("");
  myConflictInfoArea.setFocusable(false);
  init();
}
 
Example 30
Source Project: consulo   Source File: MacrosDialog.java    License: Apache License 2.0 5 votes vote down vote up
public MacrosDialog(Component parent) {
  super(parent, true);
  MacroManager.getInstance().cacheMacrosPreview(DataManager.getInstance().getDataContext(parent));
  setTitle(IdeBundle.message("title.macros"));
  setOKButtonText(IdeBundle.message("button.insert"));

  myMacrosModel = new DefaultListModel();
  myMacrosList = new JBList(myMacrosModel);
  myPreviewTextarea = new JTextArea();

  init();
}