Search in sources :

Example 1 with LeiningenProjectsManager

use of de.janthomae.leiningenplugin.project.LeiningenProjectsManager in project intellij-leiningen-plugin by derkork.

the class AddManagedFilesAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project ideaProject = e.getData(PlatformDataKeys.PROJECT);
    final LeiningenProjectsManager manager = LeiningenProjectsManager.getInstance(ideaProject);
    FileChooserDescriptor leinProjectFileDescriptor = new FileChooserDescriptor(true, false, false, false, false, true) {

        @Override
        public boolean isFileSelectable(VirtualFile file) {
            return super.isFileSelectable(file) && !manager.isManagedFile(file);
        }

        @Override
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            return (file.isDirectory() || LeiningenProjectsManager.isProjectFile(file)) && super.isFileVisible(file, showHiddenFiles);
        }
    };
    VirtualFile fileToSelect = e.getData(PlatformDataKeys.VIRTUAL_FILE);
    FileChooserDialog dialog = FileChooserFactory.getInstance().createFileChooser(leinProjectFileDescriptor, ideaProject, null);
    VirtualFile[] files = dialog.choose(fileToSelect, ideaProject);
    if (files.length == 0)
        return;
    for (VirtualFile file : files) {
        manager.importLeiningenProject(file, ideaProject);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) LeiningenProjectsManager(de.janthomae.leiningenplugin.project.LeiningenProjectsManager) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) FileChooserDialog(com.intellij.openapi.fileChooser.FileChooserDialog)

Example 2 with LeiningenProjectsManager

use of de.janthomae.leiningenplugin.project.LeiningenProjectsManager in project intellij-leiningen-plugin by derkork.

the class RefreshProjectsAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project theProject = e.getData(PlatformDataKeys.PROJECT);
    final LeiningenProjectsManager manager = LeiningenProjectsManager.getInstance(theProject);
    final List<LeiningenProject> projects = manager.getLeiningenProjects();
    for (LeiningenProject project : projects) {
        try {
            project.reimport(theProject);
        } catch (LeiningenProjectException e1) {
        // Just ignore it for now
        }
    }
}
Also used : LeiningenProject(de.janthomae.leiningenplugin.project.LeiningenProject) Project(com.intellij.openapi.project.Project) LeiningenProjectsManager(de.janthomae.leiningenplugin.project.LeiningenProjectsManager) LeiningenProject(de.janthomae.leiningenplugin.project.LeiningenProject) LeiningenProjectException(de.janthomae.leiningenplugin.project.LeiningenProjectException)

Aggregations

Project (com.intellij.openapi.project.Project)2 LeiningenProjectsManager (de.janthomae.leiningenplugin.project.LeiningenProjectsManager)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 FileChooserDialog (com.intellij.openapi.fileChooser.FileChooserDialog)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 LeiningenProject (de.janthomae.leiningenplugin.project.LeiningenProject)1 LeiningenProjectException (de.janthomae.leiningenplugin.project.LeiningenProjectException)1