Skip to content

Commit

Permalink
Merge pull request #10 from skyrylyuk/master
Browse files Browse the repository at this point in the history
Add Setting description and screenshots. Implement refresh project tree after save Settings
  • Loading branch information
dmytrodanylyk committed Nov 14, 2015
2 parents fc51f78 + e201cf7 commit 3efe36f
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 5 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ Usage
1. Rick click on layout folder (or any other)
2. In context menu click Group/Ungroup

Settings

Plugin setting can be found by path 'Settings'('Preferences' on Mac Os) -> 'Other Settings' -> 'Folding Plugin'

![](screenshots/Settings.png)

By default, grouping happens by part of filename which situated before first symbol underscore(_). Also, this part
of filename is not hide. Patter for grouping setup as regular expression and can be change 'Setting' -> 'Other Setting'
-> 'Android Folding' -> 'Use custom pattern'. 'Hide Folding Prefix' take potability hide part of filename with
complete with pattern.

| Default | Folding default | Folding with hide prefix |
| ------------- |:----------------:| :-----------------------:|
| ![](screenshots/Project_Tree_Default.png) | ![](screenshots/Project_Tree_Folding.png) | ![](screenshots/Project_Tree_Hide_Prefix.png) |

## Limitations

The Android project view defines its own structure and does not allow modifying the structure through any extensions. Make sure your are in Project structure view, NOT Android.
Expand Down
Binary file added screenshots/Project_Tree_Default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/Project_Tree_Folding.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/Project_Tree_Hide_Prefix.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/Settings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/com/dd/DirectoryNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
import java.util.ArrayList;
import java.util.List;

public class DirectoryNode extends ProjectViewNode<String> {
public class DirectoryNode extends ProjectViewNode<PsiFile> {

private final String mName;
private List<AbstractTreeNode> mChildNodeList;

protected DirectoryNode(Project project, ViewSettings viewSettings, String name) {
super(project, name, viewSettings);
protected DirectoryNode(Project project, ViewSettings viewSettings, PsiFile directory, String name) {
super(project, directory, viewSettings);
mName = name;
mChildNodeList = new ArrayList<AbstractTreeNode>();
}
Expand Down
6 changes: 4 additions & 2 deletions src/com/dd/ProjectStructureProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ private List<AbstractTreeNode> createComposedFiles(@NotNull Collection<AbstractT
}

for (String composedDirName : composedDirNameSet) {
DirectoryNode composedDirNode = new DirectoryNode(project, viewSettings, composedDirName);
List<AbstractTreeNode> composedFileNodes = filterByDirName(fileNodes, composedDirName);
PsiFile psiFile = (PsiFile) composedFileNodes.get(0).getValue();
DirectoryNode composedDirNode = new DirectoryNode(project, viewSettings, psiFile, composedDirName);
composedDirNode.addAllChildren(composedFileNodes);
resultList.add(composedDirNode);
}

if (!notComposedFileNodes.isEmpty()) {
DirectoryNode composedDirNode = new DirectoryNode(project, viewSettings, OTHER_NODE);
PsiFile psiFile = (PsiFile) notComposedFileNodes.get(0).getValue();
DirectoryNode composedDirNode = new DirectoryNode(project, viewSettings, psiFile, OTHER_NODE);
composedDirNode.addAllChildren(notComposedFileNodes);
resultList.add(composedDirNode);
}
Expand Down
11 changes: 11 additions & 0 deletions src/com/dd/SettingConfigurable.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.dd;

import com.intellij.ide.projectView.ProjectView;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;

Expand All @@ -13,6 +15,7 @@
import java.awt.event.ActionListener;

/**
*
* Created by skyrylyuk on 10/15/15.
*/
public class SettingConfigurable implements Configurable {
Expand Down Expand Up @@ -100,6 +103,14 @@ public void apply() throws ConfigurationException {
PropertiesComponent.getInstance().setValue(PREFIX_PATTERN, customPattern.getText());
PropertiesComponent.getInstance().setValue(PREFIX_HIDE, Boolean.valueOf(hideFoldingPrefix.isSelected()).toString());

if (isModified) {
Project currentProject = Utils.getCurrentProject();

if (currentProject != null) {
ProjectView.getInstance(currentProject).refresh();
}
}

isModified = false;
}

Expand Down

0 comments on commit 3efe36f

Please sign in to comment.