summaryrefslogtreecommitdiff
path: root/platform/vcs-impl/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'platform/vcs-impl/src/com')
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/FrameDialogWrapper.java135
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java1
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesFragmentedDiffPanel.java2
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java6
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java13
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java5
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurableProvider.java41
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java83
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusAction.java20
9 files changed, 268 insertions, 38 deletions
diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/FrameDialogWrapper.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/FrameDialogWrapper.java
new file mode 100644
index 000000000000..f89e28ea8b6b
--- /dev/null
+++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/FrameDialogWrapper.java
@@ -0,0 +1,135 @@
+package com.intellij.openapi.diff.impl.dir;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.ui.FrameWrapper;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+
+public abstract class FrameDialogWrapper {
+ public enum Mode {FRAME, MODAL, NON_MODAL}
+
+ @NotNull
+ protected abstract JComponent getPanel();
+
+ @Nullable
+ protected String getDimensionServiceKey() {
+ return null;
+ }
+
+ @Nullable
+ protected JComponent getPreferredFocusedComponent() {
+ return null;
+ }
+
+ @Nullable
+ protected String getTitle() {
+ return null;
+ }
+
+ @Nullable
+ protected Project getProject() {
+ return null;
+ }
+
+ @NotNull
+ protected Mode getMode() {
+ return Mode.MODAL;
+ }
+
+ public void show() {
+ switch (getMode()) {
+ case FRAME:
+ new MyFrameWrapper(getProject(), getMode(), getPanel(), getPreferredFocusedComponent(), getTitle(), getDimensionServiceKey())
+ .show();
+ return;
+ case MODAL:
+ case NON_MODAL:
+ new MyDialogWrapper(getProject(), getMode(), getPanel(), getPreferredFocusedComponent(), getTitle(), getDimensionServiceKey())
+ .show();
+ return;
+ default:
+ throw new IllegalArgumentException(getMode().toString());
+ }
+ }
+
+ private static class MyDialogWrapper extends DialogWrapper {
+ private final JComponent myComponent;
+ private final JComponent myPreferredFocusedComponent;
+ private final String myDimensionServiceKey;
+
+ public MyDialogWrapper(@Nullable Project project,
+ @NotNull Mode mode,
+ @NotNull JComponent component,
+ @Nullable JComponent preferredFocusedComponent,
+ @Nullable String title,
+ @Nullable String dimensionServiceKey) {
+ super(project, true);
+ myComponent = component;
+ myPreferredFocusedComponent = preferredFocusedComponent;
+ myDimensionServiceKey = dimensionServiceKey;
+
+ if (title != null) {
+ setTitle(title);
+ }
+ switch (mode) {
+ case MODAL:
+ setModal(true);
+ break;
+ case NON_MODAL:
+ setModal(false);
+ break;
+ default:
+ throw new IllegalArgumentException(mode.toString());
+ }
+
+ init();
+ }
+
+ @Override
+ protected JComponent createCenterPanel() {
+ return myComponent;
+ }
+
+ @Nullable
+ @Override
+ public JComponent getPreferredFocusedComponent() {
+ return myPreferredFocusedComponent;
+ }
+
+ @Nullable
+ @Override
+ protected String getDimensionServiceKey() {
+ return myDimensionServiceKey;
+ }
+
+ // it is information dialog - no need to OK or Cancel. Close the dialog by clicking the cross button or pressing Esc.
+ @NotNull
+ @Override
+ protected Action[] createActions() {
+ return new Action[0];
+ }
+ }
+
+ private static class MyFrameWrapper extends FrameWrapper {
+ public MyFrameWrapper(@Nullable Project project,
+ @NotNull Mode mode,
+ @NotNull JComponent component,
+ @Nullable JComponent preferredFocusedComponent,
+ @Nullable String title,
+ @Nullable String dimensionServiceKey) {
+ super(project, dimensionServiceKey);
+
+ assert mode == Mode.FRAME;
+
+ if (title != null) {
+ setTitle(title);
+ }
+ setComponent(component);
+ setPreferredFocusedComponent(preferredFocusedComponent);
+ closeOnEsc();
+ }
+ }
+}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java
index 291289854fa7..a347531b2363 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java
@@ -205,6 +205,7 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware, Ann
handler.completed(file.getPath());
if (!exceptionRef.isNull()) {
+ LOG.warn(exceptionRef.get());
AbstractVcsHelper.getInstance(project).showErrors(Arrays.asList(exceptionRef.get()), VcsBundle.message("message.title.annotate"));
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesFragmentedDiffPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesFragmentedDiffPanel.java
index 53092e6a1369..6afbc181b98c 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesFragmentedDiffPanel.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesFragmentedDiffPanel.java
@@ -187,7 +187,7 @@ public class ChangesFragmentedDiffPanel implements Disposable {
current = range;
}
if (current == null) return null;
- final Fragment at = fragments.getFragmentAt(offset, FragmentSide.SIDE1, Condition.TRUE);
+ final Fragment at = fragments.getFragmentAt(offset, FragmentSide.SIDE1, Conditions.<Fragment>alwaysTrue());
if (at == null) return null;
final TextRange opposite = at.getRange(FragmentSide.SIDE2);
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java
index 6e44a7864b3d..0e38675a8239 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java
@@ -79,7 +79,11 @@ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements Pr
StartupManager.getInstance(myProject).registerPostStartupActivity(new DumbAwareRunnable() {
public void run() {
myLife.born();
- markEverythingDirty();
+ ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
+ public void run() {
+ markEverythingDirty();
+ }
+ });
}
});
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java
index 6619b98ea5e9..2708f5130040 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java
@@ -21,7 +21,10 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
-import com.intellij.openapi.components.*;
+import com.intellij.openapi.components.PersistentStateComponent;
+import com.intellij.openapi.components.State;
+import com.intellij.openapi.components.Storage;
+import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressManagerQueue;
@@ -64,12 +67,8 @@ import java.util.concurrent.TimeUnit;
* @author yole
*/
@State(
- name="CommittedChangesCache",
- roamingType = RoamingType.DISABLED,
- storages= {
- @Storage(
- file = StoragePathMacros.WORKSPACE_FILE
- )}
+ name = "CommittedChangesCache",
+ storages = {@Storage(file = StoragePathMacros.WORKSPACE_FILE)}
)
public class CommittedChangesCache implements PersistentStateComponent<CommittedChangesCache.State> {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.changes.committed.CommittedChangesCache");
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java
index 497db3da7d9f..47fae2b88339 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java
@@ -175,6 +175,11 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
ProjectLevelVcsManager.getInstance(project).getAllActiveVcss());
}
+ @NotNull
+ public List<RefreshableOnComponent> getAdditionalComponents() {
+ return Collections.unmodifiableList(myAdditionalComponents);
+ }
+
public static void commitPaths(final Project project, Collection<FilePath> paths, final LocalChangeList initialSelection,
@Nullable final CommitExecutor executor, final String comment) {
final ChangeListManager manager = ChangeListManager.getInstance(project);
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurableProvider.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurableProvider.java
new file mode 100644
index 000000000000..0ff9ef6c96d6
--- /dev/null
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurableProvider.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.vcs.configurable;
+
+import com.intellij.openapi.options.Configurable;
+import com.intellij.openapi.options.ConfigurableProvider;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vcs.ProjectLevelVcsManager;
+import org.jetbrains.annotations.NotNull;
+
+public final class VcsManagerConfigurableProvider extends ConfigurableProvider {
+ private final Project myProject;
+
+ public VcsManagerConfigurableProvider(Project project) {
+ myProject = project;
+ }
+
+ @NotNull
+ @Override
+ public Configurable createConfigurable() {
+ return new VcsManagerConfigurable(myProject);
+ }
+
+ @Override
+ public boolean canCreateConfigurable() {
+ return ProjectLevelVcsManager.getInstance(myProject).getAllVcss().length > 0;
+ }
+}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java
index daef43857c4e..abc43dd3a34d 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java
@@ -295,6 +295,23 @@ public class LineStatusTracker {
}
}
+ private void markFileUnchanged() {
+ ApplicationManager.getApplication().invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ FileDocumentManager.getInstance().saveDocument(myDocument);
+ boolean stillEmpty;
+ synchronized (myLock) {
+ stillEmpty = myRanges.isEmpty();
+ }
+ if (stillEmpty) {
+ // file was modified, and now it's not -> dirty local change
+ myVcsDirtyScopeManager.fileDirty(myVirtualFile);
+ }
+ }
+ });
+ }
+
private class MyDocumentListener extends DocumentAdapter {
// We have 3 document versions:
// * VCS version
@@ -457,20 +474,7 @@ public class LineStatusTracker {
}
if (myRanges.isEmpty() && myVirtualFile != null) {
- ApplicationManager.getApplication().invokeLater(new Runnable() {
- @Override
- public void run() {
- FileDocumentManager.getInstance().saveDocument(myDocument);
- boolean stillEmpty;
- synchronized (myLock) {
- stillEmpty = myRanges.isEmpty();
- }
- if (stillEmpty) {
- // file was modified, and now it's not -> dirty local change
- myVcsDirtyScopeManager.fileDirty(myVirtualFile);
- }
- }
- });
+ markFileUnchanged();
}
}
}
@@ -764,15 +768,10 @@ public class LineStatusTracker {
}
}
- public void rollbackChanges(@NotNull BitSet lines) {
- myApplication.assertWriteAccessAllowed();
-
- synchronized (myLock) {
- if (myBulkUpdate) return;
-
- try {
- mySuppressUpdate = true;
-
+ public void rollbackChanges(@NotNull final BitSet lines) {
+ runBulkRollback(new Runnable() {
+ @Override
+ public void run() {
Range first = null;
Range last = null;
@@ -816,11 +815,41 @@ public class LineStatusTracker {
doUpdateRanges(beforeChangedLine1, beforeChangedLine2, shift, beforeTotalLines);
}
}
- catch (Throwable e) {
+ });
+ }
+
+ public void rollbackAllChanges() {
+ runBulkRollback(new Runnable() {
+ @Override
+ public void run() {
+ myDocument.setText(myVcsDocument.getText());
+
+ removeAnathema();
+ removeHighlightersFromMarkupModel();
+
+ markFileUnchanged();
+ }
+ });
+ }
+
+ private void runBulkRollback(@NotNull Runnable task) {
+ myApplication.assertWriteAccessAllowed();
+
+ synchronized (myLock) {
+ if (myBulkUpdate) return;
+
+ try {
+ mySuppressUpdate = true;
+
+ task.run();
+ }
+ catch (Error e) {
+ reinstallRanges();
+ throw e;
+ }
+ catch (RuntimeException e) {
reinstallRanges();
- if (e instanceof Error) throw ((Error)e);
- if (e instanceof RuntimeException) throw ((RuntimeException)e);
- throw new RuntimeException(e);
+ throw e;
}
finally {
mySuppressUpdate = false;
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusAction.java
index 1286b6815fcf..529da7371bf7 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusAction.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusAction.java
@@ -12,8 +12,6 @@
*/
package com.intellij.openapi.vcs.ex;
-import com.intellij.icons.AllIcons;
-import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.application.ApplicationManager;
@@ -73,6 +71,15 @@ public class RollbackLineStatusAction extends DumbAwareAction {
BitSet lines = new BitSet(totalLines + 1);
List<Caret> carets = editor.getCaretModel().getAllCarets();
+
+ if (carets.size() == 1) {
+ Caret caret = carets.get(0);
+ if (caret.getSelectionStart() == 0 && caret.getSelectionEnd() == document.getTextLength()) {
+ doRollback(tracker);
+ return;
+ }
+ }
+
for (Caret caret : carets) {
if (caret.hasSelection()) {
int line1 = editor.offsetToLogicalPosition(caret.getSelectionStart()).line;
@@ -107,6 +114,15 @@ public class RollbackLineStatusAction extends DumbAwareAction {
});
}
+ private static void doRollback(@NotNull final LineStatusTracker tracker) {
+ execute(tracker, new Runnable() {
+ @Override
+ public void run() {
+ tracker.rollbackAllChanges();
+ }
+ });
+ }
+
private static void execute(@NotNull final LineStatusTracker tracker, @NotNull final Runnable task) {
CommandProcessor.getInstance().executeCommand(tracker.getProject(), new Runnable() {
public void run() {