|
Lines 42-48
import org.eclipse.ui.plugin.AbstractUIPlugin;
Link Here
|
| 42 |
import org.osgi.framework.BundleContext; |
42 |
import org.osgi.framework.BundleContext; |
| 43 |
import org.osgi.framework.Version; |
43 |
import org.osgi.framework.Version; |
| 44 |
|
44 |
|
| 45 |
public class ValgrindLaunchPlugin extends AbstractUIPlugin implements IPropertyChangeListener { |
45 |
public class ValgrindLaunchPlugin extends AbstractUIPlugin { |
| 46 |
|
46 |
|
| 47 |
// The plug-in ID |
47 |
// The plug-in ID |
| 48 |
public static final String PLUGIN_ID = PluginConstants.LAUNCH_PLUGIN_ID; |
48 |
public static final String PLUGIN_ID = PluginConstants.LAUNCH_PLUGIN_ID; |
|
Lines 72-80
public class ValgrindLaunchPlugin extends AbstractUIPlugin implements IPropertyC
Link Here
|
| 72 |
|
72 |
|
| 73 |
protected HashMap<String, IConfigurationElement> toolMap; |
73 |
protected HashMap<String, IConfigurationElement> toolMap; |
| 74 |
|
74 |
|
| 75 |
private ValgrindCommand valgrindCommand; |
|
|
| 76 |
private IPath valgrindLocation; |
| 77 |
private Version valgrindVersion; |
| 78 |
private ILaunchConfiguration config; |
75 |
private ILaunchConfiguration config; |
| 79 |
private ILaunch launch; |
76 |
private ILaunch launch; |
| 80 |
|
77 |
|
|
Lines 94-102
public class ValgrindLaunchPlugin extends AbstractUIPlugin implements IPropertyC
Link Here
|
| 94 |
public void start(BundleContext context) throws Exception { |
91 |
public void start(BundleContext context) throws Exception { |
| 95 |
super.start(context); |
92 |
super.start(context); |
| 96 |
plugin = this; |
93 |
plugin = this; |
| 97 |
|
|
|
| 98 |
// Register as listener for changes to the property page |
| 99 |
ValgrindPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); |
| 100 |
} |
94 |
} |
| 101 |
|
95 |
|
| 102 |
/* |
96 |
/* |
|
Lines 117-153
public class ValgrindLaunchPlugin extends AbstractUIPlugin implements IPropertyC
Link Here
|
| 117 |
return plugin; |
111 |
return plugin; |
| 118 |
} |
112 |
} |
| 119 |
|
113 |
|
| 120 |
public IPath getValgrindLocation() throws CoreException { |
114 |
public static IPath getValgrindLocation() throws CoreException { |
| 121 |
if (valgrindLocation == null) { |
115 |
return getValgrindLocation(new ValgrindCommand()); |
| 122 |
findValgrindLocation(); |
|
|
| 123 |
} |
| 124 |
|
| 125 |
return valgrindLocation; |
| 126 |
} |
| 127 |
|
| 128 |
public void setValgrindLocation(IPath valgrindLocation) { |
| 129 |
this.valgrindLocation = valgrindLocation; |
| 130 |
} |
116 |
} |
| 131 |
|
117 |
|
| 132 |
public Version getValgrindVersion() throws CoreException { |
118 |
public static IPath getValgrindLocation(ValgrindCommand command) throws CoreException { |
| 133 |
if (valgrindVersion == null) { |
119 |
if (command.isEnabled()) { |
| 134 |
findValgrindVersion(); |
|
|
| 135 |
} |
| 136 |
// check for minimum supported version |
| 137 |
if (valgrindVersion.compareTo(MIN_VER) < 0) { |
| 138 |
throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, NLS.bind(Messages.getString("ValgrindLaunchPlugin.Error_min_version"), valgrindVersion.toString(), MIN_VER.toString()))); //$NON-NLS-1$ |
| 139 |
} |
| 140 |
return valgrindVersion; |
| 141 |
} |
| 142 |
|
| 143 |
public void setValgrindVersion(Version valgrindVersion) { |
| 144 |
this.valgrindVersion = valgrindVersion; |
| 145 |
} |
| 146 |
|
| 147 |
private void findValgrindLocation() throws CoreException { |
| 148 |
if (getValgrindCommand().isEnabled()) { |
| 149 |
try { |
120 |
try { |
| 150 |
valgrindLocation = Path.fromOSString(getValgrindCommand().whichValgrind()); |
121 |
return Path.fromOSString(command.whichValgrind()); |
| 151 |
} catch (IOException e) { |
122 |
} catch (IOException e) { |
| 152 |
IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, Messages.getString("ValgrindLaunchPlugin.Please_ensure_Valgrind"), e); //$NON-NLS-1$ |
123 |
IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, Messages.getString("ValgrindLaunchPlugin.Please_ensure_Valgrind"), e); //$NON-NLS-1$ |
| 153 |
throw new CoreException(status); |
124 |
throw new CoreException(status); |
|
Lines 158-171
public class ValgrindLaunchPlugin extends AbstractUIPlugin implements IPropertyC
Link Here
|
| 158 |
throw new CoreException(status); |
129 |
throw new CoreException(status); |
| 159 |
} |
130 |
} |
| 160 |
} |
131 |
} |
| 161 |
|
132 |
|
| 162 |
private void findValgrindVersion() throws CoreException { |
133 |
public static Version getValgrindVersion(ValgrindCommand command, IPath valgrindLocation) throws CoreException { |
|
|
134 |
Version valgrindVersion = null; |
| 163 |
try { |
135 |
try { |
| 164 |
if (valgrindLocation == null) { |
136 |
String verString = command.whichVersion(valgrindLocation.toOSString()); |
| 165 |
findValgrindLocation(); |
|
|
| 166 |
} |
| 167 |
|
| 168 |
String verString = getValgrindCommand().whichVersion(valgrindLocation.toOSString()); |
| 169 |
verString = verString.replace(VERSION_PREFIX, ""); //$NON-NLS-1$ |
137 |
verString = verString.replace(VERSION_PREFIX, ""); //$NON-NLS-1$ |
| 170 |
if (verString.indexOf(VERSION_DELIMITER) > 0) { |
138 |
if (verString.indexOf(VERSION_DELIMITER) > 0) { |
| 171 |
verString = verString.substring(0, verString.indexOf(VERSION_DELIMITER)); |
139 |
verString = verString.substring(0, verString.indexOf(VERSION_DELIMITER)); |
|
Lines 180-198
public class ValgrindLaunchPlugin extends AbstractUIPlugin implements IPropertyC
Link Here
|
| 180 |
IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, NLS.bind(Messages.getString("ValgrindLaunchPlugin.Couldn't_determine_version"), valgrindLocation), e); //$NON-NLS-1$ |
148 |
IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, NLS.bind(Messages.getString("ValgrindLaunchPlugin.Couldn't_determine_version"), valgrindLocation), e); //$NON-NLS-1$ |
| 181 |
throw new CoreException(status); |
149 |
throw new CoreException(status); |
| 182 |
} |
150 |
} |
| 183 |
} |
151 |
|
| 184 |
|
152 |
// check for minimum supported version |
| 185 |
public void setValgrindCommand(ValgrindCommand command) { |
153 |
if (valgrindVersion.compareTo(MIN_VER) < 0) { |
| 186 |
valgrindCommand = command; |
154 |
throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, NLS.bind(Messages.getString("ValgrindLaunchPlugin.Error_min_version"), valgrindVersion.toString(), MIN_VER.toString()))); //$NON-NLS-1$ |
| 187 |
} |
|
|
| 188 |
|
| 189 |
protected ValgrindCommand getValgrindCommand() { |
| 190 |
if (valgrindCommand == null) { |
| 191 |
valgrindCommand = new ValgrindCommand(); |
| 192 |
} |
155 |
} |
| 193 |
return valgrindCommand; |
156 |
return valgrindVersion; |
| 194 |
} |
157 |
} |
| 195 |
|
158 |
|
|
|
159 |
public static Version getValgrindVersion() throws CoreException { |
| 160 |
ValgrindCommand command = new ValgrindCommand(); |
| 161 |
return getValgrindVersion(command, getValgrindLocation(command)); |
| 162 |
} |
| 163 |
|
| 196 |
public String[] getRegisteredToolIDs() { |
164 |
public String[] getRegisteredToolIDs() { |
| 197 |
Set<String> ids = getToolMap().keySet(); |
165 |
Set<String> ids = getToolMap().keySet(); |
| 198 |
return ids.toArray(new String[ids.size()]); |
166 |
return ids.toArray(new String[ids.size()]); |
|
Lines 319-333
public class ValgrindLaunchPlugin extends AbstractUIPlugin implements IPropertyC
Link Here
|
| 319 |
} |
287 |
} |
| 320 |
return toolMap; |
288 |
return toolMap; |
| 321 |
} |
289 |
} |
| 322 |
|
|
|
| 323 |
public void propertyChange(PropertyChangeEvent event) { |
| 324 |
String prop = event.getProperty(); |
| 325 |
if (prop.equals(ValgrindPreferencePage.VALGRIND_PATH) |
| 326 |
|| prop.equals(ValgrindPreferencePage.VALGRIND_ENABLE)) { |
| 327 |
// Reset Valgrind location and version |
| 328 |
valgrindLocation = null; |
| 329 |
valgrindVersion = null; |
| 330 |
} |
| 331 |
} |
| 332 |
|
| 333 |
} |
290 |
} |