Issue #1967 eclipse 3.8 compatibility

Change-Id: I37a42670b1fe9634b1de4b751f284971b545ac7b

Former-commit-id: 6c709fa5aa71daf4af3f4a9c7f2a56e19e0b06c7
This commit is contained in:
Nate Jensen 2013-05-01 16:47:35 -05:00 committed by Bryan Kowal
parent 75a499f802
commit b35365b8a8
11 changed files with 302 additions and 138 deletions

View file

@ -123,12 +123,6 @@
install-size="0"
version="0.0.0"/>
<plugin
id="com.python.pydev.debug"
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin
id="com.python.pydev.fastparser"
download-size="0"
@ -171,12 +165,6 @@
install-size="0"
version="0.0.0"/>
<plugin
id="org.python.pydev.django"
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin
id="org.python.pydev.help"
download-size="0"
@ -195,12 +183,6 @@
install-size="0"
version="0.0.0"/>
<plugin
id="org.python.pydev.red_core"
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin
id="org.python.pydev.refactoring"
download-size="0"
@ -361,4 +343,22 @@
version="0.0.0"
unpack="false"/>
<plugin
id="org.python.pydev.shared_core"
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin
id="org.python.pydev.shared_interactive_console"
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin
id="org.python.pydev.shared_ui"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>

View file

@ -23,6 +23,7 @@ Require-Bundle: org.python.pydev,
com.raytheon.uf.common.colormap;bundle-version="1.12.1174",
com.raytheon.uf.viz.localization;bundle-version="1.12.1174",
org.eclipse.equinox.p2.director.app;bundle-version="1.0.201",
com.raytheon.uf.common.util;bundle-version="1.12.1174"
com.raytheon.uf.common.util;bundle-version="1.12.1174",
com.python.pydev.analysis;bundle-version="2.7.3"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

View file

@ -413,4 +413,15 @@
</activeWhen>
</handler>
</extension>
<extension
point="org.eclipse.ui.activities">
<activity
id="com.raytheon.uf.viz.localization.perspective.stopPydev"
name="com.raytheon.uf.viz.localization.perspective.stopPydev">
</activity>
<activityPatternBinding
activityId="com.raytheon.uf.viz.localization.perspective.stopPydev"
pattern="org.python.pydev.debug.*">
</activityPatternBinding>
</extension>
</plugin>

View file

@ -19,30 +19,16 @@
**/
package com.raytheon.uf.viz.localization.perspective;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.texteditor.ITextEditor;
import org.python.pydev.core.IInterpreterInfo;
import org.python.pydev.core.IInterpreterManager;
import org.python.pydev.core.REF;
import org.python.pydev.core.Tuple;
import org.python.pydev.plugin.PydevPlugin;
import org.python.pydev.runners.SimplePythonRunner;
import org.python.pydev.ui.pythonpathconf.InterpreterInfo;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.viz.ui.perspectives.AbstractVizPerspectiveManager;
/**
@ -56,6 +42,7 @@ import com.raytheon.viz.ui.perspectives.AbstractVizPerspectiveManager;
* ------------ ---------- ----------- --------------------------
* May 18, 2010 mnash Initial creation
* Nov 02, 2012 1302 djohnson Remove printStackTrace.
* May 1, 2013 1967 njensen Separated out pydev specific code
*
* </pre>
*
@ -65,8 +52,6 @@ import com.raytheon.viz.ui.perspectives.AbstractVizPerspectiveManager;
public class LocalizationPerspectiveManager extends
AbstractVizPerspectiveManager {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(LocalizationPerspectiveManager.class);
/** The edit position restore map */
private final Map<IEditorInput, Point> restoreMap = new HashMap<IEditorInput, Point>();
@ -83,80 +68,7 @@ public class LocalizationPerspectiveManager extends
*/
@Override
protected void open() {
try {
// Attempt the initialization twice before reporting errors,
// sometimes it can fail unexpectedly and recover a second time.
// Goal is to auto setup python interpreter to use for editing
// python files
for (int i = 0; i < 2; ++i) {
boolean retry = i > 0;
// Setup python environment for pydev
IInterpreterManager mgr = PydevPlugin
.getPythonInterpreterManager();
String persistedStr = mgr.getPersistedString();
if ((persistedStr == null) || "".equals(persistedStr.trim())) {
IInterpreterInfo iinfo = null;
String pathToFile = null;
String LD_PATH = System.getenv("PATH");
String[] folders = LD_PATH.split(File.pathSeparator); // Win32
for (String folder : folders) {
File python = new File(folder, "python");
if (python.exists() && python.isFile()
&& python.canExecute()) {
pathToFile = python.getAbsolutePath();
break;
}
}
if (pathToFile != null) {
try {
// Taken from pydev source to get rid of UI prompt
File script = PydevPlugin
.getScriptWithinPySrc("interpreterInfo.py");
Tuple<String, String> outTup = new SimplePythonRunner()
.runAndGetOutputWithInterpreter(pathToFile,
REF.getFileAbsolutePath(script),
null, null, null,
new NullProgressMonitor());
iinfo = InterpreterInfo
.fromString(outTup.o1, false);
// end taken
} catch (Throwable e) {
if (retry) {
throw e;
}
continue;
}
if (iinfo == null) {
if (retry) {
throw new Exception(
"Could not generate python info, python editors may not function 100%");
} else {
continue;
}
}
mgr.setPersistedString(iinfo.toString());
List<IInterpreterInfo> infoList = new ArrayList<IInterpreterInfo>();
infoList.add(iinfo);
mgr.setInfos(infoList);
} else {
if (retry) {
throw new Exception(
"Could not find python on PATH, be sure to set environment variable");
} else {
continue;
}
}
}
// We made it here? success!
break;
}
} catch (Throwable t) {
statusHandler.handle(
Priority.PROBLEM,
"Error setting up python interpreter: "
+ t.getLocalizedMessage(), t);
}
PydevSetup.preparePydev();
}
@Override

View file

@ -0,0 +1,212 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.localization.perspective;
import java.io.File;
import java.io.IOException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.python.pydev.core.IInterpreterInfo;
import org.python.pydev.core.IInterpreterManager;
import org.python.pydev.core.docutils.StringUtils;
import org.python.pydev.editor.PydevShowBrowserMessage;
import org.python.pydev.plugin.PydevPlugin;
import org.python.pydev.runners.SimplePythonRunner;
import org.python.pydev.shared_core.structure.Tuple;
import org.python.pydev.ui.pythonpathconf.InterpreterInfo;
import com.python.pydev.analysis.AnalysisPlugin;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.FileUtil;
/**
* Utilities that configure pydev to work properly in the Viz Localization
* Perspective. Works around deficiencies in the pydev code.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 1, 2013 1967 njensen Initial creation
*
* </pre>
*
* @author njensen
* @version 1.0
*/
public class PydevSetup {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(PydevSetup.class);
/**
* Prepares pydev to be used in the localization perspective with as few
* annoyances as possible.
*/
public static void preparePydev() {
preventFundingPopup();
initializeInterpreter();
}
/**
* Attempts to initialize the python interpreter based on the PATH
* environment, saving the user the trouble of initializing it through the
* preference page.
*/
public static void initializeInterpreter() {
try {
// Attempt the initialization twice before reporting errors,
// sometimes it can fail unexpectedly and recover a second time.
// Goal is to auto setup python interpreter to use for editing
// python files
for (int i = 0; i < 2; ++i) {
boolean retry = i > 0;
// Setup python environment for pydev
IInterpreterManager mgr = PydevPlugin
.getPythonInterpreterManager();
String persistedStr = mgr.getPersistedString();
if ((persistedStr == null) || "".equals(persistedStr.trim())) {
IInterpreterInfo iinfo = null;
String pathToFile = null;
String LD_PATH = System.getenv("PATH");
String[] folders = LD_PATH.split(File.pathSeparator); // Win32
for (String folder : folders) {
File python = new File(folder, "python");
if (python.exists() && python.isFile()
&& python.canExecute()) {
pathToFile = python.getAbsolutePath();
break;
}
}
if (pathToFile != null) {
try {
// Taken from pydev source to get rid of UI prompt
File script = PydevPlugin
.getScriptWithinPySrc("interpreterInfo.py");
Tuple<String, String> outTup = new SimplePythonRunner()
.runAndGetOutputWithInterpreter(pathToFile,
script.getAbsolutePath(), null,
null, null,
new NullProgressMonitor(), null);
iinfo = InterpreterInfo
.fromString(outTup.o1, false);
// end taken
} catch (Throwable e) {
if (retry) {
throw e;
}
continue;
}
if (iinfo == null) {
if (retry) {
throw new Exception(
"Could not generate python info, python editors may not function 100%");
} else {
continue;
}
}
IInterpreterInfo[] infoList = new IInterpreterInfo[] { iinfo };
setupStupidFile(mgr, iinfo);
mgr.setInfos(infoList, null, null);
} else {
if (retry) {
throw new Exception(
"Could not find python on PATH, be sure to set environment variable");
} else {
continue;
}
}
}
// We made it here? success!
break;
}
} catch (Throwable t) {
statusHandler.handle(
Priority.PROBLEM,
"Error setting up python interpreter: "
+ t.getLocalizedMessage(), t);
}
}
/**
* Initializes a file to prevent pydev from sending out an error message
* that is not actually an error. Pydev looks for a particular file and if
* it does not exist, sends an error. However, if the file exists but has
* the wrong contents, it only sends out an info. Either way, pydev
* continues on and takes care of things, so the error message is useless.
* This code is derived from pydev's AdditionalSystemInterpreterInfo
* constructor.
*
* @param manager
* @param info
*/
private static void setupStupidFile(IInterpreterManager manager,
IInterpreterInfo info) {
try {
File base = null;
IPath stateLocation = AnalysisPlugin.getDefault()
.getStateLocation();
base = stateLocation.toFile();
String additionalInfoInterpreter = info.getExecutableOrJar();
File file = new File(
base,
manager.getManagerRelatedName()
+ "_"
+ StringUtils
.getExeAsFileSystemValidPath(additionalInfoInterpreter));
if (!file.exists()) {
file.mkdirs();
File persistingFolder = file;
File persistingLocation = new File(persistingFolder,
manager.getManagerRelatedName() + ".pydevsysteminfo");
FileUtil.bytes2File(new byte[0], persistingLocation);
}
} catch (IOException e) {
// no need to log this notably since this whole method only exists
// to prevent a stupid error message from being seen
statusHandler.debug(e.getLocalizedMessage());
}
}
/**
* Sets the preference value to prevent pydev from popping up the dialog
* that requests money for the developer's personal projects
*/
public static void preventFundingPopup() {
IPreferenceStore pydevPrefStore = PydevPlugin.getDefault()
.getPreferenceStore();
pydevPrefStore.setValue(PydevShowBrowserMessage.PYDEV_FUNDING_SHOWN,
"true");
}
}

View file

@ -132,6 +132,7 @@ import com.raytheon.uf.viz.localization.service.ILocalizationService;
* May 26, 2010 mnash Initial creation
* Feb 13, 2013 1610 mschenke Fixed null pointer by repopulating LocalizationFileGroupData
* objects even if they weren't expanded
* May 1st, 2013 1967 njensen Fix for pydev 2.7
*
* </pre>
*
@ -1235,7 +1236,8 @@ public class FileTreeView extends ViewPart implements IPartListener2,
IFolder folder = (IFolder) parentData.getResource();
IResource rsc = null;
if (file != null) {
rsc = folder.getFile(fileItem.getText() + " - "
rsc = folder.getFile(file.getContext().getLocalizationLevel() + "_"
+ file.getContext().getContextName() + "_"
+ parentItem.getText());
} else {
rsc = createFolder(folder, fileItem.getText());
@ -1423,26 +1425,30 @@ public class FileTreeView extends ViewPart implements IPartListener2,
@Override
public void resourceChanged(IResourceChangeEvent event) {
for (IEditorReference ref : getSite().getPage().getEditorReferences()) {
IEditorInput editorInput = ref.getEditor(false).getEditorInput();
if (editorInput instanceof LocalizationEditorInput) {
LocalizationEditorInput input = (LocalizationEditorInput) editorInput;
IFile inputFile = input.getFile();
IResourceDelta rootDelta = event.getDelta();
IResourceDelta docDelta = rootDelta.findMember(inputFile
.getFullPath());
if (docDelta != null
&& docDelta.getKind() == IResourceDelta.CHANGED
&& (docDelta.getFlags() & IResourceDelta.CONTENT) == IResourceDelta.CONTENT) {
try {
LocalizationFile file = input.getLocalizationFile();
if (file.getContext().getLocalizationLevel()
.isSystemLevel() == false) {
input.getLocalizationFile().save();
IEditorPart part = ref.getEditor(false);
if (part != null) {
IEditorInput editorInput = part.getEditorInput();
if (editorInput instanceof LocalizationEditorInput) {
LocalizationEditorInput input = (LocalizationEditorInput) editorInput;
IFile inputFile = input.getFile();
IResourceDelta rootDelta = event.getDelta();
IResourceDelta docDelta = rootDelta.findMember(inputFile
.getFullPath());
if (docDelta != null
&& docDelta.getKind() == IResourceDelta.CHANGED
&& (docDelta.getFlags() & IResourceDelta.CONTENT) == IResourceDelta.CONTENT) {
try {
LocalizationFile file = input.getLocalizationFile();
if (file.getContext().getLocalizationLevel()
.isSystemLevel() == false) {
input.getLocalizationFile().save();
}
} catch (LocalizationOpFailedException e) {
statusHandler.handle(
Priority.PROBLEM,
"Error saving file: "
+ e.getLocalizedMessage(), e);
}
} catch (LocalizationOpFailedException e) {
statusHandler
.handle(Priority.PROBLEM, "Error saving file: "
+ e.getLocalizedMessage(), e);
}
}
}

View file

@ -20,7 +20,18 @@ Developed on the Raytheon Visualization Environment (viz)
<launcherArgs>
<programArgs>-data @user.home/caveData -user @user.home/caveData -clean</programArgs>
<programArgsLin>-consoleLog</programArgsLin>
<vmArgs>-Xincgc -Xms16M -Xmx256M -Xss2024k -Dosgi.instance.area.readOnly=true -Dosgi.hook.configurators.exclude=org.eclipse.core.runtime.internal.adaptor.EclipseLogHook,org.eclipse.core.runtime.internal.adaptor.EclipseErrorHandler -Dorg.eclipse.update.reconcile=false -Dqpid.dest_syntax=BURL -Dorg.eclipse.update.reconcile=false -XX:MaxPermSize=128m -Dorg.eclipse.ui/KEY_CONFIGURATION_ID=com.raytheon.viz.ui.awips.scheme -Dawips.mode=pypies -Dqpid.dest_syntax=BURL -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dlog4j.configuration=log4j-alertviz.xml</vmArgs>
<vmArgs>-Xincgc -Xms16M -Xmx256M -Xss2024k
-Dosgi.instance.area.readOnly=true
-Declipse.log.enabled=false
-Dorg.eclipse.update.reconcile=false
-Dqpid.dest_syntax=BURL
-Dorg.eclipse.update.reconcile=false
-XX:MaxPermSize=128m
-Dorg.eclipse.ui/KEY_CONFIGURATION_ID=com.raytheon.viz.ui.awips.scheme
-Dqpid.dest_syntax=BURL
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dlog4j.configuration=log4j-alertviz.xml</vmArgs>
</launcherArgs>
<windowImages/>

View file

@ -219,7 +219,7 @@
unpack="false"/>
<plugin
id="org.eclipse.equinox.p2.metadata.generator"
id="org.eclipse.equinox.p2.publisher.eclipse"
download-size="0"
install-size="0"
version="0.0.0"

View file

@ -17,8 +17,18 @@
<programArgs>-data @user.home/caveData -user @user.home/caveData -clean</programArgs>
<programArgsLin>-consoleLog</programArgsLin>
<vmArgs>-Xincgc -Dosgi.instance.area.readOnly=true
-Dosgi.hook.configurators.exclude=org.eclipse.core.runtime.internal.adaptor.EclipseLogHook,org.eclipse.core.runtime.internal.adaptor.EclipseErrorHandler
-XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -Dorg.eclipse.update.reconcile=false -XX:MaxPermSize=128m -Dorg.eclipse.ui/KEY_CONFIGURATION_ID=com.raytheon.viz.ui.awips.scheme -Dawips.mode=pypies -Dqpid.dest_syntax=BURL -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -XX:OnOutOfMemoryError=&quot;capture -t no -p $pid &amp;&quot; -Dlog4j.configuration=log4j-viz-core.xml</vmArgs>
-Declipse.log.enabled=false
-XX:+UnlockDiagnosticVMOptions
-XX:+UnsyncloadClass
-Dorg.eclipse.update.reconcile=false
-XX:MaxPermSize=128m
-Dorg.eclipse.ui/KEY_CONFIGURATION_ID=com.raytheon.viz.ui.awips.scheme
-Dqpid.dest_syntax=BURL
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-XX:OnOutOfMemoryError=&quot;capture -t no -p $pid &amp;&quot;
-Dlog4j.configuration=log4j-viz-core.xml</vmArgs>
<vmArgsLin>-Xmx1280M</vmArgsLin>
<vmArgsWin>-Dfile.encoding=UTF-8 -Xmx768M</vmArgsWin>
</launcherArgs>

View file

@ -15,12 +15,12 @@
<launcherArgs>
<programArgs>-data @user.home/caveData -user @user.home/caveData -clean -consoleLog -alertviz</programArgs>
<vmArgs>-Xincgc -Xmx1024M -Dosgi.instance.area.readOnly=true
-Dosgi.hook.configurators.exclude=org.eclipse.core.runtime.internal.adaptor.EclipseLogHook,org.eclipse.core.runtime.internal.adaptor.EclipseErrorHandler
<vmArgs>-Xincgc -Xmx1024M -Dosgi.instance.area.readOnly=true
-Declipse.log.enabled=false
-XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass
-Dorg.eclipse.update.reconcile=false -XX:MaxPermSize=128m
-Dorg.eclipse.ui/KEY_CONFIGURATION_ID=com.raytheon.viz.ui.awips.scheme
-Dawips.mode=pypies -Dqpid.dest_syntax=BURL
-Dqpid.dest_syntax=BURL
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

View file

@ -58,6 +58,7 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
* 3/18/2013 1802 bphillip Added additional database functions. Enforcing mandatory transaction propogation
* 3/27/2013 1802 bphillip Changed transaction propagation of query methods
* 4/9/2013 1802 bphillip Modified how arguments are passed in to query methods
* May 1st, 2013 1967 njensen Fixed autoboxing for Eclipse 3.8
*
* </pre>
*
@ -195,7 +196,7 @@ public abstract class SessionManagedDao<IDENTIFIER extends Serializable, ENTITY
}
@Transactional(propagation = Propagation.REQUIRED)
public List<ENTITY> query(String queryString, int maxResults,
public List<ENTITY> query(String queryString, Integer maxResults,
Object... params) {
return executeHQLQuery(queryString, maxResults, params);
@ -264,7 +265,7 @@ public abstract class SessionManagedDao<IDENTIFIER extends Serializable, ENTITY
@SuppressWarnings("unchecked")
@Transactional(propagation = Propagation.REQUIRED)
public <T extends Object> List<T> executeHQLQuery(final String queryString,
int maxResults, Object... params) {
Integer maxResults, Object... params) {
if (params.length % 2 != 0) {
throw new IllegalArgumentException(
"Wrong number of arguments submitted to executeHQLQuery.");