Skip to content

Commit

Permalink
dbeaver/pro#2902 EAP limitations
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadelessFox committed Jun 5, 2024
1 parent 786cf80 commit 564e3e1
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,8 @@ default boolean isCommunity() {
return false;
}

/**
* Whether this product is part of the Early Access Program
*/
boolean isEarlyAccessProgram();
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ public boolean hasProductFeature(@NotNull String featureName) {
};
}

@Override
public boolean isEarlyAccessProgram() {
// TODO: Should be configurable!
return true;
}

/////////////////////////////////////////
// IApplication

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSInstance;
import org.jkiss.dbeaver.registry.DataSourceDescriptor;
import org.jkiss.dbeaver.registry.DataSourceRegistry;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import org.jkiss.dbeaver.runtime.jobs.ConnectJob;
import org.jkiss.dbeaver.runtime.jobs.DisconnectJob;
Expand Down Expand Up @@ -89,6 +90,19 @@ public static void connectToDataSource(
return;
}

if (DBWorkbench.getPlatform().getApplication().isEarlyAccessProgram()) {
final long liveConnectionCount = DataSourceRegistry.getAllDataSources().stream()
.filter(DBPDataSourceContainer::isConnected)
.count();
if (liveConnectionCount >= 5) {
DBWorkbench.getPlatformUI().showWarningMessageBox(
"Too many connections",
"You can't have more than 5 simultaneous connections when participating in early access program."
);
return;
}
}

// Ask for additional credentials if needed
if (!DataSourceHandlerUtils.resolveSharedCredentials(dataSource, onFinish)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.IWorkbenchPropertyPage;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import org.jkiss.dbeaver.ui.ShellUtils;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.internal.statistics.StatisticCollectionMessages;
import org.jkiss.dbeaver.ui.preferences.AbstractPrefPage;
import org.jkiss.dbeaver.utils.HelpUtils;

/**
* PrefPageUsageStatistics
Expand Down Expand Up @@ -76,6 +78,15 @@ protected Control createPreferenceContent(@NotNull Composite parent) {
NLS.bind(StatisticCollectionMessages.statistic_collection_pref_content_opensource_link, LINK_GIHUB_REPO),
SelectionListener.widgetSelectedAdapter(selectionEvent -> ShellUtils.launchProgram(LINK_GIHUB_REPO)));

if (DBWorkbench.getPlatform().getApplication().isEarlyAccessProgram()) {
checkSendUsageStatistics.setEnabled(false);
UIUtils.createInfoLink(
composite,
"You cannot opt-out from data sharing when participating in <a>early access program</a>.",
() -> ShellUtils.launchProgram(HelpUtils.getHelpExternalReference("Early-access-program"))
);
}

performDefaults();
return composite;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@
import org.eclipse.swt.widgets.Shell;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.DBIcon;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import org.jkiss.dbeaver.ui.ShellUtils;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.BaseDialog;
import org.jkiss.dbeaver.ui.internal.statistics.StatisticCollectionMessages;
import org.jkiss.dbeaver.utils.HelpUtils;

/**
* StatisticsCollectionConfirmDialog
*/
public class StatisticsCollectionConfirmDialog extends BaseDialog {

private Button shareData;
private Button doNotShareDataButton;

public StatisticsCollectionConfirmDialog(Shell parentShell) {
super(parentShell, StatisticCollectionMessages.statistic_collection_dialog_title, DBIcon.STATUS_INFO);
Expand All @@ -52,19 +55,31 @@ protected Composite createDialogArea(@NotNull Composite parent) {

PrefPageUsageStatistics.createDataShareComposite(composite);

if (!DBWorkbench.getPlatform().getApplication().isEarlyAccessProgram()) {
UIUtils.createEmptyLabel(composite, 1, 1);
UIUtils.createLink(
composite,
StatisticCollectionMessages.statistic_collection_pref_link,
SelectionListener.widgetSelectedAdapter(selectionEvent -> {
Shell parentShell = getParentShell();
close();
UIUtils.showPreferencesFor(parentShell, null, PrefPageUsageStatistics.PAGE_ID);
})
);
}

UIUtils.createEmptyLabel(composite, 1, 1);
UIUtils.createLink(composite,
StatisticCollectionMessages.statistic_collection_pref_link,
SelectionListener.widgetSelectedAdapter(selectionEvent -> {
Shell parentShell = getParentShell();
close();
UIUtils.showPreferencesFor(
parentShell,
null,
PrefPageUsageStatistics.PAGE_ID);
}));
UIUtils.createEmptyLabel(composite, 1, 1);
shareData = UIUtils.createCheckbox(composite, StatisticCollectionMessages.statistic_collection_dont_share_lbl, false);
doNotShareDataButton = UIUtils.createCheckbox(composite, StatisticCollectionMessages.statistic_collection_dont_share_lbl, false);

if (DBWorkbench.getPlatform().getApplication().isEarlyAccessProgram()) {
doNotShareDataButton.setEnabled(false);
UIUtils.createInfoLink(
composite,
"You cannot opt-out from data sharing when participating in <a>early access program</a>.",
() -> ShellUtils.launchProgram(HelpUtils.getHelpExternalReference("Early-access-program"))
);
}

return composite;
}

Expand All @@ -75,7 +90,7 @@ protected void createButtonsForButtonBar(@NotNull Composite parent) {

@Override
protected void buttonPressed(int buttonId) {
if (shareData.getSelection()) {
if (doNotShareDataButton.getSelection()) {
// DO NOT SEND
UIStatisticsActivator.setTrackingEnabled(buttonId == IDialogConstants.NO_ID);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,17 @@ public class UIStatisticsActivator extends AbstractUIPlugin {
public static final String PLUGIN_ID = "org.jkiss.dbeaver.ui.statistics";

public static final String PREF_FEATURE_TRACKING_ENABLED = "feature.tracking.enabled";
public static final String PREF_STATISTICS_PREVIEW_ENABLED = "feature.statistics.preview.enabled";
public static final String PREF_SKIP_DATA_SHARE_CONFIRMATION = "feature.tracking.skipConfirmation";

// The shared instance
private static UIStatisticsActivator plugin;
private DBPPreferenceStore preferences;
private static FeatureStatisticsCollector tracker;

public UIStatisticsActivator() {
}

public static boolean isTrackingEnabled() {
// TODO: Need to somehow enforce this to be true if we're in the EAP
return getDefault().getPreferences().getBoolean(PREF_FEATURE_TRACKING_ENABLED);
}

Expand All @@ -53,21 +52,6 @@ public static void setTrackingEnabled(boolean enabled) {
return;
}
setPreferenceValue(PREF_FEATURE_TRACKING_ENABLED, enabled);
if (tracker != null) {
if (enabled) {
tracker.startMonitor();
} else {
tracker.stopMonitor();
}
}
}

public static boolean isDetailsPreviewEnabled() {
return getDefault().getPreferences().getBoolean(PREF_STATISTICS_PREVIEW_ENABLED);
}

public static void setDetailsPreviewEnabled(boolean enabled) {
setPreferenceValue(PREF_STATISTICS_PREVIEW_ENABLED, enabled);
}

public static boolean isSkipDataShareConfirmation() {
Expand Down

0 comments on commit 564e3e1

Please sign in to comment.