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

bug 341362: C/C++ General > Paths & Symbols > Include Files > Add... > File system... file filter is broken

This commit is contained in:
Andrew Gvozdev 2011-03-30 18:22:05 +00:00
parent f9be56f5d4
commit be1a78cd90
5 changed files with 77 additions and 23 deletions

View file

@ -414,7 +414,17 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
public static String getFileSystemFileDialog(Shell shell, String text) { public static String getFileSystemFileDialog(Shell shell, String text) {
FileDialog dialog = new FileDialog(shell); FileDialog dialog = new FileDialog(shell);
if(text != null && text.trim().length() != 0) dialog.setFilterPath(text); if(text != null && text.trim().length() != 0) dialog.setFilterPath(text);
dialog.setFilterExtensions(new String[] {"*.a;*.so;*.dll;*.lib"}); //$NON-NLS-1$ dialog.setText(FILESYSTEM_FILE_DIALOG_TITLE);
return dialog.open();
}
/**
* @since 5.3
*/
public static String getFileSystemFileDialog(Shell shell, String text, String[] filter) {
FileDialog dialog = new FileDialog(shell);
if(text != null && text.trim().length() != 0) dialog.setFilterPath(text);
dialog.setFilterExtensions(filter);
dialog.setText(FILESYSTEM_FILE_DIALOG_TITLE); dialog.setText(FILESYSTEM_FILE_DIALOG_TITLE);
return dialog.open(); return dialog.open();
} }

View file

@ -282,10 +282,15 @@ public class ExpDialog extends AbstractPropertyDialog {
} }
} else if (e.widget.equals(b_file)) { } else if (e.widget.equals(b_file)) {
if (kind == ICSettingEntry.INCLUDE_PATH || if (kind == ICSettingEntry.INCLUDE_PATH ||
kind == ICSettingEntry.LIBRARY_PATH) kind == ICSettingEntry.LIBRARY_PATH) {
s = AbstractCPropertyTab.getFileSystemDirDialog(shell, txt2.getText()); s = AbstractCPropertyTab.getFileSystemDirDialog(shell, txt2.getText());
else } else if (kind==ICSettingEntry.INCLUDE_FILE) {
s = AbstractCPropertyTab.getFileSystemFileDialog(shell, txt2.getText(), IncludeDialog.FILTER_INCLUDE_FILE);
} else if (kind==ICSettingEntry.LIBRARY_FILE) {
s = AbstractCPropertyTab.getFileSystemFileDialog(shell, txt2.getText(), IncludeDialog.FILTER_LIBRARY_FILE);
} else {
s = AbstractCPropertyTab.getFileSystemFileDialog(shell, txt2.getText()); s = AbstractCPropertyTab.getFileSystemFileDialog(shell, txt2.getText());
}
if (s != null) { if (s != null) {
txt2.setText(s); txt2.setText(s);
c_wsp.setSelection(false); c_wsp.setSelection(false);

View file

@ -34,9 +34,16 @@ import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.internal.ui.newui.Messages; import org.eclipse.cdt.internal.ui.newui.Messages;
/** /**
* A combined dialog which allows selecting file or folder from workspace or filesystem
* and some more features. The dialog is used on "Paths and Symbols" properties page.
* Note that currently it is used not only for include files/folders but for library
* files/folders as well.
*
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
*/ */
public class IncludeDialog extends AbstractPropertyDialog { public class IncludeDialog extends AbstractPropertyDialog {
static final String[] FILTER_INCLUDE_FILE = new String[] {"*.h;*.hpp", "*"}; //$NON-NLS-1$ //$NON-NLS-2$
static final String[] FILTER_LIBRARY_FILE = new String[] {"*.a;*.so;*.dll;*.lib", "*"}; //$NON-NLS-1$ //$NON-NLS-2$
public String sdata; public String sdata;
private Button b_add2confs; private Button b_add2confs;
private Button b_add2langs; private Button b_add2langs;
@ -50,6 +57,7 @@ public class IncludeDialog extends AbstractPropertyDialog {
private Button c_wsp; private Button c_wsp;
private ICConfigurationDescription cfgd; private ICConfigurationDescription cfgd;
private boolean isWsp = false; private boolean isWsp = false;
private int kind = 0;
static final int NEW_FILE = 0; static final int NEW_FILE = 0;
static final int NEW_DIR = 1; static final int NEW_DIR = 1;
@ -59,14 +67,24 @@ public class IncludeDialog extends AbstractPropertyDialog {
static final int DIR_MASK = 1; static final int DIR_MASK = 1;
static final int OLD_MASK = 2; static final int OLD_MASK = 2;
public IncludeDialog(Shell parent, int _mode, /**
String title, String _data, ICConfigurationDescription _cfgd, int flags) { * @since 5.3
*/
public IncludeDialog(Shell parent, int mode, String title, String data,
ICConfigurationDescription cfgd, int flags, int kind) {
super(parent, title); super(parent, title);
mode = _mode; this.mode = mode;
sdata = _data; this.sdata = data;
cfgd = _cfgd; this.cfgd = cfgd;
if (flags == ICSettingEntry.VALUE_WORKSPACE_PATH) this.isWsp = (flags == ICSettingEntry.VALUE_WORKSPACE_PATH);
isWsp = true; this.kind = kind;
}
public IncludeDialog(Shell parent, int mode, String title, String data,
ICConfigurationDescription cfgd, int flags) {
this(parent, mode, title, data, cfgd, flags, 0);
} }
@Override @Override
@ -193,10 +211,16 @@ public class IncludeDialog extends AbstractPropertyDialog {
c_wsp.setImage(getWspImage(c_wsp.getSelection())); c_wsp.setImage(getWspImage(c_wsp.getSelection()));
} }
} else if (e.widget.equals(b_file)) { } else if (e.widget.equals(b_file)) {
if ((mode & DIR_MASK)== DIR_MASK) if ((mode & DIR_MASK)== DIR_MASK) {
s = AbstractCPropertyTab.getFileSystemDirDialog(shell, text.getText()); s = AbstractCPropertyTab.getFileSystemDirDialog(shell, text.getText());
} else {
if (kind==ICSettingEntry.INCLUDE_FILE)
s = AbstractCPropertyTab.getFileSystemFileDialog(shell, text.getText(), FILTER_INCLUDE_FILE);
else if (kind==ICSettingEntry.LIBRARY_FILE)
s = AbstractCPropertyTab.getFileSystemFileDialog(shell, text.getText(), FILTER_LIBRARY_FILE);
else else
s = AbstractCPropertyTab.getFileSystemFileDialog(shell, text.getText()); s = AbstractCPropertyTab.getFileSystemFileDialog(shell, text.getText());
}
if (s != null) { if (s != null) {
text.setText(s); text.setText(s);
c_wsp.setSelection(false); c_wsp.setSelection(false);

View file

@ -53,8 +53,14 @@ public class IncludeFileTab extends AbstractLangsListTab {
@Override @Override
public ICLanguageSettingEntry doAdd() { public ICLanguageSettingEntry doAdd() {
IncludeDialog dlg = new IncludeDialog(usercomp.getShell(), IncludeDialog.NEW_FILE, Messages.IncludeFileTab_1, IncludeDialog dlg = new IncludeDialog(
EMPTY_STR, getResDesc().getConfiguration(), 0); usercomp.getShell(),
IncludeDialog.NEW_FILE,
Messages.IncludeFileTab_1,
EMPTY_STR,
getResDesc().getConfiguration(),
0,
ICSettingEntry.INCLUDE_FILE);
if (dlg.open() && dlg.text1.trim().length() > 0) { if (dlg.open() && dlg.text1.trim().length() > 0) {
toAllCfgs = dlg.check1; toAllCfgs = dlg.check1;
toAllLang = dlg.check3; toAllLang = dlg.check3;
@ -69,10 +75,14 @@ public class IncludeFileTab extends AbstractLangsListTab {
@Override @Override
public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) { public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
IncludeDialog dlg = new IncludeDialog(usercomp.getShell(), IncludeDialog.OLD_FILE, IncludeDialog dlg = new IncludeDialog(
usercomp.getShell(),
IncludeDialog.OLD_FILE,
Messages.IncludeFileTab_2, Messages.IncludeFileTab_2,
ent.getValue(), getResDesc().getConfiguration(), ent.getValue(),
(ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH)); getResDesc().getConfiguration(),
ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH,
ICSettingEntry.INCLUDE_FILE);
if (dlg.open()) { if (dlg.open()) {
int flags = 0; int flags = 0;
if (dlg.check2) if (dlg.check2)

View file

@ -49,7 +49,10 @@ public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreL
IncludeDialog dlg = new IncludeDialog( IncludeDialog dlg = new IncludeDialog(
usercomp.getShell(), IncludeDialog.NEW_FILE, usercomp.getShell(), IncludeDialog.NEW_FILE,
Messages.LibraryTab_1, Messages.LibraryTab_1,
EMPTY_STR, getResDesc().getConfiguration(), 0); EMPTY_STR,
getResDesc().getConfiguration(),
0,
ICSettingEntry.LIBRARY_FILE);
if (dlg.open() && dlg.text1.trim().length() > 0 ) { if (dlg.open() && dlg.text1.trim().length() > 0 ) {
toAllCfgs = dlg.check1; toAllCfgs = dlg.check1;
toAllLang = dlg.check3; toAllLang = dlg.check3;
@ -65,8 +68,10 @@ public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreL
IncludeDialog dlg = new IncludeDialog( IncludeDialog dlg = new IncludeDialog(
usercomp.getShell(), IncludeDialog.OLD_FILE, usercomp.getShell(), IncludeDialog.OLD_FILE,
Messages.LibraryTab_2, Messages.LibraryTab_2,
ent.getValue(), getResDesc().getConfiguration(), ent.getValue(),
(ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH)); getResDesc().getConfiguration(),
ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH,
ICSettingEntry.LIBRARY_FILE);
if (dlg.open() && dlg.text1.trim().length() > 0 ) { if (dlg.open() && dlg.text1.trim().length() > 0 ) {
int flags = 0; int flags = 0;
if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH; if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;