1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

New method added in ICOptionPage

Preferences getPreferences()
This commit is contained in:
Alain Magloire 2003-10-14 20:36:34 +00:00
parent 833492ccf0
commit 71c5ec9d07
5 changed files with 38 additions and 16 deletions

View file

@ -99,6 +99,9 @@ public abstract class AbstractBinaryParserPage extends AbstractCOptionPage {
public void setContainer(ICOptionContainer container) { public void setContainer(ICOptionContainer container) {
super.setContainer(container); super.setContainer(container);
initializeParserPageMap(); initializeParserPageMap();
ICOptionPage page = getCurrentBinaryParserPage();
if (page != null)
page.setContainer(container);
} }
public ICOptionPage getBinaryParserPage(String parserID) { public ICOptionPage getBinaryParserPage(String parserID) {

View file

@ -116,7 +116,6 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(getContainer().getProject()); ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(getContainer().getProject());
desc.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID); desc.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, (String) idMap.get(selected)); desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, (String) idMap.get(selected));
CCorePlugin.getDefault().getCoreModel().resetBinaryParser(getContainer().getProject());
} else { } else {
fPrefs.setValue(CCorePlugin.PREF_BINARY_PARSER, (String) idMap.get(selected)); fPrefs.setValue(CCorePlugin.PREF_BINARY_PARSER, (String) idMap.get(selected));
} }
@ -128,11 +127,17 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
// We have to do it last to make sure the parser id is save // We have to do it last to make sure the parser id is save
// in .cdtproject // in .cdtproject
super.performApply(new SubProgressMonitor(monitor, 1)); super.performApply(new SubProgressMonitor(monitor, 1));
// Reset the binary parser the paths may have change.
if (getContainer().getProject() != null)
CCorePlugin.getDefault().getCoreModel().resetBinaryParser(getContainer().getProject());
monitor.done(); monitor.done();
} }
public void setContainer(ICOptionContainer container) { public void setContainer(ICOptionContainer container) {
super.setContainer(container); super.setContainer(container);
IExtensionPoint point = CCorePlugin.getDefault().getDescriptor().getExtensionPoint(CCorePlugin.BINARY_PARSER_SIMPLE_ID); IExtensionPoint point = CCorePlugin.getDefault().getDescriptor().getExtensionPoint(CCorePlugin.BINARY_PARSER_SIMPLE_ID);
if (point != null) { if (point != null) {
IExtension[] exts = point.getExtensions(); IExtension[] exts = point.getExtensions();
@ -181,6 +186,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
// Give a change to the UI contributors to react. // Give a change to the UI contributors to react.
// But do it last after the comboBox is set. // But do it last after the comboBox is set.
handleBinaryParserChanged(); handleBinaryParserChanged();
super.performDefaults();
getContainer().updateContainer(); getContainer().updateContainer();
} }

View file

@ -25,6 +25,7 @@ import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPluginDescriptor; import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.ModifyListener;
@ -42,6 +43,9 @@ import org.eclipse.swt.widgets.Text;
*/ */
public class GNUElfBinaryParserPage extends AbstractCOptionPage { public class GNUElfBinaryParserPage extends AbstractCOptionPage {
public final static String PREF_ADDR2LINE_PATH = CUIPlugin.PLUGIN_ID + ".addr2line"; //$NON-NLS-1$
public final static String PREF_CPPFILT_PATH = CUIPlugin.PLUGIN_ID + ".cppfilt"; //$NON-NLS-1$
protected Text fAddr2LineCommandText; protected Text fAddr2LineCommandText;
protected Text fCPPFiltCommandText; protected Text fCPPFiltCommandText;
@ -52,12 +56,14 @@ public class GNUElfBinaryParserPage extends AbstractCOptionPage {
if (monitor == null) { if (monitor == null) {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
} }
String addr2line = fAddr2LineCommandText.getText().trim();
String cppfilt = fCPPFiltCommandText.getText().trim();
monitor.beginTask("Saving Attributes", 1); monitor.beginTask("Saving Attributes", 1);
IProject proj = getContainer().getProject(); IProject proj = getContainer().getProject();
if (proj != null) { if (proj != null) {
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj); ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj);
String addr2line = fAddr2LineCommandText.getText().trim();
String cppfilt = fCPPFiltCommandText.getText().trim();
ICExtensionReference[] cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID); ICExtensionReference[] cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
if (cext.length == 0) { if (cext.length == 0) {
// The value was not save yet and we need to save it now // The value was not save yet and we need to save it now
@ -87,6 +93,12 @@ public class GNUElfBinaryParserPage extends AbstractCOptionPage {
cext[0].setExtensionData("c++filt", cppfilt); cext[0].setExtensionData("c++filt", cppfilt);
} }
} }
} else {
Preferences store = getContainer().getPreferences();
if (store != null) {
store.setValue(PREF_ADDR2LINE_PATH, addr2line);
store.setValue(PREF_CPPFILT_PATH, cppfilt);
}
} }
} }
@ -107,9 +119,15 @@ public class GNUElfBinaryParserPage extends AbstractCOptionPage {
} }
} catch (CoreException e) { } catch (CoreException e) {
} }
} else {
Preferences store = getContainer().getPreferences();
if (store != null) {
addr2line = store.getString(PREF_ADDR2LINE_PATH);
cppfilt = store.getString(PREF_CPPFILT_PATH);
}
} }
fAddr2LineCommandText.setText((addr2line == null) ? "addr2line" : addr2line); fAddr2LineCommandText.setText((addr2line == null || addr2line.length() == 0) ? "addr2line" : addr2line);
fCPPFiltCommandText.setText((cppfilt == null) ? "c++filt" : cppfilt); fCPPFiltCommandText.setText((cppfilt == null || cppfilt.length() == 0) ? "c++filt" : cppfilt);
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -12,7 +12,7 @@ package org.eclipse.cdt.ui.dialogs;
***********************************************************************/ ***********************************************************************/
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.core.runtime.Preferences;
public interface ICOptionContainer { public interface ICOptionContainer {
@ -25,6 +25,6 @@ public interface ICOptionContainer {
* *
* @return the preference store, or <code>null</code> if none * @return the preference store, or <code>null</code> if none
*/ */
public IPreferenceStore getPreferenceStore(); public Preferences getPreferences();
} }

View file

@ -12,6 +12,7 @@ import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock; import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.WizardPage; import org.eclipse.jface.wizard.WizardPage;
@ -56,17 +57,11 @@ public abstract class NewCProjectWizardOptionPage extends WizardPage implements
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getPreferenceStore() * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getPreferenceStore()
*/ */
public IPreferenceStore getPreferenceStore() { public abstract Preferences getPreferences();
return preferenceStore;
}
/** /* (non-Javadoc)
* @param store * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getProject()
*/ */
public void setPreferenceStore(IPreferenceStore store) {
preferenceStore = store;
}
public abstract IProject getProject(); public abstract IProject getProject();
} }