1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Bug #175504: explicit workspace/filesystem setting

This commit is contained in:
Oleg Krasilnikov 2007-02-28 10:00:15 +00:00
parent 5727eccf3e
commit 3af158b7d9
12 changed files with 109 additions and 49 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 368 B

After

Width:  |  Height:  |  Size: 353 B

View file

@ -60,11 +60,11 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
// boolean savedShowBI = false;
// List incs;
public static final Image IMG_FS = CPluginImages.get(CPluginImages.IMG_FILESYSTEM);
public static final Image IMG_WS = CPluginImages.get(CPluginImages.IMG_WORKSPACE);
public static final Image IMG_MK = CPluginImages.get(CPluginImages.IMG_OBJS_MACRO);
private static final String ALL = "[All]"; //$NON-NLS-1$
private static final String LIST = "[List]"; //$NON-NLS-1$
private static final Image IMG_FS = CPluginImages.get(CPluginImages.IMG_FILESYSTEM);
private static final Image IMG_WS = CPluginImages.get(CPluginImages.IMG_WORKSPACE);
private static final Image IMG_MK = CPluginImages.get(CPluginImages.IMG_OBJS_MACRO);
private static Map names_l = new HashMap();
private static Map names_t = new HashMap();
private static String[] names_ls;
@ -158,8 +158,8 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
* Methods to be implemented in descendants
*/
public abstract int getKind();
public abstract ICLanguageSettingEntry doAdd(String s1, String s2);
public abstract ICLanguageSettingEntry doEdit(String s1, String s2);
public abstract ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp);
public abstract ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp);
public abstract boolean hasValues();
/**
@ -175,6 +175,7 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
ICExternalSetting[] vals = cfg.getExternalSettings();
if (vals == null || vals.length == 0) {
tv.setInput(null);
setButtons();
return;
}
for (int i=0; i<vals.length; i++) {
@ -214,9 +215,9 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
case 0: // add
dlg = new ExpDialog(usercomp.getShell(), true,
"Create", EMPTY_STR, EMPTY_STR, cfg, //$NON-NLS-1$
null, null, getKind(), names_ls, names_ts, namesList);
null, null, getKind(), names_ls, names_ts, namesList, false);
if (dlg.open()) {
ent[0] = doAdd(dlg.text1.trim(), dlg.text2.trim());
ent[0] = doAdd(dlg.text1.trim(), dlg.text2.trim(), dlg.check2);
if (ent[0] != null)
if (dlg.check1) { // apply to all ?
ICConfigurationDescription[] cfgs = page.getCfgsEditable();
@ -240,14 +241,14 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
s2 = old.getValue();
} else
s1 = s2 = old.getName();
boolean isWsp = (old.entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
dlg = new ExpDialog(usercomp.getShell(), false,
"Edit", s1, s2, cfg, //$NON-NLS-1$
id2name(old.setting.getCompatibleLanguageIds(), names_l),
id2name(old.setting.getCompatibleContentTypeIds(), names_t),
getKind(), names_ls, names_ts, null);
getKind(), names_ls, names_ts, null, isWsp);
if (dlg.open()) {
ent[0] = doEdit(dlg.text1.trim(), dlg.text2.trim());
ent[0] = doEdit(dlg.text1.trim(), dlg.text2.trim(), dlg.check2);
ICLanguageSettingEntry[] ls = old.setting.getEntries(getKind());
ICLanguageSettingEntry[] ls2 = new ICLanguageSettingEntry[ls.length];
for (int x=0; x<ls.length; x++)
@ -439,4 +440,9 @@ outer:
for (int i=0; i<lst.length; i++) s = s + lst[i] + '\n';
return s;
}
static public Image getWspImage(boolean isWsp) {
return isWsp ? AbstractExportTab.IMG_WS : AbstractExportTab.IMG_FS;
}
}

View file

@ -34,7 +34,7 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry;
public class ExpDialog extends AbstractPropertyDialog {
protected static final String TO_ALL = "Apply to all"; //$NON-NLS-1$
protected static final String TO_ALL = NewUIMessages.getResourceString("ExpDialog.5"); //$NON-NLS-1$
public String[] sel_types = null;
public String[] sel_langs = null;
@ -46,13 +46,14 @@ public class ExpDialog extends AbstractPropertyDialog {
private Button c_langs;
private Button c_types;
private Button c_all;
private Button c_wsp;
private Button b_vars;
private Button b_work;
private Button b_file;
private Button b_ok;
private Button b_ko;
private boolean newAction;
private boolean newAction, isWsp;
private int kind;
private ICConfigurationDescription cfgd;
private String[] names_l, names_t;
@ -63,7 +64,7 @@ public class ExpDialog extends AbstractPropertyDialog {
ICConfigurationDescription _cfgd,
String[] _langs, String[] _types,
int _kind, String[] _names_l, String[] _names_t,
java.util.List _existing) {
java.util.List _existing, boolean _isWsp) {
super(parent, title);
super.text1 = (_data1 == null) ? EMPTY_STR : _data1;
super.text2 = (_data2 == null) ? EMPTY_STR : _data2;
@ -75,14 +76,20 @@ public class ExpDialog extends AbstractPropertyDialog {
names_l = _names_l;
names_t = _names_t;
existing = _existing;
isWsp = _isWsp;
}
protected Control createDialogArea(Composite c) {
c.setLayout(new GridLayout(4, true));
GridData gd;
if (c.getLayoutData() instanceof GridData) {
gd = (GridData)c.getLayoutData();
gd.horizontalIndent = 10;
c.setLayoutData(gd);
}
c.setLayout(new GridLayout(4, true));
Label l1 = new Label(c, SWT.NONE);
l1.setText("Name:"); //$NON-NLS-1$
l1.setText(NewUIMessages.getResourceString("ExpDialog.6")); //$NON-NLS-1$
l1.setLayoutData(new GridData(GridData.BEGINNING));
txt1 = new Text(c, SWT.SINGLE | SWT.BORDER);
@ -95,7 +102,7 @@ public class ExpDialog extends AbstractPropertyDialog {
}});
Label l2 = new Label(c, SWT.NONE);
l2.setText("Value:"); //$NON-NLS-1$
l2.setText(NewUIMessages.getResourceString("ExpDialog.7")); //$NON-NLS-1$
l2.setLayoutData(new GridData(GridData.BEGINNING));
txt2 = new Text(c, SWT.SINGLE | SWT.BORDER);
@ -128,9 +135,24 @@ public class ExpDialog extends AbstractPropertyDialog {
b_work = setupButton(c, AbstractCPropertyTab.WORKSPACEBUTTON_NAME);
b_file = setupButton(c, AbstractCPropertyTab.FILESYSTEMBUTTON_NAME);
c_wsp = new Button(c, SWT.CHECK);
c_wsp.setText(NewUIMessages.getResourceString("ExpDialog.4")); //$NON-NLS-1$
gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = 3;
c_wsp.setLayoutData(gd);
c_wsp.setSelection(isWsp);
c_wsp.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
c_wsp.setImage(AbstractExportTab.getWspImage(c_wsp.getSelection()));
}});
c_wsp.setImage(AbstractExportTab.getWspImage(isWsp));
if (kind == ICSettingEntry.MACRO) {
b_work.setVisible(false);
b_file.setVisible(false);
c_wsp.setVisible(false);
}
Group dest = new Group(c, SWT.NONE);
@ -188,7 +210,7 @@ public class ExpDialog extends AbstractPropertyDialog {
c.getShell().setDefaultButton(b_ok);
c.pack();
Rectangle r = shell.getBounds();
r.width = 400;
r.width = 420;
shell.setBounds(r);
setButtons();
return c;
@ -205,10 +227,10 @@ public class ExpDialog extends AbstractPropertyDialog {
name = txt2.getText().trim();
if (name.length() == 0) {
enabled = false;
message.setText("Name cannot be empty !"); //$NON-NLS-1$
message.setText(NewUIMessages.getResourceString("ExpDialog.8")); //$NON-NLS-1$
}
if (enabled && existing != null && existing.contains(name)) {
message.setText("The same name already exists !"); //$NON-NLS-1$
message.setText(NewUIMessages.getResourceString("ExpDialog.9")); //$NON-NLS-1$
enabled = false;
}
b_ok.setEnabled(enabled);
@ -221,6 +243,7 @@ public class ExpDialog extends AbstractPropertyDialog {
super.text1 = txt1.getText();
super.text2 = txt2.getText();
super.check1 = c_all.getSelection();
super.check2 = c_wsp.getSelection();
sel_langs = (c_langs.getSelection()) ? null : langs.getSelection();
sel_types = (c_types.getSelection()) ? null : types.getSelection();
result = true;
@ -239,7 +262,8 @@ public class ExpDialog extends AbstractPropertyDialog {
if (s != null) {
s = strip_wsp(s);
txt2.setText(s);
text1 = s; // to be compared with final text
c_wsp.setSelection(true);
c_wsp.setImage(AbstractExportTab.getWspImage(c_wsp.getSelection()));
}
} else if (e.widget.equals(b_file)) {
if (kind == ICSettingEntry.INCLUDE_PATH ||
@ -247,7 +271,11 @@ public class ExpDialog extends AbstractPropertyDialog {
s = AbstractCPropertyTab.getFileSystemDirDialog(shell, txt2.getText());
else
s = AbstractCPropertyTab.getFileSystemFileDialog(shell, txt2.getText());
if (s != null) txt2.setText(s);
if (s != null) {
txt2.setText(s);
c_wsp.setSelection(false);
c_wsp.setImage(AbstractExportTab.getWspImage(c_wsp.getSelection()));
}
}
}

View file

@ -16,15 +16,13 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry;
public class ExpIncludeTab extends AbstractExportTab {
public ICLanguageSettingEntry doAdd(String s1, String s2) {
int flags = 0;
if (s1.equals(s2))
flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) {
int flags = isWsp ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0;
return new CIncludePathEntry(s2, flags);
}
public ICLanguageSettingEntry doEdit(String s1, String s2) {
return doAdd(s1, s2);
public ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp) {
return doAdd(s1, s2, isWsp);
}
public int getKind() { return ICSettingEntry.INCLUDE_PATH; }

View file

@ -24,14 +24,13 @@ public class ExpLibraryPathTab extends AbstractExportTab implements IPathEntrySt
updateData(getResDesc());
}
public ICLanguageSettingEntry doAdd(String s1, String s2) {
int flags = 0;
if (s1.equals(s2)) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) {
int flags = isWsp ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0;
return new CLibraryPathEntry(s2, flags);
}
public ICLanguageSettingEntry doEdit(String s1, String s2) {
return doAdd(s1, s2);
public ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp) {
return doAdd(s1, s2, isWsp);
}
public int getKind() { return ICSettingEntry.LIBRARY_PATH; }

View file

@ -24,14 +24,13 @@ public class ExpLibraryTab extends AbstractExportTab implements IPathEntryStoreL
updateData(getResDesc());
}
public ICLanguageSettingEntry doAdd(String s1, String s2) {
int flags = 0;
if (s1.equals(s2)) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) {
int flags = isWsp ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0;
return new CLibraryFileEntry(s2, flags);
}
public ICLanguageSettingEntry doEdit(String s1, String s2) {
return doAdd(s1, s2);
public ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp) {
return doAdd(s1, s2, isWsp);
}
public int getKind() { return ICSettingEntry.LIBRARY_FILE; }

View file

@ -16,12 +16,13 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry;
public class ExpSymbolTab extends AbstractExportTab {
public ICLanguageSettingEntry doAdd(String s1, String s2) {
// isWsp is ignored for symbols
public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) {
return new CMacroEntry(s1, s2, 0);
}
public ICLanguageSettingEntry doEdit(String s1, String s2) {
return doAdd(s1, s2);
public ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp) {
return doAdd(s1, s2, isWsp);
}
public int getKind() { return ICSettingEntry.MACRO; }

View file

@ -13,8 +13,10 @@ package org.eclipse.cdt.ui.newui;
//import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@ -38,7 +40,9 @@ public class IncludeDialog extends AbstractPropertyDialog {
private Button b_ok;
private Button b_ko;
private int mode;
private Button c_wsp;
private ICConfigurationDescription cfgd;
private boolean isWsp = false;
static final int NEW_FILE = 0;
static final int NEW_DIR = 1;
@ -55,7 +59,7 @@ public class IncludeDialog extends AbstractPropertyDialog {
sdata = _data;
cfgd = _cfgd;
if (flags == ICSettingEntry.VALUE_WORKSPACE_PATH)
text2 = sdata; // preserve "workspace" state
isWsp = true;
}
protected Control createDialogArea(Composite c) {
@ -98,6 +102,19 @@ public class IncludeDialog extends AbstractPropertyDialog {
b_work = setupButton(c, AbstractCPropertyTab.WORKSPACEBUTTON_NAME);
b_file = setupButton(c, AbstractCPropertyTab.FILESYSTEMBUTTON_NAME);
c_wsp = new Button(c, SWT.CHECK);
c_wsp.setText(NewUIMessages.getResourceString("ExpDialog.4")); //$NON-NLS-1$
gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = 5;
c_wsp.setLayoutData(gd);
c_wsp.setSelection(isWsp);
c_wsp.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
c_wsp.setImage(AbstractExportTab.getWspImage(c_wsp.getSelection()));
}});
c_wsp.setImage(AbstractExportTab.getWspImage(isWsp));
c.getShell().setDefaultButton(b_ok);
c.pack();
setButtons();
@ -113,6 +130,7 @@ public class IncludeDialog extends AbstractPropertyDialog {
if (e.widget.equals(b_ok)) {
text1 = text.getText();
check1 = b_add2all.getSelection();
check2 = c_wsp.getSelection();
result = true;
shell.dispose();
} else if (e.widget.equals(b_ko)) {
@ -125,14 +143,19 @@ public class IncludeDialog extends AbstractPropertyDialog {
if (s != null) {
s = strip_wsp(s);
text.setText(s);
text2 = s; // to be compared with final text
c_wsp.setSelection(true);
c_wsp.setImage(AbstractExportTab.getWspImage(c_wsp.getSelection()));
}
} else if (e.widget.equals(b_file)) {
if ((mode & DIR_MASK)== DIR_MASK)
s = AbstractCPropertyTab.getFileSystemDirDialog(shell, text.getText());
else
s = AbstractCPropertyTab.getFileSystemFileDialog(shell, text.getText());
if (s != null) text.setText(s);
if (s != null) {
text.setText(s);
c_wsp.setSelection(false);
c_wsp.setImage(AbstractExportTab.getWspImage(c_wsp.getSelection()));
}
} else if (e.widget.equals(b_vars)) {
s = AbstractCPropertyTab.getVariableDialog(shell, cfgd);
if (s != null) text.insert(s);

View file

@ -34,7 +34,7 @@ public class IncludeTab extends AbstractLangsListTab {
if (dlg.open() && dlg.text1.trim().length() > 0 ) {
toAll = dlg.check1;
int flags = 0;
if (dlg.text1.equals(dlg.text2)) { // see IncludeDialog why.
if (dlg.check2) { // isWsp
flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
}
return new CIncludePathEntry(dlg.text1, flags);
@ -50,7 +50,7 @@ public class IncludeTab extends AbstractLangsListTab {
(ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH));
if (dlg.open()) {
int flags = 0;
if (dlg.text1.equals(dlg.text2)) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
return new CIncludePathEntry(dlg.text1, flags);
} else
return null;

View file

@ -48,7 +48,7 @@ public class LibraryPathTab extends AbstractLangsListTab implements IPathEntrySt
EMPTY_STR, getResDesc().getConfiguration(), 0);
if (dlg.open() && dlg.text1.trim().length() > 0 ) {
int flags = 0;
if (dlg.text1.equals(dlg.text2)) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
return new CLibraryPathEntry(dlg.text1, flags);
}
return null;
@ -62,7 +62,7 @@ public class LibraryPathTab extends AbstractLangsListTab implements IPathEntrySt
(ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH));
if (dlg.open() && dlg.text1.trim().length() > 0 ) {
int flags = 0;
if (dlg.text1.equals(dlg.text2)) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
return new CLibraryPathEntry(dlg.text1, flags);
}
return null;

View file

@ -48,7 +48,7 @@ public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreL
EMPTY_STR, getResDesc().getConfiguration(), 0);
if (dlg.open() && dlg.text1.trim().length() > 0 ) {
int flags = 0;
if (dlg.text1.equals(dlg.text2)) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
return new CLibraryFileEntry(dlg.text1, flags);
}
return null;
@ -62,7 +62,7 @@ public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreL
(ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH));
if (dlg.open() && dlg.text1.trim().length() > 0 ) {
int flags = 0;
if (dlg.text1.equals(dlg.text2)) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
return new CLibraryFileEntry(dlg.text1, flags);
}
return null;

View file

@ -479,6 +479,12 @@ ExpDialog.0=To all configurations
ExpDialog.1=Save to:
ExpDialog.2=Languages
ExpDialog.3=Content types
ExpDialog.4=Is workspace path
ExpDialog.5=Apply to all
ExpDialog.6=Name:
ExpDialog.7=Value:
ExpDialog.8=Name cannot be empty \!
ExpDialog.9=The same name already exists \!
ConfigMultiSelectionDialog.0=Select configurations
ConfigMultiSelectionDialog.1=At least 2 configurations should be selected
SymbolDialog.0=Name: