Skip to content

Commit

Permalink
[562040] Provide support for donation from within the IDE
Browse files Browse the repository at this point in the history
  • Loading branch information
merks committed Apr 12, 2020
1 parent 5ee21ff commit b46c176
Show file tree
Hide file tree
Showing 12 changed files with 269 additions and 9 deletions.
Expand Up @@ -153,7 +153,17 @@ private ProductCatalog create()
IProduct product = Platform.getProduct();
if (product != null)
{
String name = product.getName();
String name = product.getProperty("aboutText");
if (name != null && name.startsWith("Eclipse"))
{
name = name.replaceAll("[\n\r]+.*", "");
}

if (StringUtil.isEmpty(name))
{
name = product.getName();
}

if (!StringUtil.isEmpty(name))
{
selfProduct.setLabel(name);
Expand Down
10 changes: 5 additions & 5 deletions plugins/org.eclipse.oomph.setup.editor/META-INF/MANIFEST.MF
Expand Up @@ -2,13 +2,13 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.oomph.setup.editor;singleton:=true
Bundle-Version: 1.16.0.qualifier
Bundle-Version: 1.17.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.oomph.setup.presentation.SetupEditorPlugin$Implementation
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.eclipse.oomph.setup.editor;version="1.16.0";x-internal:=true,
Export-Package: org.eclipse.oomph.setup.editor;version="1.17.0";x-internal:=true,
org.eclipse.oomph.setup.presentation;version="1.5.0";x-internal:=true,
org.eclipse.oomph.setup.presentation.handlers;version="1.5.0";x-internal:=true,
org.eclipse.oomph.setup.presentation.templates;version="1.5.0";x-internal:=true
Expand All @@ -20,18 +20,18 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)",
org.eclipse.oomph.resources.edit;bundle-version="[1.10.0,2.0.0)";visibility:=reexport,
org.eclipse.oomph.preferences;bundle-version="[1.11.0,2.0.0)",
org.eclipse.oomph.setup.edit;bundle-version="[1.14.0,2.0.0)";visibility:=reexport,
org.eclipse.oomph.setup.ui;bundle-version="[1.16.0,2.0.0)",
org.eclipse.oomph.setup.ui;bundle-version="[1.17.0,2.0.0)",
org.eclipse.oomph.setup.sync;bundle-version="[1.12.0,2.0.0)",
org.eclipse.oomph.workingsets.edit;bundle-version="[1.10.0,2.0.0)";visibility:=reexport,
org.eclipse.oomph.workingsets.editor;bundle-version="[1.11.0,2.0.0)",
org.eclipse.emf.ecore.xmi;bundle-version="[2.10.0,3.0.0)";visibility:=reexport,
org.eclipse.emf.edit.ui;bundle-version="[2.10.0,3.0.0)";visibility:=reexport,
org.eclipse.equinox.p2.metadata;bundle-version="[2.0.0,3.0.0)",
org.eclipse.oomph.ui;bundle-version="[1.13.0,2.0.0)",
org.eclipse.oomph.ui;bundle-version="[1.14.0,2.0.0)",
org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)";visibility:=reexport,
org.eclipse.oomph.base.edit;bundle-version="[1.12.0,2.0.0)";visibility:=reexport,
org.eclipse.oomph.setup.p2.edit;bundle-version="[1.12.0,2.0.0)",
org.eclipse.oomph.p2.edit;bundle-version="[1.12.0,2.0.0)";visibility:=reexport,
org.eclipse.oomph.p2.edit;bundle-version="[1.13.0,2.0.0)";visibility:=reexport,
org.eclipse.oomph.p2.ui;bundle-version="[1.13.0,2.0.0)"
Bundle-ActivationPolicy: lazy
Automatic-Module-Name: org.eclipse.oomph.setup.editor
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions plugins/org.eclipse.oomph.setup.editor/plugin.properties
Expand Up @@ -77,4 +77,7 @@ _UI_SetupModelWizard_description6 = Create a new project catalog setup model
_UI_SetupModelWizard_label7 = Setup Macro Model
_UI_SetupModelWizard_description7 = Create a new macro setup model with the camel case name of the macro

_UI_Donate_label = Donate
_UI_Donate_description = Donate to the development of the Eclipse IDE


28 changes: 28 additions & 0 deletions plugins/org.eclipse.oomph.setup.editor/plugin.xml
Expand Up @@ -174,6 +174,20 @@
id="org.eclipse.oomph.setup.editor.refreshCache"
name="Refresh Remote Cache">
</command>
<command
defaultHandler="org.eclipse.oomph.setup.presentation.handlers.DonateHandler"
description="%_UI_Donate_description"
id="org.eclipse.oomph.setup.donate"
name="%_UI_Donate_label">
</command>
</extension>

<extension
point="org.eclipse.ui.commandImages">
<image
commandId="org.eclipse.oomph.setup.donate"
icon="icons/heart.png">
</image>
</extension>

<extension
Expand Down Expand Up @@ -475,6 +489,20 @@
style="push">
</command>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="menu:help?after=about">
<command
commandId="org.eclipse.oomph.setup.donate"
style="push">
<visibleWhen>
<test
forcePluginActivation="true"
property="org.eclipse.oomph.setup.ui.donating">
</test>
</visibleWhen>
</command>
</menuContribution>
</extension>

</plugin>
2 changes: 1 addition & 1 deletion plugins/org.eclipse.oomph.setup.editor/pom.xml
Expand Up @@ -20,7 +20,7 @@
</parent>
<groupId>org.eclipse.oomph</groupId>
<artifactId>org.eclipse.oomph.setup.editor</artifactId>
<version>1.16.0-SNAPSHOT</version>
<version>1.17.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

<build>
Expand Down
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2020 Ed Merks (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Ed Merks - initial API and implementation
*/
package org.eclipse.oomph.setup.presentation.handlers;

import org.eclipse.oomph.setup.presentation.SetupEditorPlugin;
import org.eclipse.oomph.setup.ui.SetupPropertyTester;
import org.eclipse.oomph.util.PropertiesUtil;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWebBrowser;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;

import javax.net.ssl.SSLEngineResult.Status;

import java.net.URL;

/**
* @author Ed Merks
*/
public class DonateHandler extends AbstractHandler
{
public DonateHandler()
{
}

public Object execute(ExecutionEvent event) throws ExecutionException
{
IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
try
{
String donating = SetupPropertyTester.getDonating();
int style = IWorkbenchBrowserSupport.AS_EDITOR;
if ("true".equals(PropertiesUtil.getProperty("org.eclipse.oomph.setup.dontate.navigation", "false")))
{
style |= IWorkbenchBrowserSupport.NAVIGATION_BAR;
}

if ("true".equals(PropertiesUtil.getProperty("org.eclipse.oomph.setup.dontate.location", "false")))
{
style |= IWorkbenchBrowserSupport.LOCATION_BAR;
}

IWebBrowser browser = browserSupport.createBrowser(style, "donate", SetupEditorPlugin.INSTANCE.getString("_UI_Donate_label"), donating);
browser.openURL(new URL(donating));
}
catch (Exception ex)
{
SetupEditorPlugin.INSTANCE.log(ex, IStatus.WARNING);
}

return Status.OK;
}
}
Expand Up @@ -1437,7 +1437,7 @@ public void widgetSelected(SelectionEvent e)
protected void handleWidgetSelected()
{
String resolvedURI = uri.toString().replace("${installer.version}", URI.encodeQuery(SelfUpdate.getProductVersion(), true)).replace("${scope}",
URI.encodeQuery(StringUtil.safe(scopeLabel), false));
URI.encodeQuery(StringUtil.safe(scopeLabel).replace("+", "%2B"), false));
OS.INSTANCE.openSystemBrowser(resolvedURI);
update(getURI(), getText(), getToolTipText(), AnimationStyle.NONE, false, buttonColor, scopeLabel);
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/org.eclipse.oomph.setup.ui/plugin.xml
Expand Up @@ -104,7 +104,7 @@
class="org.eclipse.oomph.setup.ui.SetupPropertyTester"
id="org.eclipse.oomph.setup.ui.propertyTester"
namespace="org.eclipse.oomph.setup.ui"
properties="starting,performing,handling,showToolBarContributions,syncEnabled"
properties="starting,performing,handling,showToolBarContributions,syncEnabled,donating"
type="java.lang.Object">
</propertyTester>
</extension>
Expand Down
Expand Up @@ -42,6 +42,8 @@ public class SetupPropertyTester extends PropertyTester

public static final String SHOW_PROGRESS_IN_WIZARD = "showProgressInWizard";

public static final String DONATING = "donating";

private static final Preferences PREFERENCES = SetupUIPlugin.INSTANCE.getInstancePreferences();

private static boolean starting;
Expand All @@ -54,6 +56,8 @@ public class SetupPropertyTester extends PropertyTester

private static boolean started;

private static String donating;

static
{
((IEclipsePreferences)PREFERENCES).addPreferenceChangeListener(new IEclipsePreferences.IPreferenceChangeListener()
Expand Down Expand Up @@ -108,6 +112,11 @@ public boolean test(Object receiver, String property, Object[] args, Object expe
return testShowToolBarContributions(receiver, args, expectedValue);
}

if (DONATING.equals(property))
{
return testDonating(receiver, args, expectedValue);
}

return false;
}

Expand Down Expand Up @@ -167,6 +176,16 @@ private boolean testShowToolBarContributions(Object receiver, Object[] args, Obj
return expectedValue.equals(value);
}

private boolean testDonating(Object receiver, Object[] args, Object expectedValue)
{
if (expectedValue == null)
{
expectedValue = Boolean.TRUE;
}

return expectedValue.equals(donating != null);
}

public static void setStarting(boolean starting)
{
if (!starting)
Expand Down Expand Up @@ -236,6 +255,17 @@ public void widgetDisposed(DisposeEvent e)
UIPropertyTester.requestEvaluation(PREFIX + HANDLING, false);
}

public static String getDonating()
{
return donating;
}

public static void setDonating(String donating)
{
SetupPropertyTester.donating = donating;
UIPropertyTester.requestEvaluation(PREFIX + DONATING, false);
}

public static boolean isShowProgressInWizard()
{
return PREFERENCES.getBoolean(SHOW_PROGRESS_IN_WIZARD, false);
Expand Down

0 comments on commit b46c176

Please sign in to comment.