Author: fbricon
Date: 2011-11-08 13:29:20 -0500 (Tue, 08 Nov 2011)
New Revision: 36223
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/dialog/MaterializeLibraryDialog.java
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/handlers/MaterializeLibraryHandler.java
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/buildpath/MaterializeLibraryJob.java
Log:
JBIDE-9879 : add an option to keep source attachments (or not)
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/buildpath/MaterializeLibraryJob.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/buildpath/MaterializeLibraryJob.java 2011-11-08
18:27:51 UTC (rev 36222)
+++
trunk/common/plugins/org.jboss.tools.common.jdt/src/org/jboss/tools/common/jdt/core/buildpath/MaterializeLibraryJob.java 2011-11-08
18:29:20 UTC (rev 36223)
@@ -43,11 +43,13 @@
private final IJavaProject javaProject;
private final Map<IPath, String> jars;
private final IClasspathContainer containerToRemove;
+ private final boolean keepSourceAttachments;
public MaterializeLibraryJob(IJavaProject javaProject,
IClasspathContainer containerToMaterialize,
Map<IPath, String> jars,
- IFolder libFolder) {
+ IFolder libFolder,
+ boolean keepSourceAttachments) {
super(Messages.Materialize_Library);
if (javaProject == null || javaProject.getProject() == null) {
throw new IllegalArgumentException("Project must not be null");
@@ -62,6 +64,7 @@
this.libFolder = libFolder;
this.containerToRemove = containerToMaterialize;
this.jars = jars;
+ this.keepSourceAttachments = keepSourceAttachments;
}
@Override
@@ -167,8 +170,8 @@
IPath destinationFilePath) throws CoreException {
try {
return JavaCore.newLibraryEntry(destinationFilePath,
- entry.getSourceAttachmentPath(),
- entry.getSourceAttachmentRootPath(),
+ (keepSourceAttachments)?entry.getSourceAttachmentPath():null,
+ (keepSourceAttachments)?entry.getSourceAttachmentRootPath():null,
entry.getAccessRules(), entry.getExtraAttributes(),
entry.isExported());
} catch (Exception e) {
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/dialog/MaterializeLibraryDialog.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/dialog/MaterializeLibraryDialog.java 2011-11-08
18:27:51 UTC (rev 36222)
+++
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/dialog/MaterializeLibraryDialog.java 2011-11-08
18:29:20 UTC (rev 36223)
@@ -80,6 +80,11 @@
private CheckboxTableViewer classpathEntriesViewer;
+ private Button keepSourceBtn;
+
+ private boolean keepSources;
+
+
public MaterializeLibraryDialog(Shell shell, IProject project, IClasspathContainer
containerToMaterialize, String defaultLib) {
super(shell);
setShellStyle(super.getShellStyle() | SWT.RESIZE | SWT.MODELESS);
@@ -234,10 +239,21 @@
addSelectionButton(container, "Select All", true);
addSelectionButton(container, "Deselect All", false);
+ keepSourceBtn = addCheckButton(container, "Keep source attachments",
keepSources);
+ keepSourceBtn.setToolTipText("Source attachment paths may contain absolute
paths");
addTableListeners();
}
+ private Button addCheckButton(Composite container, String label, boolean selected) {
+ Button checkBtn = new Button(container, SWT.CHECK);
+ checkBtn.setText(label);
+ checkBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER,
+ true, false, 2, 1));
+ checkBtn.setSelection(selected);
+ return checkBtn;
+ }
+
private void addTableListeners() {
addCellEditors();
}
@@ -247,18 +263,7 @@
"EMPTY", SOURCE_PROPERTY, FILENAME_PROPERTY });
TextCellEditor ce = new TextCellEditor(classpathEntriesViewer.getTable());
-// ce.setValidator(new ICellEditorValidator() {
-// @Override
-// public String isValid(Object arg0) {
-// String name = arg0.toString();
-// return (checkValidName(name))?null:name;
-// }
-// });
-
- CellEditor[] editors = new CellEditor[] {
- null,
- new TextCellEditor(classpathEntriesViewer.getTable()),
- ce };
+ CellEditor[] editors = new CellEditor[] {null, ce, ce };
classpathEntriesViewer.setCellEditors(editors);
classpathEntriesViewer.setCellModifier(new FileNameCellModifier());
@@ -272,6 +277,10 @@
return libFolder;
}
+ public boolean isKeepSources() {
+ return keepSources;
+ }
+
private static IFolder getLibFolderFromText(String text) {
String portablePath = text.replaceAll("\\\\", "/");
IPath path = new Path(portablePath);
@@ -284,6 +293,7 @@
return;
}
libFolder = getLibFolderFromText(libfolderText.getText());
+ keepSources = keepSourceBtn.getSelection();
super.okPressed();
}
@@ -445,4 +455,5 @@
(name.endsWith(".jar") || name.endsWith(".zip"));
}
+
}
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/handlers/MaterializeLibraryHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/handlers/MaterializeLibraryHandler.java 2011-11-08
18:27:51 UTC (rev 36222)
+++
trunk/common/plugins/org.jboss.tools.common.jdt.ui/src/org/jboss/tools/common/jdt/ui/buildpath/handlers/MaterializeLibraryHandler.java 2011-11-08
18:29:20 UTC (rev 36223)
@@ -86,7 +86,8 @@
Job job = new MaterializeLibraryJob(javaProject,
containerToMaterialize,
jarsToMaterialize,
- libFolder);
+ libFolder,
+ dialog.isKeepSources());
job.setRule(getRule(project));
job.addJobChangeListener(new IJobChangeListener() {