use of com.intellij.psi.PsiDirectory in project folding-plugin by dmytrodanylyk.
the class ProjectStructureProvider method modify.
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings viewSettings) {
List<AbstractTreeNode> resultList = new ArrayList<>();
if (parent.getValue() instanceof PsiDirectory) {
PsiDirectory directory = (PsiDirectory) parent.getValue();
String path = directory.getVirtualFile().getPath();
if (SettingsManager.isComposed(path)) {
resultList.addAll(createComposedFiles(children, viewSettings));
} else {
resultList.addAll(children);
}
} else {
resultList.addAll(children);
}
return resultList;
}
use of com.intellij.psi.PsiDirectory in project folding-plugin by dmytrodanylyk.
the class ComposeAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent actionEvent) {
Object nav = actionEvent.getData(CommonDataKeys.NAVIGATABLE);
if (nav instanceof PsiDirectory) {
PsiDirectory directory = (PsiDirectory) nav;
String path = directory.getVirtualFile().getPath();
if (SettingsManager.isComposed(path)) {
SettingsManager.removeComposedFolder(path);
} else {
SettingsManager.addComposedFolder(path);
}
Project project = actionEvent.getData(CommonDataKeys.PROJECT);
if (project != null) {
ProjectView.getInstance(project).refresh();
}
}
}
use of com.intellij.psi.PsiDirectory in project intellij-plugins by StepicOrg.
the class NavigationUtils method findNodeWithObject.
@Nullable
private static DefaultMutableTreeNode findNodeWithObject(@NotNull TreeNode root, PsiFileSystemItem file) {
for (int i = 0; i < root.getChildCount(); i++) {
TreeNode child = root.getChildAt(i);
if (child instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) child;
Object userObject = node.getUserObject();
if (userObject instanceof PsiDirectoryNode) {
PsiDirectoryNode directoryNode = (PsiDirectoryNode) userObject;
PsiDirectory value = directoryNode.getValue();
if (file.equals(value)) {
return node;
}
}
node = findNodeWithObject(child, file);
if (node != null) {
return node;
}
}
}
return null;
}
use of com.intellij.psi.PsiDirectory in project intellij-plugins by StepicOrg.
the class NavBarModelExtensionUtils method getPresentableText.
@Nullable
public static String getPresentableText(@Nullable final Object object) {
if (object instanceof Project) {
Project project = (Project) object;
StudyNode root = StepikProjectManager.getProjectRoot(project);
if (root == null) {
return null;
}
return root.getName();
}
if (object instanceof PsiDirectory) {
PsiDirectory psiDirectory = (PsiDirectory) object;
PresentationData data = new PresentationData();
updatePresentationData(data, psiDirectory);
String text = data.getPresentableText();
if (text != null)
return text;
}
return null;
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class CCChangeCourseInfo method update.
@Override
public void update(@NotNull AnActionEvent event) {
final Project project = event.getProject();
final Presentation presentation = event.getPresentation();
if (project == null) {
return;
}
presentation.setEnabledAndVisible(false);
if (!CCUtils.isCourseCreator(project)) {
return;
}
final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0) {
return;
}
presentation.setEnabledAndVisible(true);
}
Aggregations