mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Use ${ProjName} for workspace includes when possible
Use ${ProjName} for workspace includes referencing folders from the project to better support project renames Inspired by the implementation for selecting includes in build settings located in FileListControl.java Fixes #402 --------- Co-authored-by: jantje <eclipse@baeyens.it> Co-authored-by: Jonah Graham <jonah@kichwacoders.com>
This commit is contained in:
parent
9dcaf509fa
commit
501e7db9a1
3 changed files with 32 additions and 9 deletions
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.ui; singleton:=true
|
||||
Bundle-Version: 8.0.200.qualifier
|
||||
Bundle-Version: 8.1.0.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
|
|
|
@ -496,28 +496,43 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
|
|||
}
|
||||
|
||||
public static String getWorkspaceDirDialog(Shell shell, String text) {
|
||||
return getWorkspaceDialog(shell, text, true, null);
|
||||
return getWorkspaceDialog(shell, text, true, true, null);
|
||||
}
|
||||
|
||||
public static String getWorkspaceFileDialog(Shell shell, String text) {
|
||||
return getWorkspaceDialog(shell, text, false, null);
|
||||
return getWorkspaceDialog(shell, text, false, true, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 8.1
|
||||
*/
|
||||
public static String getWorkspaceDirDialog(Shell shell, String text, IProject prj) {
|
||||
return getWorkspaceDialog(shell, text, true, true, prj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 8.1
|
||||
*/
|
||||
public static String getWorkspaceFileDialog(Shell shell, String text, IProject prj) {
|
||||
return getWorkspaceDialog(shell, text, false, true, prj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.4
|
||||
*/
|
||||
public static String getProjectDirDialog(Shell shell, String text, IProject prj) {
|
||||
return getWorkspaceDialog(shell, text, true, prj);
|
||||
return getWorkspaceDialog(shell, text, true, false, prj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.4
|
||||
*/
|
||||
public static String getProjectFileDialog(Shell shell, String text, IProject prj) {
|
||||
return getWorkspaceDialog(shell, text, false, prj);
|
||||
return getWorkspaceDialog(shell, text, false, false, prj);
|
||||
}
|
||||
|
||||
private static String getWorkspaceDialog(Shell shell, String text, boolean dir, IProject prj) {
|
||||
private static String getWorkspaceDialog(Shell shell, String text, boolean dir, boolean selectFromRoot,
|
||||
IProject prj) {
|
||||
String currentPathText;
|
||||
IPath path;
|
||||
currentPathText = text;
|
||||
|
@ -528,7 +543,7 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
|
|||
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(),
|
||||
new WorkbenchContentProvider());
|
||||
|
||||
if (prj == null)
|
||||
if (prj == null || selectFromRoot)
|
||||
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
|
||||
else
|
||||
dialog.setInput(prj);
|
||||
|
@ -576,8 +591,14 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
|
|||
if (dialog.open() == Window.OK) {
|
||||
IResource resource = (IResource) dialog.getFirstResult();
|
||||
if (resource != null) {
|
||||
if (resource.getProject().equals(prj)) {
|
||||
String projectPath = new Path("${ProjName}").append(resource.getProjectRelativePath()) //$NON-NLS-1$
|
||||
.makeAbsolute().toString();
|
||||
return "${workspace_loc:" + projectPath + "}"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
StringBuilder buf = new StringBuilder();
|
||||
return buf.append("${").append("workspace_loc:").append(resource.getFullPath()).append("}").toString(); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
|
||||
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.settings.model.ICMultiConfigDescription;
|
|||
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||
import org.eclipse.cdt.internal.ui.newui.Messages;
|
||||
import org.eclipse.cdt.ui.CDTSharedImages;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
|
@ -205,10 +206,11 @@ public class IncludeDialog extends AbstractPropertyDialog {
|
|||
} else if (e.widget.equals(b_ko)) {
|
||||
shell.dispose();
|
||||
} else if (e.widget.equals(b_work)) {
|
||||
IProject project = cfgd.getProjectDescription().getProject();
|
||||
if ((mode & DIR_MASK) == DIR_MASK)
|
||||
s = AbstractCPropertyTab.getWorkspaceDirDialog(shell, text.getText());
|
||||
s = AbstractCPropertyTab.getWorkspaceDirDialog(shell, text.getText(), project);
|
||||
else
|
||||
s = AbstractCPropertyTab.getWorkspaceFileDialog(shell, text.getText());
|
||||
s = AbstractCPropertyTab.getWorkspaceFileDialog(shell, text.getText(), project);
|
||||
if (s != null) {
|
||||
s = strip_wsp(s);
|
||||
text.setText(s);
|
||||
|
|
Loading…
Add table
Reference in a new issue