Commit 17acf307 authored by Alexander Diewald's avatar Alexander Diewald

CLI: Add switch for triggering a platform shutdown

Use-case: Other CLI switches trigger some algortihms in some automated
tasks that use AF3. After processing these switches, the application
must be shutdown to indicate the end of processing in AF3.

Issue-Ref: 3994
Issue-Url: https://af3-developer.fortiss.org/issues/3994Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent bf8efe9e
ToolingBaseUIActivator.java dbb6f64b87a553ffbcfeb92160d84b63073dfd89 GREEN
ToolingBaseUIActivator.java d961cd206d8f44e851b2211430b25fee3d9071c0 YELLOW
......@@ -19,6 +19,8 @@ import static org.eclipse.jface.resource.ResourceLocator.imageDescriptorFromBund
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.fortiss.tooling.base.ui.cli.ShutdownPlatformCLIHandler;
import org.fortiss.tooling.kernel.service.ICommandLineInterfaceService;
import org.osgi.framework.BundleContext;
/**
......@@ -39,6 +41,9 @@ public class ToolingBaseUIActivator extends AbstractUIPlugin {
super.start(context);
plugin = this;
System.out.println("[Plugin] " + PLUGIN_ID + " started.");
ICommandLineInterfaceService cliService = ICommandLineInterfaceService.getInstance();
cliService.registerHandler("--shutdown", new ShutdownPlatformCLIHandler());
}
/** {@inheritDoc} */
......
ShutdownPlatformCLIHandler.java ea3d5d4522efcb01b66a9b0a3481739d71efb278 YELLOW
/*-------------------------------------------------------------------------+
| Copyright 2020 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.cli;
import static org.eclipse.ui.PlatformUI.getWorkbench;
import org.fortiss.tooling.kernel.extension.ICommandLineSwitchHandler;
/**
* Enables users of the CLI to trigger a platform shutdown after the preceding CLI switches were
* handled. Useful for automation tasks.
*
* @author diewald
*/
public class ShutdownPlatformCLIHandler implements ICommandLineSwitchHandler {
/** {@inheritDoc} */
@Override
public boolean hasAdditionalArgument() {
return false;
}
/** {@inheritDoc} */
@Override
public void handleCLISwitch(String argument) {
getWorkbench().close();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment