Skip to content

Commit 0b97e87

Browse files
b (#16) Rename notification group for update activity
1 parent 52d48c3 commit 0b97e87

File tree

7 files changed

+30
-34
lines changed

7 files changed

+30
-34
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Fixed
11+
12+
- Renamed notification group for update activity (#16)
13+
814
## [0.2.0]
915

1016
### Added

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=0.2.0
1+
version=0.2.1
22

33
# Intellij SDK
44
intellijSdkVersion=2022.2

graph-database-plugin/src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
<preFormatProcessor implementation="com.albertoventurini.graphdbplugin.language.cypher.formatter.CypherPreFormatter" />
184184
<codeInsight.lineMarkerProvider language="Cypher" implementationClass="com.albertoventurini.graphdbplugin.jetbrains.component.linemarker.CypherLineMarkerProvider"/>
185185

186-
<notificationGroup id="GraphDatabaseSupportUpdateNotification"
186+
<notificationGroup id="graphdbplugin.notifications.update"
187187
displayType="STICKY_BALLOON" />
188188
</extensions>
189189

platform/src/main/java/com/albertoventurini/graphdbplugin/platform/GraphBundle.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
package com.albertoventurini.graphdbplugin.platform;
88

9-
import com.intellij.CommonBundle;
9+
import com.intellij.AbstractBundle;
1010
import org.jetbrains.annotations.PropertyKey;
1111

1212
import java.util.ResourceBundle;
@@ -18,12 +18,12 @@ public class GraphBundle {
1818
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
1919

2020
public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
21-
return CommonBundle.message(BUNDLE, key, params);
21+
return AbstractBundle.message(BUNDLE, key, params);
2222
}
2323

2424
public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue,
2525
Object... params) {
26-
return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
26+
return AbstractBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
2727
}
2828

2929
}

ui/jetbrains/src/main/java/com/albertoventurini/graphdbplugin/jetbrains/component/settings/SettingsComponent.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88

99
import com.intellij.openapi.application.ApplicationManager;
1010

11+
/**
12+
* This service allows persisting and reading configuration settings.
13+
*/
1114
public interface SettingsComponent {
1215

1316
static SettingsComponent getInstance() {
1417
return ApplicationManager.getApplication().getService(SettingsComponent.class);
1518
}
1619

17-
String getUserId();
18-
1920
boolean isGraphViewZoomInverted();
2021

2122
void invertGraphViewZoom(boolean state);

ui/jetbrains/src/main/java/com/albertoventurini/graphdbplugin/jetbrains/component/settings/SettingsComponentImpl.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,10 @@
88

99
import com.intellij.ide.util.PropertiesComponent;
1010

11-
import java.util.UUID;
12-
1311
public class SettingsComponentImpl implements SettingsComponent {
1412

15-
private static final String USE_FILE_SPECIFIC_PARAMS_KEY = "GraphDbSupport.UseFileSpecificParams";
16-
private static final String USER_ID = "GraphDbSupport.UserId";
17-
private static final String KNOWN_PLUGIN_VERSION = "GraphDbSupport.KnownPluginVersion";
18-
private static final String GRAPH_VIEW_INVERT_ZOOM = "GraphDbSupport.GraphViewInvertZoom";
19-
20-
@Override
21-
public String getUserId() {
22-
if (!properties().isValueSet(USER_ID)) {
23-
properties().setValue(USER_ID, UUID.randomUUID().toString());
24-
}
25-
return properties().getValue(USER_ID);
26-
}
13+
private static final String KNOWN_PLUGIN_VERSION = "GraphDbPlugin.KnownPluginVersion";
14+
private static final String GRAPH_VIEW_INVERT_ZOOM = "GraphDbPlugin.GraphViewInvertZoom";
2715

2816
@Override
2917
public boolean isGraphViewZoomInverted() {

ui/jetbrains/src/main/java/com/albertoventurini/graphdbplugin/jetbrains/component/updater/PluginUpdateActivity.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,34 @@
1616
import com.albertoventurini.graphdbplugin.platform.GraphConstants;
1717
import org.jetbrains.annotations.NotNull;
1818

19-
import javax.swing.event.HyperlinkEvent;
19+
import java.util.concurrent.atomic.AtomicBoolean;
2020

21+
/**
22+
* Displays a notification when the plugin was updated to a new version.
23+
*/
2124
public class PluginUpdateActivity implements StartupActivity, DumbAware {
2225

23-
private static final String NOTIFICATION_ID = "GraphDatabaseSupportUpdateNotification";
24-
private boolean isUpdateNotificationShown = false;
26+
private final AtomicBoolean isUpdateNotificationShown = new AtomicBoolean(false);
2527

2628
@Override
27-
public void runActivity(@NotNull Project project) {
28-
String currentVersion = PluginUtil.getVersion();
29-
String knownVersion = SettingsComponent.getInstance().getKnownPluginVersion();
29+
public void runActivity(@NotNull final Project project) {
30+
final String currentVersion = PluginUtil.getVersion();
31+
final String knownVersion = SettingsComponent.getInstance().getKnownPluginVersion();
3032

31-
boolean isUpdated = !currentVersion.equals(knownVersion);
33+
final boolean isUpdated = !currentVersion.equals(knownVersion);
3234
if (isUpdated || GraphConstants.IS_DEVELOPMENT) {
33-
if (!isUpdateNotificationShown) {
35+
if (isUpdateNotificationShown.compareAndSet(false, true)) {
3436
SettingsComponent.getInstance().setKnownPluginVersion(currentVersion);
3537
showNotification(project, currentVersion);
36-
isUpdateNotificationShown = true;
3738
}
3839
}
3940
}
4041

41-
private void showNotification(Project project, String currentVersion) {
42-
NotificationGroup group = NotificationGroupManager.getInstance()
43-
.getNotificationGroup("GraphDatabaseSupportUpdateNotification");
42+
private void showNotification(@NotNull final Project project, String currentVersion) {
43+
final NotificationGroup group = NotificationGroupManager.getInstance()
44+
.getNotificationGroup("graphdbplugin.notifications.update");
4445

45-
Notification notification = group.createNotification(
46+
final Notification notification = group.createNotification(
4647
GraphBundle.message("updater.title", currentVersion),
4748
GraphBundle.message("updater.notification"),
4849
NotificationType.INFORMATION

0 commit comments

Comments
 (0)