From ab19e48172ccb93dfb46e7d857b8b466fe4078cc Mon Sep 17 00:00:00 2001 From: Fr Jeremy Krieg Date: Sat, 21 Oct 2023 01:43:38 +1030 Subject: [PATCH] [bndtools] Create menu interface for LaunchToBndrun Signed-off-by: Fr Jeremy Krieg --- bndtools.core.services/bnd.bnd | 10 +- .../launchtobndrun/LaunchToBndrunAction.java | 66 ++++++++++ bndtools.core/_plugin.xml | 16 +++ .../bndtools.cocoa.macosx.aarch64.bndrun | 1 + .../bndtools.cocoa.macosx.x86_64.bndrun | 1 + .../bndtools.gtk.linux.x86_64.bndrun | 1 + bndtools.core/bndtools.shared.latest.bndrun | 122 ++++++++++++++++++ bndtools.core/bndtools.win32.x86_64.bndrun | 1 + 8 files changed, 216 insertions(+), 2 deletions(-) create mode 100644 bndtools.core.services/src/org/bndtools/pde/launchtobndrun/LaunchToBndrunAction.java create mode 100644 bndtools.core/bndtools.shared.latest.bndrun diff --git a/bndtools.core.services/bnd.bnd b/bndtools.core.services/bnd.bnd index dc260a8ba5..7d3a870e16 100644 --- a/bndtools.core.services/bnd.bnd +++ b/bndtools.core.services/bnd.bnd @@ -12,7 +12,8 @@ Import-Package: \ # Bundle Content -includepackage: \ - org.bndtools.core.editors.quickfix + org.bndtools.core.editors.quickfix,\ + org.bndtools.pde.launchtobndrun -conditionalpackage: \ aQute.lib.*,\ @@ -36,4 +37,9 @@ Import-Package: \ org.eclipse.swt.cocoa.macosx.x86_64,\ org.eclipse.jface.text,\ org.osgi.service.component.annotations;version='1.3.0',\ - slf4j.api + slf4j.api,\ + org.eclipse.jface,\ + org.eclipse.core.commands,\ + org.eclipse.ui.ide,\ + org.eclipse.ui.workbench,\ + biz.aQute.bnd.pde diff --git a/bndtools.core.services/src/org/bndtools/pde/launchtobndrun/LaunchToBndrunAction.java b/bndtools.core.services/src/org/bndtools/pde/launchtobndrun/LaunchToBndrunAction.java new file mode 100644 index 0000000000..9fa0d95239 --- /dev/null +++ b/bndtools.core.services/src/org/bndtools/pde/launchtobndrun/LaunchToBndrunAction.java @@ -0,0 +1,66 @@ +package org.bndtools.pde.launchtobndrun; + +import java.util.Iterator; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; +import org.osgi.service.component.annotations.Component; + +import aQute.lib.io.IO; +import biz.aQute.bnd.pde.launch2bndrun.LaunchToBndrun; + +@Component +public class LaunchToBndrunAction implements IObjectActionDelegate { + + IFile[] selected; + + @Override + public void run(IAction action) { + if (selected == null) { + return; + } + IFile s = selected[0]; + + try { + LaunchToBndrun lbr = new LaunchToBndrun(5, s.getContents()); + String name = s.getName() + .replaceAll("\\.launch$", ".bndrun"); + + IFile f = s.getParent() + .getFile(new Path(name)); + f.create(IO.stream(lbr.getDoc() + .get()), true, null); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + if (selection == null || !(selection instanceof StructuredSelection)) { + selected = null; + return; + } + StructuredSelection ss = (StructuredSelection) selection; + selected = new IFile[ss.size()]; + int n = 0; + for (@SuppressWarnings("unchecked") + Iterator i = ss.iterator(); i.hasNext();) { + selected[n++] = i.next(); + } + } + + @Override + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + // TODO Auto-generated method stub + + } + +} diff --git a/bndtools.core/_plugin.xml b/bndtools.core/_plugin.xml index 0b2e939518..0d19543825 100644 --- a/bndtools.core/_plugin.xml +++ b/bndtools.core/_plugin.xml @@ -882,6 +882,22 @@ + + + + + diff --git a/bndtools.core/bndtools.cocoa.macosx.aarch64.bndrun b/bndtools.core/bndtools.cocoa.macosx.aarch64.bndrun index f038254aad..79b8de34bd 100644 --- a/bndtools.core/bndtools.cocoa.macosx.aarch64.bndrun +++ b/bndtools.core/bndtools.cocoa.macosx.aarch64.bndrun @@ -29,6 +29,7 @@ -runbundles: \ biz.aQute.bnd.embedded-repo;version=snapshot,\ biz.aQute.bnd.maven;version=snapshot,\ + biz.aQute.bnd.pde;version=snapshot,\ biz.aQute.bnd.util;version=snapshot,\ biz.aQute.bndlib;version=snapshot,\ biz.aQute.repository;version=snapshot,\ diff --git a/bndtools.core/bndtools.cocoa.macosx.x86_64.bndrun b/bndtools.core/bndtools.cocoa.macosx.x86_64.bndrun index 479b82db99..808ad906bb 100644 --- a/bndtools.core/bndtools.cocoa.macosx.x86_64.bndrun +++ b/bndtools.core/bndtools.cocoa.macosx.x86_64.bndrun @@ -29,6 +29,7 @@ -runbundles: \ biz.aQute.bnd.embedded-repo;version=snapshot,\ biz.aQute.bnd.maven;version=snapshot,\ + biz.aQute.bnd.pde;version=snapshot,\ biz.aQute.bnd.util;version=snapshot,\ biz.aQute.bndlib;version=snapshot,\ biz.aQute.repository;version=snapshot,\ diff --git a/bndtools.core/bndtools.gtk.linux.x86_64.bndrun b/bndtools.core/bndtools.gtk.linux.x86_64.bndrun index 9b6f225c0e..42995a234d 100644 --- a/bndtools.core/bndtools.gtk.linux.x86_64.bndrun +++ b/bndtools.core/bndtools.gtk.linux.x86_64.bndrun @@ -28,6 +28,7 @@ -runbundles: \ biz.aQute.bnd.embedded-repo;version=snapshot,\ biz.aQute.bnd.maven;version=snapshot,\ + biz.aQute.bnd.pde;version=snapshot,\ biz.aQute.bnd.util;version=snapshot,\ biz.aQute.bndlib;version=snapshot,\ biz.aQute.repository;version=snapshot,\ diff --git a/bndtools.core/bndtools.shared.latest.bndrun b/bndtools.core/bndtools.shared.latest.bndrun new file mode 100644 index 0000000000..43e9c32a34 --- /dev/null +++ b/bndtools.core/bndtools.shared.latest.bndrun @@ -0,0 +1,122 @@ +# This run file contains all the cross-platform bundle and settings to run Bndtools. + +# Do not run this, use the platform-specific bndrun files (which "-include" this) + +-runfw: org.eclipse.osgi;version='[3.18.500.v20230801-1826,3.18.500.v20230801-1826]' + +-runvm: \ + -Xmx2g, \ + -ea + +-runpath: \ + ch.qos.logback.classic,\ + ch.qos.logback.core,\ + org.apache.felix.logback,\ + slf4j.api + +-runproperties: \ + eclipse.application=org.eclipse.ui.ide.workbench,\ + eclipse.consoleLog=,\ + eclipse.home.location=${fileuri;${.}/../bndtools.test/workspace},\ + eclipse.launcher=bndtools.core,\ + eclipse.product=org.eclipse.sdk.ide,\ + osgi.console=,\ + osgi.instance.area.default=../bndtools.test/workspace,\ + org.osgi.framework.bootdelegation='javax.net,javax.management,javax.net.ssl',\ + logback.configurationFile=${fileuri;${.}/logback.xml} + +# Keep sorted so that we can diff +-runrequires: \ + bnd.identity;id='biz.aQute.bnd.embedded-repo',\ + bnd.identity;id='bndtools.api',\ + bnd.identity;id='bndtools.builder',\ + bnd.identity;id='bndtools.core',\ + bnd.identity;id='bndtools.core.services',\ + bnd.identity;id='bndtools.jareditor',\ + bnd.identity;id='bndtools.m2e',\ + bnd.identity;id='bndtools.m2e.debug.fragment',\ + bnd.identity;id='bndtools.pde',\ + bnd.identity;id='bndtools.release',\ + bnd.identity;id='com.google.guava',\ + bnd.identity;id='javax.annotation',\ + bnd.identity;id='org.apache.ant',\ + bnd.identity;id='org.apache.felix.gogo.command',\ + bnd.identity;id='org.apache.felix.gogo.runtime',\ + bnd.identity;id='org.apache.felix.gogo.shell',\ + bnd.identity;id='org.bndtools.applaunch',\ + bnd.identity;id='org.bndtools.headless.build.manager',\ + bnd.identity;id='org.bndtools.headless.build.plugin.ant',\ + bnd.identity;id='org.bndtools.headless.build.plugin.gradle',\ + bnd.identity;id='org.bndtools.launch',\ + bnd.identity;id='org.bndtools.remoteinstall',\ + bnd.identity;id='org.bndtools.templates.template',\ + bnd.identity;id='org.bndtools.templating',\ + bnd.identity;id='org.bndtools.templating.gitrepo',\ + bnd.identity;id='org.bndtools.versioncontrol.ignores.manager',\ + bnd.identity;id='org.bndtools.versioncontrol.ignores.plugin.git',\ + bnd.identity;id='org.eclipse.ant.core',\ + bnd.identity;id='org.eclipse.ant.ui',\ + bnd.identity;id='org.eclipse.emf.ant',\ + bnd.identity;id='org.eclipse.emf.codegen.ecore.ui',\ + bnd.identity;id='org.eclipse.emf.codegen.ui',\ + bnd.identity;id='org.eclipse.emf.common.ui',\ + bnd.identity;id='org.eclipse.emf.databinding',\ + bnd.identity;id='org.eclipse.emf.databinding.edit',\ + bnd.identity;id='org.eclipse.emf.edit.ui',\ + bnd.identity;id='org.eclipse.emf.exporter',\ + bnd.identity;id='org.eclipse.emf.importer',\ + bnd.identity;id='org.eclipse.emf.importer.ecore',\ + bnd.identity;id='org.eclipse.emf.importer.java',\ + bnd.identity;id='org.eclipse.core.databinding.beans',\ + bnd.identity;id='org.eclipse.core.filesystem',\ + bnd.identity;id='org.eclipse.e4.tools.services',\ + bnd.identity;id='org.eclipse.egit.ui',\ + bnd.identity;id='org.eclipse.equinox.console',\ + bnd.identity;id='org.eclipse.equinox.event',\ + bnd.identity;id='org.eclipse.jdt.annotation',\ + bnd.identity;id='org.eclipse.m2e.binaryproject.ui',\ + bnd.identity;id='org.eclipse.m2e.discovery',\ + bnd.identity;id='org.eclipse.m2e.editor',\ + bnd.identity;id='org.eclipse.m2e.jdt.ui',\ + bnd.identity;id='org.eclipse.m2e.profiles.core',\ + bnd.identity;id='org.eclipse.m2e.profiles.ui',\ + bnd.identity;id='org.eclipse.m2e.refactoring',\ + bnd.identity;id='org.eclipse.m2e.scm',\ + bnd.identity;id='org.eclipse.m2e.sourcelookup.ui',\ + bnd.identity;id='org.eclipse.osgi.compatibility.state',\ + bnd.identity;id='org.eclipse.pde.build',\ + bnd.identity;id='org.eclipse.pde.core',\ + bnd.identity;id='org.eclipse.pde.genericeditor.extension',\ + bnd.identity;id='org.eclipse.pde.launching',\ + bnd.identity;id='org.eclipse.pde.runtime',\ + bnd.identity;id='org.eclipse.pde.ua.core',\ + bnd.identity;id='org.eclipse.pde.ua.ui',\ + bnd.identity;id='org.eclipse.pde.ui',\ + bnd.identity;id='org.eclipse.sdk',\ + bnd.identity;id='org.eclipse.ui.browser',\ + bnd.identity;id='org.eclipse.ui.console',\ + bnd.identity;id='org.eclipse.ui.ide',\ + bnd.identity;id='org.eclipse.ui.ide.application',\ + bnd.identity;id='junit-platform-commons';version='${range;[===,==+);${junit.platform.eclipse.version}}',\ + bnd.identity;id='junit-platform-engine';version='${range;[===,==+);${junit.platform.eclipse.version}}',\ + bnd.identity;id='junit-platform-launcher';version='${range;[===,==+);${junit.platform.eclipse.version}}' + +-runblacklist: \ + bnd.identity;id='biz.aQute.bnd.annotation',\ + bnd.identity;id='biz.aQute.bnd.transform',\ + bnd.identity;id='biz.aQute.junit',\ + bnd.identity;id='org.apache.felix.scr';version='[0,2.1.16)',\ + bnd.identity;id='osgi.*',\ + bnd.identity;id='org.osgi.*.annotations' + +-runrepos: \ + "Workspace",\ + "Maven Central",\ + "Eclipse 4.29 (2023-09)" + +-runee: JavaSE-17 + +# This will help us keep -runbundles sorted +-runstartlevel: \ + order=sortbynameversion,\ + begin=-1 diff --git a/bndtools.core/bndtools.win32.x86_64.bndrun b/bndtools.core/bndtools.win32.x86_64.bndrun index 3100d7c7dd..0829dc3f9d 100644 --- a/bndtools.core/bndtools.win32.x86_64.bndrun +++ b/bndtools.core/bndtools.win32.x86_64.bndrun @@ -27,6 +27,7 @@ -runbundles: \ biz.aQute.bnd.embedded-repo;version=snapshot,\ biz.aQute.bnd.maven;version=snapshot,\ + biz.aQute.bnd.pde;version=snapshot,\ biz.aQute.bnd.util;version=snapshot,\ biz.aQute.bndlib;version=snapshot,\ biz.aQute.repository;version=snapshot,\