mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
Remove Version number from zips
Change-Id: Ifc9ba2e47a61f2d545b7c4b40c327b661b4f48ba
This commit is contained in:
committed by
Thomas Clark
parent
da2ea9ea87
commit
77dac9bd77
@@ -133,7 +133,7 @@ public class WPILibCore extends AbstractUIPlugin {
|
||||
}
|
||||
|
||||
public String getDefaultVersion() {
|
||||
return "2013-test-0.4";
|
||||
return "0.2";
|
||||
}
|
||||
|
||||
public String getCurrentVersion() {
|
||||
|
||||
@@ -22,12 +22,12 @@ import edu.wpi.first.wpilib.plugins.core.WPILibCore;
|
||||
|
||||
public abstract class AbstractInstaller {
|
||||
protected File installLocation;
|
||||
protected String version;
|
||||
protected String version, installedVersion;
|
||||
|
||||
public AbstractInstaller(String version) {
|
||||
this.installLocation = new File(WPILibCore.getDefault().getWPILibBaseDir()
|
||||
+ File.separator + getFeatureName() + File.separator + version);
|
||||
public AbstractInstaller(String version, String installedVersion, String path) {
|
||||
this.installLocation = new File(path);
|
||||
this.version = version;
|
||||
this.installedVersion = installedVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +55,7 @@ public abstract class AbstractInstaller {
|
||||
WPILibCore.logInfo("Installing "+getFeatureName()+" if necessary");
|
||||
|
||||
if (!isInstalled()) {
|
||||
WPILibCore.logInfo("Install necessary");
|
||||
WPILibCore.logInfo("Install necessary for " + getFeatureName());
|
||||
try {
|
||||
install();
|
||||
} catch (InstallException e) {
|
||||
@@ -64,9 +64,9 @@ public abstract class AbstractInstaller {
|
||||
getErrorMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
updateInstalledVersion(version);
|
||||
WPILibCore.logInfo("Installed");
|
||||
WPILibCore.logInfo("Installed" + getFeatureName());
|
||||
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public abstract class AbstractInstaller {
|
||||
* @return True for is there and newer, false otherwise.
|
||||
*/
|
||||
protected boolean isInstalled() {
|
||||
return installLocation.exists();
|
||||
return installLocation.exists() && !version.contains("DEVELOPMENT") && version.equals(installedVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,7 +138,7 @@ public abstract class AbstractInstaller {
|
||||
}
|
||||
|
||||
// Call 'unzip'
|
||||
final String[] cmd = {"unzip", tmpFile.getAbsolutePath(), "-d", installLocation.getAbsolutePath()};
|
||||
final String[] cmd = {"unzip" , "-o", tmpFile.getAbsolutePath(), "-d", installLocation.getAbsolutePath()};
|
||||
WPILibCore.logInfo("unzip "+tmpFile.getAbsolutePath()+" -d "+installLocation.getAbsolutePath());
|
||||
final Process unzipProcess = DebugPlugin.exec(cmd, installLocation);
|
||||
try (final InputStream is = unzipProcess.getInputStream()) {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package edu.wpi.first.wpilib.plugins.core.installer;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
|
||||
import edu.wpi.first.wpilib.plugins.core.WPILibCore;
|
||||
@@ -11,7 +9,7 @@ import edu.wpi.first.wpilib.plugins.core.preferences.PreferenceConstants;
|
||||
public class ToolsInstaller extends AbstractInstaller {
|
||||
|
||||
public ToolsInstaller(String version) {
|
||||
super(version);
|
||||
super(version, WPILibCore.getDefault().getPreferenceStore().getString(PreferenceConstants.TOOLS_VERSION), WPILibCore.getDefault().getWPILibBaseDir() + "/tools");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,13 +20,8 @@ public class ToolsInstaller extends AbstractInstaller {
|
||||
@Override
|
||||
protected void updateInstalledVersion(String version) {
|
||||
IPreferenceStore prefs = WPILibCore.getDefault().getPreferenceStore();
|
||||
if (prefs.getBoolean(PreferenceConstants.UPDATE_TOOLS_VERSION)) {
|
||||
WPILibCore.logInfo("Forcing library version to "+version);
|
||||
Properties props = WPILibCore.getDefault().getProjectProperties(null);
|
||||
props.setProperty("version", version);
|
||||
WPILibCore.getDefault().saveGlobalProperties(props);
|
||||
prefs.setValue(PreferenceConstants.TOOLS_VERSION, version);
|
||||
}
|
||||
prefs.setValue(PreferenceConstants.TOOLS_VERSION, version);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,8 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
|
||||
IPreferenceStore store = WPILibCore.getDefault().getPreferenceStore();
|
||||
store.setDefault(PreferenceConstants.TEAM_NUMBER,
|
||||
WPILibCore.getDefault().getProjectProperties(null).getProperty("team-number", "0"));
|
||||
store.setDefault(PreferenceConstants.TOOLS_VERSION, WPILibCore.getDefault().getDefaultVersion());
|
||||
store.setDefault(PreferenceConstants.UPDATE_TOOLS_VERSION, true);
|
||||
String val = store.getString(PreferenceConstants.TOOLS_VERSION);
|
||||
if (!store.contains(PreferenceConstants.TOOLS_VERSION) && val != null)
|
||||
store.setValue(PreferenceConstants.TOOLS_VERSION, "none");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class Activator extends AbstractUIPlugin implements IStartup {
|
||||
}
|
||||
|
||||
private String getCurrentVersion() {
|
||||
return WPILibCPPPlugin.getDefault().getDefaultToolchainVersion();
|
||||
return "4.4.1-csery-gcc";
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -11,7 +11,8 @@ import edu.wpi.first.wpilib.plugins.cpp.preferences.PreferenceConstants;
|
||||
public class ToolchainInstaller extends AbstractInstaller {
|
||||
|
||||
public ToolchainInstaller(String version) {
|
||||
super(version);
|
||||
super(version,
|
||||
WPILibCPPPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.TOOLCHAIN_INSTALLED), WPILibCPPPlugin.getDefault().getToolchain());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -21,11 +22,8 @@ public class ToolchainInstaller extends AbstractInstaller {
|
||||
|
||||
@Override
|
||||
protected void updateInstalledVersion(String version) {
|
||||
IPreferenceStore prefs = WPILibCPPPlugin.getDefault().getPreferenceStore();
|
||||
if (prefs.getBoolean(PreferenceConstants.UPDATE_TOOLCHAIN_VERSION)) {
|
||||
System.out.println("Forcing library version to "+version);
|
||||
prefs.setValue(PreferenceConstants.TOOLCHAIN_VERSION, version);
|
||||
}
|
||||
WPILibCPPPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.TOOLCHAIN_INSTALLED,
|
||||
WPILibCPPPlugin.getDefault().getCurrentVersion());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,7 +33,7 @@ public class Activator extends AbstractUIPlugin implements IStartup {
|
||||
}
|
||||
|
||||
private String getCurrentVersion() {
|
||||
return WPILibCPPPlugin.getDefault().getDefaultToolchainVersion();
|
||||
return "4.4.1-csery-gcc";
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -11,7 +11,8 @@ import edu.wpi.first.wpilib.plugins.cpp.preferences.PreferenceConstants;
|
||||
public class ToolchainInstaller extends AbstractInstaller {
|
||||
|
||||
public ToolchainInstaller(String version) {
|
||||
super(version);
|
||||
super(version,
|
||||
WPILibCPPPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.TOOLCHAIN_INSTALLED), WPILibCPPPlugin.getDefault().getToolchain());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -21,11 +22,8 @@ public class ToolchainInstaller extends AbstractInstaller {
|
||||
|
||||
@Override
|
||||
protected void updateInstalledVersion(String version) {
|
||||
IPreferenceStore prefs = WPILibCPPPlugin.getDefault().getPreferenceStore();
|
||||
if (prefs.getBoolean(PreferenceConstants.UPDATE_TOOLCHAIN_VERSION)) {
|
||||
System.out.println("Forcing library version to "+version);
|
||||
prefs.setValue(PreferenceConstants.TOOLCHAIN_VERSION, version);
|
||||
}
|
||||
WPILibCPPPlugin.getDefault().getPreferenceStore().setDefault(PreferenceConstants.TOOLCHAIN_INSTALLED,
|
||||
WPILibCPPPlugin.getDefault().getCurrentVersion());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,7 +33,7 @@ public class Activator extends AbstractUIPlugin implements IStartup {
|
||||
}
|
||||
|
||||
private String getCurrentVersion() {
|
||||
return WPILibCPPPlugin.getDefault().getDefaultToolchainVersion();
|
||||
return "4.4.1-csery-gcc";
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -11,7 +11,8 @@ import edu.wpi.first.wpilib.plugins.cpp.preferences.PreferenceConstants;
|
||||
public class ToolchainInstaller extends AbstractInstaller {
|
||||
|
||||
public ToolchainInstaller(String version) {
|
||||
super(version);
|
||||
super(version,
|
||||
WPILibCPPPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.TOOLCHAIN_INSTALLED), WPILibCPPPlugin.getDefault().getToolchain());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -21,11 +22,8 @@ public class ToolchainInstaller extends AbstractInstaller {
|
||||
|
||||
@Override
|
||||
protected void updateInstalledVersion(String version) {
|
||||
IPreferenceStore prefs = WPILibCPPPlugin.getDefault().getPreferenceStore();
|
||||
if (prefs.getBoolean(PreferenceConstants.UPDATE_TOOLCHAIN_VERSION)) {
|
||||
System.out.println("Forcing library version to "+version);
|
||||
prefs.setValue(PreferenceConstants.TOOLCHAIN_VERSION, version);
|
||||
}
|
||||
WPILibCPPPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.TOOLCHAIN_INSTALLED,
|
||||
WPILibCPPPlugin.getDefault().getCurrentVersion());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,13 +58,9 @@ public class WPILibCPPPlugin extends AbstractUIPlugin implements IStartup {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public String getDefaultToolchainVersion() {
|
||||
return "arm-none-linux-gnueabi-4.4.1";
|
||||
}
|
||||
|
||||
public String getToolchain() {
|
||||
return WPILibCore.getDefault().getWPILibBaseDir()
|
||||
+ File.separator + "toolchains" + File.separator + getPreferenceStore().getString(PreferenceConstants.TOOLCHAIN_VERSION);
|
||||
+ File.separator + "toolchains" + File.separator + "current";
|
||||
}
|
||||
|
||||
public String getCurrentVersion() {
|
||||
@@ -82,7 +78,7 @@ public class WPILibCPPPlugin extends AbstractUIPlugin implements IStartup {
|
||||
|
||||
public String getCPPDir() {
|
||||
return WPILibCore.getDefault().getWPILibBaseDir()
|
||||
+ File.separator + "cpp" + File.separator + getPreferenceStore().getString(PreferenceConstants.LIBRARY_VERSION);
|
||||
+ File.separator + "cpp" + File.separator + "current";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
package edu.wpi.first.wpilib.plugins.cpp.installer;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
|
||||
import edu.wpi.first.wpilib.plugins.core.WPILibCore;
|
||||
import edu.wpi.first.wpilib.plugins.core.installer.AbstractInstaller;
|
||||
import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin;
|
||||
import edu.wpi.first.wpilib.plugins.cpp.preferences.PreferenceConstants;
|
||||
@@ -19,28 +14,23 @@ import edu.wpi.first.wpilib.plugins.cpp.preferences.PreferenceConstants;
|
||||
public class CPPInstaller extends AbstractInstaller {
|
||||
|
||||
public CPPInstaller(String version) {
|
||||
super(version);
|
||||
super(version,
|
||||
WPILibCPPPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.LIBRARY_INSTALLED), WPILibCPPPlugin.getDefault().getCPPDir());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFeatureName() {
|
||||
return "cpp";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateInstalledVersion(String version) {
|
||||
IPreferenceStore prefs = WPILibCPPPlugin.getDefault().getPreferenceStore();
|
||||
if (prefs.getBoolean(PreferenceConstants.UPDATE_LIBRARY_VERSION)) {
|
||||
WPILibCPPPlugin.logInfo("Forcing library version to "+version);
|
||||
Properties props = WPILibCore.getDefault().getProjectProperties(null);
|
||||
props.setProperty("cpp-version", version);
|
||||
WPILibCore.getDefault().saveGlobalProperties(props);
|
||||
prefs.setValue(PreferenceConstants.LIBRARY_VERSION, version);
|
||||
}
|
||||
WPILibCPPPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.LIBRARY_INSTALLED,
|
||||
WPILibCPPPlugin.getDefault().getCurrentVersion());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected InputStream getInstallResourceStream() {
|
||||
return CPPInstaller.class.getResourceAsStream("/resources/cpp.zip");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFeatureName()
|
||||
{
|
||||
return "cpp";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
package edu.wpi.first.wpilib.plugins.cpp.preferences;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
|
||||
import edu.wpi.first.wpilib.plugins.core.WPILibCore;
|
||||
import edu.wpi.first.wpilib.plugins.core.preferences.ComboFieldEditor;
|
||||
import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin;
|
||||
|
||||
/**
|
||||
* This class represents a preference page that
|
||||
* is contributed to the Preferences dialog. By
|
||||
* subclassing <samp>FieldEditorPreferencePage</samp>, we
|
||||
* can use the field support built into JFace that allows
|
||||
* us to create a page that is small and knows how to
|
||||
* save, restore and apply itself.
|
||||
* <p>
|
||||
* This page is used to modify preferences only. They
|
||||
* are stored in the preference store that belongs to
|
||||
* the main plug-in class. That way, preferences can
|
||||
* be accessed directly via the preference store.
|
||||
*/
|
||||
|
||||
public class CPPPreferencePage
|
||||
extends FieldEditorPreferencePage
|
||||
implements IWorkbenchPreferencePage {
|
||||
ComboFieldEditor toolchainVersionEditor;
|
||||
BooleanFieldEditor autoUpdateToolchainEditor;
|
||||
private ComboFieldEditor wpiLibVersionEditor;
|
||||
private BooleanFieldEditor autoUpdateEditor;
|
||||
|
||||
public CPPPreferencePage() {
|
||||
super(GRID);
|
||||
setPreferenceStore(WPILibCPPPlugin.getDefault().getPreferenceStore());
|
||||
setDescription("Change workspace level settings for C++.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the field editors. Field editors are abstractions of
|
||||
* the common GUI blocks needed to manipulate various types
|
||||
* of preferences. Each field editor knows how to save and
|
||||
* restore itself.
|
||||
*/
|
||||
public void createFieldEditors() {
|
||||
wpiLibVersionEditor = new ComboFieldEditor(PreferenceConstants.LIBRARY_VERSION,
|
||||
"&Library Version:", getFieldEditorParent(), getInstalledVersions());
|
||||
addField(wpiLibVersionEditor);
|
||||
autoUpdateEditor = new BooleanFieldEditor(PreferenceConstants.UPDATE_LIBRARY_VERSION,
|
||||
"&Auto Update Library Version", getFieldEditorParent());
|
||||
addField(autoUpdateEditor);
|
||||
toolchainVersionEditor = new ComboFieldEditor(PreferenceConstants.TOOLCHAIN_VERSION,
|
||||
"&Toolchain Version:", getFieldEditorParent(), getInstalledToolchains());
|
||||
addField(toolchainVersionEditor);
|
||||
autoUpdateToolchainEditor = new BooleanFieldEditor(PreferenceConstants.UPDATE_TOOLCHAIN_VERSION,
|
||||
"&Auto Update Toolchain Version", getFieldEditorParent());
|
||||
addField(autoUpdateToolchainEditor);
|
||||
}
|
||||
|
||||
private List<String> getInstalledVersions() {
|
||||
File[] dirs = new File(WPILibCore.getDefault().getWPILibBaseDir()+File.separator+"cpp")
|
||||
.listFiles(new FileFilter() {
|
||||
@Override public boolean accept(File f) {
|
||||
return f.isDirectory();
|
||||
}
|
||||
});
|
||||
List<String> versions = new ArrayList<String>();
|
||||
for (File dir : dirs) {
|
||||
versions.add(dir.getName());
|
||||
}
|
||||
Collections.sort(versions);
|
||||
return versions;
|
||||
}
|
||||
|
||||
private List<String> getInstalledToolchains() {
|
||||
File[] dirs = new File(WPILibCore.getDefault().getWPILibBaseDir()+File.separator+"toolchains")
|
||||
.listFiles(new FileFilter() {
|
||||
@Override public boolean accept(File f) {
|
||||
return f.isDirectory();
|
||||
}
|
||||
});
|
||||
List<String> versions = new ArrayList<String>();
|
||||
for (File dir : dirs) {
|
||||
versions.add(dir.getName());
|
||||
}
|
||||
Collections.sort(versions);
|
||||
return versions;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
|
||||
*/
|
||||
public void init(IWorkbench workbench) {
|
||||
WPILibCPPPlugin.logInfo("Preferences initialized.");
|
||||
Properties props = WPILibCore.getDefault().getProjectProperties(null);
|
||||
getPreferenceStore().setValue(PreferenceConstants.LIBRARY_VERSION,
|
||||
props.getProperty("cpp-version", WPILibCPPPlugin.getDefault().getCurrentVersion()));
|
||||
}
|
||||
|
||||
@Override public void performApply() {
|
||||
performOk();
|
||||
}
|
||||
|
||||
@Override public boolean performOk() {
|
||||
Properties props = WPILibCore.getDefault().getProjectProperties(null);
|
||||
props.setProperty("cpp-version", wpiLibVersionEditor.getChoice());
|
||||
WPILibCore.getDefault().saveGlobalProperties(props);
|
||||
return super.performOk();
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,6 @@ package edu.wpi.first.wpilib.plugins.cpp.preferences;
|
||||
* Constant definitions for plug-in preferences
|
||||
*/
|
||||
public class PreferenceConstants {
|
||||
public static final String LIBRARY_VERSION = "libraryVersionPreference";
|
||||
public static final String UPDATE_LIBRARY_VERSION = "udpateLibraryVersionPreference";
|
||||
public static final String TOOLCHAIN_VERSION = "toolchainVersionPreference";
|
||||
public static final String UPDATE_TOOLCHAIN_VERSION = "udpateToolchainVersionPreference";
|
||||
public static final String LIBRARY_INSTALLED = "libraryVersion_current";
|
||||
public static final String TOOLCHAIN_INSTALLED = "toolchainVersion_current";
|
||||
}
|
||||
|
||||
@@ -18,11 +18,8 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
|
||||
*/
|
||||
public void initializeDefaultPreferences() {
|
||||
IPreferenceStore store = WPILibCPPPlugin.getDefault().getPreferenceStore();
|
||||
store.setDefault(PreferenceConstants.LIBRARY_VERSION,
|
||||
WPILibCore.getDefault().getProjectProperties(null)
|
||||
.getProperty("cpp-version", WPILibCPPPlugin.getDefault().getCurrentVersion()));
|
||||
store.setDefault(PreferenceConstants.UPDATE_LIBRARY_VERSION, true);
|
||||
store.setDefault(PreferenceConstants.TOOLCHAIN_VERSION, WPILibCPPPlugin.getDefault().getDefaultToolchainVersion());
|
||||
store.setDefault(PreferenceConstants.UPDATE_TOOLCHAIN_VERSION, true);
|
||||
if (!store.contains(PreferenceConstants.LIBRARY_INSTALLED))
|
||||
store.setValue(PreferenceConstants.LIBRARY_INSTALLED,
|
||||
"none");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,15 +157,6 @@
|
||||
</enablement>
|
||||
</commonWizard>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.preferencePages">
|
||||
<page
|
||||
category="edu.wpi.first.wpilib.plugins.core.preferences.WPILibPreferencePage"
|
||||
class="edu.wpi.first.wpilib.plugins.java.preferences.JavaPreferencePage"
|
||||
id="edu.wpi.first.wpilib.plugins.java.preferences.JavaPreferencePage"
|
||||
name="Java Preferences">
|
||||
</page>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.core.runtime.preferences">
|
||||
<initializer
|
||||
|
||||
@@ -78,12 +78,16 @@ public class WPILibJavaPlugin extends AbstractUIPlugin implements IStartup {
|
||||
return "DEVELOPMENT";
|
||||
}
|
||||
}
|
||||
public String getJavaPath() {
|
||||
return WPILibCore.getDefault().getWPILibBaseDir()
|
||||
+ File.separator + "java" + File.separator + "current";
|
||||
}
|
||||
|
||||
public Properties getProjectProperties(IProject project) {
|
||||
Properties defaults = WPILibCore.getDefault().getProjectProperties(project);
|
||||
Properties props;
|
||||
try {
|
||||
File file = new File(WPILibCore.getDefault().getWPILibBaseDir()+"/java/"+getCurrentVersion()+"/ant/build.properties");
|
||||
File file = new File(WPILibCore.getDefault().getWPILibBaseDir()+"/java/current/ant/build.properties");
|
||||
props = new AntPropertiesParser(new FileInputStream(file)).getProperties(defaults);
|
||||
} catch (Exception e) {
|
||||
WPILibJavaPlugin.logError("Error getting properties.", e);
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package edu.wpi.first.wpilib.plugins.java.installer;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
|
||||
import edu.wpi.first.wpilib.plugins.core.WPILibCore;
|
||||
import edu.wpi.first.wpilib.plugins.core.installer.AbstractInstaller;
|
||||
import edu.wpi.first.wpilib.plugins.java.WPILibJavaPlugin;
|
||||
import edu.wpi.first.wpilib.plugins.java.preferences.PreferenceConstants;
|
||||
@@ -19,7 +16,9 @@ import edu.wpi.first.wpilib.plugins.java.preferences.PreferenceConstants;
|
||||
public class JavaInstaller extends AbstractInstaller {
|
||||
|
||||
public JavaInstaller(String version) {
|
||||
super(version);
|
||||
super(version,
|
||||
WPILibJavaPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.LIBRARY_INSTALLED),
|
||||
WPILibJavaPlugin.getDefault().getJavaPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,14 +29,7 @@ public class JavaInstaller extends AbstractInstaller {
|
||||
@Override
|
||||
protected void updateInstalledVersion(String version) {
|
||||
IPreferenceStore prefs = WPILibJavaPlugin.getDefault().getPreferenceStore();
|
||||
if (prefs.getBoolean(PreferenceConstants.UPDATE_LIBRARY_VERSION)) {
|
||||
WPILibJavaPlugin.logInfo("Forcing library version to "+version);
|
||||
Properties props = WPILibCore.getDefault().getProjectProperties(null);
|
||||
props.setProperty("version", version);
|
||||
WPILibCore.getDefault().saveGlobalProperties(props);
|
||||
prefs.setValue(PreferenceConstants.LIBRARY_VERSION, version);
|
||||
}
|
||||
WPILibJavaPlugin.getDefault().updateProjects();
|
||||
prefs.setValue(PreferenceConstants.LIBRARY_INSTALLED, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
package edu.wpi.first.wpilib.plugins.java.preferences;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
|
||||
import edu.wpi.first.wpilib.plugins.core.WPILibCore;
|
||||
import edu.wpi.first.wpilib.plugins.core.preferences.ComboFieldEditor;
|
||||
import edu.wpi.first.wpilib.plugins.java.WPILibJavaPlugin;
|
||||
|
||||
/**
|
||||
* This class represents a preference page that
|
||||
* is contributed to the Preferences dialog. By
|
||||
* subclassing <samp>FieldEditorPreferencePage</samp>, we
|
||||
* can use the field support built into JFace that allows
|
||||
* us to create a page that is small and knows how to
|
||||
* save, restore and apply itself.
|
||||
* <p>
|
||||
* This page is used to modify preferences only. They
|
||||
* are stored in the preference store that belongs to
|
||||
* the main plug-in class. That way, preferences can
|
||||
* be accessed directly via the preference store.
|
||||
*/
|
||||
|
||||
public class JavaPreferencePage
|
||||
extends FieldEditorPreferencePage
|
||||
implements IWorkbenchPreferencePage {
|
||||
ComboFieldEditor wpiLibVersionEditor;
|
||||
BooleanFieldEditor autoUpdateEditor;
|
||||
|
||||
public JavaPreferencePage() {
|
||||
super(GRID);
|
||||
setPreferenceStore(WPILibJavaPlugin.getDefault().getPreferenceStore());
|
||||
setDescription("Change workspace level settings for Java.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the field editors. Field editors are abstractions of
|
||||
* the common GUI blocks needed to manipulate various types
|
||||
* of preferences. Each field editor knows how to save and
|
||||
* restore itself.
|
||||
*/
|
||||
public void createFieldEditors() {
|
||||
wpiLibVersionEditor = new ComboFieldEditor(PreferenceConstants.LIBRARY_VERSION,
|
||||
"&Library Version:", getFieldEditorParent(), getInstalledVersions());
|
||||
addField(wpiLibVersionEditor);
|
||||
autoUpdateEditor = new BooleanFieldEditor(PreferenceConstants.UPDATE_LIBRARY_VERSION,
|
||||
"&Auto Update Library Version", getFieldEditorParent());
|
||||
addField(autoUpdateEditor);
|
||||
}
|
||||
|
||||
private List<String> getInstalledVersions() {
|
||||
File[] dirs = new File(WPILibCore.getDefault().getWPILibBaseDir()+File.separator+"java")
|
||||
.listFiles(new FileFilter() {
|
||||
@Override public boolean accept(File f) {
|
||||
return f.isDirectory();
|
||||
}
|
||||
});
|
||||
List<String> versions = new ArrayList<String>();
|
||||
for (File dir : dirs) {
|
||||
versions.add(dir.getName());
|
||||
}
|
||||
Collections.sort(versions);
|
||||
return versions;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
|
||||
*/
|
||||
public void init(IWorkbench workbench) {
|
||||
WPILibJavaPlugin.logInfo("Preferences initialized.");
|
||||
Properties props = WPILibCore.getDefault().getProjectProperties(null);
|
||||
getPreferenceStore().setValue(PreferenceConstants.LIBRARY_VERSION,
|
||||
props.getProperty("version", WPILibJavaPlugin.getDefault().getCurrentVersion()));
|
||||
}
|
||||
|
||||
@Override public void performApply() {
|
||||
performOk();
|
||||
}
|
||||
|
||||
@Override public boolean performOk() {
|
||||
Properties props = WPILibCore.getDefault().getProjectProperties(null);
|
||||
props.setProperty("version", wpiLibVersionEditor.getChoice());
|
||||
WPILibCore.getDefault().saveGlobalProperties(props);
|
||||
WPILibJavaPlugin.getDefault().updateProjects();
|
||||
return super.performOk();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,5 @@ package edu.wpi.first.wpilib.plugins.java.preferences;
|
||||
* Constant definitions for plug-in preferences
|
||||
*/
|
||||
public class PreferenceConstants {
|
||||
public static final String LIBRARY_VERSION = "libraryVersionPreference";
|
||||
public static final String UPDATE_LIBRARY_VERSION = "udpateLibraryVersionPreference";
|
||||
public static final String LIBRARY_INSTALLED = "libraryVersion_current";
|
||||
}
|
||||
|
||||
@@ -18,9 +18,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
|
||||
*/
|
||||
public void initializeDefaultPreferences() {
|
||||
IPreferenceStore store = WPILibJavaPlugin.getDefault().getPreferenceStore();
|
||||
store.setDefault(PreferenceConstants.LIBRARY_VERSION,
|
||||
WPILibCore.getDefault().getProjectProperties(null)
|
||||
.getProperty("version", WPILibJavaPlugin.getDefault().getCurrentVersion()));
|
||||
store.setDefault(PreferenceConstants.UPDATE_LIBRARY_VERSION, true);
|
||||
if (!store.contains(PreferenceConstants.LIBRARY_INSTALLED))
|
||||
store.setValue(PreferenceConstants.LIBRARY_INSTALLED, "none");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user