Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ${ProjName} for workspace includes referencing folders from the project to better support project renames #402 #405

Merged
merged 4 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,28 +496,43 @@ public static String getVariableDialog(Shell shell, ICConfigurationDescription c
}

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs @since - but we can resolve that later in the review process

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which version number is to be used?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The minor version in MANIFEST.MF needs to be increased and use that number. The auto-fix in Eclipse should do that if you have API baseline setup. If you don't have it setup I think it will be 8.1

I can handle that as part of the merging if it isn't straightforward for you.

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;
Expand All @@ -528,7 +543,7 @@ private static String getWorkspaceDialog(Shell shell, String text, boolean dir,
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);
Expand Down Expand Up @@ -576,8 +591,14 @@ public IStatus validate(Object[] selection) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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;
Expand Down Expand Up @@ -205,10 +206,11 @@ public void buttonPressed(SelectionEvent e) {
} 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);
Expand Down