summaryrefslogtreecommitdiff
path: root/platform/lang-impl/src/com/intellij/openapi
diff options
context:
space:
mode:
Diffstat (limited to 'platform/lang-impl/src/com/intellij/openapi')
-rw-r--r--platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ModuleStateStorageManager.java1
-rw-r--r--platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdaterImpl.java86
-rw-r--r--platform/lang-impl/src/com/intellij/openapi/util/registry/RegistryUi.java31
-rw-r--r--platform/lang-impl/src/com/intellij/openapi/vcs/checkin/CheckinHandlerUtil.java12
4 files changed, 94 insertions, 36 deletions
diff --git a/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ModuleStateStorageManager.java b/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ModuleStateStorageManager.java
index c62954177884..ea6d2fcc59fc 100644
--- a/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ModuleStateStorageManager.java
+++ b/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ModuleStateStorageManager.java
@@ -37,6 +37,7 @@ class ModuleStateStorageManager extends StateStorageManagerImpl {
return new ModuleStoreImpl.ModuleFileData(ROOT_TAG_NAME, myModule);
}
+ @Nullable
@Override
protected String getOldStorageSpec(Object component, final String componentName, final StateStorageOperation operation) {
return ModuleStoreImpl.DEFAULT_STATE_STORAGE;
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdaterImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdaterImpl.java
index a96432e2b64c..962aa81c3e59 100644
--- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdaterImpl.java
+++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdaterImpl.java
@@ -37,8 +37,12 @@ import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.EmptyRunnable;
-import com.intellij.openapi.vfs.*;
-import com.intellij.openapi.vfs.impl.BulkVirtualFileListenerAdapter;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.vfs.VirtualFileManager;
+import com.intellij.openapi.vfs.newvfs.BulkFileListener;
+import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent;
+import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
+import com.intellij.openapi.vfs.newvfs.events.VFileMoveEvent;
import com.intellij.psi.PsiManager;
import com.intellij.psi.impl.PsiManagerEx;
import com.intellij.psi.impl.file.impl.FileManagerImpl;
@@ -48,8 +52,11 @@ import com.intellij.util.indexing.FileBasedIndexProjectHandler;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -86,33 +93,39 @@ public class PushedFilePropertiesUpdaterImpl extends PushedFilePropertiesUpdater
}
});
- myConnection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkVirtualFileListenerAdapter(new VirtualFileAdapter() {
+ myConnection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
@Override
- public void fileCreated(@NotNull final VirtualFileEvent event) {
- final VirtualFile file = event.getFile();
- final FilePropertyPusher[] pushers = file.isDirectory() ? myPushers : myFilePushers;
- if (!event.isFromRefresh() || !file.isDirectory()) {
- // push synchronously to avoid entering dumb mode in the middle of a meaningful write action
- // avoid dumb mode for just one file
- doPushRecursively(file, pushers, ProjectRootManager.getInstance(myProject).getFileIndex());
- }
- else {
- schedulePushRecursively(file, pushers);
- }
- }
+ public void after(@NotNull List<? extends VFileEvent> events) {
+ List<Runnable> delayedTasks = ContainerUtil.newArrayList();
+ for (VFileEvent event : events) {
+ final VirtualFile file = event.getFile();
+ if (file == null) continue;
- @Override
- public void fileMoved(@NotNull final VirtualFileMoveEvent event) {
- final VirtualFile file = event.getFile();
- final FilePropertyPusher[] pushers = file.isDirectory() ? myPushers : myFilePushers;
- if (pushers.length == 0) return;
- for (FilePropertyPusher pusher : pushers) {
- file.putUserData(pusher.getFileDataKey(), null);
+ final FilePropertyPusher[] pushers = file.isDirectory() ? myPushers : myFilePushers;
+ if (pushers.length == 0) continue;
+
+ if (event instanceof VFileCreateEvent) {
+ if (!event.isFromRefresh() || !file.isDirectory()) {
+ // push synchronously to avoid entering dumb mode in the middle of a meaningful write action
+ // avoid dumb mode for just one file
+ doPushRecursively(file, pushers, ProjectRootManager.getInstance(myProject).getFileIndex());
+ }
+ else {
+ ContainerUtil.addIfNotNull(delayedTasks, createRecursivePushTask(file, pushers));
+ }
+ } else if (event instanceof VFileMoveEvent) {
+ for (FilePropertyPusher pusher : pushers) {
+ file.putUserData(pusher.getFileDataKey(), null);
+ }
+ // push synchronously to avoid entering dumb mode in the middle of a meaningful write action
+ doPushRecursively(file, pushers, ProjectRootManager.getInstance(myProject).getFileIndex());
+ }
+ }
+ if (!delayedTasks.isEmpty()) {
+ queueTasks(delayedTasks);
}
- // push synchronously to avoid entering dumb mode in the middle of a meaningful write action
- doPushRecursively(file, pushers, ProjectRootManager.getInstance(myProject).getFileIndex());
}
- }));
+ });
}
});
}
@@ -128,7 +141,7 @@ public class PushedFilePropertiesUpdaterImpl extends PushedFilePropertiesUpdater
@Override
public void pushRecursively(VirtualFile file, Project project) {
- PushedFilePropertiesUpdaterImpl.this.schedulePushRecursively(file, pusher);
+ queueTasks(ContainerUtil.createMaybeSingletonList(createRecursivePushTask(file, new FilePropertyPusher[]{pusher})));
}
});
}
@@ -140,16 +153,17 @@ public class PushedFilePropertiesUpdaterImpl extends PushedFilePropertiesUpdater
doPushAll(myPushers);
}
- private void schedulePushRecursively(final VirtualFile dir, final FilePropertyPusher... pushers) {
- if (pushers.length == 0) return;
+ @Nullable
+ private Runnable createRecursivePushTask(final VirtualFile dir, final FilePropertyPusher[] pushers) {
+ if (pushers.length == 0) return null;
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
- if (!fileIndex.isInContent(dir)) return;
- queueTask(new Runnable() {
+ if (!fileIndex.isInContent(dir)) return null;
+ return new Runnable() {
@Override
public void run() {
doPushRecursively(dir, pushers, fileIndex);
}
- });
+ };
}
private void doPushRecursively(VirtualFile dir, final FilePropertyPusher[] pushers, ProjectFileIndex fileIndex) {
@@ -162,8 +176,10 @@ public class PushedFilePropertiesUpdaterImpl extends PushedFilePropertiesUpdater
});
}
- private void queueTask(Runnable action) {
- myTasks.offer(action);
+ private void queueTasks(List<? extends Runnable> actions) {
+ for (Runnable action : actions) {
+ myTasks.offer(action);
+ }
final DumbModeTask task = new DumbModeTask() {
@Override
public void performInDumbMode(@NotNull ProgressIndicator indicator) {
@@ -221,12 +237,12 @@ public class PushedFilePropertiesUpdaterImpl extends PushedFilePropertiesUpdater
@Override
public void pushAll(final FilePropertyPusher... pushers) {
- queueTask(new Runnable() {
+ queueTasks(Arrays.asList(new Runnable() {
@Override
public void run() {
doPushAll(pushers);
}
- });
+ }));
}
private void doPushAll(final FilePropertyPusher[] pushers) {
diff --git a/platform/lang-impl/src/com/intellij/openapi/util/registry/RegistryUi.java b/platform/lang-impl/src/com/intellij/openapi/util/registry/RegistryUi.java
index 0978f8f09ec7..65f2d758fcfd 100644
--- a/platform/lang-impl/src/com/intellij/openapi/util/registry/RegistryUi.java
+++ b/platform/lang-impl/src/com/intellij/openapi/util/registry/RegistryUi.java
@@ -17,6 +17,7 @@
package com.intellij.openapi.util.registry;
import com.intellij.icons.AllIcons;
+import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationInfo;
@@ -27,6 +28,7 @@ import com.intellij.openapi.application.impl.LaterInvocator;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.ShadowAction;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.*;
import com.intellij.ui.table.JBTable;
import com.intellij.util.PlatformIcons;
@@ -54,6 +56,7 @@ import java.util.List;
* @author Konstantin Bulenkov
*/
public class RegistryUi implements Disposable {
+ private static final String RECENT_PROPERTIES_KEY = "RegistryRecentKeys";
private final JBTable myTable;
private final JTextArea myDescriptionLabel;
@@ -143,6 +146,7 @@ public class RegistryUi implements Disposable {
RegistryValue rv = myModel.getRegistryValue(row);
if (rv.isBoolean()) {
rv.setValue(!rv.asBoolean());
+ keyChanged(rv.getKey());
for (int i : new int[]{0, 1, 2}) myModel.fireTableCellUpdated(row, i);
revaliateActions();
if (search.isPopupActive()) search.hidePopup();
@@ -217,10 +221,21 @@ public class RegistryUi implements Disposable {
private MyTableModel() {
myAll = Registry.getAll();
+ final List<String> recent = getRecent();
+
Collections.sort(myAll, new Comparator<RegistryValue>() {
@Override
public int compare(@NotNull RegistryValue o1, @NotNull RegistryValue o2) {
- return o1.getKey().compareTo(o2.getKey());
+ final String key1 = o1.getKey();
+ final String key2 = o2.getKey();
+ final int i1 = recent.indexOf(key1);
+ final int i2 = recent.indexOf(key2);
+ final boolean c1 = i1 != -1;
+ final boolean c2 = i2 != -1;
+ if (c1 && !c2) return -1;
+ if (!c1 && c2) return 1;
+ if (c1 && c2) return i1 - i2;
+ return key1.compareToIgnoreCase(key2);
}
});
}
@@ -264,6 +279,19 @@ public class RegistryUi implements Disposable {
}
}
+ private static List<String> getRecent() {
+ String value = PropertiesComponent.getInstance().getValue(RECENT_PROPERTIES_KEY);
+ return StringUtil.isEmpty(value) ? new ArrayList<String>(0) : StringUtil.split(value, "=");
+ }
+
+ private static void keyChanged(String key) {
+ final List<String> recent = getRecent();
+ recent.remove(key);
+ recent.add(0, key);
+ final String newValue = StringUtil.join(recent, "=");
+ PropertiesComponent.getInstance().setValue(RECENT_PROPERTIES_KEY, newValue);
+ }
+
public boolean show() {
DialogWrapper dialog = new DialogWrapper(true) {
{
@@ -468,6 +496,7 @@ public class RegistryUi implements Disposable {
} else {
myValue.setValue(myField.getText().trim());
}
+ keyChanged(myValue.getKey());
}
revaliateActions();
return super.stopCellEditing();
diff --git a/platform/lang-impl/src/com/intellij/openapi/vcs/checkin/CheckinHandlerUtil.java b/platform/lang-impl/src/com/intellij/openapi/vcs/checkin/CheckinHandlerUtil.java
index 7a6b61f4722b..4a5a644d4fbe 100644
--- a/platform/lang-impl/src/com/intellij/openapi/vcs/checkin/CheckinHandlerUtil.java
+++ b/platform/lang-impl/src/com/intellij/openapi/vcs/checkin/CheckinHandlerUtil.java
@@ -20,6 +20,7 @@ import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ex.ProjectEx;
+import com.intellij.openapi.roots.GeneratedSourcesFilter;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vfs.VfsUtilCore;
@@ -34,11 +35,22 @@ import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
import javax.swing.*;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
/**
* @author oleg
*/
public class CheckinHandlerUtil {
+ public static List<VirtualFile> filterOutGeneratedAndExcludedFiles(@NotNull Collection<VirtualFile> files, @NotNull Project project) {
+ ProjectFileIndex fileIndex = ProjectFileIndex.SERVICE.getInstance(project);
+ List<VirtualFile> result = new ArrayList<VirtualFile>(files.size());
+ for (VirtualFile file : files) {
+ if (!fileIndex.isExcluded(file) && !GeneratedSourcesFilter.isGeneratedSourceByAnyFilter(file, project)) {
+ result.add(file);
+ }
+ }
+ return result;
+ }
public static PsiFile[] getPsiFiles(final Project project, final Collection<VirtualFile> selectedFiles) {
ArrayList<PsiFile> result = new ArrayList<PsiFile>();