public class LaunchShortcut implements ILaunchShortcut {
@Override
public void launch(ISelection selection, String mode) {
new myAppRunner().runFromSelection(selection);
}
@Override
public void launch(IEditorPart editorPart, String mode) {
if (editorPart instanceof MultiPageEditorPart) {
MultiPageEditorPart editor = (MultiPageEditorPart) editorPart;
new myAppRunner().runFromEditor(editor);
}
}
}
public void runFromSelection(ISelection selection) {
IProject project = ProjectUtil.getActiveAdtCoreProject(selection, null, null,
IAdtCoreProject.ABAP_PROJECT_NATURE);
if (project == null) {
MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "No selection",
"No ABAP Project selected");
} else {
...
...
public void runFromEditor(MultiPageEditorPart editor) {
IProject project = null;
if (editor instanceof IProjectProvider) {
IProjectProvider projectProvider = (IProjectProvider) editor;
project = projectProvider.getProject();
}
if (project == null) {
MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "No selection",
"No ABAP Project selected");
}
...
...
private void callBapi(IProject project, ArrayList<MyAppObjectStr> items) {
try {
String destinationId = com.sap.adt.project.AdtCoreProjectServiceFactory.createCoreProjectService()
.getDestinationId(project);
JCoDestination destination = JCoDestinationManager.getDestination(destinationId);
JCoFunction function = destination.getRepository().getFunction("Z_MY_APP");
...
function.execute(destination);
...
} catch (JCoException | PartInitException e1) {
e1.printStackTrace();
}
}
if (selection instanceof ITreeSelection) {
ITreeSelection treeSelection = (ITreeSelection) selection;
ArrayList<myObjects> items = new ArrayList<myObjects>();
for (final Iterator<?> i = treeSelection.iterator(); i.hasNext();) {
Object nodeObject = i.next();
if (nodeObject instanceof TreeNode) {
TreeNode node = (TreeNode) nodeObject;
if (node.getValue() instanceof AdtObjectReference) {
AdtObjectReference value = (AdtObjectReference) node.getValue();
myObject item = new myObject();
item.name = value.getName(); // Name of the class for example
item.type = value.getType().split("/")[0]; // CLAS/OC for example - I only want the bit before the /
items.add(item);
}
}
}
}
if (editor instanceof IAdtFormEditor) {
String objectName = editor.getTitle();
IAdtFormEditor formEditor = (IAdtFormEditor) editor;
String objectType = formEditor.getModel().getType();
ArrayList<MyObject> items = new ArrayList<MyObject>();
MyObject myObject = new MyObject();
myObject.name = objectName.split(" ")[1]; // Splitting "SystemID ObjectName"
myObject.type = objectType.split("/")[0]; // Splitting e.g. "CLAS/OC"
items.add(myObject);
...
}
public class LaunchConfigurationDelegate implements ILaunchConfigurationDelegate {
@Override
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor)
throws CoreException {
monitor.beginTask("Running ...", 0);
new myAppRunner().run(config, launch);
monitor.done();
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 |