use of com.intellij.ui.LoadingNode in project intellij-community by JetBrains.
the class NotificationMessageElement method updateStyle.
protected void updateStyle(@NotNull JEditorPane editorPane, @Nullable JTree tree, Object value, boolean selected, boolean hasFocus) {
final HTMLDocument htmlDocument = (HTMLDocument) editorPane.getDocument();
final Style style = htmlDocument.getStyleSheet().getStyle(MSG_STYLE);
if (value instanceof LoadingNode) {
StyleConstants.setForeground(style, JBColor.GRAY);
} else {
if (selected) {
StyleConstants.setForeground(style, hasFocus ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground());
} else {
StyleConstants.setForeground(style, UIUtil.getTreeTextForeground());
}
}
if (UIUtil.isUnderGTKLookAndFeel() || UIUtil.isUnderNimbusLookAndFeel() && selected && hasFocus || tree != null && WideSelectionTreeUI.isWideSelection(tree)) {
editorPane.setOpaque(false);
} else {
editorPane.setOpaque(selected && hasFocus);
}
htmlDocument.setCharacterAttributes(0, htmlDocument.getLength(), style, false);
}
use of com.intellij.ui.LoadingNode in project azure-tools-for-java by Microsoft.
the class ServerExplorerToolWindowFactory method createToolWindowContent.
@Override
@AzureOperation(name = "common|explorer.initialize", type = AzureOperation.Type.SERVICE)
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {
// initialize azure service module
AzureModule azureModule = new AzureModuleImpl(project);
HDInsightUtil.setHDInsightRootModule(azureModule);
azureModule.setSparkServerlessModule(new CosmosSparkClusterRootModuleImpl(azureModule));
azureModule.setArcadiaModule(new ArcadiaSparkClusterRootModuleImpl(azureModule));
// initialize aris service module
SqlBigDataClusterModule arisModule = new SqlBigDataClusterModule(project);
// initialize with all the service modules
DefaultTreeModel treeModel = new DefaultTreeModel(initRoot(project, ImmutableList.of(azureModule, arisModule)));
treeModelMap.put(project, treeModel);
// initialize tree
final JTree tree = new Tree(treeModel);
tree.setRootVisible(false);
tree.setCellRenderer(new NodeTreeCellRenderer());
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
new TreeSpeedSearch(tree);
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot();
final DefaultMutableTreeNode azureRoot = (DefaultMutableTreeNode) root.getChildAt(0);
final List<? extends com.microsoft.azure.toolkit.intellij.common.component.Tree.TreeNode<?>> modules = AzureExplorer.getModules().stream().map(m -> new com.microsoft.azure.toolkit.intellij.common.component.Tree.TreeNode<>(m, tree)).collect(Collectors.toList());
modules.forEach(azureRoot::add);
azureModule.setClearResourcesListener(() -> modules.forEach(m -> m.clearChildren()));
com.microsoft.azure.toolkit.intellij.common.component.Tree.installPopupMenu(tree);
treeModel.reload();
DataManager.registerDataProvider(tree, dataId -> {
if (StringUtils.equals(dataId, Action.SOURCE)) {
final DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (Objects.nonNull(selectedNode)) {
return selectedNode.getUserObject();
}
}
return null;
});
// add a click handler for the tree
tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) {
treeNodeDblClicked(e, tree, project);
}
}
@Override
public void mousePressed(MouseEvent e) {
treeMousePressed(e, tree);
}
});
// add keyboard handler for the tree
tree.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
TreePath treePath = tree.getAnchorSelectionPath();
if (treePath == null) {
return;
}
final Object raw = treePath.getLastPathComponent();
if (raw instanceof com.microsoft.azure.toolkit.intellij.common.component.Tree.TreeNode || raw instanceof LoadingNode) {
return;
}
SortableTreeNode treeNode = (SortableTreeNode) raw;
Node node = (Node) treeNode.getUserObject();
Rectangle rectangle = tree.getRowBounds(tree.getRowForPath(treePath));
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (!node.isLoading()) {
node.getClickAction().fireNodeActionEvent();
}
} else if (e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU) {
if (node.hasNodeActions()) {
JPopupMenu menu = createPopupMenuForNode(node);
menu.show(e.getComponent(), (int) rectangle.getX(), (int) rectangle.getY());
}
}
}
});
// add the tree to the window
toolWindow.getComponent().add(new JBScrollPane(tree));
// set tree and tree path to expand the node later
azureModule.setTree(tree);
azureModule.setTreePath(tree.getPathForRow(0));
// setup toolbar icons
addToolbarItems(toolWindow, project, azureModule);
}
use of com.intellij.ui.LoadingNode in project azure-tools-for-java by Microsoft.
the class ServerExplorerToolWindowFactory method getTreeNodeOnMouseClick.
@Nullable
private Node getTreeNodeOnMouseClick(JTree tree, TreePath treePath) {
final Object raw = treePath.getLastPathComponent();
if (raw instanceof com.microsoft.azure.toolkit.intellij.common.component.Tree.TreeNode || raw instanceof LoadingNode) {
return null;
}
SortableTreeNode treeNode = (SortableTreeNode) raw;
Node node = (Node) treeNode.getUserObject();
// set tree and tree path to expand the node later
node.setTree(tree);
node.setTreePath(treePath);
return node;
}
use of com.intellij.ui.LoadingNode in project android by JetBrains.
the class ApkDiffPanel method createUIComponents.
private void createUIComponents() {
myTreeModel = new DefaultTreeModel(new LoadingNode());
myTree = new Tree(myTreeModel);
myTree.setShowsRootHandles(true);
// show root node only when showing LoadingNode
myTree.setRootVisible(true);
myTree.setPaintBusy(true);
Convertor<TreePath, String> convertor = new Convertor<TreePath, String>() {
@Override
public String convert(TreePath path) {
ApkEntry e = ApkEntry.fromNode(path.getLastPathComponent());
if (e == null) {
return null;
}
return e.getPath();
}
};
TreeSpeedSearch treeSpeedSearch = new TreeSpeedSearch(myTree, convertor, true);
ColumnTreeBuilder builder = new ColumnTreeBuilder(myTree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("File").setPreferredWidth(600).setHeaderAlignment(SwingConstants.LEADING).setRenderer(new NameRenderer(treeSpeedSearch))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Old Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(ApkDiffEntry::getOldSize))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("New Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(ApkDiffEntry::getNewSize))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Diff Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(ApkEntry::getSize)));
myColumnTreePane = (JScrollPane) builder.build();
}
use of com.intellij.ui.LoadingNode in project android by JetBrains.
the class ColumnTreeBuilderTest method testTreeFillsViewportIfSmallerThanViewport.
@Test
public void testTreeFillsViewportIfSmallerThanViewport() throws Exception {
// Prepare
DefaultTreeModel treeModel = new DefaultTreeModel(new LoadingNode());
Tree tree = new Tree(treeModel);
ColumnTreeBuilder builder = new ColumnTreeBuilder(tree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("A").setPreferredWidth(30).setHeaderAlignment(SwingConstants.LEADING).setRenderer(new MyEmptyRenderer())).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("B").setPreferredWidth(60).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new MyEmptyRenderer()));
JScrollPane columnTreePane = (JScrollPane) builder.build();
columnTreePane.setPreferredSize(new Dimension(100, 100));
assertThat(tree.getHeight()).isEqualTo(0);
// Act: Simulate layout
columnTreePane.setSize(new Dimension(100, 100));
columnTreePane.doLayout();
columnTreePane.getViewport().doLayout();
columnTreePane.getViewport().getView().doLayout();
// Assert: Check the tree height has been extended to the whole viewport
assertThat(tree.getHeight()).isGreaterThan(0);
assertThat(tree.getHeight()).isEqualTo(columnTreePane.getViewport().getHeight());
}
Aggregations