mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
added preference storing of symbols and paths
This commit is contained in:
parent
6a2b389c5f
commit
26d4065b60
1 changed files with 71 additions and 82 deletions
|
@ -1,6 +1,21 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
* QNX Software Systems - Move to Make plugin
|
||||||
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.make.ui;
|
package org.eclipse.cdt.make.ui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
||||||
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.core.MakeScannerInfo;
|
import org.eclipse.cdt.make.core.MakeScannerInfo;
|
||||||
import org.eclipse.cdt.make.core.MakeScannerProvider;
|
import org.eclipse.cdt.make.core.MakeScannerProvider;
|
||||||
import org.eclipse.cdt.ui.AbstractCOptionPage;
|
import org.eclipse.cdt.ui.AbstractCOptionPage;
|
||||||
|
@ -9,10 +24,11 @@ import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
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.jface.dialogs.InputDialog;
|
import org.eclipse.jface.dialogs.InputDialog;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.MouseAdapter;
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
import org.eclipse.swt.events.MouseEvent;
|
||||||
import org.eclipse.swt.events.MouseListener;
|
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.graphics.Font;
|
import org.eclipse.swt.graphics.Font;
|
||||||
|
@ -23,19 +39,10 @@ import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.List;
|
import org.eclipse.swt.widgets.List;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v0.5
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v05.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Rational Software - Initial API and implementation
|
|
||||||
***********************************************************************/
|
|
||||||
|
|
||||||
public class BuildPathInfoBlock extends AbstractCOptionPage {
|
public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
|
|
||||||
|
private static final String PREF_SYMBOLS = "ScannerSymbols";
|
||||||
|
private static final String PREF_INCLUDES = "ScannerIncludes";
|
||||||
private static final String PREFIX = "BuildPathInfoBlock"; //$NON-NLS-1$
|
private static final String PREFIX = "BuildPathInfoBlock"; //$NON-NLS-1$
|
||||||
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
|
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
|
||||||
private static final String PATHS = PREFIX + ".paths"; //$NON-NLS-1$
|
private static final String PATHS = PREFIX + ".paths"; //$NON-NLS-1$
|
||||||
|
@ -64,17 +71,11 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
private Button symbolDown;
|
private Button symbolDown;
|
||||||
private Shell shell;
|
private Shell shell;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param valid
|
|
||||||
*/
|
|
||||||
public BuildPathInfoBlock() {
|
public BuildPathInfoBlock() {
|
||||||
super(CUIPlugin.getResourceString(LABEL));
|
super(CUIPlugin.getResourceString(LABEL));
|
||||||
setDescription("Set the include paths and preprocessor symbols for this project");
|
setDescription("Set the include paths and preprocessor symbols for this project");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param composite
|
|
||||||
*/
|
|
||||||
private void createPathListButtons(Composite parent) {
|
private void createPathListButtons(Composite parent) {
|
||||||
// Create a composite for the buttons
|
// Create a composite for the buttons
|
||||||
pathButtonComp = ControlFactory.createComposite(parent, 1);
|
pathButtonComp = ControlFactory.createComposite(parent, 1);
|
||||||
|
@ -124,9 +125,6 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param composite
|
|
||||||
*/
|
|
||||||
private void createPathListControl(Composite parent, int numColumns) {
|
private void createPathListControl(Composite parent, int numColumns) {
|
||||||
// Create the list
|
// Create the list
|
||||||
pathList = new List(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
|
pathList = new List(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||||
|
@ -135,20 +133,10 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
enablePathButtons();
|
enablePathButtons();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
pathList.addMouseListener(new MouseListener() {
|
pathList.addMouseListener(new MouseAdapter() {
|
||||||
|
|
||||||
public void mouseDoubleClick(MouseEvent e) {
|
public void mouseDoubleClick(MouseEvent e) {
|
||||||
editPathListItem();
|
editPathListItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseDown(MouseEvent e) {
|
|
||||||
// Handled by the selection listener
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseUp(MouseEvent e) {
|
|
||||||
// Handled by the selection listener
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Make it occupy the first 2 columns
|
// Make it occupy the first 2 columns
|
||||||
|
@ -158,9 +146,6 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
pathList.setFont(parent.getFont());
|
pathList.setFont(parent.getFont());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param composite
|
|
||||||
*/
|
|
||||||
private void createSymbolListButtons(Composite parent) {
|
private void createSymbolListButtons(Composite parent) {
|
||||||
// Create a composite for the buttons
|
// Create a composite for the buttons
|
||||||
symbolButtonComp = ControlFactory.createComposite(parent, 1);
|
symbolButtonComp = ControlFactory.createComposite(parent, 1);
|
||||||
|
@ -209,9 +194,6 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
SWTUtil.setButtonDimensionHint(symbolDown);
|
SWTUtil.setButtonDimensionHint(symbolDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param composite
|
|
||||||
*/
|
|
||||||
private void createSymbolListControl(Composite parent, int numColumns) {
|
private void createSymbolListControl(Composite parent, int numColumns) {
|
||||||
// Create the list
|
// Create the list
|
||||||
symbolList = new List(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
|
symbolList = new List(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||||
|
@ -220,19 +202,10 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
enableSymbolButtons();
|
enableSymbolButtons();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
symbolList.addMouseListener(new MouseListener() {
|
symbolList.addMouseListener(new MouseAdapter() {
|
||||||
|
|
||||||
public void mouseDoubleClick(MouseEvent e) {
|
public void mouseDoubleClick(MouseEvent e) {
|
||||||
editSymbolListItem();
|
editSymbolListItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseDown(MouseEvent e) {
|
|
||||||
// Handled by the selection event
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseUp(MouseEvent e) {
|
|
||||||
// Handled by the selection event
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Make it occupy the first n-1 columns
|
// Make it occupy the first n-1 columns
|
||||||
|
@ -260,16 +233,59 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
info.update();
|
info.update();
|
||||||
monitor.done();
|
monitor.done();
|
||||||
|
} else {
|
||||||
|
setIncludes(MakeCorePlugin.getDefault().getPluginPreferences());
|
||||||
|
setSymbols(MakeCorePlugin.getDefault().getPluginPreferences());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performDefaults() {
|
public void performDefaults() {
|
||||||
|
pathList.removeAll();
|
||||||
|
symbolList.removeAll();
|
||||||
if (getContainer().getProject() != null) {
|
if (getContainer().getProject() != null) {
|
||||||
pathList.removeAll();
|
pathList.setItems(getIncludes(MakeCorePlugin.getDefault().getPluginPreferences()));
|
||||||
symbolList.removeAll();
|
symbolList.setItems(getSymbols(MakeCorePlugin.getDefault().getPluginPreferences()));
|
||||||
// dinglis-TODO: set list to preference settings
|
|
||||||
getContainer().updateContainer();
|
|
||||||
}
|
}
|
||||||
|
getContainer().updateContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSymbols(Preferences prefs) {
|
||||||
|
prefs.setValue(PREF_SYMBOLS, stringArrayToString(getSymbolListContents()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setIncludes(Preferences prefs) {
|
||||||
|
prefs.setValue(PREF_INCLUDES, stringArrayToString(getPathListContents()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String stringArrayToString(String[] strings) {
|
||||||
|
StringBuffer buf = new StringBuffer();
|
||||||
|
for (int i = 0; i < strings.length; i++) {
|
||||||
|
buf.append(strings[i]).append(';');
|
||||||
|
}
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] getSymbols(Preferences prefs) {
|
||||||
|
String syms = prefs.getString(PREF_SYMBOLS);
|
||||||
|
return parseStringToList(syms);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] getIncludes(Preferences prefs) {
|
||||||
|
String syms = prefs.getString(PREF_INCLUDES);
|
||||||
|
return parseStringToList(syms);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] parseStringToList(String syms) {
|
||||||
|
String[] empty = new String[0];
|
||||||
|
if (syms != null && syms.length() > 0) {
|
||||||
|
StringTokenizer tok = new StringTokenizer(syms, ";");
|
||||||
|
ArrayList list = new ArrayList(tok.countTokens());
|
||||||
|
while (tok.hasMoreElements()) {
|
||||||
|
list.add(tok.nextToken());
|
||||||
|
}
|
||||||
|
return (String[]) list.toArray(empty);
|
||||||
|
}
|
||||||
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -404,23 +420,14 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
setControl(composite);
|
setControl(composite);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String[] getPathListContents() {
|
private String[] getPathListContents() {
|
||||||
return pathList.getItems();
|
return pathList.getItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String[] getSymbolListContents() {
|
private String[] getSymbolListContents() {
|
||||||
return symbolList.getItems();
|
return symbolList.getItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void handleAddPath() {
|
protected void handleAddPath() {
|
||||||
// Popup an entry dialog
|
// Popup an entry dialog
|
||||||
InputDialog dialog =
|
InputDialog dialog =
|
||||||
|
@ -436,9 +443,6 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void handleAddSymbol() {
|
protected void handleAddSymbol() {
|
||||||
// Popup an entry dialog
|
// Popup an entry dialog
|
||||||
InputDialog dialog =
|
InputDialog dialog =
|
||||||
|
@ -454,9 +458,6 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void handlePathDown() {
|
protected void handlePathDown() {
|
||||||
// Get the selection index
|
// Get the selection index
|
||||||
int index = pathList.getSelectionIndex();
|
int index = pathList.getSelectionIndex();
|
||||||
|
@ -478,9 +479,6 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
enablePathButtons();
|
enablePathButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void handlePathUp() {
|
protected void handlePathUp() {
|
||||||
// Get the selection index
|
// Get the selection index
|
||||||
int index = pathList.getSelectionIndex();
|
int index = pathList.getSelectionIndex();
|
||||||
|
@ -497,9 +495,6 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
enablePathButtons();
|
enablePathButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void handleRemovePath() {
|
protected void handleRemovePath() {
|
||||||
// Get the selection index
|
// Get the selection index
|
||||||
int index = pathList.getSelectionIndex();
|
int index = pathList.getSelectionIndex();
|
||||||
|
@ -516,9 +511,6 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
enablePathButtons();
|
enablePathButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void handleRemoveSymbol() {
|
protected void handleRemoveSymbol() {
|
||||||
// Get the selection index
|
// Get the selection index
|
||||||
int index = symbolList.getSelectionIndex();
|
int index = symbolList.getSelectionIndex();
|
||||||
|
@ -533,9 +525,6 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
enableSymbolButtons();
|
enableSymbolButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void handleSymbolDown() {
|
protected void handleSymbolDown() {
|
||||||
// Get the selection index
|
// Get the selection index
|
||||||
int index = symbolList.getSelectionIndex();
|
int index = symbolList.getSelectionIndex();
|
||||||
|
@ -557,9 +546,6 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
enableSymbolButtons();
|
enableSymbolButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void handleSymbolUp() {
|
protected void handleSymbolUp() {
|
||||||
// Get the selection index
|
// Get the selection index
|
||||||
int index = symbolList.getSelectionIndex();
|
int index = symbolList.getSelectionIndex();
|
||||||
|
@ -593,6 +579,9 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
symbolList.setItems(info.getPreprocessorSymbols());
|
symbolList.setItems(info.getPreprocessorSymbols());
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
pathList.setItems(getIncludes(MakeCorePlugin.getDefault().getPluginPreferences()));
|
||||||
|
symbolList.setItems(getSymbols(MakeCorePlugin.getDefault().getPluginPreferences()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue