Search in sources :

Example 1 with IgnoredFileBean

use of com.intellij.openapi.vcs.changes.IgnoredFileBean in project intellij-community by JetBrains.

the class IgnoredFilesTest method testPatternIsIgnored.

@Test
public void testPatternIsIgnored() throws Exception {
    final String dirPath1 = myClientRoot.getPath() + "/a";
    final File dir = new File(myClientRoot, "a");
    dir.mkdir();
    final File innerDir = new File(dir, "innerDir");
    innerDir.mkdir();
    final File file1 = new File(innerDir, "file1");
    final File file2 = new File(innerDir, "file2");
    file1.createNewFile();
    file2.createNewFile();
    final VirtualFile innerVf = myLocalFileSystem.refreshAndFindFileByIoFile(innerDir);
    final VirtualFile vf1 = myLocalFileSystem.refreshAndFindFileByIoFile(file1);
    final VirtualFile vf2 = myLocalFileSystem.refreshAndFindFileByIoFile(file2);
    final IgnoredFileBean ignoredFileBean = IgnoredBeanFactory.withMask("file*");
    myChangeListManager.addFilesToIgnore(ignoredFileBean);
    dirty();
    Assert.assertNotNull(innerVf);
    Assert.assertFalse(myChangeListManager.isIgnoredFile(innerVf));
    Assert.assertEquals(FileStatus.UNKNOWN, myChangeListManager.getStatus(innerVf));
    Assert.assertTrue(myChangeListManager.isUnversioned(innerVf));
    assertFoundAndIgnored(vf1);
    assertFoundAndIgnored(vf2);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) IgnoredFileBean(com.intellij.openapi.vcs.changes.IgnoredFileBean) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Test(org.junit.Test)

Example 2 with IgnoredFileBean

use of com.intellij.openapi.vcs.changes.IgnoredFileBean in project intellij-community by JetBrains.

the class IgnoredSettingsPanel method apply.

public void apply() {
    IgnoredFileBean[] toIgnore = getItems();
    myChangeListManager.setFilesToIgnore(toIgnore);
    for (IgnoredFileBean bean : toIgnore) {
        if (bean.getType() == IgnoreSettingsType.UNDER_DIR) {
            myDirectoriesManuallyRemovedFromIgnored.remove(bean.getPath());
        }
    }
    myChangeListManager.getIgnoredFilesComponent().setDirectoriesManuallyRemovedFromIgnored(myDirectoriesManuallyRemovedFromIgnored);
}
Also used : IgnoredFileBean(com.intellij.openapi.vcs.changes.IgnoredFileBean)

Example 3 with IgnoredFileBean

use of com.intellij.openapi.vcs.changes.IgnoredFileBean in project intellij-community by JetBrains.

the class IgnoredSettingsPanel method setItems.

private void setItems(final IgnoredFileBean[] filesToIgnore) {
    myModel = new DefaultListModel();
    for (IgnoredFileBean bean : filesToIgnore) {
        myModel.addElement(bean);
    }
    myList.setModel(myModel);
}
Also used : IgnoredFileBean(com.intellij.openapi.vcs.changes.IgnoredFileBean)

Example 4 with IgnoredFileBean

use of com.intellij.openapi.vcs.changes.IgnoredFileBean in project intellij-plugins by JetBrains.

the class Flexmojos3GenerateConfigTask method perform.

public void perform(final Project project, final MavenEmbeddersManager embeddersManager, final MavenConsole console, final MavenProgressIndicator indicator) throws MavenProcessCanceledException {
    if (myModule.isDisposed())
        return;
    indicator.setText(FlexBundle.message("generating.flex.config.for", myMavenProject.getDisplayName()));
    final MavenProjectsTree.EmbedderTask task = new MavenProjectsTree.EmbedderTask() {

        public void run(MavenEmbedderWrapper embedder) throws MavenProcessCanceledException {
            List<VirtualFile> temporaryFiles = null;
            final IgnoredFileBean[] filesToIgnoreOriginal = ChangeListManager.getInstance(project).getFilesToIgnore();
            try {
                MavenWorkspaceMap workspaceMap = new MavenWorkspaceMap();
                temporaryFiles = mavenIdToOutputFileMapping(workspaceMap, project, myTree.getProjects());
                embedder.customizeForStrictResolve(workspaceMap, console, indicator);
                final String generateConfigGoal = FlexmojosImporter.FLEXMOJOS_GROUP_ID + ":" + FlexmojosImporter.FLEXMOJOS_ARTIFACT_ID + ":generate-config-" + myMavenProject.getPackaging();
                final MavenExplicitProfiles profilesIds = myMavenProject.getActivatedProfilesIds();
                MavenServerExecutionResult result = embedder.execute(myMavenProject.getFile(), profilesIds.getEnabledProfiles(), profilesIds.getDisabledProfiles(), Collections.singletonList(generateConfigGoal));
                if (result.projectData == null) {
                    myFlexConfigInformer.showFlexConfigWarningIfNeeded(project);
                }
                MavenUtil.invokeAndWaitWriteAction(project, () -> {
                    // need to refresh externally created file
                    final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(myConfigFilePath);
                    if (file != null) {
                        file.refresh(false, false);
                        updateMainClass(myModule, file);
                    }
                });
            } catch (MavenProcessCanceledException e) {
                throw e;
            } catch (Exception e) {
                myFlexConfigInformer.showFlexConfigWarningIfNeeded(project);
                console.printException(e);
                MavenLog.LOG.warn(e);
            } finally {
                ChangeListManager.getInstance(project).setFilesToIgnore(filesToIgnoreOriginal);
                if (temporaryFiles != null && !temporaryFiles.isEmpty()) {
                    removeTemporaryFiles(project, temporaryFiles);
                }
            }
        }
    };
    myTree.executeWithEmbedder(myMavenProject, embeddersManager, MavenEmbeddersManager.FOR_POST_PROCESSING, console, indicator, task);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenProcessCanceledException(org.jetbrains.idea.maven.utils.MavenProcessCanceledException) MavenExplicitProfiles(org.jetbrains.idea.maven.model.MavenExplicitProfiles) MavenEmbedderWrapper(org.jetbrains.idea.maven.server.MavenEmbedderWrapper) MavenProcessCanceledException(org.jetbrains.idea.maven.utils.MavenProcessCanceledException) IOException(java.io.IOException) ConfigurationException(com.intellij.openapi.options.ConfigurationException) MavenServerExecutionResult(org.jetbrains.idea.maven.server.MavenServerExecutionResult) IgnoredFileBean(com.intellij.openapi.vcs.changes.IgnoredFileBean) MavenWorkspaceMap(org.jetbrains.idea.maven.model.MavenWorkspaceMap)

Example 5 with IgnoredFileBean

use of com.intellij.openapi.vcs.changes.IgnoredFileBean in project intellij-community by JetBrains.

the class IgnoredFilesTest method testDirIsIgnored.

@Test
public void testDirIsIgnored() throws Exception {
    //final String dirPath1 = myClientRoot.getPath() + "/a";
    final File dir = new File(myClientRoot, "a");
    dir.mkdir();
    final File innerDir = new File(dir, "innerDir");
    innerDir.mkdir();
    final File file1 = new File(innerDir, "file1");
    final File file2 = new File(innerDir, "file2");
    file1.createNewFile();
    file2.createNewFile();
    final VirtualFile innerVf = myLocalFileSystem.refreshAndFindFileByIoFile(innerDir);
    final VirtualFile vf1 = myLocalFileSystem.refreshAndFindFileByIoFile(file1);
    final VirtualFile vf2 = myLocalFileSystem.refreshAndFindFileByIoFile(file2);
    final IgnoredFileBean ignoredFileBean = IgnoredBeanFactory.ignoreUnderDirectory(FileUtil.toSystemIndependentName(dir.getPath()), myProject);
    myChangeListManager.addFilesToIgnore(ignoredFileBean);
    dirty();
    assertFoundAndIgnored(innerVf);
    assertFoundAndIgnored(vf1);
    assertFoundAndIgnored(vf2);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) IgnoredFileBean(com.intellij.openapi.vcs.changes.IgnoredFileBean) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Test(org.junit.Test)

Aggregations

IgnoredFileBean (com.intellij.openapi.vcs.changes.IgnoredFileBean)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 File (java.io.File)6 Test (org.junit.Test)6 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 IOException (java.io.IOException)1 MavenExplicitProfiles (org.jetbrains.idea.maven.model.MavenExplicitProfiles)1 MavenWorkspaceMap (org.jetbrains.idea.maven.model.MavenWorkspaceMap)1 MavenEmbedderWrapper (org.jetbrains.idea.maven.server.MavenEmbedderWrapper)1 MavenServerExecutionResult (org.jetbrains.idea.maven.server.MavenServerExecutionResult)1 MavenProcessCanceledException (org.jetbrains.idea.maven.utils.MavenProcessCanceledException)1