当前位置: 首页>>代码示例>>Java>>正文


Java DataManager类代码示例

本文整理汇总了Java中com.intellij.ide.DataManager的典型用法代码示例。如果您正苦于以下问题:Java DataManager类的具体用法?Java DataManager怎么用?Java DataManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DataManager类属于com.intellij.ide包,在下文中一共展示了DataManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isRenamingHandlerWithValidName

import com.intellij.ide.DataManager; //导入依赖的package包/类
private boolean isRenamingHandlerWithValidName(@NotNull String name, Project project) {
  PsiElement elementToRename;
  String oldName;
  Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
  if (editor != null) {
    DataContext dataContext = DataManager.getInstance().getDataContext(editor.getComponent());
    elementToRename = PsiElementRenameHandler.getElement(dataContext);
    if (elementToRename instanceof AppleScriptHandler) {
      oldName = ((AppleScriptHandler) elementToRename).getName();
      final String[] newParts = name.split(":");
      final String[] oldParts = oldName != null ? oldName.split(":") : null;
      if (oldParts == null || oldParts.length != newParts.length) {
        return false;
      }
      for (String part : newParts) {
        if (!isIdentifier(part)) {
          return false;
        }
      }
      return true;
    } else
      return false;
  } else
    return false;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:26,代码来源:AppleScriptNamesValidator.java

示例2: run

import com.intellij.ide.DataManager; //导入依赖的package包/类
@Override
public void run(AnActionButton button) {
    // 获取选中节点
    final DefaultMutableTreeNode selectedNode = getSelectedNode();
    if (selectedNode == null) {
        return;
    }
    List<AnAction> actions = getMultipleActions(selectedNode);
    if (actions == null || actions.isEmpty()) {
        return;
    }
    // 显示新增按钮
    final DefaultActionGroup group = new DefaultActionGroup(actions);
    JBPopupFactory.getInstance()
            .createActionGroupPopup(null, group, DataManager.getInstance().getDataContext(button.getContextComponent()),
                    JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true).show(button.getPreferredPopupPoint());
}
 
开发者ID:hykes,项目名称:CodeGen,代码行数:18,代码来源:TemplateAddAction.java

示例3: updateRecentProjectsMenu

import com.intellij.ide.DataManager; //导入依赖的package包/类
@Override
public void updateRecentProjectsMenu () {
  RecentProjectsManager projectsManager = RecentProjectsManager.getInstance();
  if (projectsManager == null) return;
  final AnAction[] recentProjectActions = projectsManager.getRecentProjectsActions(false);
  recentProjectsMenu.removeAll();

  for (final AnAction action : recentProjectActions) {
    MenuItem menuItem = new MenuItem(((ReopenProjectAction)action).getProjectName());
    menuItem.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        action.actionPerformed(AnActionEvent.createFromAnAction(action, null, ActionPlaces.DOCK_MENU, DataManager.getInstance().getDataContext(null)));
      }
    });
    recentProjectsMenu.add(menuItem);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:MacDockDelegate.java

示例4: createCustomComponent

import com.intellij.ide.DataManager; //导入依赖的package包/类
@Override
public JComponent createCustomComponent(Presentation presentation) {
    JRadioButton jRadioButton = new JRadioButton("");
    jRadioButton.addActionListener(e -> {
        JRadioButton radioButton = (JRadioButton) e.getSource();
        ActionToolbar actionToolbar = UIUtil.getParentOfType(ActionToolbar.class, radioButton);
        DataContext dataContext = actionToolbar != null ? actionToolbar.getToolbarDataContext() : DataManager.getInstance().getDataContext(radioButton);
        JBRadioAction.this.actionPerformed(AnActionEvent.createFromAnAction(JBRadioAction.this, null, "unknown", dataContext));
        System.out.println("JBRadioAction.createCustomComponent");
        if (mActionListener != null) {
            mActionListener.actionPerformed(e);
        }
    });
    presentation.putClientProperty("selected", selected);
    this.updateCustomComponent(jRadioButton, presentation);
    return jRadioButton;
}
 
开发者ID:FingerArt,项目名称:ApiDebugger,代码行数:18,代码来源:JBRadioAction.java

示例5: actionPerformed

import com.intellij.ide.DataManager; //导入依赖的package包/类
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 = PlatformDataKeys.TOOL_WINDOW.getData(context);
    if (tw != null) {
      tw.hide(null);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:CloseActiveTabAction.java

示例6: installEditAction

import com.intellij.ide.DataManager; //导入依赖的package包/类
public static Disposable installEditAction(final JTree tree, String actionName) {
  final DoubleClickListener listener = new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (tree.getPathForLocation(e.getX(), e.getY()) == null) return false;
      DataContext dataContext = DataManager.getInstance().getDataContext(tree);
      GotoFrameSourceAction.doAction(dataContext);
      return true;
    }
  };
  listener.installOn(tree);

  final AnAction action = ActionManager.getInstance().getAction(actionName);
  action.registerCustomShortcutSet(CommonShortcuts.getEditSource(), tree);

  return new Disposable() {
    public void dispose() {
      listener.uninstall(tree);
      action.unregisterCustomShortcutSet(tree);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:DebuggerAction.java

示例7: createUIComponents

import com.intellij.ide.DataManager; //导入依赖的package包/类
private void createUIComponents() {
  myExplorerPanel = new JPanel(new BorderLayout());
  DataManager.registerDataProvider(myExplorerPanel, new DataProvider() {
    @Nullable
    @Override
    public Object getData(@NonNls String dataId) {
      if (CommonDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)) {
        return myExplorer.getSelectedFiles();
      }
      else if (FileSystemTree.DATA_KEY.is(dataId)) {
        return myExplorer;
      }
      return null;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:MapExternalResourceDialog.java

示例8: moveClass

import com.intellij.ide.DataManager; //导入依赖的package包/类
private void moveClass(Project project, Editor editor, PsiFile file, PsiClass aClass) {
  RefactoringActionHandler moveHandler = RefactoringActionHandlerFactory.getInstance().createMoveHandler();
  DataManager dataManager = DataManager.getInstance();
  DataContext dataContext = dataManager.getDataContext();
  final String fqName = aClass.getQualifiedName();
  LOG.assertTrue(fqName != null);
  PsiDirectory directory = PackageUtil
    .findOrCreateDirectoryForPackage(myCurrentModule, StringUtil.getPackageName(fqName), mySourceRoot, true);
  DataContext context = SimpleDataContext.getSimpleContext(LangDataKeys.TARGET_PSI_ELEMENT.getName(), directory, dataContext);

  moveHandler.invoke(project, new PsiElement[]{aClass}, context);
  PsiReference reference = file.findReferenceAt(editor.getCaretModel().getOffset());
  PsiClass newClass = JavaPsiFacade.getInstance(project).findClass(fqName, GlobalSearchScope.moduleScope(myCurrentModule));
  if (reference != null && newClass != null) {
    final QuestionAction action = new AddImportAction(project, reference, editor, newClass);
    action.execute();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:MoveClassToModuleFix.java

示例9: isEnabledOnElements

import com.intellij.ide.DataManager; //导入依赖的package包/类
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
  Project currProject = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext());

  if (currProject == null) {
    return false;
  }

  if (elements.length > 1) return false;

  for (PsiElement element : elements) {
    if (!(element instanceof PsiMethod || element instanceof PsiVariable)) {
      return false;
    }
  }

  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ChangeTypeSignatureAction.java

示例10: testTypeInEmptyConsole

import com.intellij.ide.DataManager; //导入依赖的package包/类
public void testTypeInEmptyConsole() throws Exception {
  final ConsoleViewImpl console = createConsole();
  try {
    console.clear();
    EditorActionManager actionManager = EditorActionManager.getInstance();
    final DataContext dataContext = DataManager.getInstance().getDataContext();
    TypedAction action = actionManager.getTypedAction();
    action.actionPerformed(console.getEditor(), 'h', dataContext);
    assertEquals(1, console.getContentSize());
  }
  catch (Exception e) {
    e.printStackTrace();
  }
  finally {
    Disposer.dispose(console);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ConsoleViewImplTest.java

示例11: doFix

import com.intellij.ide.DataManager; //导入依赖的package包/类
@Override
public void doFix(@NotNull final Project project,
                  ProblemDescriptor descriptor) {

  final PsiElement constant = descriptor.getPsiElement();
  final Application application = ApplicationManager.getApplication();
  application.invokeLater(new Runnable() {

    @Override
    public void run() {
      if (!constant.isValid()) return;
      final JavaRefactoringActionHandlerFactory factory =
        JavaRefactoringActionHandlerFactory.getInstance();
      final RefactoringActionHandler introduceHandler =
        factory.createIntroduceConstantHandler();
      final DataManager dataManager = DataManager.getInstance();
      final DataContext dataContext = dataManager.getDataContext();
      introduceHandler.invoke(project, new PsiElement[]{constant},
                              dataContext);
    }
  }, project.getDisposed());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:IntroduceConstantFix.java

示例12: createLibrary

import com.intellij.ide.DataManager; //导入依赖的package包/类
@Nullable
public Library createLibrary() {
  final NewLibraryConfiguration configuration =
    CreateNewLibraryAction.createNewLibraryConfiguration(myLibraryType, myParentComponent, myProject);
  if (configuration == null) return null;

  final NewLibraryEditor libraryEditor = new NewLibraryEditor(configuration.getLibraryType(), configuration.getProperties());
  libraryEditor.setName(configuration.getDefaultLibraryName());
  configuration.addRoots(libraryEditor);

  final LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
  List<LibraryTable> tables = Arrays.asList(myRootModel.getModuleLibraryTable(),
                                            registrar.getLibraryTable(myProject),
                                            registrar.getLibraryTable());

  CreateNewLibraryDialog dialog = new CreateNewLibraryDialog(myParentComponent, myContext, libraryEditor, tables, 1);
  final Module contextModule = LangDataKeys.MODULE_CONTEXT.getData(DataManager.getInstance().getDataContext(myParentComponent));
  dialog.setContextModule(contextModule);
  if (dialog.showAndGet()) {
    return dialog.createLibrary();
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:NewLibraryChooser.java

示例13: clearDiffPanel

import com.intellij.ide.DataManager; //导入依赖的package包/类
private void clearDiffPanel() {
  if (myDiffPanelComponent != null) {
    myDiffPanel.remove(myDiffPanelComponent);
    myDiffPanelComponent = null;
    if (myCurrentElement != null) {
      myCurrentElement.disposeDiffComponent();
    }
  }
  if (myViewComponent != null) {
    myDiffPanel.remove(myViewComponent);
    myViewComponent = null;
    if (myCurrentElement != null) {
      myCurrentElement.disposeViewComponent();
    }
  }
  myCurrentElement = null;
  myDiffPanel.remove(getErrorLabel());
  DataManager.removeDataProvider(myDiffPanel);
  myDiffPanel.repaint();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:DirDiffPanel.java

示例14: PyConfigureInterpretersLinkPanel

import com.intellij.ide.DataManager; //导入依赖的package包/类
public PyConfigureInterpretersLinkPanel(final JPanel parentPanel) {
  super(new BorderLayout());
  myConfigureLabel = new JBLabel("<html><a href=\"#\">Configure Interpreters");
  myConfigureLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      if (clickCount == 1) {
        Settings settings = Settings.KEY.getData(DataManager.getInstance().getDataContext(parentPanel));
        if (settings != null) {
          settings.select(settings.find(PyActiveSdkModuleConfigurable.class.getName()));
          return true;
        }
      }
      return false;
    }
  }.installOn(myConfigureLabel);

  add(myConfigureLabel, BorderLayout.CENTER);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PyConfigureInterpretersLinkPanel.java

示例15: onChosen

import com.intellij.ide.DataManager; //导入依赖的package包/类
@Override
public PopupStep onChosen(ActionItem actionChoice, boolean finalChoice, final int eventModifiers) {
  if (!actionChoice.isEnabled()) return FINAL_CHOICE;
  final AnAction action = actionChoice.getAction();
  DataManager mgr = DataManager.getInstance();

  final DataContext dataContext = myContext != null ? mgr.getDataContext(myContext) : mgr.getDataContext();

  if (action instanceof ActionGroup && (!finalChoice || !((ActionGroup)action).canBePerformed(dataContext))) {
      return createActionsStep((ActionGroup)action, dataContext, myEnableMnemonics, true, myShowDisabledActions, null, myContext, false,
                               myPreselectActionCondition, false);
  }
  else {
    myFinalRunnable = new Runnable() {
      @Override
      public void run() {
        performAction(action, eventModifiers);
      }
    };
    return FINAL_CHOICE;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PopupFactoryImpl.java


注:本文中的com.intellij.ide.DataManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。