GDPR support: menu action for Data Sharing Options

This commit is contained in:
Vassiliy.Kudryashov
2017-12-14 22:16:33 +03:00
parent a8ee32f847
commit 5a73440a00
2 changed files with 40 additions and 0 deletions
@@ -0,0 +1,39 @@
/*
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.ide.actions;
import com.intellij.ide.gdpr.Consent;
import com.intellij.ide.gdpr.ConsentOptions;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.util.Pair;
import com.intellij.ui.AppUIUtil;
import java.util.Collection;
public class DataSharingOptionsAction extends DumbAwareAction {
public DataSharingOptionsAction() {
super("Data Sharing Options...", "Data Sharing Options", null);
}
@Override
public void update(AnActionEvent e) {
e.getPresentation().setEnabledAndVisible(!ConsentOptions.getConsents().first.isEmpty());
}
@Override
public void actionPerformed(AnActionEvent e) {
final Pair<Collection<Consent>, Boolean> consentsToShow = ConsentOptions.getConsents();
try {
final Collection<Consent> result = AppUIUtil.confirmConsentOptions(consentsToShow.first);
if (result != null) {
ConsentOptions.setConsents(result);
}
}
catch (Exception ex) {
Logger.getInstance(DataSharingOptionsAction.class).warn(ex);
}
}
}
@@ -559,6 +559,7 @@
<separator/>
<action id="CheckForUpdate" class="com.intellij.openapi.updateSettings.impl.CheckForUpdateAction"/>
<action id="About" class="com.intellij.ide.actions.AboutAction"/>
<action id="DataSharingOptions" class="com.intellij.ide.actions.DataSharingOptionsAction"/>
</group>
<group id="OtherMenu" class="com.intellij.ide.actions.NonEmptyActionGroup"/>