Skip to content

Commit

Permalink
[574644] Support direct drag&drop of Auto-Launch-Installer Button
Browse files Browse the repository at this point in the history
https://bugs.eclipse.org/bugs/show_bug.cgi?id=574644

Change-Id: I5f48f5687610205036d74e6a9579842264796c63
  • Loading branch information
HannesWell committed Jul 4, 2021
1 parent f877298 commit c61e85c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
Expand Up @@ -360,7 +360,7 @@ public boolean handleMissingIndex(Shell shell)

public void runEventLoop(Shell shell)
{
// Use our own even loop so we can process delayed events.
// Use our own event loop so we can process delayed events.
// This ensures that we do not process delayed events while any other modal dialog is in its own event loop.
Display display = shell.getDisplay();
while (!shell.isDisposed())
Expand Down
@@ -1,12 +1,13 @@
/*
* Copyright (c) 2016 Ed Merks (Berlin, Germany) and others.
* Copyright (c) 2016, 2021 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:
* Eike Stepper - initial API and implementation
* Hannes Wellmann - Bug 574644: Support direct drag&drop of Auto-Launch-Installer Button
*/
package org.eclipse.oomph.setup.ui;

Expand Down Expand Up @@ -56,6 +57,8 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* @author Ed Merks
Expand Down Expand Up @@ -409,9 +412,41 @@ public void doExecute()

class LoadResourceCommand extends ResourceCommand
{
private static final Pattern AUTO_LAUNCHER_WEBSITE = Pattern.compile("^https?://www\\.eclipse\\.org/setups/installer/\\?"); //$NON-NLS-1$

private static final Pattern SETUP_URL_PARAMETER = Pattern.compile("url=([^&]+)"); //$NON-NLS-1$

private static URI extractSetupURLIfAutoLauncherURL(URI uri)
{
if (AUTO_LAUNCHER_WEBSITE.matcher(uri.toString()).find() && uri.hasQuery())
{
Matcher matcher = SETUP_URL_PARAMETER.matcher(uri.query());
if (matcher.find())
{
String setupURL = matcher.group(1);
return URI.createURI(setupURL);
}
}
return uri;
}

private static Collection<?> extractSetupURLsIfAutoLauncherURLs(Collection<?> collection)
{
if (collection == null)
{
return collection;
}
Collection<Object> copy = new ArrayList<Object>(collection.size());
for (Object object : collection)
{
copy.add(object instanceof URI ? extractSetupURLIfAutoLauncherURL((URI)object) : object);
}
return copy;
}

protected LoadResourceCommand(EditingDomain domain, Collection<?> collection)
{
super(domain, collection);
super(domain, extractSetupURLsIfAutoLauncherURLs(collection));
}

@Override
Expand Down

0 comments on commit c61e85c

Please sign in to comment.