From 49f14f0278277e965b3f96cc9b7419e67c584957 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Fri, 28 Jun 2019 12:55:03 +0200 Subject: [PATCH] Work on IDE --- ide/features/org.argeo.slc.ide/feature.xml | 558 ++++++++- .../META-INF/MANIFEST.MF | 2 +- .../org.argeo.slc.ide.product | 1053 +---------------- .../org.argeo.slc.ide.branding/plugin.xml | 6 +- .../org.argeo.slc.ide.ui/META-INF/MANIFEST.MF | 51 +- ide/plugins/org.argeo.slc.ide.ui/bnd.bnd | 8 +- ide/plugins/org.argeo.slc.ide.ui/plugin.xml | 16 +- .../argeo/slc/ide/ui/DeployedSlcSystem.java | 50 - .../argeo/slc/ide/ui/EmbeddedSlcSystem.java | 34 - .../src/org/argeo/slc/ide/ui/SlcSystem.java | 10 - .../preferences/SlcLaunchPreferencePage.java | 34 - .../SlcScriptLaunchConfigurationTab.java | 188 --- .../SlcScriptLaunchConfigurationTabGroup.java | 16 - .../script/SlcScriptLaunchDelegate.java | 258 ---- .../script/SlcScriptLaunchShortcut.java | 127 -- .../SlcScriptLaunchShortcutWithDialog.java | 11 - .../ide/ui/launch/script/SlcScriptUtils.java | 23 - 17 files changed, 643 insertions(+), 1802 deletions(-) delete mode 100644 ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/DeployedSlcSystem.java delete mode 100644 ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/EmbeddedSlcSystem.java delete mode 100644 ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/SlcSystem.java delete mode 100644 ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/preferences/SlcLaunchPreferencePage.java delete mode 100644 ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchConfigurationTab.java delete mode 100644 ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchConfigurationTabGroup.java delete mode 100644 ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchDelegate.java delete mode 100644 ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchShortcut.java delete mode 100644 ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchShortcutWithDialog.java delete mode 100644 ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptUtils.java diff --git a/ide/features/org.argeo.slc.ide/feature.xml b/ide/features/org.argeo.slc.ide/feature.xml index b4cb5460c..b5b9d55f4 100644 --- a/ide/features/org.argeo.slc.ide/feature.xml +++ b/ide/features/org.argeo.slc.ide/feature.xml @@ -2,7 +2,7 @@ @@ -54,7 +54,561 @@ and limitations under the License. id="org.argeo.slc.ide.ui" download-size="0" install-size="0" - version="1.1.1.qualifier" + version="0.0.0" + unpack="false"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ide/plugins/org.argeo.slc.ide.branding/META-INF/MANIFEST.MF b/ide/plugins/org.argeo.slc.ide.branding/META-INF/MANIFEST.MF index 2c7c4a9fd..ee62975b0 100644 --- a/ide/plugins/org.argeo.slc.ide.branding/META-INF/MANIFEST.MF +++ b/ide/plugins/org.argeo.slc.ide.branding/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Argeo IDE Bundle-SymbolicName: org.argeo.slc.ide.branding;singleton:=true -Bundle-Version: 1.1.1.D20121107_1340 +Bundle-Version: 2.1.0.qualifier Bundle-Vendor: Argeo.org Require-Bundle: org.eclipse.ui, org.eclipse.osgi, diff --git a/ide/plugins/org.argeo.slc.ide.branding/org.argeo.slc.ide.product b/ide/plugins/org.argeo.slc.ide.branding/org.argeo.slc.ide.product index 6561c4101..7b2bd4927 100644 --- a/ide/plugins/org.argeo.slc.ide.branding/org.argeo.slc.ide.product +++ b/ide/plugins/org.argeo.slc.ide.branding/org.argeo.slc.ide.product @@ -1,7 +1,7 @@ - + @@ -16,8 +16,6 @@ -console - -Dargeo.osgi.start.2.node=org.eclipse.equinox.http.servlet,org.eclipse.equinox.http.jetty,org.eclipse.equinox.metatype,org.eclipse.equinox.cm,org.eclipse.rap.rwt.osgi -Dargeo.osgi.start.3.node=org.argeo.cms -Dargeo.osgi.start.4.apps=org.eclipse.gemini.blueprint.extender -Djava.security.manager= -Djava.security.policy=all.policy - -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts @@ -29,13 +27,14 @@ startupProgressRect="0,280,455,15" startupMessageRect="7,220,441,20" startupForegroundColor="0066D0" /> - + + org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8 @@ -134,999 +133,69 @@ This Agreement is governed by the laws of the State of New York and the intellec - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - diff --git a/ide/plugins/org.argeo.slc.ide.branding/plugin.xml b/ide/plugins/org.argeo.slc.ide.branding/plugin.xml index 850762749..d93417c59 100644 --- a/ide/plugins/org.argeo.slc.ide.branding/plugin.xml +++ b/ide/plugins/org.argeo.slc.ide.branding/plugin.xml @@ -6,8 +6,8 @@ id="product" point="org.eclipse.core.runtime.products"> + application="org.eclipse.e4.ui.workbench.swt.E4Application" + name="Argeo IDE"> @@ -34,7 +34,7 @@ + value="Argeo IDE"> @@ -41,10 +41,10 @@ diff --git a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/DeployedSlcSystem.java b/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/DeployedSlcSystem.java deleted file mode 100644 index 89924322a..000000000 --- a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/DeployedSlcSystem.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.argeo.slc.ide.ui; - -import java.io.File; -import java.io.IOException; -import java.util.List; -import java.util.Vector; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.launching.IVMInstall; -import org.eclipse.jdt.launching.JavaRuntime; - -public class DeployedSlcSystem implements SlcSystem { - private File baseDir; - private String relLibDir = "lib"; - - public DeployedSlcSystem(String baseDirPath) { - try { - this.baseDir = new File(baseDirPath).getCanonicalFile(); - } catch (IOException e) { - throw new RuntimeException("Cannot get path for " + baseDirPath, e); - } - } - - public String[] getClasspath() throws CoreException { - List classpath = new Vector(); - File libDir = new File(baseDir.getPath() + File.separator + relLibDir); - File[] files = libDir.listFiles(); - for (File file : files) { - try { - classpath.add(file.getCanonicalPath()); - } catch (IOException e) { - throw new RuntimeException("Cannot get path for " + file, e); - } - } - return classpath.toArray(new String[classpath.size()]); - } - - public IVMInstall getVmInstall() throws CoreException { - return JavaRuntime.getDefaultVMInstall(); - } - - public String getAntHome() { - return baseDir.getPath(); - } - - public String getJavaLibraryPath() { - return baseDir.getPath() + File.separator + "bin"; - } - -} diff --git a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/EmbeddedSlcSystem.java b/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/EmbeddedSlcSystem.java deleted file mode 100644 index e2414e0e0..000000000 --- a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/EmbeddedSlcSystem.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.argeo.slc.ide.ui; - -import org.argeo.slc.ide.ui.launch.preferences.SlcLaunchPreferencePage; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.launching.IVMInstall; -import org.eclipse.jdt.launching.JavaRuntime; - -public class EmbeddedSlcSystem implements SlcSystem { - private final IJavaProject project; - - public EmbeddedSlcSystem(IJavaProject project) { - this.project = project; - } - - public String[] getClasspath() throws CoreException { - return JavaRuntime.computeDefaultRuntimeClassPath(project); - } - - public String getJavaLibraryPath() { - String javaLibPath = SlcIdeUiPlugin.getDefault() - .getPreferenceStore().getString( - SlcLaunchPreferencePage.PREF_SLC_RUNTIME_LOCATION); - if (javaLibPath == null || javaLibPath.equals("")) - return null; - else - return javaLibPath; - } - - public IVMInstall getVmInstall() throws CoreException { - return JavaRuntime.getVMInstall(project); - } - -} diff --git a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/SlcSystem.java b/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/SlcSystem.java deleted file mode 100644 index ff797c66a..000000000 --- a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/SlcSystem.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.argeo.slc.ide.ui; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.launching.IVMInstall; - -public interface SlcSystem { - public String[] getClasspath() throws CoreException; - public String getJavaLibraryPath(); - public IVMInstall getVmInstall() throws CoreException; -} diff --git a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/preferences/SlcLaunchPreferencePage.java b/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/preferences/SlcLaunchPreferencePage.java deleted file mode 100644 index 24c675760..000000000 --- a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/preferences/SlcLaunchPreferencePage.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.argeo.slc.ide.ui.launch.preferences; - -import org.argeo.slc.ide.ui.SlcIdeUiPlugin; -import org.eclipse.jface.preference.DirectoryFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -public class SlcLaunchPreferencePage extends FieldEditorPreferencePage implements - IWorkbenchPreferencePage { - public final static String PREF_SLC_RUNTIME_LOCATION = SlcIdeUiPlugin.ID - + ".slcRuntimeLocation"; - public final static String PREF_EMBEDDED_JAVA_LIBRARY_PATH = SlcIdeUiPlugin.ID - + ".embeddedJavaLibraryPath"; - - public SlcLaunchPreferencePage() { -// IPreferenceStore store = SlcUiLaunchPlugin.getDefault() -// .getPreferenceStore(); -// setPreferenceStore(store); - setDescription("Argeo SLC Launch Preferences"); - } - - @Override - protected void createFieldEditors() { - addField(new DirectoryFieldEditor(PREF_SLC_RUNTIME_LOCATION, - "SLC Runtime", getFieldEditorParent())); - addField(new DirectoryFieldEditor(PREF_EMBEDDED_JAVA_LIBRARY_PATH, - "Embedded Java Library Path", getFieldEditorParent())); - } - - public void init(IWorkbench workbench) { - } - -} diff --git a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchConfigurationTab.java b/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchConfigurationTab.java deleted file mode 100644 index 3af85d653..000000000 --- a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchConfigurationTab.java +++ /dev/null @@ -1,188 +0,0 @@ -package org.argeo.slc.ide.ui.launch.script; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -public class SlcScriptLaunchConfigurationTab extends - AbstractLaunchConfigurationTab { - - private Text scriptTF; - private Text propertiesTF; - private Text runtimeTF; - private Text targetsTF; - private Button pre093B; - - public void createControl(Composite parent) { - Composite body = new Composite(parent, SWT.NONE); - setControl(body); - body.setLayout(new GridLayout(1, false)); - body.setFont(parent.getFont()); - - createLabel(body, "Script location"); - scriptTF = createSingleText(body); - createWorkspaceButton(body); - - createLabel(body, "Runtime"); - runtimeTF = createSingleText(body); - - createLabel(body, "Targets"); - targetsTF = createSingleText(body); - - createLabel(body, "Properties"); - propertiesTF = createMultipleText(body, 10); - - pre093B = createCheckBox(body, "Pre SLC v0.9.3"); - } - - public String getName() { - return "SLC"; - } - - public void initializeFrom(ILaunchConfiguration configuration) { - try { - scriptTF.setText(configuration.getAttribute( - SlcScriptUtils.ATTR_SCRIPT, "")); - - boolean pre093 = configuration.getAttribute( - SlcScriptUtils.ATTR_PRE093, false); - - propertiesTF.setText(configuration.getAttribute( - SlcScriptUtils.ATTR_PROPERTIES, "")); - runtimeTF.setText(configuration.getAttribute( - SlcScriptUtils.ATTR_RUNTIME, "")); - targetsTF.setText(configuration.getAttribute( - SlcScriptUtils.ATTR_TARGETS, "")); - pre093B.setSelection(pre093); - } catch (CoreException e) { - throw new RuntimeException("Cannot initialize tab", e); - } - - } - - public void performApply(ILaunchConfigurationWorkingCopy configuration) { - configuration.setAttribute(SlcScriptUtils.ATTR_SCRIPT, scriptTF - .getText()); - configuration.setAttribute(SlcScriptUtils.ATTR_PROPERTIES, propertiesTF - .getText()); - configuration.setAttribute(SlcScriptUtils.ATTR_RUNTIME, runtimeTF - .getText()); - configuration.setAttribute(SlcScriptUtils.ATTR_TARGETS, targetsTF - .getText()); - configuration.setAttribute(SlcScriptUtils.ATTR_PRE093, pre093B - .getSelection()); - } - - public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { - configuration.setAttribute(SlcScriptUtils.ATTR_SCRIPT, ""); - configuration.setAttribute(SlcScriptUtils.ATTR_PROPERTIES, ""); - configuration.setAttribute(SlcScriptUtils.ATTR_RUNTIME, ""); - configuration.setAttribute(SlcScriptUtils.ATTR_TARGETS, ""); - configuration.setAttribute(SlcScriptUtils.ATTR_PRE093, false); - } - - // UI Utils - protected Label createLabel(Composite parent, String text) { - Label t = new Label(parent, SWT.NONE | SWT.WRAP); - t.setText(text); - t.setFont(parent.getFont()); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 1; - t.setLayoutData(gd); - return t; - } - - protected Text createSingleText(Composite parent) { - Text t = new Text(parent, SWT.SINGLE | SWT.BORDER); - t.setFont(parent.getFont()); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 1; - t.setLayoutData(gd); - t.addModifyListener(modifyListener); - return t; - } - - protected Text createMultipleText(Composite parent, int verticalSpan) { - Text t = new Text(parent, SWT.MULTI | SWT.BORDER); - t.setFont(parent.getFont()); - GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true); - gd.horizontalSpan = 1; - gd.verticalSpan = verticalSpan; - t.setLayoutData(gd); - t.addModifyListener(modifyListener); - return t; - } - - protected Button createCheckBox(Composite parent, String label) { - Button b = new Button(parent, SWT.CHECK); - b.setFont(parent.getFont()); - b.setText(label); - b.addSelectionListener(selectionListener); - return b; - - } - - protected Button createWorkspaceButton(Composite parent) { - Button b = new Button(parent, SWT.PUSH); - b.setFont(parent.getFont()); - b.setText("Workspace..."); - b.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - } - - public void widgetSelected(SelectionEvent e) { - handleWorkspaceLocationButtonSelected(); - } - }); - return b; - } - - protected void handleWorkspaceLocationButtonSelected() { - // FIXME do not use resource framework -// ResourceSelectionDialog dialog; -// dialog = new ResourceSelectionDialog(getShell(), ResourcesPlugin -// .getWorkspace().getRoot(), "Select a file"); -// if (dialog.open() == Window.OK) { -// Object[] results = dialog.getResult(); -// if (results == null || results.length < 1) { -// return; -// } -// IResource resource = (IResource) results[0]; -// scriptTF.setText(SlcScriptUtils -// .convertToWorkspaceLocation(resource)); -// updateLaunchConfigurationDialog(); -// } - } - - // LISTENERS - /** - * Modify listener that simply updates the owning launch configuration - * dialog. - */ - private ModifyListener modifyListener = new ModifyListener() { - public void modifyText(ModifyEvent evt) { - updateLaunchConfigurationDialog(); - } - }; - private SelectionListener selectionListener = new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - } - - public void widgetSelected(SelectionEvent e) { - updateLaunchConfigurationDialog(); - } - }; - -} diff --git a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchConfigurationTabGroup.java b/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchConfigurationTabGroup.java deleted file mode 100644 index e7d54a3cd..000000000 --- a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchConfigurationTabGroup.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.argeo.slc.ide.ui.launch.script; - -import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; -import org.eclipse.debug.ui.CommonTab; -import org.eclipse.debug.ui.ILaunchConfigurationDialog; -import org.eclipse.debug.ui.ILaunchConfigurationTab; - -public class SlcScriptLaunchConfigurationTabGroup extends - AbstractLaunchConfigurationTabGroup { - - public void createTabs(ILaunchConfigurationDialog dialog, String mode) { - ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] { - new SlcScriptLaunchConfigurationTab(), new CommonTab() }; - setTabs(tabs); - } -} diff --git a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchDelegate.java b/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchDelegate.java deleted file mode 100644 index 75d8ce7a8..000000000 --- a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchDelegate.java +++ /dev/null @@ -1,258 +0,0 @@ -package org.argeo.slc.ide.ui.launch.script; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.List; -import java.util.Properties; -import java.util.Vector; - -import org.argeo.slc.ide.ui.DeployedSlcSystem; -import org.argeo.slc.ide.ui.EmbeddedSlcSystem; -import org.argeo.slc.ide.ui.SlcSystem; -import org.argeo.slc.ide.ui.SlcIdeUiPlugin; -import org.argeo.slc.ide.ui.launch.preferences.SlcLaunchPreferencePage; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.variables.IStringVariableManager; -import org.eclipse.core.variables.VariablesPlugin; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate; -import org.eclipse.jdt.launching.IVMRunner; -import org.eclipse.jdt.launching.VMRunnerConfiguration; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.swt.widgets.Shell; - -public class SlcScriptLaunchDelegate extends - AbstractJavaLaunchConfigurationDelegate { - public static final String ID = "org.argeo.slc.launch.slcScriptLaunchType"; - - public final static String ANT_MAIN = "org.apache.tools.ant.Main"; - public final static String SLC_MAIN = "org.argeo.slc.cli.SlcMain"; - - @SuppressWarnings("deprecation") - public void launch(ILaunchConfiguration configuration, String mode, - ILaunch launch, IProgressMonitor monitor) throws CoreException { - if (!saveBeforeLaunch(configuration, mode, monitor)) - return; - - String scriptLocation = configuration.getAttribute( - SlcScriptUtils.ATTR_SCRIPT, ""); - if (scriptLocation.equals("")) - abort("Script has to be provided", null, 1); - - IStringVariableManager manager = VariablesPlugin.getDefault() - .getStringVariableManager(); - scriptLocation = manager.performStringSubstitution(scriptLocation); - IPath path = new Path(scriptLocation); - IFile[] files = ResourcesPlugin.getWorkspace().getRoot() - .findFilesForLocation(path); - - if (files.length == 0) - abort("Coulkd not find related file", null, 1); - - IFile file = (IFile) files[0]; - DebugPlugin - .logMessage("Launching " + file.getLocation().toFile(), null); - - boolean pre093 = configuration.getAttribute(SlcScriptUtils.ATTR_PRE093, - false); - - // Retrieve SLC Runtime - SlcSystem slcSystem = findSlcSystem(file, pre093); - if (slcSystem == null) - return; - - IVMRunner vmRunner = slcSystem.getVmInstall().getVMRunner(mode); - final VMRunnerConfiguration vmConfig; - if (pre093) { - vmConfig = createPre093Config(slcSystem, file, mode); - } else { - vmConfig = createConfig(slcSystem, file, mode, configuration); - } - vmRunner.run(vmConfig, launch, monitor); - } - - protected SlcSystem findSlcSystem(IFile file, boolean pre093) - throws CoreException { - SlcSystem slcSystem = null; - - IProject project = file.getProject(); - if (project.getNature("org.eclipse.jdt.core.javanature") != null) { - IJavaProject javaProject = JavaCore.create(project); - if (checkProjectForEmbedded(javaProject, pre093)) { - slcSystem = new EmbeddedSlcSystem(javaProject); - } - } - - if (slcSystem == null) { - String slcRuntimePath = SlcIdeUiPlugin.getDefault() - .getPreferenceStore().getString( - SlcLaunchPreferencePage.PREF_SLC_RUNTIME_LOCATION); - if (slcRuntimePath == null || slcRuntimePath.equals("")) { - showError("SLC Runtime path is not set. Set it in Windows > Preferences > SLC"); - return null; - } - - slcSystem = new DeployedSlcSystem(slcRuntimePath); - } - - return slcSystem; - } - - protected boolean checkProjectForEmbedded(IJavaProject project, - boolean pre093) { - try { - IType mainType = null; - if (pre093) - mainType = project.findType(ANT_MAIN); - else - mainType = project.findType(SLC_MAIN); - - if (mainType == null) - return false; - else - return true; - } catch (JavaModelException e) { - e.printStackTrace(); - return false; - } - } - - // Regular SLC - protected VMRunnerConfiguration createConfig(SlcSystem deployedSlc, - IFile file, String mode, ILaunchConfiguration configuration) - throws CoreException { - VMRunnerConfiguration vmConfig = new VMRunnerConfiguration(SLC_MAIN, - deployedSlc.getClasspath()); - vmConfig.setVMArguments(getVmArguments(deployedSlc)); - vmConfig.setWorkingDirectory(file.getLocation().toFile().getParent()); - vmConfig.setProgramArguments(getProgramArguments(deployedSlc, file, - mode, configuration)); - return vmConfig; - } - - protected String[] getVmArguments(SlcSystem deployedSlc) { - List list = new Vector(); - if (deployedSlc.getJavaLibraryPath() != null) - list.add("-Djava.library.path=" + deployedSlc.getJavaLibraryPath()); - return list.toArray(new String[list.size()]); - } - - protected String[] getProgramArguments(SlcSystem deployedSlc, IFile file, - String mode, ILaunchConfiguration configuration) - throws CoreException { - List list = new Vector(); - - list.add("--mode"); - list.add("single"); - - // Script - list.add("--script"); - list.add(file.getLocation().toFile().getAbsolutePath()); - - // Runtime - String runtime = configuration.getAttribute( - SlcScriptUtils.ATTR_RUNTIME, ""); - if (!runtime.equals("")) { - list.add("--runtime"); - list.add(runtime); - } - - // Targets - String targets = configuration.getAttribute( - SlcScriptUtils.ATTR_TARGETS, ""); - if (!targets.equals("")) { - list.add("--targets"); - list.add(targets); - } - - // Properties - Properties properties = new Properties(); - String str = configuration.getAttribute(SlcScriptUtils.ATTR_PROPERTIES, - ""); - ByteArrayInputStream in = new ByteArrayInputStream(str.getBytes()); - try { - properties.load(in); - } catch (IOException e) { - throw new RuntimeException("Cannot read properties", e); - } finally { - if (in != null) - try { - in.close(); - } catch (IOException e) { - // silent - } - } - - for (Object key : properties.keySet()) { - list.add("-p"); - StringBuffer buf = new StringBuffer(""); - buf.append(key).append('=').append(properties.get(key)); - list.add(buf.toString()); - } - - // Debug mode - if (mode.equals(ILaunchManager.DEBUG_MODE)) { - list.add("--property"); - list.add("log4j.logger.org.argeo.slc=DEBUG"); - } - return list.toArray(new String[list.size()]); - } - - // Pre SLC v0.9.3 - protected VMRunnerConfiguration createPre093Config(SlcSystem deployedSlc, - IFile file, String mode) throws CoreException { - VMRunnerConfiguration vmConfig = new VMRunnerConfiguration(ANT_MAIN, - deployedSlc.getClasspath()); - vmConfig.setVMArguments(getPre093VmArguments(deployedSlc)); - vmConfig.setWorkingDirectory(file.getLocation().toFile().getParent()); - vmConfig.setProgramArguments(getPre093ProgramArguments(deployedSlc, - file, mode)); - return vmConfig; - } - - protected String[] getPre093VmArguments(SlcSystem deployedSlc) { - List list = new Vector(); - // list.add("-Dant.home=" + deployedSlc.getAntHome()); - if (deployedSlc.getJavaLibraryPath() != null) - list.add("-Djava.library.path=" + deployedSlc.getJavaLibraryPath()); - return list.toArray(new String[list.size()]); - } - - protected String[] getPre093ProgramArguments(SlcSystem deployedSlc, - IFile file, String mode) { - List list = new Vector(); - list.add("-f"); - list.add(file.getLocation().toFile().getAbsolutePath()); - if (mode.equals(ILaunchManager.DEBUG_MODE)) { - list.add("-d"); - } - return list.toArray(new String[list.size()]); - } - - // Utilities - private static void showError(String message) { - Shell shell = SlcIdeUiPlugin.getDefault().getWorkbench() - .getActiveWorkbenchWindow().getShell(); - - IStatus status = new Status(IStatus.ERROR, SlcIdeUiPlugin.ID, - message); - ErrorDialog.openError(shell, "Error", "Cannot launch SLC script", - status); - } - -} diff --git a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchShortcut.java b/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchShortcut.java deleted file mode 100644 index dfb0044f5..000000000 --- a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchShortcut.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.argeo.slc.ide.ui.launch.script; - -import org.argeo.slc.ide.ui.SlcIdeUiPlugin; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationType; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.debug.ui.ILaunchShortcut; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorPart; - -public class SlcScriptLaunchShortcut implements ILaunchShortcut { - private boolean showDialog = false; - - public void launch(ISelection selection, String mode) { - try { - if (!(selection instanceof IStructuredSelection)) { - throw new RuntimeException("Unknown selection " - + selection.getClass()); - } - IStructuredSelection sSelection = (IStructuredSelection) selection; - if (sSelection.size() != 1) { - throw new RuntimeException("Can only launch one SLC script."); - } - Object obj = sSelection.iterator().next(); - if (!(obj instanceof IFile)) { - throw new RuntimeException("Can only launch files."); - } - IFile file = ((IFile) obj); - - ILaunchManager manager = DebugPlugin.getDefault() - .getLaunchManager(); - ILaunchConfigurationType type = manager - .getLaunchConfigurationType(SlcScriptLaunchDelegate.ID); - - // Find or create config - String configLocation = SlcScriptUtils - .convertToWorkspaceLocation(file); - ILaunchConfiguration config = findLaunchConfiguration( - configLocation, manager.getLaunchConfigurations(type)); - if (config == null) { - ILaunchConfigurationWorkingCopy wc = type.newInstance(null, - generateName(file)); - wc.setAttribute(SlcScriptUtils.ATTR_SCRIPT, configLocation); - wc.setMappedResources(new IFile[] { file }); - config = wc.doSave(); - } - - // Launch - launch(config, mode); - } catch (CoreException e) { - Shell shell = SlcIdeUiPlugin.getDefault().getWorkbench() - .getActiveWorkbenchWindow().getShell(); - ErrorDialog.openError(shell, "Error", - "Cannot execute SLC launch shortcut", e.getStatus()); - } - - } - - protected String generateName(IFile file) { - IPath relativePath = file.getProjectRelativePath(); - String name = relativePath.toString(); - int idx = name.lastIndexOf(".xml"); - if (idx > 0) - name = name.substring(0, idx); - - if (name.startsWith("src/main/slc/root/")) - name = name.substring("src/main/slc/root/".length()); - else if (name.startsWith("src/main/slc/")) - name = name.substring("src/main/slc/".length()); - - name = name.replace('/', '.');// otherwise not properly saved - return name; - } - - protected ILaunchConfiguration findLaunchConfiguration( - String configLocation, ILaunchConfiguration[] configs) - throws CoreException { - for (ILaunchConfiguration config : configs) { - String loc = config.getAttribute(SlcScriptUtils.ATTR_SCRIPT, ""); - if (loc.equals(configLocation)) { - return config; - } - } - return null; - } - - protected void launch(ILaunchConfiguration configuration, String mode) - throws CoreException { - if (showDialog) { - IStatus status = new Status(IStatus.INFO, SlcIdeUiPlugin.ID, - "Configure SLC Launch"); - String groupId; - if (mode.equals(ILaunchManager.DEBUG_MODE)) { - groupId = IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP; - } else { - groupId = IDebugUIConstants.ID_RUN_LAUNCH_GROUP; - } - DebugUITools.openLaunchConfigurationDialog(SlcIdeUiPlugin - .getDefault().getWorkbench().getActiveWorkbenchWindow() - .getShell(), configuration, groupId, status); - } else { - DebugUITools.launch(configuration, mode); - } - - } - - public void launch(IEditorPart editor, String mode) { - // not (yet) implemented - } - - public void setShowDialog(boolean showDialog) { - this.showDialog = showDialog; - } - -} diff --git a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchShortcutWithDialog.java b/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchShortcutWithDialog.java deleted file mode 100644 index 9e8dd3e35..000000000 --- a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptLaunchShortcutWithDialog.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.argeo.slc.ide.ui.launch.script; - - -public class SlcScriptLaunchShortcutWithDialog extends SlcScriptLaunchShortcut { - - public SlcScriptLaunchShortcutWithDialog() { - super(); - setShowDialog(true); - } - -} diff --git a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptUtils.java b/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptUtils.java deleted file mode 100644 index 9a5bc42c9..000000000 --- a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/launch/script/SlcScriptUtils.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.argeo.slc.ide.ui.launch.script; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.variables.VariablesPlugin; - -public class SlcScriptUtils { - - public final static String ATTR_SCRIPT = "script"; - public final static String ATTR_PROPERTIES = "properties"; - public final static String ATTR_RUNTIME = "runtime"; - public final static String ATTR_TARGETS = "targets"; - public final static String ATTR_PRE093 = "pre093"; - - public static String convertToWorkspaceLocation(IResource resource) { - return VariablesPlugin.getDefault().getStringVariableManager() - .generateVariableExpression("workspace_loc", - resource.getFullPath().toString()); - } - - private SlcScriptUtils() { - - } -} -- 2.39.2