mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 00:36:16 +02:00
bug 341362: C/C++ General > Paths & Symbols > Include Files > Add... > File system... file filter is broken
This commit is contained in:
parent
f9be56f5d4
commit
be1a78cd90
5 changed files with 77 additions and 23 deletions
|
@ -414,11 +414,21 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
|
|||
public static String getFileSystemFileDialog(Shell shell, String text) {
|
||||
FileDialog dialog = new FileDialog(shell);
|
||||
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);
|
||||
return dialog.open();
|
||||
}
|
||||
|
||||
public static String getVariableDialog(Shell shell, ICConfigurationDescription cfgd) {
|
||||
|
||||
ICdtVariableManager vm = CCorePlugin.getDefault().getCdtVariableManager();
|
||||
|
|
|
@ -282,10 +282,15 @@ public class ExpDialog extends AbstractPropertyDialog {
|
|||
}
|
||||
} else if (e.widget.equals(b_file)) {
|
||||
if (kind == ICSettingEntry.INCLUDE_PATH ||
|
||||
kind == ICSettingEntry.LIBRARY_PATH)
|
||||
kind == ICSettingEntry.LIBRARY_PATH) {
|
||||
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());
|
||||
}
|
||||
if (s != null) {
|
||||
txt2.setText(s);
|
||||
c_wsp.setSelection(false);
|
||||
|
|
|
@ -34,9 +34,16 @@ import org.eclipse.cdt.ui.CDTSharedImages;
|
|||
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.
|
||||
*/
|
||||
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;
|
||||
private Button b_add2confs;
|
||||
private Button b_add2langs;
|
||||
|
@ -50,6 +57,7 @@ public class IncludeDialog extends AbstractPropertyDialog {
|
|||
private Button c_wsp;
|
||||
private ICConfigurationDescription cfgd;
|
||||
private boolean isWsp = false;
|
||||
private int kind = 0;
|
||||
|
||||
static final int NEW_FILE = 0;
|
||||
static final int NEW_DIR = 1;
|
||||
|
@ -59,14 +67,24 @@ public class IncludeDialog extends AbstractPropertyDialog {
|
|||
static final int DIR_MASK = 1;
|
||||
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);
|
||||
mode = _mode;
|
||||
sdata = _data;
|
||||
cfgd = _cfgd;
|
||||
if (flags == ICSettingEntry.VALUE_WORKSPACE_PATH)
|
||||
isWsp = true;
|
||||
this.mode = mode;
|
||||
this.sdata = data;
|
||||
this.cfgd = cfgd;
|
||||
this.isWsp = (flags == ICSettingEntry.VALUE_WORKSPACE_PATH);
|
||||
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
|
||||
|
@ -193,10 +211,16 @@ public class IncludeDialog extends AbstractPropertyDialog {
|
|||
c_wsp.setImage(getWspImage(c_wsp.getSelection()));
|
||||
}
|
||||
} 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());
|
||||
else
|
||||
s = AbstractCPropertyTab.getFileSystemFileDialog(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
|
||||
s = AbstractCPropertyTab.getFileSystemFileDialog(shell, text.getText());
|
||||
}
|
||||
if (s != null) {
|
||||
text.setText(s);
|
||||
c_wsp.setSelection(false);
|
||||
|
|
|
@ -53,8 +53,14 @@ public class IncludeFileTab extends AbstractLangsListTab {
|
|||
|
||||
@Override
|
||||
public ICLanguageSettingEntry doAdd() {
|
||||
IncludeDialog dlg = new IncludeDialog(usercomp.getShell(), IncludeDialog.NEW_FILE, Messages.IncludeFileTab_1,
|
||||
EMPTY_STR, getResDesc().getConfiguration(), 0);
|
||||
IncludeDialog dlg = new IncludeDialog(
|
||||
usercomp.getShell(),
|
||||
IncludeDialog.NEW_FILE,
|
||||
Messages.IncludeFileTab_1,
|
||||
EMPTY_STR,
|
||||
getResDesc().getConfiguration(),
|
||||
0,
|
||||
ICSettingEntry.INCLUDE_FILE);
|
||||
if (dlg.open() && dlg.text1.trim().length() > 0) {
|
||||
toAllCfgs = dlg.check1;
|
||||
toAllLang = dlg.check3;
|
||||
|
@ -69,10 +75,14 @@ public class IncludeFileTab extends AbstractLangsListTab {
|
|||
|
||||
@Override
|
||||
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,
|
||||
ent.getValue(), getResDesc().getConfiguration(),
|
||||
(ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH));
|
||||
ent.getValue(),
|
||||
getResDesc().getConfiguration(),
|
||||
ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH,
|
||||
ICSettingEntry.INCLUDE_FILE);
|
||||
if (dlg.open()) {
|
||||
int flags = 0;
|
||||
if (dlg.check2)
|
||||
|
|
|
@ -48,8 +48,11 @@ public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreL
|
|||
public ICLanguageSettingEntry doAdd() {
|
||||
IncludeDialog dlg = new IncludeDialog(
|
||||
usercomp.getShell(), IncludeDialog.NEW_FILE,
|
||||
Messages.LibraryTab_1,
|
||||
EMPTY_STR, getResDesc().getConfiguration(), 0);
|
||||
Messages.LibraryTab_1,
|
||||
EMPTY_STR,
|
||||
getResDesc().getConfiguration(),
|
||||
0,
|
||||
ICSettingEntry.LIBRARY_FILE);
|
||||
if (dlg.open() && dlg.text1.trim().length() > 0 ) {
|
||||
toAllCfgs = dlg.check1;
|
||||
toAllLang = dlg.check3;
|
||||
|
@ -64,9 +67,11 @@ public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreL
|
|||
public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
|
||||
IncludeDialog dlg = new IncludeDialog(
|
||||
usercomp.getShell(), IncludeDialog.OLD_FILE,
|
||||
Messages.LibraryTab_2,
|
||||
ent.getValue(), getResDesc().getConfiguration(),
|
||||
(ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH));
|
||||
Messages.LibraryTab_2,
|
||||
ent.getValue(),
|
||||
getResDesc().getConfiguration(),
|
||||
ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH,
|
||||
ICSettingEntry.LIBRARY_FILE);
|
||||
if (dlg.open() && dlg.text1.trim().length() > 0 ) {
|
||||
int flags = 0;
|
||||
if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
|
||||
|
|
Loading…
Add table
Reference in a new issue