-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added procedure and function grouping in metadata view. #78
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.neueda.jetbrains.plugin.graphdb.jetbrains.ui.datasource.metadata.tree; | ||
|
||
import javax.swing.tree.DefaultMutableTreeNode; | ||
import java.util.ArrayList; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Function; | ||
|
||
class Directory implements TreeNode, TreeNodeDirectory { | ||
private final Map<String, Directory> directories; | ||
private final List<Leaf> functions; | ||
private final String name; | ||
private final Function<TreeNode, DefaultMutableTreeNode> directoryProducer; | ||
private final Function<TreeNode, DefaultMutableTreeNode> functionProducer; | ||
|
||
public Directory( | ||
String name, | ||
Function<TreeNode, DefaultMutableTreeNode> directoryProducer, | ||
Function<TreeNode, DefaultMutableTreeNode> functionProducer | ||
) { | ||
this.name = name; | ||
this.directoryProducer = directoryProducer; | ||
this.functionProducer = functionProducer; | ||
this.directories = new LinkedHashMap<>(); | ||
this.functions = new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
public Directory getDirectory(String name) { | ||
return directories.computeIfAbsent( | ||
name, | ||
(k) -> new Directory(k, directoryProducer, functionProducer) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is 'k'? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'k' stands for key, however I changed it to 'newName' for more understanding |
||
); | ||
} | ||
|
||
@Override | ||
public void addLeaf(String name) { | ||
functions.add(new Leaf(name, functionProducer)); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public DefaultMutableTreeNode getMutableTreeNode() { | ||
DefaultMutableTreeNode root = directoryProducer.apply(this); | ||
|
||
directories.values().forEach((directory) -> root.add(directory.getMutableTreeNode())); | ||
functions.forEach((function) -> root.add(function.getMutableTreeNode())); | ||
|
||
return root; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.neueda.jetbrains.plugin.graphdb.jetbrains.ui.datasource.metadata.tree; | ||
|
||
import javax.swing.tree.DefaultMutableTreeNode; | ||
import java.util.function.Function; | ||
|
||
class Leaf implements TreeNode { | ||
private final String name; | ||
private Function<TreeNode, DefaultMutableTreeNode> mutableTreeNodeProducer; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mutableTreeNodeProducer should be final There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
|
||
public Leaf(String name, Function<TreeNode, DefaultMutableTreeNode> mutableTreeNodeProducer) { | ||
this.name = name; | ||
this.mutableTreeNodeProducer = mutableTreeNodeProducer; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public DefaultMutableTreeNode getMutableTreeNode() { | ||
return mutableTreeNodeProducer.apply(this); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.neueda.jetbrains.plugin.graphdb.jetbrains.ui.datasource.metadata.tree; | ||
|
||
import com.intellij.icons.AllIcons; | ||
import com.intellij.ui.treeStructure.PatchedDefaultMutableTreeNode; | ||
import com.neueda.jetbrains.plugin.graphdb.jetbrains.component.datasource.state.DataSourceApi; | ||
import com.neueda.jetbrains.plugin.graphdb.jetbrains.ui.datasource.tree.MetadataTreeNodeModel; | ||
import com.neueda.jetbrains.plugin.graphdb.jetbrains.ui.datasource.tree.Neo4jTreeNodeType; | ||
|
||
import javax.swing.tree.DefaultMutableTreeNode; | ||
import java.util.function.Function; | ||
|
||
public final class MutableTreeNodeProducers { | ||
|
||
public static Function<TreeNode, DefaultMutableTreeNode> function(Neo4jTreeNodeType type, DataSourceApi dataSourceApi) { | ||
return treeNode -> new PatchedDefaultMutableTreeNode( | ||
new MetadataTreeNodeModel(type, dataSourceApi, treeNode.getName(), AllIcons.Nodes.Function) | ||
); | ||
} | ||
|
||
public static Function<TreeNode, DefaultMutableTreeNode> directory(Neo4jTreeNodeType type, DataSourceApi dataSourceApi) { | ||
return treeNode -> new PatchedDefaultMutableTreeNode( | ||
new MetadataTreeNodeModel(type, dataSourceApi, treeNode.getName(), AllIcons.Nodes.Package) | ||
); | ||
} | ||
|
||
private MutableTreeNodeProducers() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Constructor should be in the top of the class There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.neueda.jetbrains.plugin.graphdb.jetbrains.ui.datasource.metadata.tree; | ||
|
||
import javax.swing.tree.DefaultMutableTreeNode; | ||
import java.util.ArrayList; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Function; | ||
|
||
public class Root implements TreeNode, TreeNodeDirectory { | ||
|
||
private final DefaultMutableTreeNode root; | ||
private final Map<String, Directory> directories; | ||
private final List<Leaf> functions; | ||
private final Function<TreeNode, DefaultMutableTreeNode> directoryProducer; | ||
private final Function<TreeNode, DefaultMutableTreeNode> functionProducer; | ||
|
||
public Root( | ||
DefaultMutableTreeNode root, | ||
Function<TreeNode, DefaultMutableTreeNode> directoryProducer, | ||
Function<TreeNode, DefaultMutableTreeNode> functionProducer | ||
) { | ||
this.root = root; | ||
this.directoryProducer = directoryProducer; | ||
this.functionProducer = functionProducer; | ||
this.directories = new LinkedHashMap<>(); | ||
this.functions = new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
public Directory getDirectory(String name) { | ||
return directories.computeIfAbsent( | ||
name, | ||
(k) -> new Directory(k, directoryProducer, functionProducer) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't understand what is 'k'. Please use full names for the variables There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'k' stands for key, however I changed it to 'newName' for more understanding |
||
); | ||
} | ||
|
||
@Override | ||
public void addLeaf(String name) { | ||
functions.add(new Leaf(name, functionProducer)); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "root"; | ||
} | ||
|
||
@Override | ||
public DefaultMutableTreeNode getMutableTreeNode() { | ||
directories.values().forEach((directory) -> root.add(directory.getMutableTreeNode())); | ||
functions.forEach((function) -> root.add(function.getMutableTreeNode())); | ||
|
||
return root; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.neueda.jetbrains.plugin.graphdb.jetbrains.ui.datasource.metadata.tree; | ||
|
||
import javax.swing.tree.DefaultMutableTreeNode; | ||
|
||
public interface TreeNode { | ||
|
||
public String getName(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Access modifier is 'public' is redudant here. In interfaces access modifier by default is public There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
|
||
public DefaultMutableTreeNode getMutableTreeNode(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Access modifier is 'public' is redudant here. In interfaces access modifier by default is public There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.neueda.jetbrains.plugin.graphdb.jetbrains.ui.datasource.metadata.tree; | ||
|
||
public interface TreeNodeDirectory extends TreeNode { | ||
|
||
public void addLeaf(String name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Access modifier is 'public' is redudant here. In interfaces access modifier by default is public There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
|
||
public TreeNodeDirectory getDirectory(String name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Access modifier is 'public' is redudant here. In interfaces access modifier by default is public There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use imports with '*'. Use only imports what you need