remove shelf notification

This commit is contained in:
Bas Leijdekkers
2017-06-14 21:19:11 +02:00
parent 2438847912
commit d3ece932d5
6 changed files with 9 additions and 118 deletions
@@ -533,7 +533,6 @@ vcs.shelf.action.restore.text=Restore
vcs.shelf.action.restore.description=Makes selected already unshelved changelist(s) available for unshelve again
vcs.shelf.move.text=Move shelves to the new location
vcs.shelf.store.base.content=Shelve base revisions of files under distributed version control systems
vcs.shelf.current.file.changes.on.shelf.notification=Show notification in the editor when changes to current file are present on the shelf
delete.all.already.unshelved=Delete All Already Unshelved
delete.all.already.unshelved.confirmation=Do you want to delete all already unshelved changelists?\nThis operation cannot be undone.
highlight.annotation.before.not.selected.text=Show before...
@@ -102,7 +102,4 @@
<component><interface-class>com.intellij.openapi.vcs.contentAnnotation.ContentAnnotationCache</interface-class>
<implementation-class>com.intellij.openapi.vcs.contentAnnotation.ContentAnnotationCacheImpl</implementation-class></component>
</project-components>
<extensions defaultExtensionNs="com.intellij">
<editorNotificationProvider implementation="com.intellij.openapi.vcs.changes.shelf.ShelvedChangesNotificationProvider"/>
</extensions>
</idea-plugin>
@@ -68,7 +68,6 @@ public final class VcsConfiguration implements PersistentStateComponent<VcsConfi
public boolean MOVE_SHELVES = false;
// asked only for non-DVCS
public boolean INCLUDE_TEXT_INTO_SHELF = true;
public boolean SHOW_CURRENT_FILE_CHANGES_ON_SHELF = true;
public Boolean SHOW_PATCH_IN_EXPLORER = null;
public boolean SHOW_FILE_HISTORY_DETAILS = true;
public boolean SHOW_DIRTY_RECURSIVELY = false;
@@ -1,85 +0,0 @@
/*
* Copyright 2000-2017 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.changes.shelf;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.VcsConfiguration;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.EditorNotificationPanel;
import com.intellij.ui.EditorNotifications;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author Bas Leijdekkers
*/
public class ShelvedChangesNotificationProvider extends EditorNotifications.Provider<EditorNotificationPanel> implements DumbAware {
private static final Key<EditorNotificationPanel> KEY = Key.create("file.changes.present.on.shelf.notification.panel");
final Project myProject;
public ShelvedChangesNotificationProvider(Project project) {
myProject = project;
myProject.getMessageBus().connect(project).subscribe(ShelveChangesManager.SHELF_TOPIC, new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
EditorNotifications.getInstance(myProject).updateAllNotifications();
}
});
}
@NotNull
@Override
public Key<EditorNotificationPanel> getKey() {
return KEY;
}
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
if (!VcsConfiguration.getInstance(myProject).SHOW_CURRENT_FILE_CHANGES_ON_SHELF) {
return null;
}
final String path = file.getPath();
final List<ShelvedChangeList> foundChangeLists = ShelveChangesManager.getInstance(myProject).getShelvedChangeLists()
.stream().filter(l -> findChange(path, l).isPresent()).collect(Collectors.toList());
if (foundChangeLists.isEmpty()) {
return null;
}
final EditorNotificationPanel notificationPanel = new EditorNotificationPanel();
final int size = foundChangeLists.size();
notificationPanel.setText("Changes to this file are present in " + size + " shelved change list" + (size > 1 ? "s" : ""));
final int nameLength = size == 1 ? 50 : size == 2 ? 35 : 20;
foundChangeLists.stream().limit(3).forEach(
l -> notificationPanel.createActionLabel("Show '" + StringUtil.shortenTextWithEllipsis(l.toString(), nameLength, 0, true) + '\'',
() -> findChange(path, l).ifPresent(
c -> ShelvedChangesViewManager.getInstance(myProject).showChangeInView(c))));
return notificationPanel;
}
private Optional<ShelvedChange> findChange(String path, ShelvedChangeList shelvedChangeList) {
return shelvedChangeList.getChanges(myProject).stream().filter(c -> path.endsWith(c.getBeforePath())).findAny();
}
}
@@ -236,7 +236,7 @@ public class ShelvedChangesViewManager implements ProjectComponent {
state.applyTo(myTree);
if (myPostUpdateRunnable != null) {
myPostUpdateRunnable.run();
}
}
}
myPostUpdateRunnable = null;
}
@@ -302,11 +302,11 @@ public class ShelvedChangesViewManager implements ProjectComponent {
private static class ChangelistComparator implements Comparator<ShelvedChangeList> {
private final static ChangelistComparator ourInstance = new ChangelistComparator();
public static ChangelistComparator getInstance() {
return ourInstance;
}
@Override
public int compare(ShelvedChangeList o1, ShelvedChangeList o2) {
return o2.DATE.compareTo(o1.DATE);
@@ -320,18 +320,10 @@ public class ShelvedChangesViewManager implements ProjectComponent {
}
}
public void showChangeInView(final ShelvedChange change) {
showTargetInView(change);
}
public void activateView(final ShelvedChangeList list) {
showTargetInView(list);
}
private void showTargetInView(Object target) {
Runnable runnable = () -> {
if (target != null) {
TreeUtil.selectNode(myTree, TreeUtil.findNodeWithObject(myRoot, target));
if (list != null) {
TreeUtil.selectNode(myTree, TreeUtil.findNodeWithObject(myRoot, list));
}
myContentManager.setSelectedContent(myContent);
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
@@ -442,7 +434,7 @@ public class ShelvedChangesViewManager implements ProjectComponent {
if (node.getUserObject() instanceof ShelvedChangeList) {
final ShelvedChangeList list = (ShelvedChangeList)node.getUserObject();
if (((! recycled) && (! list.isRecycled())) ||
(recycled && list.isRecycled())) {
(recycled && list.isRecycled())) {
changeLists.add(list);
}
}
@@ -549,7 +541,7 @@ public class ShelvedChangesViewManager implements ProjectComponent {
int count = node.getChildCount();
String numFilesText = spaceAndThinSpace() + count + " " + StringUtil.pluralize("file", count) + ",";
append(numFilesText, SimpleTextAttributes.GRAYED_ATTRIBUTES);
String date = DateFormatUtil.formatPrettyDateTime(changeListData.DATE);
append(" " + date, SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
@@ -797,7 +789,7 @@ public class ShelvedChangesViewManager implements ProjectComponent {
if (myCurrentShelvedElement != null) {
if (keepBinarySelection(selectedBinaryChanges, myCurrentShelvedElement.getBinaryFile()) ||
keepShelvedSelection(selectedChanges, myCurrentShelvedElement.getShelvedChange())) {
dropCachesIfNeededAndUpdate(myCurrentShelvedElement);
dropCachesIfNeededAndUpdate(myCurrentShelvedElement);
return;
}
}
@@ -18,7 +18,6 @@ package com.intellij.openapi.vcs.configurable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.VcsConfiguration;
import com.intellij.ui.EditorNotifications;
import com.intellij.ui.JBColor;
import com.intellij.ui.components.JBCheckBox;
import com.intellij.ui.components.JBLabel;
@@ -46,7 +45,6 @@ public class ShelfProjectConfigurationPanel extends JPanel {
@NotNull private static final String DEFAULT_LOCATION_HINT = "Default location is ";
@NotNull private final VcsConfiguration myVcsConfiguration;
@NotNull private final Project myProject;
@NotNull private final JBCheckBox myShowCurrentFileChangesNotification;
@NotNull private final JBCheckBox myBaseRevisionTexts;
@NotNull private final JLabel myInfoLabel;
@@ -54,7 +52,6 @@ public class ShelfProjectConfigurationPanel extends JPanel {
super(new BorderLayout());
myProject = project;
myVcsConfiguration = VcsConfiguration.getInstance(project);
myShowCurrentFileChangesNotification = new JBCheckBox(VcsBundle.message("vcs.shelf.current.file.changes.on.shelf.notification"));
myBaseRevisionTexts = new JBCheckBox(VcsBundle.message("vcs.shelf.store.base.content"));
myInfoLabel = new JLabel();
myInfoLabel.setBorder(null);
@@ -73,8 +70,6 @@ public class ShelfProjectConfigurationPanel extends JPanel {
JPanel contentPanel = new JPanel(new GridBagLayout());
final GridBagConstraints gb = new GridBagConstraints(0, 0, 1, 1, 1, 1, NORTHWEST, NONE,
JBUI.insets(3), 0, 0);
contentPanel.add(myShowCurrentFileChangesNotification, gb);
gb.gridy++;
contentPanel.add(createStoreBaseRevisionOption(), gb);
JPanel shelfConfigurablePanel = new JPanel(new BorderLayout(DEFAULT_HGAP, DEFAULT_VGAP));
@@ -123,20 +118,14 @@ public class ShelfProjectConfigurationPanel extends JPanel {
}
public void restoreFromSettings() {
myShowCurrentFileChangesNotification.setSelected(myVcsConfiguration.SHOW_CURRENT_FILE_CHANGES_ON_SHELF);
myBaseRevisionTexts.setSelected(myVcsConfiguration.INCLUDE_TEXT_INTO_SHELF);
}
public boolean isModified() {
return myVcsConfiguration.SHOW_CURRENT_FILE_CHANGES_ON_SHELF != myShowCurrentFileChangesNotification.isSelected() ||
myVcsConfiguration.INCLUDE_TEXT_INTO_SHELF != myBaseRevisionTexts.isSelected();
return myVcsConfiguration.INCLUDE_TEXT_INTO_SHELF != myBaseRevisionTexts.isSelected();
}
public void apply() {
if (myVcsConfiguration.SHOW_CURRENT_FILE_CHANGES_ON_SHELF != myShowCurrentFileChangesNotification.isSelected()) {
EditorNotifications.getInstance(myProject).updateAllNotifications();
}
myVcsConfiguration.SHOW_CURRENT_FILE_CHANGES_ON_SHELF = myShowCurrentFileChangesNotification.isSelected();
myVcsConfiguration.INCLUDE_TEXT_INTO_SHELF = myBaseRevisionTexts.isSelected();
}
}