Skip to content
Snippets Groups Projects
Commit e7b920de authored by Andreas Bayha's avatar Andreas Bayha
Browse files

Added context menu entry with call of "deploy" command.


Signed-off-by: default avatarAndreas Bayha <bayha@fortiss.org>
parent cc459bc7
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,8 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="3.7.0";visibility:=reexport,
org.fortiss.af3.project.ui;bundle-version="1.0.0";visibility:=reexport,
org.fortiss.tooling.base.ui;bundle-version="1.0.0";visibility:=reexport,
org.fortiss.af3.platform.raspberry.ui;bundle-version="2.13.0";visibility:=reexport,
org.fortiss.af3.platform.modelsconference;bundle-version="2.13.0"
org.fortiss.af3.platform.modelsconference;bundle-version="2.13.0",
org.fortiss.af3.deployment.ui
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Vendor: fortiss GmbH
......@@ -35,4 +35,16 @@
provider="org.fortiss.af3.platform.modelsconference.ui.MCBProtoypeProvider">
</modelPrototypeProvider>
</extension>
<extension
point="org.fortiss.tooling.kernel.ui.contextMenuContribution">
<contextMenuContribution
contributor="org.fortiss.af3.platform.modelsconference.ui.generator.SSHDeploymentGeneratorEasyStartMenu">
</contextMenuContribution>
</extension>
<extension
point="org.fortiss.af3.project.executionTarget">
<executionTarget
target="org.fortiss.af3.platform.modelsconference.ui.generator.SSHDeploymentGeneratorExecutionTarget">
</executionTarget>
</extension>
</plugin>
SSHDeploymentGeneratorEasyStartMenu.java 542428f44fe8d3686265887fa3ae8602e52b2d04 YELLOW
SSHDeploymentGeneratorExecutionTarget.java 4f148980269e30d34502c758e331ae7ac8f8f09b YELLOW
/*-------------------------------------------------------------------------+
| Copyright 2018 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.af3.platform.modelsconference.ui.generator;
import static org.fortiss.af3.project.ui.AF3ProjectUIActivator.getImageDescriptor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.fortiss.af3.deployment.model.Deployment;
import org.fortiss.af3.project.extension.IExecutionTarget;
import org.fortiss.af3.project.services.IExecutionService;
import org.fortiss.af3.project.ui.execution.EasyStartMenuBase;
import org.fortiss.tooling.kernel.model.INamedElement;
import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
import org.fortiss.tooling.kernel.ui.service.INavigatorService;
/**
* {@link EasyStartMenuBase} for the {@link SSHDeploymentGeneratorExecutionTarget}.
*
* @author hoelzl
* @author bayha
*/
public class SSHDeploymentGeneratorEasyStartMenu extends EasyStartMenuBase {
/** Constructor. */
public SSHDeploymentGeneratorEasyStartMenu() {
super(getDeploymentGeneratorTargetFromExecutionService());
}
/** Returns the simulator execution target. */
private static IExecutionTarget getDeploymentGeneratorTargetFromExecutionService() {
return IExecutionService.INSTANCE
.getSpecificExecutionTarget(SSHDeploymentGeneratorExecutionTarget.class);
}
/** {@inheritDoc} */
@Override
public String getMenuSectionID() {
return IContextMenuService.BOTTOM_MOST_MENU_SECTION_ID;
}
/** {@inheritDoc} */
@Override
protected boolean acceptSelection(INamedElement selection,
ContextMenuContextProvider contextProvider) {
return (selection instanceof Deployment) &&
INavigatorService.getInstance().isNavigatorView(contextProvider);
}
/** {@inheritDoc} */
@Override
protected String getActionName() {
return "Run DeploymentGenerator and deploy";
}
/** {@inheritDoc} */
@Override
protected ImageDescriptor getActionIcon() {
return getImageDescriptor("icons/execution_configuration.gif");
}
/** {@inheritDoc} */
@Override
protected String getStartupFailureMessage(Exception e) {
return "Starting the code generator failed. Please check if your model is free of error markers and every component has a defined behavior. Please consult the error log for detailed error information.";
}
}
/*-------------------------------------------------------------------------+
| Copyright 2018 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.af3.platform.modelsconference.ui.generator;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import java.io.IOException;
import org.fortiss.af3.deployment.ui.generator.DeploymentGeneratorExecutionTarget;
import org.fortiss.af3.platform.modelsconference.ui.AF3PlatformModelsConferencUIActivator;
import org.fortiss.af3.project.extension.data.Executable;
/**
* ExecutionTarget for deployment generator extended with a call of a deploy script.
*
* @author bayha
*/
public class SSHDeploymentGeneratorExecutionTarget extends DeploymentGeneratorExecutionTarget {
/** {@inheritDoc} */
@Override
protected void doExecute(Executable executable) {
super.doExecute(executable);
Runtime r = Runtime.getRuntime();
int retCode = -1;
try {
Process p = r.exec("deploy");
retCode = p.waitFor();
} catch(IOException e) {
e.printStackTrace();
} catch(InterruptedException e) {
e.printStackTrace();
}
if(retCode != 0) {
error(AF3PlatformModelsConferencUIActivator.getDefault(),
"Generated code could not be deployed.");
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment