Java Code Examples for com.intellij.ide.DataManager#registerDataProvider()
The following examples show how to use
com.intellij.ide.DataManager#registerDataProvider() .
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: DirDiffFrame.java From consulo with Apache License 2.0 | 6 votes |
public DirDiffFrame(Project project, DirDiffTableModel model) { super(project, "DirDiffDialog"); setSize(new Dimension(800, 600)); setTitle(model.getTitle()); myPanel = new DirDiffPanel(model, new DirDiffWindow(this)); Disposer.register(this, myPanel); setComponent(myPanel.getPanel()); if (project != null) { setProject(project); } closeOnEsc(); DataManager.registerDataProvider(myPanel.getPanel(), new DataProvider() { @Override public Object getData(@Nonnull @NonNls Key dataId) { if (PlatformDataKeys.HELP_ID == dataId) { return "reference.dialogs.diff.folder"; } return null; } }); }
Example 2
Source File: BranchActionGroupPopup.java From consulo with Apache License 2.0 | 6 votes |
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 3
Source File: DiffSideView.java From consulo with Apache License 2.0 | 5 votes |
public void setEditorSource(final Project project, final EditorSource source) { MyState state = new MyState(); myEditorSource = source; myLineMarker.attach(myEditorSource); Editor editor = myEditorSource.getEditor(); final FileEditor fileEditor = myEditorSource.getFileEditor(); if (editor == null) { insertComponent(fileEditor == null ? MOCK_COMPONENT : fileEditor.getComponent()); DataManager.registerDataProvider(myPanel, new DataProvider() { @Override public Object getData(@Nonnull @NonNls Key<?> dataId) { if (CommonDataKeys.PROJECT == dataId) { return project; } if (PlatformDataKeys.FILE_EDITOR == dataId) { return fileEditor; } return null; } }); if (fileEditor != null) { ScrollUtil.scrollVertically(fileEditor.getComponent(), 0); ScrollUtil.scrollHorizontally(fileEditor.getComponent(), 0); } } else { DataManager.removeDataProvider(myPanel); editor.getScrollingModel().scrollHorizontally(0); insertComponent(editor.getComponent()); applyHighlighter(); setMouseListeners(source); MyEditorFocusListener.install(this); state.restore(); } }
Example 4
Source File: BaseLabel.java From consulo with Apache License 2.0 | 5 votes |
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 5
Source File: RunConfigurable.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public JComponent createComponent() { for (RunConfigurationsSettings each : Extensions.getExtensions(RunConfigurationsSettings.EXTENSION_POINT)) { UnnamedConfigurable configurable = each.createConfigurable(); myAdditionalSettings.add(Pair.create(configurable, configurable.createComponent())); } myWholePanel = new JPanel(new BorderLayout()); DataManager.registerDataProvider(myWholePanel, new DataProvider() { @Nullable @Override public Object getData(@Nonnull @NonNls Key dataId) { return RunConfigurationSelector.KEY == dataId ? new RunConfigurationSelector() { @Override public void select(@Nonnull RunConfiguration configuration) { selectConfiguration(configuration); } } : null; } }); mySplitter.setFirstComponent(createLeftPanel()); mySplitter.setSecondComponent(myRightPanel); myWholePanel.add(mySplitter, BorderLayout.CENTER); updateDialog(); Dimension d = myWholePanel.getPreferredSize(); d.width = Math.max(d.width, 800); d.height = Math.max(d.height, 600); myWholePanel.setPreferredSize(d); mySplitter.setProportion(myProperties.getFloat(DIVIDER_PROPORTION, 0.3f)); return myWholePanel; }
Example 6
Source File: ConfigurationSettingsEditorWrapper.java From consulo with Apache License 2.0 | 5 votes |
@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 7
Source File: LanguageConsoleImpl.java From consulo with Apache License 2.0 | 5 votes |
public void setupEditor(@Nonnull EditorEx editor) { ConsoleViewUtil.setupConsoleEditor(editor, false, false); editor.getContentComponent().setFocusCycleRoot(false); editor.setHorizontalScrollbarVisible(true); editor.setVerticalScrollbarVisible(true); editor.setBorder(null); EditorSettings editorSettings = editor.getSettings(); editorSettings.setAdditionalLinesCount(1); editorSettings.setAdditionalColumnsCount(1); DataManager.registerDataProvider(editor.getComponent(), (dataId) -> getEditorData(editor, dataId)); }
Example 8
Source File: LanguageConsoleImpl.java From consulo with Apache License 2.0 | 5 votes |
private void initComponents() { setupComponents(); myPanel.add(myHistoryViewer.getComponent()); myPanel.add(myConsoleExecutionEditor.getComponent()); myPanel.add(myScrollBar); myPanel.setBackground(myConsoleExecutionEditor.getEditor().getBackgroundColor()); DataManager.registerDataProvider(myPanel, this); }
Example 9
Source File: AnalyzeDependenciesComponent.java From consulo with Apache License 2.0 | 5 votes |
/** * @return a created tree component (to be used as */ private JComponent createTreeComponent() { myExplanationTree = new Tree(new DefaultTreeModel(buildTree())); myExplanationTree.setRootVisible(false); myExplanationTree.setCellRenderer(new ExplanationTreeRenderer()); DataManager.registerDataProvider(myExplanationTree, this); TreeUtil.expandAll(myExplanationTree); final NavigateAction navigateAction = new NavigateAction(); navigateAction.registerCustomShortcutSet(new CustomShortcutSet(CommonShortcuts.DOUBLE_CLICK_1.getShortcuts()[0]), myExplanationTree); DefaultActionGroup group = new DefaultActionGroup(); group.addAction(navigateAction); PopupHandler.installUnknownPopupHandler(myExplanationTree, group, ActionManager.getInstance()); return new JBScrollPane(myExplanationTree); }
Example 10
Source File: TfsTreeForm.java From azure-devops-intellij with MIT License | 5 votes |
public TfsTreeForm() { DataManager.registerDataProvider(tree, this); new TreeSpeedSearch(tree); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { selectedItem = doGetSelectedItem(); pathField.setText(selectedItem != null ? selectedItem.path : null); eventDispatcher.getMulticaster().selectionChanged(); } }); PopupHandler.installPopupHandler(tree, POPUP_ACTION_GROUP, ActionPlaces.REMOTE_HOST_DIALOG_POPUP); setMessage(null, false); }
Example 11
Source File: DiffRequestProcessor.java From consulo with Apache License 2.0 | 5 votes |
protected void buildToolbar(@Nullable List<AnAction> viewerActions) { ActionGroup group = collectToolbarActions(viewerActions); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.DIFF_TOOLBAR, group, true); DataManager.registerDataProvider(toolbar.getComponent(), myMainPanel); toolbar.setTargetComponent(toolbar.getComponent()); myToolbarPanel.setContent(toolbar.getComponent()); for (AnAction action : group.getChildren(null)) { DiffUtil.registerAction(action, myMainPanel); } }
Example 12
Source File: MergeRequestProcessor.java From consulo with Apache License 2.0 | 5 votes |
protected void buildToolbar(@Nullable List<AnAction> viewerActions) { ActionGroup group = collectToolbarActions(viewerActions); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.DIFF_TOOLBAR, group, true); DataManager.registerDataProvider(toolbar.getComponent(), myMainPanel); toolbar.setTargetComponent(toolbar.getComponent()); myToolbarPanel.setContent(toolbar.getComponent()); for (AnAction action : group.getChildren(null)) { DiffUtil.registerAction(action, myMainPanel); } }
Example 13
Source File: StatisticsPanel.java From consulo with Apache License 2.0 | 5 votes |
public StatisticsPanel(final Project project, final TestFrameworkRunningModel model) { myProject = project; myTableModel = new StatisticsTableModel(); myStatisticsTableView.setModelAndUpdateColumns(myTableModel); myFrameworkRunningModel = model; final Runnable gotoSuiteOrParentAction = createGotoSuiteOrParentAction(); new DoubleClickListener() { @Override protected boolean onDoubleClick(MouseEvent e) { gotoSuiteOrParentAction.run(); return true; } }.installOn(myStatisticsTableView); // Fire selection changed and move focus on SHIFT+ENTER final KeyStroke shiftEnterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_MASK); SMRunnerUtil.registerAsAction(shiftEnterKey, "select-test-proxy-in-test-view", new Runnable() { public void run() { showSelectedProxyInTestsTree(); } }, myStatisticsTableView); // Expand selected or go to parent on ENTER final KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); SMRunnerUtil.registerAsAction(enterKey, "go-to-selected-suite-or-parent", gotoSuiteOrParentAction, myStatisticsTableView); // Contex menu in Table PopupHandler.installPopupHandler(myStatisticsTableView, IdeActions.GROUP_TESTTREE_POPUP, ActionPlaces.TESTTREE_VIEW_POPUP); // set this statistic tab as dataprovider for test's table view DataManager.registerDataProvider(myStatisticsTableView, this); }
Example 14
Source File: DesktopEditorsSplitters.java From consulo with Apache License 2.0 | 4 votes |
public DesktopEditorsSplitters(FileEditorManagerImpl manager, DockManager dockManager, boolean createOwnDockableContainer) { myComponent = new IdePanePanel(new BorderLayout()) { @Override protected void paintComponent(Graphics g) { if (showEmptyText()) { Graphics2D gg = IdeBackgroundUtil.withFrameBackground(g, this); super.paintComponent(gg); g.setColor(UIUtil.isUnderDarcula() ? UIUtil.getBorderColor() : new Color(0, 0, 0, 50)); g.drawLine(0, 0, getWidth(), 0); } } }; myComponent.setFocusTraversalPolicy(new MyFocusTraversalPolicy()); myComponent.setTransferHandler(new MyTransferHandler()); DataManager.registerDataProvider(myComponent, dataId -> { if (dataId == KEY) { return this; } return null; }); AWTComponentProviderUtil.putMark(myComponent, this); myManager = manager; myFocusWatcher = new MyFocusWatcher(); clear(); if (createOwnDockableContainer) { DockableEditorTabbedContainer dockable = new DockableEditorTabbedContainer(myManager.getProject(), this, false); Disposer.register(manager.getProject(), dockable); dockManager.register(dockable); } KeymapManagerListener keymapListener = keymap -> { myComponent.invalidate(); myComponent.repaint(); }; KeymapManager.getInstance().addKeymapManagerListener(keymapListener, this); Application.get().getMessageBus().connect(this).subscribe(UISettingsListener.TOPIC, source -> { if (!myManager.getProject().isOpen()) { return; } for (VirtualFile file : getOpenFiles()) { updateFileBackgroundColor(file); updateFileIcon(file); updateFileColor(file); } }); }
Example 15
Source File: Notification.java From consulo with Apache License 2.0 | 4 votes |
public static void setDataProvider(@Nonnull Notification notification, @Nonnull JComponent component) { DataManager.registerDataProvider(component, dataId -> KEY == dataId ? notification : null); }
Example 16
Source File: BranchActionGroupPopup.java From consulo with Apache License 2.0 | 4 votes |
private BranchActionGroupPopup(@Nullable WizardPopup aParent, @Nonnull ListPopupStep aStep, @Nullable Object parentValue) { super(aParent, aStep, DataContext.EMPTY_CONTEXT, parentValue); // don't store children popup userSize; myKey = null; DataManager.registerDataProvider(getList(), dataId -> POPUP_MODEL == dataId ? getListModel() : null); }
Example 17
Source File: XVariablesView.java From consulo with Apache License 2.0 | 4 votes |
public XVariablesView(@Nonnull XDebugSessionImpl session) { super(session.getProject(), session.getDebugProcess().getEditorsProvider(), session.getValueMarkers()); myComponent = new BorderLayoutPanel(); myComponent.add(super.getPanel()); DataManager.registerDataProvider(myComponent, this); }
Example 18
Source File: JBList.java From consulo with Apache License 2.0 | 4 votes |
public void setDataProvider(@Nonnull DataProvider provider) { DataManager.registerDataProvider(this, provider); }
Example 19
Source File: DirDiffViewer.java From consulo with Apache License 2.0 | 4 votes |
public DirDiffViewer(@Nonnull DiffContext context, @Nonnull ContentDiffRequest request) { myContext = context; myRequest = request; List<DiffContent> contents = request.getContents(); DiffElement element1 = createDiffElement(contents.get(0)); DiffElement element2 = createDiffElement(contents.get(1)); Project project = context.getProject(); if (project == null) project = DefaultProjectFactory.getInstance().getDefaultProject(); DirDiffTableModel model = new DirDiffTableModel(project, element1, element2, new DirDiffSettings()); myDirDiffPanel = new DirDiffPanel(model, new DirDiffWindow((DirDiffFrame)null) { @Override public Window getWindow() { return null; } @Override public Disposable getDisposable() { return DirDiffViewer.this; } @Override public void setTitle(String title) { } }); myPanel = new JPanel(new BorderLayout()); myPanel.add(myDirDiffPanel.getPanel(), BorderLayout.CENTER); DataManager.registerDataProvider(myPanel, new DataProvider() { @Override public Object getData(@Nonnull @NonNls Key dataId) { if (PlatformDataKeys.HELP_ID == dataId) { return "reference.dialogs.diff.folder"; } return myDirDiffPanel.getData(dataId); } }); }
Example 20
Source File: MindMapDocumentEditor.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
public MindMapDocumentEditor( final Project project, final VirtualFile file ) { this.project = project; this.file = file; this.panelController = new MindMapPanelControllerImpl(this); this.mindMapPanel = new MindMapPanel(panelController); this.mindMapPanel.putTmpObject("project", project); this.mindMapPanel.putTmpObject("editor", this); this.mindMapPanel.addMindMapListener(this); this.mainScrollPane = new JScrollPane(this.mindMapPanel, JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JBScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); // NB! JBScrollPane sometime doesn't show scrollbars so that it replaced by swing panel this.mainScrollPane.getVerticalScrollBar().setUnitIncrement(16); this.mainScrollPane.getVerticalScrollBar().setBlockIncrement(128); this.mainScrollPane.getHorizontalScrollBar().setUnitIncrement(16); this.mainScrollPane.getHorizontalScrollBar().setBlockIncrement(128); this.mainScrollPane.setWheelScrollingEnabled(true); this.mainScrollPane.setAutoscrolls(true); final Document document = FileDocumentManager.getInstance().getDocument(this.file); this.documents = new Document[] {document}; this.mindMapPanel.setDropTarget(new DropTarget(this.mindMapPanel, this)); loadMindMapFromDocument(); this.undoHelper = new UndoHelper(this.project, this); this.undoHelper.addWatchedDocument(getDocument()); this.documentListener = new DocumentAdapter() { @Override public void documentChanged(DocumentEvent e) { loadMindMapFromDocument(); } }; this.getDocument().addDocumentListener(this.documentListener); DataManager.registerDataProvider(this.mainScrollPane, this); this.findTextPanel = new FindTextPanel(this); this.mainScrollPane.setColumnHeaderView(this.findTextPanel); this.mainScrollPane.getHorizontalScrollBar().addAdjustmentListener(this); this.mainScrollPane.getVerticalScrollBar().addAdjustmentListener(this); this.mainPanel = new JBPanel(new BorderLayout()); this.mainPanel.add(this.mainScrollPane, BorderLayout.CENTER); this.mainPanel.add(this.findTextPanel, BorderLayout.NORTH); }