/** * Creates the action with its text, description and icon. * * @param tree LivingDoc repository tree. * @param toWorkingVersion true for current/working version. False otherwise. */ public SwitchVersionAction(final SimpleTree tree, final boolean toWorkingVersion) { super(); this.repositoryTree = tree; this.toCurrentVersion = toWorkingVersion; String text; Icon icon; if (toCurrentVersion) { text = I18nSupport.getValue("toolwindows.action.working.tooltip"); icon = AllIcons.Actions.NewFolder; } else { text = I18nSupport.getValue("toolwindows.action.implemented.tooltip"); icon = AllIcons.Actions.Module; } Presentation presentation = getTemplatePresentation(); presentation.setText(text); presentation.setDescription(text); presentation.setIcon(icon); }
private void setupMetadataPanel(Project project, SimpleToolWindowPanel metadataPanel) { RestClientService restClientService = ServiceManager.getService(project, RestClientService.class); SimpleNode metadataRootNode = new MetadataExplorerRootNode(project, restClientService, "Metadata"); SimpleTree metadataTree = new SimpleTree(); SimpleTreeBuilder metadataTreeBuilder = new SimpleTreeBuilder(metadataTree, (DefaultTreeModel)metadataTree.getModel(), new ExplorerTreeStructure(metadataRootNode), null); Disposer.register(project, metadataTreeBuilder); metadataTree.addTreeExpansionListener(new ExplorerTreeExpansionListener(metadataTreeBuilder)); metadataTree.setCellRenderer(new ExplorerCellRenderer()); ActionToolbar toolbar = createToolbar(metadataRootNode, metadataTreeBuilder); toolbar.setTargetComponent(metadataPanel); metadataPanel.setToolbar(toolbar.getComponent()); metadataPanel.setContent(ScrollPaneFactory.createScrollPane(metadataTree)); metadataTree.setShowsRootHandles(true); }
private void setupToolingMetadataPanel(Project project, SimpleToolWindowPanel toolingMetadataPanel) { ToolingRestClientService toolingRestClientService = ServiceManager.getService(project, ToolingRestClientService.class); SimpleNode toolingMetadataRootNode = new MetadataExplorerRootNode(project, toolingRestClientService, " Tooling Metadata"); SimpleTree toolingMetadataTree = new SimpleTree(); SimpleTreeBuilder toolingMetadataTreeBuilder = new SimpleTreeBuilder(toolingMetadataTree, (DefaultTreeModel)toolingMetadataTree.getModel(), new ExplorerTreeStructure(toolingMetadataRootNode), null); Disposer.register(project, toolingMetadataTreeBuilder); toolingMetadataTree.addTreeExpansionListener(new ExplorerTreeExpansionListener(toolingMetadataTreeBuilder)); toolingMetadataTree.setCellRenderer(new ExplorerCellRenderer()); ActionToolbar toolbar = createToolbar(toolingMetadataRootNode, toolingMetadataTreeBuilder); toolbar.setTargetComponent(toolingMetadataPanel); toolingMetadataPanel.setToolbar(toolbar.getComponent()); toolingMetadataPanel.setContent(ScrollPaneFactory.createScrollPane(toolingMetadataTree)); toolingMetadataTree.setShowsRootHandles(true); }
private void initTree() { tree = new SimpleTree() { private final JLabel myLabel = new JLabel("This is not a SeedStack project."); @Override protected void paintComponent(Graphics g) { super.paintComponent(g); if (!isSeedStackProject()) { myLabel.setFont(getFont()); myLabel.setBackground(getBackground()); myLabel.setForeground(getForeground()); Rectangle bounds = getBounds(); Dimension size = myLabel.getPreferredSize(); myLabel.setBounds(0, 0, size.width, size.height); int x = (bounds.width - size.width) / 2; Graphics g2 = g.create(bounds.x + x, bounds.y + 20, bounds.width, bounds.height); try { myLabel.paint(g2); } finally { g2.dispose(); } } } }; tree.getEmptyText().clear(); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); }
SeedStackStructure(Project project, SimpleTree tree) { this.project = project; tree.setRootVisible(true); tree.setShowsRootHandles(true); rootNode = new RootNode(); treeBuilder = new SimpleTreeBuilder(tree, (DefaultTreeModel) tree.getModel(), this, null); Disposer.register(this.project, treeBuilder); treeBuilder.initRoot(); }
static <T extends SimpleNode> List<T> getSelectedNodes(SimpleTree tree, Class<T> nodeClass) { final List<T> filtered = new ArrayList<>(); for (SimpleNode node : getSelectedNodes(tree)) { if ((nodeClass != null) && (!nodeClass.isInstance(node))) { filtered.clear(); break; } //noinspection unchecked filtered.add((T) node); } return filtered; }
private static List<SimpleNode> getSelectedNodes(SimpleTree tree) { List<SimpleNode> nodes = new ArrayList<>(); TreePath[] treePaths = tree.getSelectionPaths(); if (treePaths != null) { for (TreePath treePath : treePaths) { nodes.add(tree.getNodeFor(treePath)); } } return nodes; }
SeedStackNavigatorPanel(Project project, SimpleTree tree) { super(true, true); this.project = project; this.tree = tree; final ActionManager actionManager = ActionManager.getInstance(); ActionToolbar actionToolbar = actionManager.createActionToolbar( "SeedStack Navigator Toolbar", (DefaultActionGroup) actionManager.getAction("SeedStack.NavigatorActionsToolbar"), true ); actionToolbar.setTargetComponent(tree); setToolbar(actionToolbar.getComponent()); setContent(ScrollPaneFactory.createScrollPane(tree)); }
@Override public void handleDoubleClickOrEnter(SimpleTree tree, InputEvent inputEvent) { String actionId = getActionId(); if (actionId != null) { NavigatorUtil.executeAction(actionId, inputEvent); } else if (!(this instanceof SeedStackGroupNode)) { Optional.ofNullable(getNavigatable()).ifPresent(navigatable -> navigatable.navigate(true)); } }
/** * @param tree LivingDoc repository tree. */ public TagImplementedAction(final SimpleTree tree) { super(I18nSupport.getValue("toolwindows.action.tag.tooltip"), I18nSupport.getValue("toolwindows.action.tag.tooltip"), AllIcons.Actions.GroupByPackage); this.repositoryTree = tree; }
/** * Creates the action with its text, description and icon. * * @param tree LivingDoc repository tree. */ public OpenRemoteDocumentAction(final SimpleTree tree) { super(I18nSupport.getValue("toolwindows.action.open.tooltip"), I18nSupport.getValue("toolwindows.action.open.tooltip"), AllIcons.Javaee.WebModule); this.repositoryTree = tree; }
private void createRepositoryTree() { tree = new SimpleTree(); tree.setCellRenderer(new TreeCellRendererLivingDoc()); tree.setRootVisible(true); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); treeModel = new DefaultTreeModel(rootNode, true); tree.setModel(treeModel); JBScrollPane scrollPane = new JBScrollPane(tree); mainContent.add(scrollPane, BorderLayout.CENTER); }
@Override public void handleDoubleClickOrEnter(SimpleTree tree, InputEvent inputEvent) { mySubstitutionParameters.setShowContent(this); final LayoutTree layoutTree = (LayoutTree)tree; final CompositePackagingElementNode parentNode = getParentNode(); if (parentNode != null) { layoutTree.addSubtreeToUpdate(parentNode); } }
@Nullable private Object getSelected() { if (isSimpleTree()) { FilteringTreeStructure.FilteringNode selected = (FilteringTreeStructure.FilteringNode)((SimpleTree)myTree).getSelectedNode(); return selected != null ? selected.getDelegate() : null; } else { final Object[] nodes = myTree.getSelectedNodes(Object.class, null); return nodes.length > 0 ? nodes[0] : null; } }
@Override public void handleDoubleClickOrEnter(SimpleTree tree, InputEvent inputEvent) { final Project project = getExternalProjectsView().getProject(); ProgramRunnerUtil.executeConfiguration(project, mySettings, DefaultRunExecutor.getRunExecutorInstance()); final RunManagerEx runManagerEx = RunManagerEx.getInstanceEx(project); runManagerEx.setSelectedConfiguration(mySettings); }
@Override public void handleDoubleClickOrEnter(SimpleTree tree, InputEvent inputEvent) { if (inputEvent instanceof MouseEvent) { inputEvent.consume(); } final DomElement domElement = getDomElement(); if (domElement.isValid()) { final DomElementNavigationProvider provider = DomElementsNavigationManager.getManager(domElement.getManager().getProject()) .getDomElementsNavigateProvider(DomElementsNavigationManager.DEFAULT_PROVIDER_NAME); provider.navigate(domElement, true); } }
public CapturesToolWindow(@NotNull final Project project) { myProject = project; DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode()); myTree = new SimpleTree(model); myTree.setRootVisible(false); myStructure = new CapturesTreeStructure(myProject); myBuilder = new AbstractTreeBuilder(myTree, model, myStructure, null); Disposer.register(this, myBuilder); Disposer.register(project, this); myBuilder.initRootNode(); myBuilder.getInitialized().doWhenDone(new Runnable() { @Override public void run() { myBuilder.getUi().expandAll(null); } }); myTree.addHierarchyListener(this); CaptureService.getInstance(myProject).addListener(this); CaptureService.getInstance(myProject).update(); myStructure.update(); myTree.setPopupGroup(getPopupActions(), "Context"); myTree.putClientProperty(DataManager.CLIENT_PROPERTY_DATA_PROVIDER, this); }
public AtomController(@NotNull Project project, @NotNull JBScrollPane scrollPane) { scrollPane.getHorizontalScrollBar().setUnitIncrement(20); scrollPane.getVerticalScrollBar().setUnitIncrement(20); myTree = new SimpleTree(); myTree.setRowHeight(TreeUtil.TREE_ROW_HEIGHT); myTree.setRootVisible(false); myTree.setLineStyleAngled(); myTree.getEmptyText().setText(SELECT_CAPTURE); myLoadingPanel = new JBLoadingPanel(new BorderLayout(), project); myLoadingPanel.add(myTree); scrollPane.setViewportView(myLoadingPanel); myAtomTreeRenderer = new AtomTreeRenderer(); }
public StateController(@NotNull GfxTraceEditor editor, @NotNull JBScrollPane scrollPane) { myEditor = editor; myTree = new SimpleTree(); myTree.setRowHeight(TreeUtil.TREE_ROW_HEIGHT); myTree.setRootVisible(false); myTree.setCellRenderer(new StateTreeRenderer()); myTree.getEmptyText().setText(SELECT_CAPTURE); myLoadingPanel = new JBLoadingPanel(new BorderLayout(), editor.getProject()); myLoadingPanel.add(myTree); scrollPane.setViewportView(myLoadingPanel); }
private void initTree() { myTree = new SimpleTree() { private final JLabel myLabel = new JLabel( ProjectBundle.message("maven.navigator.nothing.to.display", MavenUtil.formatHtmlImage(ADD_ICON_URL), MavenUtil.formatHtmlImage(SYNC_ICON_URL))); @Override protected void paintComponent(Graphics g) { super.paintComponent(g); if (myProjectsManager.hasProjects()) return; myLabel.setFont(getFont()); myLabel.setBackground(getBackground()); myLabel.setForeground(getForeground()); Rectangle bounds = getBounds(); Dimension size = myLabel.getPreferredSize(); myLabel.setBounds(0, 0, size.width, size.height); int x = (bounds.width - size.width) / 2; Graphics g2 = g.create(bounds.x + x, bounds.y + 20, bounds.width, bounds.height); try { myLabel.paint(g2); } finally { g2.dispose(); } } }; myTree.getEmptyText().clear(); myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); }
@Override public void handleSelection(@NotNull final SimpleTree tree) { myQueriesTreeContext.queryWorkItems(new TfsExecutionUtil.Process<WorkItemsQueryResult>() { @NotNull @Override public WorkItemsQueryResult run() throws TfsException, VcsException { return new WorkItemsQueryResult(myQuery.queryWorkItems(getServer(), tree, null)); } }); }
public JahiaTreeStructure(Project project, SimpleTree tree) { tree.setRootVisible(false); tree.setShowsRootHandles(true); myTreeBuilder = new SimpleTreeBuilder(tree, (DefaultTreeModel)tree.getModel(), this, null); Disposer.register(project, myTreeBuilder); myRoot = new RootNode(project); myTreeBuilder.expand(myRoot, null); myTreeBuilder.initRoot(); }
public static <T extends CndSimpleNode> List<T> getSelectedNodes(SimpleTree tree, Class<T> nodeClass) { final List<T> filtered = new ArrayList<>(); for (SimpleNode node : getSelectedNodes(tree)) { if ((nodeClass != null) && (!nodeClass.isInstance(node))) { filtered.clear(); break; } filtered.add((T)node); } return filtered; }
private void initTree() { myTree = new SimpleTree() { // private final JLabel myLabel = new JLabel( // ProjectBundle.message("maven.navigator.nothing.to.display", MavenUtil.formatHtmlImage(ADD_ICON_URL), // MavenUtil.formatHtmlImage(SYNC_ICON_URL))); // private final JLabel myLabel = new JLabel("There are no CND definitions files to display."); // // @Override // protected void paintComponent(Graphics g) { // super.paintComponent(g); // // if (myProjectsManager.hasProjects()) return; // // myLabel.setFont(getFont()); // myLabel.setBackground(getBackground()); // myLabel.setForeground(getForeground()); // Rectangle bounds = getBounds(); // Dimension size = myLabel.getPreferredSize(); // myLabel.setBounds(0, 0, size.width, size.height); // // int x = (bounds.width - size.width) / 2; // Graphics g2 = g.create(bounds.x + x, bounds.y + 20, bounds.width, bounds.height); // try { // myLabel.paint(g2); // } // finally { // g2.dispose(); // } // } // }; myTree.getEmptyText().clear(); myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); }
public void handleDoubleClickOrEnter(SimpleTree tree, InputEvent inputEvent) { if (inputEvent instanceof MouseEvent) { inputEvent.consume(); } final DomElement domElement = getDomElement(); if (domElement.isValid()) { final DomElementNavigationProvider provider = DomElementsNavigationManager.getManager(domElement.getManager().getProject()) .getDomElementsNavigateProvider(DomElementsNavigationManager.DEFAULT_PROVIDER_NAME); provider.navigate(domElement, true); } }
private void setupDataSplitPane(Project project) { RestClientService restClientService = ServiceManager.getService(project, RestClientService.class); SimpleNode dataRootNode = new DataExplorerRootNode(project, restClientService, "sObjects"); SimpleTree dataTree = new SimpleTree(); dataTree.setShowsRootHandles(true); SimpleTreeBuilder dataTreeBuilder = new SimpleTreeBuilder(dataTree, (DefaultTreeModel) dataTree.getModel(), new ExplorerTreeStructure(dataRootNode), null); Disposer.register(project, dataTreeBuilder); dataTree.addTreeExpansionListener(new ExplorerTreeExpansionListener(dataTreeBuilder)); dataTree.setCellRenderer(new ExplorerCellRenderer()); JBTable dataTable = new JBTable(); dataTable.setStriped(true); dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // Setup left panel which will display all the available sObjects SimpleToolWindowPanel treePanel = new SimpleToolWindowPanel(true, true); ActionToolbar treeToolbar = createTreeToolbar(dataRootNode, dataTreeBuilder); treeToolbar.setTargetComponent(treePanel); treePanel.setToolbar(treeToolbar.getComponent()); treePanel.setContent(ScrollPaneFactory.createScrollPane(dataTree)); dataSplitPane.add(treePanel, JSplitPane.LEFT); // Setup right panel which will display the data in the selected sObject SimpleToolWindowPanel dataPanel = new SimpleToolWindowPanel(true, true); ActionToolbar dataToolbar = createDataToolbar(dataTable); dataToolbar.setTargetComponent(dataPanel); dataPanel.setToolbar(dataToolbar.getComponent()); dataPanel.setContent(ScrollPaneFactory.createScrollPane(dataTable)); dataSplitPane.add(dataPanel, JSplitPane.RIGHT); dataSplitPane.getLeftComponent().setPreferredSize(new Dimension(250, 0)); dataSplitPane.getRightComponent().setPreferredSize(new Dimension(0, 0)); dataTree.addMouseListener(new DataExplorerMouseListener(dataTable, dataTree)); }
private void setupToolingDataSplitPane(Project project) { ToolingRestClientService toolingRestClientService = ServiceManager.getService(project, ToolingRestClientService.class); SimpleNode toolingDataRootNode = new DataExplorerRootNode(project, toolingRestClientService, "Tooling sObjects"); SimpleTree toolingDataTree = new SimpleTree(); toolingDataTree.setShowsRootHandles(true); SimpleTreeBuilder toolingDataTreeBuilder = new SimpleTreeBuilder(toolingDataTree, (DefaultTreeModel) toolingDataTree.getModel(), new ExplorerTreeStructure(toolingDataRootNode), null); Disposer.register(project, toolingDataTreeBuilder); toolingDataTree.addTreeExpansionListener(new ExplorerTreeExpansionListener(toolingDataTreeBuilder)); toolingDataTree.setCellRenderer(new ExplorerCellRenderer()); JBTable toolingDataTable = new JBTable(); toolingDataTable.setStriped(true); toolingDataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // Setup left panel which will display all the available sObjects SimpleToolWindowPanel treePanel = new SimpleToolWindowPanel(true, true); ActionToolbar treeToolbar = createTreeToolbar(toolingDataRootNode, toolingDataTreeBuilder); treeToolbar.setTargetComponent(treePanel); treePanel.setToolbar(treeToolbar.getComponent()); treePanel.setContent(ScrollPaneFactory.createScrollPane(toolingDataTree)); toolingDataSplitPane.add(treePanel, JSplitPane.LEFT); // Setup right panel which will display the data in the selected sObject SimpleToolWindowPanel dataPanel = new SimpleToolWindowPanel(true, true); ActionToolbar dataToolbar = createDataToolbar(toolingDataTable); dataToolbar.setTargetComponent(dataPanel); dataPanel.setToolbar(dataToolbar.getComponent()); dataPanel.setContent(ScrollPaneFactory.createScrollPane(toolingDataTable)); toolingDataSplitPane.add(dataPanel, JSplitPane.RIGHT); toolingDataSplitPane.getLeftComponent().setPreferredSize(new Dimension(250, 0)); toolingDataSplitPane.getRightComponent().setPreferredSize(new Dimension(0, 0)); toolingDataTree.addMouseListener(new DataExplorerMouseListener(toolingDataTable, toolingDataTree)); }
public void updateView(GradleNode rootDependency, final GradleNode selectedDependency) { // TODO replace this hack with something that populates the GradleNode graph DefaultMutableTreeNode fullRoot = new DefaultMutableTreeNode(new GradleNode("Project Dependencies")); if(rootDependency == null) { DefaultMutableTreeNode loading = new DefaultMutableTreeNode(new GradleNode("Loading...")); fullRoot.add(loading); } else { DefaultMutableTreeNode flattenedRoot = convertToSortedTreeNode(rootDependency); DefaultMutableTreeNode hierarchyRoot = convertToHierarchyTreeNode(rootDependency); fullRoot.add(flattenedRoot); fullRoot.add(hierarchyRoot); } TreeModel treeModel = new DefaultTreeModel(fullRoot); final SimpleTree fullTree = new SimpleTree(treeModel); fullTree.setCellRenderer(dependencyCellRenderer); // expand path for first level from root //fullTree.expandPath(new TreePath(hierarchyRoot.getNextNode().getPath())); SwingUtilities.invokeLater(new Runnable() { public void run() { if(gradleBaseDir != null) { toolWindow.setTitle("- " + gradleBaseDir); } splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(fullTree)); splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(information)); } }); }
public SimpleTree getRepositoryTree() { return this.tree; }
@Override public void handleDoubleClickOrEnter(SimpleTree tree, InputEvent inputEvent) { if (mySourceItem.isProvideElements() && getChildren().length == 0) { getArtifactEditor().getLayoutTreeComponent().putIntoDefaultLocations(Collections.singletonList(mySourceItem)); } }
private boolean isSimpleTree() { return myTree instanceof SimpleTree; }
@Override public void handleDoubleClickOrEnter(SimpleTree tree, InputEvent inputEvent) { String actionId = getActionId(); getExternalProjectsView().handleDoubleClickOrEnter(this, actionId, inputEvent); }
public GenerateByPatternDialog(Project project, PatternDescriptor[] descriptors) { super(project); myProject = project; setTitle("Generate by Pattern"); setOKButtonText("Generate"); myMap = new MultiMap<String, PatternDescriptor>(); for (PatternDescriptor descriptor : descriptors) { myMap.putValue(descriptor.getParentId(), descriptor); } DefaultMutableTreeNode root = createNode(null); myTree = new SimpleTree() { }; myTree.setRootVisible(false); myTree.setCellRenderer(new DefaultTreeCellRenderer() { @NotNull @Override public Component getTreeCellRendererComponent(@NotNull JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { Component component = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); Object object = ((DefaultMutableTreeNode)value).getUserObject(); if (object instanceof PatternDescriptor) { setText(((PatternDescriptor)object).getName()); setIcon(((PatternDescriptor)object).getIcon()); } return component; } }); myTree.setModel(new DefaultTreeModel(root)); myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(@NotNull TreeSelectionEvent e) { update(); } }); myEditor = TemplateEditorUtil.createEditor(true, ""); mySplitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myTree)); JPanel details = new JPanel(new BorderLayout()); details.add(myEditor.getComponent(), BorderLayout.CENTER); mySplitter.setSecondComponent(details); mySplitter.setHonorComponentsMinimumSize(true); mySplitter.setShowDividerControls(true); myTree.setSelectionRow(0); init(); }