Skip to content
Browse files

Add compiler preferences to Launch Preferences (allows different comp…

…iler for different servers).

Fix issues submitting when no compiler.
Fix indentation and typo.

Signed-off-by: Gordon Smith <gordon.smith@lexisnexis.com>
  • Loading branch information...
1 parent 865b75c commit a501a9e30a6e7872872799763fb19e68fa5cb86d @GordonSmith committed Mar 27, 2012
View
22 org.hpccsystems.eclide/src/org/hpccsystems/eclide/Activator.java
@@ -10,9 +10,11 @@
******************************************************************************/
package org.hpccsystems.eclide;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.hpccsystems.eclide.preferences.ECLPreferenceConstants;
import org.osgi.framework.BundleContext;
/**
@@ -60,6 +62,26 @@ public void stop(BundleContext context) throws Exception {
public static Activator getDefault() {
return plugin;
}
+
+ public void initializeDefaultPreferences(IPreferenceStore store) {
+ try{
+ String hpccBinFolder = System.getenv("HPCCBIN");
+ store.setDefault(ECLPreferenceConstants.P_TOOLSPATH, hpccBinFolder);
+ } catch (Exception e) {
+ store.setDefault(ECLPreferenceConstants.P_TOOLSPATH, "");
+ }
+
+ store.setDefault(ECLPreferenceConstants.P_ARGSCOMMON, "");
+ store.setDefault(ECLPreferenceConstants.P_ARGSSYNTAX, "-fsyntaxcheck=1");
+ store.setDefault(ECLPreferenceConstants.P_ARGSCOMPILE, "");
+ store.setDefault(ECLPreferenceConstants.P_ARGSCOMPILEREMOTE, "-E");
+
+ store.setDefault(ECLPreferenceConstants.P_ARGSWULOCAL, "");
+
+ store.setDefault(ECLPreferenceConstants.P_INLINERESULTLIMIT, 0);
+ store.setDefault(ECLPreferenceConstants.P_MONITORDEPENDEES, true);
+ store.setDefault(ECLPreferenceConstants.P_SUPRESSSECONDERROR, false);
+ }
/**
* Returns an image descriptor for the image file at the given
View
8 org.hpccsystems.eclide/src/org/hpccsystems/eclide/builder/ECLCompiler.java
@@ -16,6 +16,7 @@
import java.util.Set;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -36,8 +37,10 @@
import org.hpccsystems.internal.OS;
public class ECLCompiler {
-
final static String noCompiler = "Error: Unable to locate eclcc.";
+ final static String badConfigurationCode = "1004";
+ final static String badConfiguration = "Error: Invalid compiler configuration (eclcc)";
+
IProject project;
IProject[] referencedProjects;
@@ -265,6 +268,7 @@ public void checkSyntax(IFile file) {
Eclipse.deleteMarkers(file);
if (!HasCompiler()) {
+ Eclipse.addMarker(file, IMarker.SEVERITY_ERROR, badConfigurationCode, badConfiguration, 0, 0, true);
eclccConsoleWriter.println(noCompiler);
return;
}
@@ -286,6 +290,7 @@ public String getArchive(IFile file) {
Eclipse.deleteMarkers(file);
if (!HasCompiler()) {
+ Eclipse.addMarker(file, IMarker.SEVERITY_ERROR, badConfigurationCode, badConfiguration, 0, 0, true);
eclccConsoleWriter.println(noCompiler);
return "";
}
@@ -327,6 +332,7 @@ public String buildAndRun(IFile file) {
Eclipse.deleteMarkers(file);
if (!HasCompiler()) {
+ Eclipse.addMarker(file, IMarker.SEVERITY_ERROR, badConfigurationCode, badConfiguration, 0, 0, true);
eclccConsoleWriter.println(noCompiler);
return "";
}
View
102 org.hpccsystems.eclide/src/org/hpccsystems/eclide/launchers/ECLLaunchCompilerTab.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2011 HPCC Systems.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * HPCC Systems - initial API and implementation
+ ******************************************************************************/
+package org.hpccsystems.eclide.launchers;
+
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.internal.ui.SWTFactory;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.DirectoryFieldEditor;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.hpccsystems.eclide.Activator;
+import org.hpccsystems.eclide.preferences.ECLPreferenceConstants;
+import org.hpccsystems.internal.ConfigurationPreferenceStore;
+import org.hpccsystems.internal.ECLLaunchConfigurationTab;
+
+public class ECLLaunchCompilerTab extends ECLLaunchConfigurationTab {
+
+ ConfigurationPreferenceStore store;
+
+ ECLLaunchCompilerTab()
+ {
+ store = new ConfigurationPreferenceStore();
+ }
+
+ public void createCompilerEditor(Composite _parent) {
+ Group parent = SWTFactory.createGroup(_parent, "Location:", 1, 1, GridData.FILL_HORIZONTAL);
+
+ store.addField(new DirectoryFieldEditor(ECLPreferenceConstants.P_TOOLSPATH, "&HPCC Client Tools:", parent));
+ }
+
+ public void createCompilerArgumentsEditor(Composite _parent) {
+ Group parent = SWTFactory.createGroup(_parent, "Compiler Arguments:", 1, 1, GridData.FILL_HORIZONTAL);
+
+ store.addField(new StringFieldEditor(ECLPreferenceConstants.P_ARGSCOMMON, "&Common:", parent));
+ store.addField(new StringFieldEditor(ECLPreferenceConstants.P_ARGSSYNTAX, "&Syntax Check:", parent));
+ store.addField(new StringFieldEditor(ECLPreferenceConstants.P_ARGSCOMPILE, "&Local Compile:", parent));
+ store.addField(new StringFieldEditor(ECLPreferenceConstants.P_ARGSCOMPILEREMOTE, "&Remote Compile:", parent));
+ }
+
+ public void createWorkunitArgumentsEditor(Composite _parent) {
+ Group parent = SWTFactory.createGroup(_parent, "Workunit Arguments:", 1, 1, GridData.FILL_HORIZONTAL);
+
+ store.addField(new StringFieldEditor(ECLPreferenceConstants.P_ARGSWULOCAL, "&Local:", parent));
+ }
+
+ public void createMiscellaneousEditor(Composite _parent) {
+ Group parent = SWTFactory.createGroup(_parent, "Workunit Arguments:", 1, 1, GridData.FILL_HORIZONTAL);
+
+ store.addField(new IntegerFieldEditor(ECLPreferenceConstants.P_INLINERESULTLIMIT, "&Inline Result Limit:", parent));
+ store.addField(new BooleanFieldEditor(ECLPreferenceConstants.P_MONITORDEPENDEES, "&Monitor Dependees (requires manual \"Project/Clean...\")", parent));
+ store.addField(new BooleanFieldEditor(ECLPreferenceConstants.P_SUPRESSSECONDERROR, "&Supress Subsequent Errors", parent));
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite projComp = SWTFactory.createComposite(parent, parent.getFont(), 1, 1, GridData.FILL_BOTH);
+ //((GridLayout)projComp.getLayout()).verticalSpacing = 0;
+
+ createVerticalSpacer(projComp, 1);
+ createCompilerEditor(projComp);
+ createVerticalSpacer(projComp, 1);
+ createCompilerArgumentsEditor(projComp);
+ createVerticalSpacer(projComp, 1);
+ createWorkunitArgumentsEditor(projComp);
+ createVerticalSpacer(projComp, 1);
+ createMiscellaneousEditor(projComp);
+
+ setControl(projComp);
+ }
+
+ @Override
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ Activator.getDefault().initializeDefaultPreferences(store);
+ }
+
+ @Override
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ store.loadFields(configuration);
+ }
+
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ store.saveFields(configuration);
+ }
+
+ @Override
+ public String getName() {
+ return "ECLCC Compiler";
+ }
+}
View
11 org.hpccsystems.eclide/src/org/hpccsystems/eclide/launchers/ECLLaunchTabGroup.java
@@ -18,18 +18,9 @@
@Override
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
-// ECLMainLaunchConfigurationTab main = new ECLMainLaunchConfigurationTab(mode);
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
-// main,
- //new OctaveInterpreterTab(main),
new ECLLaunchServerTab(),
-// new AppletMainTab()
-// new AppletParametersTab(),
-// new JavaArgumentsTab(),
-// new JavaJRETab(),
-// new JavaClasspathTab(),
-// new CommonTab()
- //new WorkingDirectoryBlock()
+ new ECLLaunchCompilerTab(),
};
setTabs(tabs);
}
View
20 org.hpccsystems.eclide/src/org/hpccsystems/eclide/preferences/ECLPreferenceInitializer.java
@@ -26,24 +26,6 @@
*/
@Override
public void initializeDefaultPreferences() {
- IPreferenceStore store = Activator.getDefault().getPreferenceStore();
-
- try{
- String hpccBinFolder = System.getenv("HPCCBIN");
- store.setDefault(ECLPreferenceConstants.P_TOOLSPATH, hpccBinFolder);
- } catch (Exception e) {
- store.setDefault(ECLPreferenceConstants.P_TOOLSPATH, "");
- }
-
- store.setDefault(ECLPreferenceConstants.P_ARGSCOMMON, "");
- store.setDefault(ECLPreferenceConstants.P_ARGSSYNTAX, "-fsyntaxcheck=1");
- store.setDefault(ECLPreferenceConstants.P_ARGSCOMPILE, "");
- store.setDefault(ECLPreferenceConstants.P_ARGSCOMPILEREMOTE, "-E");
-
- store.setDefault(ECLPreferenceConstants.P_ARGSWULOCAL, "");
-
- store.setDefault(ECLPreferenceConstants.P_INLINERESULTLIMIT, 0);
- store.setDefault(ECLPreferenceConstants.P_MONITORDEPENDEES, true);
- store.setDefault(ECLPreferenceConstants.P_SUPRESSSECONDERROR, false);
+ Activator.getDefault().initializeDefaultPreferences(Activator.getDefault().getPreferenceStore());
}
}
View
4 org.hpccsystems.eclide/src/org/hpccsystems/internal/CmdProcess.java
@@ -111,9 +111,9 @@ public void run() {
threadStdIn.join();
threadStdErr.join();
} catch (InterruptedException e) {
- e.printStackTrace();
+ consoleOut.println(e.getMessage());
} catch (IOException e) {
- e.printStackTrace();
+ consoleOut.println(e.getMessage());
}
}
};
View
102 org.hpccsystems.eclide/src/org/hpccsystems/internal/ConfigurationPreferenceStore.java
@@ -0,0 +1,102 @@
+package org.hpccsystems.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.hpccsystems.eclide.Activator;
+
+public class ConfigurationPreferenceStore extends PreferenceStore {
+
+ IPreferenceStore globalStore;
+ ILaunchConfiguration configuration;
+
+ private List<FieldEditor> fields = null;
+
+ public ConfigurationPreferenceStore() {
+ super();
+ globalStore = Activator.getDefault().getPreferenceStore();
+ }
+
+ public ConfigurationPreferenceStore(ILaunchConfiguration configuration) {
+ this();
+ this.configuration = configuration;
+ }
+
+ public void addField(FieldEditor editor) {
+ if (fields == null) {
+ fields = new ArrayList<FieldEditor>();
+ }
+ fields.add(editor);
+ editor.setPreferenceStore(this);
+ }
+
+ public void loadFields(ILaunchConfiguration configuration) {
+ for (FieldEditor field : fields) {
+ String key = field.getPreferenceName();
+ try {
+ super.setValue(key, configuration.getAttribute(key, globalStore.getString(key)));
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ field.load();
+ }
+
+ }
+
+ public void saveFields(ILaunchConfigurationWorkingCopy configuration) {
+ for (FieldEditor field : fields) {
+ field.store();
+ String key = field.getPreferenceName();
+ configuration.setAttribute(key, super.getString(key));
+ }
+ }
+
+ // ILaunchConfiguration like calls ---
+ public String getAttribute(String key, String defaultValue) {
+ if (configuration != null) {
+ try {
+ return configuration.getAttribute(key, defaultValue);
+ } catch (CoreException e) {
+ }
+ }
+ if (this.contains(key))
+ return this.getString(key);
+ if (globalStore.contains(key))
+ return globalStore.getString(key);
+ return defaultValue;
+ }
+
+ public boolean getAttribute(String key, boolean defaultValue) {
+ if (configuration != null) {
+ try {
+ return configuration.getAttribute(key, defaultValue);
+ } catch (CoreException e) {
+ }
+ }
+ if (this.contains(key))
+ return this.getBoolean(key);
+ if (globalStore.contains(key))
+ return globalStore.getBoolean(key);
+ return defaultValue;
+ }
+
+ public int getAttribute(String key, int defaultValue) {
+ if (configuration != null) {
+ try {
+ return configuration.getAttribute(key, defaultValue);
+ } catch (CoreException e) {
+ }
+ }
+ if (this.contains(key))
+ return this.getInt(key);
+ if (globalStore.contains(key))
+ return globalStore.getInt(key);
+ return defaultValue;
+ }
+}
View
3 org.hpccsystems.eclide/src/org/hpccsystems/internal/data/Data.java
@@ -35,7 +35,7 @@ private Data() {
configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations();
for(int i = 0; i < configs.length; ++i) {
Platform p = GetPlatform(configs[i]);
- if (!platforms.contains(p))
+ if (p != null && !platforms.contains(p))
platforms.add(p);
}
} catch (CoreException e) {
@@ -126,6 +126,7 @@ public Platform GetPlatformNoCreate(String ip, int port) {
try {
Workunit.All.pushTransaction("Data.getWorkunits");
for (Platform p : getPlatforms()) {
+ assert p != null;
if (platform == null || platform.equals(p)) {
workunits.addAll(p.getWorkunits(cluster, startDate, endDate));
}

0 comments on commit a501a9e

Please sign in to comment.
Something went wrong with that request. Please try again.