Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrganor2009-07-01 05:03:39 -0400
committerrganor2009-07-01 05:03:39 -0400
commite6f2c829f9fdb799232d8f61613927436b80c4ae (patch)
tree8839b858da1ba2d2219167cd2ee3dc29ada57dd4
parent02e3d9d5a9c4237fa3dfabb04bf40209ffdf83b3 (diff)
downloadorg.eclipse.pdt-e6f2c829f9fdb799232d8f61613927436b80c4ae.tar.gz
org.eclipse.pdt-e6f2c829f9fdb799232d8f61613927436b80c4ae.tar.xz
org.eclipse.pdt-e6f2c829f9fdb799232d8f61613927436b80c4ae.zip
Bug 281772 - Library remains in build path after removed from include path
contributed by Vadim
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPIncludePathSourcePage.java18
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPIncludePathsBlock.java9
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPLibrariesWorkbookPage.java310
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPSourceContainerWorkbookPage.java18
4 files changed, 145 insertions, 210 deletions
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPIncludePathSourcePage.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPIncludePathSourcePage.java
index d69b10ad7..5b64b98e6 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPIncludePathSourcePage.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPIncludePathSourcePage.java
@@ -51,18 +51,16 @@ public class PHPIncludePathSourcePage extends PHPSourceContainerWorkbookPage {
private List<BPListElement> fAddedElements = new ArrayList<BPListElement>(1);
- private List<IChangeListener> addedElementListeners = new ArrayList<IChangeListener>(1);
-
private boolean addToBuildPath = false;
public boolean shouldAddToBuildPath() {
return addToBuildPath;
}
-
+
public List<BPListElement> getAddedElements() {
return fAddedElements;
}
-
+
public PHPIncludePathSourcePage(ListDialogField buildpathList) {
super(buildpathList);
}
@@ -235,16 +233,4 @@ public class PHPIncludePathSourcePage extends PHPSourceContainerWorkbookPage {
fFoldersList.postSetSelection(new StructuredSelection(insertedElements));
}
}
-
- public void registerAddedElementListener(IChangeListener listener) {
- if (listener != null) {
- addedElementListeners.add(listener);
- }
- }
-
- public void unregisterAddedElementListener(IChangeListener listener) {
- if (listener != null) {
- addedElementListeners.remove(listener);
- }
- }
}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPIncludePathsBlock.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPIncludePathsBlock.java
index 5dd6e2063..7718a83e0 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPIncludePathsBlock.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPIncludePathsBlock.java
@@ -41,7 +41,6 @@ import org.eclipse.php.internal.core.buildpath.BuildPathUtils;
import org.eclipse.php.internal.core.includepath.IIncludepathListener;
import org.eclipse.php.internal.core.includepath.IncludePath;
import org.eclipse.php.internal.core.includepath.IncludePathManager;
-import org.eclipse.php.internal.core.language.LanguageModelInitializer;
import org.eclipse.php.internal.ui.PHPUIMessages;
import org.eclipse.php.internal.ui.PHPUiPlugin;
import org.eclipse.swt.SWT;
@@ -81,7 +80,7 @@ public class PHPIncludePathsBlock extends AbstractIncludepathsBlock {
@Override
public void dispose() {
if (fSourceContainerPage instanceof PHPIncludePathSourcePage) {
- PHPIncludePathSourcePage page = (PHPIncludePathSourcePage) fSourceContainerPage;
+ PHPSourceContainerWorkbookPage page = (PHPSourceContainerWorkbookPage) fSourceContainerPage;
page.unregisterAddedElementListener(this);
}
IncludePathManager.getInstance().unregisterIncludepathListener(this);
@@ -154,7 +153,7 @@ public class PHPIncludePathsBlock extends AbstractIncludepathsBlock {
item.setImage(DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_PACKFRAG_ROOT));
fSourceContainerPage = new PHPIncludePathSourcePage(fBuildPathList);
- ((PHPIncludePathSourcePage)fSourceContainerPage).registerAddedElementListener((IChangeListener)composite);
+ ((PHPSourceContainerWorkbookPage)fSourceContainerPage).registerAddedElementListener((IChangeListener)composite);
item.setData(fSourceContainerPage);
item.setControl(fSourceContainerPage.getControl(folder));
@@ -214,7 +213,7 @@ public class PHPIncludePathsBlock extends AbstractIncludepathsBlock {
// disable checking for nested folders errors
}
public void configureScriptProject(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
- adaptBuildPath();
+ updateBuildPath();
flush(fBuildPathList.getElements(), getScriptProject(), monitor);
initializeTimeStamps();
updateUI();
@@ -227,7 +226,7 @@ public class PHPIncludePathsBlock extends AbstractIncludepathsBlock {
* THe user is prompted and asked if he wants to add the relevant sources to the build path as well
* see bug#255930
*/
- private void adaptBuildPath() {
+ private void updateBuildPath() {
PHPIncludePathSourcePage includePathSourcePage = (PHPIncludePathSourcePage) fSourceContainerPage;
boolean shouldAddToBuildPath = includePathSourcePage.shouldAddToBuildPath();
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPLibrariesWorkbookPage.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPLibrariesWorkbookPage.java
index e0ff0d2d3..0a3b95223 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPLibrariesWorkbookPage.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPLibrariesWorkbookPage.java
@@ -20,10 +20,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.dltk.compiler.util.Util;
-import org.eclipse.dltk.core.IAccessRule;
-import org.eclipse.dltk.core.IBuildpathEntry;
-import org.eclipse.dltk.core.IProjectFragment;
-import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.*;
import org.eclipse.dltk.core.environment.EnvironmentManager;
import org.eclipse.dltk.core.environment.IEnvironment;
import org.eclipse.dltk.internal.corext.util.Messages;
@@ -38,12 +35,16 @@ import org.eclipse.dltk.ui.util.PixelConverter;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
+import org.eclipse.php.internal.core.PHPCorePlugin;
+import org.eclipse.php.internal.core.buildpath.BuildPathUtils;
+import org.eclipse.php.internal.ui.PHPUIMessages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.IChangeListener;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
@@ -109,15 +110,12 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
IDX_ADD = 0;
}
LibrariesAdapter adapter = new LibrariesAdapter();
- fLibrariesList = new TreeListDialogField(adapter, buttonLabels,
- new PHPIPListLabelProvider());
+ fLibrariesList = new TreeListDialogField(adapter, buttonLabels, new PHPIPListLabelProvider());
fLibrariesList.setDialogFieldListener(adapter);
if (this.fWithZip) {
- fLibrariesList
- .setLabelText(NewWizardMessages.LibrariesWorkbookPage_libraries_label);
+ fLibrariesList.setLabelText(NewWizardMessages.LibrariesWorkbookPage_libraries_label);
} else {
- fLibrariesList
- .setLabelText(NewWizardMessages.LibrariesWorkbookPage_libraries_without_label);
+ fLibrariesList.setLabelText(NewWizardMessages.LibrariesWorkbookPage_libraries_without_label);
}
fLibrariesList.enableButton(IDX_REMOVE + IDX_ADD, false);
fLibrariesList.enableButton(IDX_EDIT + IDX_ADD, false);
@@ -125,7 +123,7 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
fLibrariesList.enableButton(IDX_REPLACE + IDX_ADD, false);
}
fLibrariesList.setViewerSorter(new BPListElementSorter());
-
+
}
/*
@@ -159,12 +157,10 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
// -------- UI creation
public Control getControl(Composite parent) {
-
+
PixelConverter converter = new PixelConverter(parent);
Composite composite = new Composite(parent, SWT.NONE);
- LayoutUtil.doDefaultLayout(composite,
- new DialogField[] { fLibrariesList }, true, SWT.DEFAULT,
- SWT.DEFAULT);
+ LayoutUtil.doDefaultLayout(composite, new DialogField[] { fLibrariesList }, true, SWT.DEFAULT, SWT.DEFAULT);
LayoutUtil.setHorizontalGrabbing(fLibrariesList.getTreeControl(null));
int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
fLibrariesList.setButtonsMinWidth(buttonBarWidth);
@@ -173,7 +169,6 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
return composite;
}
-
private Shell getShell() {
if (fSWTControl != null) {
return fSWTControl.getShell();
@@ -181,8 +176,7 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
return DLTKUIPlugin.getActiveWorkbenchShell();
}
- private class LibrariesAdapter implements IDialogFieldListener,
- ITreeListAdapter {
+ private class LibrariesAdapter implements IDialogFieldListener, ITreeListAdapter {
private final Object[] EMPTY_ARR = new Object[0];
// -------- IListAdapter --------
@@ -233,38 +227,37 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
private void libaryPageCustomButtonPressed(DialogField field, int index) {
BPListElement[] libentries = null;
-
- IEnvironment environment = EnvironmentManager
- .getEnvironment(this.fCurrJProject);
+
+ IEnvironment environment = EnvironmentManager.getEnvironment(this.fCurrJProject);
switch (index - IDX_ADD) {
- case IDX_ADDZIP: /* add archive */
- if (fWithZip) {
- libentries = openZipFileDialog(null);
+ case IDX_ADDZIP: /* add archive */
+ if (fWithZip) {
+ libentries = openZipFileDialog(null);
+ break;
+ }
+ case IDX_ADDEXT: /* add external archive */
+ if (fWithZip) {
+ libentries = openExtZipFileDialog(null, environment);
+ break;
+ }
+ case IDX_ADDLIB: /* add library */
+ libentries = openContainerSelectionDialog(null);
break;
- }
- case IDX_ADDEXT: /* add external archive */
- if (fWithZip) {
- libentries = openExtZipFileDialog(null, environment);
+ case IDX_ADDEXTFOL: /* add folder */
+ libentries = opensExtSourceFolderDialog(null, environment);
break;
- }
- case IDX_ADDLIB: /* add library */
- libentries = openContainerSelectionDialog(null);
- break;
- case IDX_ADDEXTFOL: /* add folder */
- libentries = opensExtSourceFolderDialog(null, environment);
- break;
- // case IDX_ADDFOL: /* add folder */
- // libentries = opensSourceFolderDialog(null);
- // break;
- case IDX_EDIT: /* edit */
- editEntry();
- return;
- case IDX_REMOVE: /* remove */
- removeEntry();
- return;
- case IDX_REPLACE: /* replace */
- replaceArchiveFile();
- return;
+ // case IDX_ADDFOL: /* add folder */
+ // libentries = opensSourceFolderDialog(null);
+ // break;
+ case IDX_EDIT: /* edit */
+ editEntry();
+ return;
+ case IDX_REMOVE: /* remove */
+ removeEntry();
+ return;
+ case IDX_REPLACE: /* replace */
+ replaceArchiveFile();
+ return;
}
if (libentries != null) {
int nElementsChosen = libentries.length;
@@ -284,8 +277,7 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
if (index == IDX_ADDLIB + IDX_ADD) {
fLibrariesList.refresh();
}
- fLibrariesList
- .postSetSelection(new StructuredSelection(libentries));
+ fLibrariesList.postSetSelection(new StructuredSelection(libentries));
}
}
@@ -297,10 +289,7 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
private void askForAddingExclusionPatternsDialog(List newEntries) {
HashSet modified = new HashSet();
List existing = fBuildPathList.getElements();
- fixNestingConflicts((BPListElement[]) newEntries
- .toArray(new BPListElement[newEntries.size()]),
- (BPListElement[]) existing.toArray(new BPListElement[existing
- .size()]), modified);
+ fixNestingConflicts((BPListElement[]) newEntries.toArray(new BPListElement[newEntries.size()]), (BPListElement[]) existing.toArray(new BPListElement[existing.size()]), modified);
if (!modified.isEmpty()) {
String title = NewWizardMessages.LibrariesWorkbookPage_exclusion_added_title;
String message = NewWizardMessages.LibrariesWorkbookPage_exclusion_added_message;
@@ -315,8 +304,7 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
}
}
- protected void libaryPageKeyPressed(TreeListDialogField field,
- KeyEvent event) {
+ protected void libaryPageKeyPressed(TreeListDialogField field, KeyEvent event) {
if (field == fLibrariesList) {
if (event.character == SWT.DEL && event.stateMask == 0) {
List selection = field.getSelectedElements();
@@ -380,12 +368,10 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
// right
// away
BPListElement containerEntry = attrib.getParent();
- HashSet changedAttributes = (HashSet) containerEntriesToUpdate
- .get(containerEntry);
+ HashSet changedAttributes = (HashSet) containerEntriesToUpdate.get(containerEntry);
if (changedAttributes == null) {
changedAttributes = new HashSet();
- containerEntriesToUpdate.put(containerEntry,
- changedAttributes);
+ containerEntriesToUpdate.put(containerEntry, changedAttributes);
}
changedAttributes.add(key); // collect the changed
// attributes
@@ -397,18 +383,25 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
fBuildPathList.dialogFieldChanged(); // validate
} else {
fLibrariesList.removeElements(selElements);
+
+ //also remove library entry from build path
+ for (Iterator iterator = selElements.iterator(); iterator.hasNext();) {
+ BPListElement entry = (BPListElement) iterator.next();
+ try {
+ BuildPathUtils.removeEntryFromBuildPath(fCurrJProject, entry.getBuildpathEntry());
+ } catch (ModelException e) {
+ PHPCorePlugin.log(e);
+ }
+ }
}
- for (Iterator iter = containerEntriesToUpdate.entrySet().iterator(); iter
- .hasNext();) {
+
+ for (Iterator iter = containerEntriesToUpdate.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Entry) iter.next();
BPListElement curr = (BPListElement) entry.getKey();
HashSet attribs = (HashSet) entry.getValue();
- String[] changedAttributes = (String[]) attribs
- .toArray(new String[attribs.size()]);
+ String[] changedAttributes = (String[]) attribs.toArray(new String[attribs.size()]);
IBuildpathEntry changedEntry = curr.getBuildpathEntry();
- updateContainerEntry(changedEntry, changedAttributes,
- fCurrJProject, ((BPListElement) curr.getParentContainer())
- .getPath());
+ updateContainerEntry(changedEntry, changedAttributes, fCurrJProject, ((BPListElement) curr.getParentContainer()).getPath());
}
}
@@ -461,12 +454,10 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
String key = elem.getKey();
BPListElement selElement = elem.getParent();
if (key.equals(BPListElement.ACCESSRULES)) {
- AccessRulesDialog dialog = new AccessRulesDialog(getShell(),
- selElement, fCurrJProject, fPageContainer != null);
+ AccessRulesDialog dialog = new AccessRulesDialog(getShell(), selElement, fCurrJProject, fPageContainer != null);
int res = dialog.open();
if (res == Window.OK || res == AccessRulesDialog.SWITCH_PAGE) {
- selElement.setAttribute(BPListElement.ACCESSRULES, dialog
- .getAccessRules());
+ selElement.setAttribute(BPListElement.ACCESSRULES, dialog.getAccessRules());
String[] changedAttributes = { BPListElement.ACCESSRULES };
attributeUpdated(selElement, changedAttributes);
fLibrariesList.refresh(elem);
@@ -495,32 +486,24 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
// }
}
- private void attributeUpdated(BPListElement selElement,
- String[] changedAttributes) {
+ private void attributeUpdated(BPListElement selElement, String[] changedAttributes) {
Object parentContainer = selElement.getParentContainer();
if (parentContainer instanceof BPListElement) { // inside a container:
// apply changes right
// away
IBuildpathEntry updatedEntry = selElement.getBuildpathEntry();
- updateContainerEntry(updatedEntry, changedAttributes,
- fCurrJProject, ((BPListElement) parentContainer).getPath());
+ updateContainerEntry(updatedEntry, changedAttributes, fCurrJProject, ((BPListElement) parentContainer).getPath());
}
}
- private void updateContainerEntry(final IBuildpathEntry newEntry,
- final String[] changedAttributes, final IScriptProject jproject,
- final IPath containerPath) {
+ private void updateContainerEntry(final IBuildpathEntry newEntry, final String[] changedAttributes, final IScriptProject jproject, final IPath containerPath) {
try {
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
- BuildPathSupport
- .modifyBuildpathEntry(null, newEntry,
- changedAttributes, jproject, containerPath,
- monitor);
+ BuildPathSupport.modifyBuildpathEntry(null, newEntry, changedAttributes, jproject, containerPath, monitor);
}
};
- PlatformUI.getWorkbench().getProgressService().run(true, true,
- new WorkbenchRunnableAdapter(runnable));
+ PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable));
} catch (InvocationTargetException e) {
String title = NewWizardMessages.LibrariesWorkbookPage_configurecontainer_error_title;
String message = NewWizardMessages.LibrariesWorkbookPage_configurecontainer_error_message;
@@ -533,29 +516,28 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
private void editElementEntry(BPListElement elem) {
BPListElement[] res = null;
switch (elem.getEntryKind()) {
- case IBuildpathEntry.BPE_CONTAINER:
- res = openContainerSelectionDialog(elem);
- break;
- case IBuildpathEntry.BPE_LIBRARY:
- IEnvironment environment = EnvironmentManager
- .getEnvironment(this.scriptProject);
- IResource resource = elem.getResource();
- if (resource == null) {
- if (Util.isArchiveFileName(elem.getPath().toOSString())) {
- res = openExtZipFileDialog(elem, environment);
- } else {
- res = opensExtSourceFolderDialog(elem, environment);
- }
- } else if (resource.getType() == IResource.FOLDER) {
- if (resource.exists()) {
- res = opensSourceFolderDialog(elem);
- } else {
- res = openNewClassFolderDialog(elem);
+ case IBuildpathEntry.BPE_CONTAINER:
+ res = openContainerSelectionDialog(elem);
+ break;
+ case IBuildpathEntry.BPE_LIBRARY:
+ IEnvironment environment = EnvironmentManager.getEnvironment(this.scriptProject);
+ IResource resource = elem.getResource();
+ if (resource == null) {
+ if (Util.isArchiveFileName(elem.getPath().toOSString())) {
+ res = openExtZipFileDialog(elem, environment);
+ } else {
+ res = opensExtSourceFolderDialog(elem, environment);
+ }
+ } else if (resource.getType() == IResource.FOLDER) {
+ if (resource.exists()) {
+ res = opensSourceFolderDialog(elem);
+ } else {
+ res = openNewClassFolderDialog(elem);
+ }
+ } else if (resource.getType() == IResource.FILE) {
+ res = openZipFileDialog(elem);
}
- } else if (resource.getType() == IResource.FILE) {
- res = openZipFileDialog(elem);
- }
- break;
+ break;
}
if (res != null && res.length > 0) {
BPListElement curr = res[0];
@@ -571,14 +553,12 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
private void updateEnabledState() {
List selElements = fLibrariesList.getSelectedElements();
fLibrariesList.enableButton(IDX_EDIT + IDX_ADD, canEdit(selElements));
- fLibrariesList.enableButton(IDX_REMOVE + IDX_ADD,
- canRemove(selElements));
+ fLibrariesList.enableButton(IDX_REMOVE + IDX_ADD, canRemove(selElements));
boolean noAttributes = containsOnlyTopLevelEntries(selElements);
if (fWithZip) {
fLibrariesList.enableButton(IDX_ADDEXT + IDX_ADD, noAttributes);
fLibrariesList.enableButton(IDX_ADDZIP + IDX_ADD, noAttributes);
- fLibrariesList.enableButton(IDX_REPLACE + IDX_ADD,
- getSelectedProjectFragment() != null);
+ fLibrariesList.enableButton(IDX_REPLACE + IDX_ADD, getSelectedProjectFragment() != null);
}
// fLibrariesList.enableButton(IDX_ADDFOL+IDX_ADD, noAttributes);
fLibrariesList.enableButton(IDX_ADDLIB + IDX_ADD, noAttributes);
@@ -591,9 +571,7 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
Object elem = selElements.get(0);
if (elem instanceof BPListElement) {
BPListElement curr = (BPListElement) elem;
- return !(curr.getResource() instanceof IFolder || curr
- .isExternalFolder())
- && curr.getParentContainer() == null;
+ return !(curr.getResource() instanceof IFolder || curr.isExternalFolder()) && curr.getParentContainer() == null;
}
if (elem instanceof BPListElementAttribute) {
BPListElementAttribute attrib = (BPListElementAttribute) elem;
@@ -635,17 +613,11 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
}
private BPListElement[] openNewClassFolderDialog(BPListElement existing) {
- String title = (existing == null) ? NewWizardMessages.LibrariesWorkbookPage_NewClassFolderDialog_new_title
- : NewWizardMessages.LibrariesWorkbookPage_NewClassFolderDialog_edit_title;
+ String title = (existing == null) ? NewWizardMessages.LibrariesWorkbookPage_NewClassFolderDialog_new_title : NewWizardMessages.LibrariesWorkbookPage_NewClassFolderDialog_edit_title;
IProject currProject = fCurrJProject.getProject();
- NewContainerDialog dialog = new NewContainerDialog(getShell(), title,
- currProject, getUsedContainers(existing), existing);
+ NewContainerDialog dialog = new NewContainerDialog(getShell(), title, currProject, getUsedContainers(existing), existing);
IPath projpath = currProject.getFullPath();
- dialog
- .setMessage(Messages
- .format(
- NewWizardMessages.LibrariesWorkbookPage_NewClassFolderDialog_description,
- projpath.toString()));
+ dialog.setMessage(Messages.format(NewWizardMessages.LibrariesWorkbookPage_NewClassFolderDialog_description, projpath.toString()));
if (dialog.open() == Window.OK) {
IFolder folder = dialog.getFolder();
return new BPListElement[] { newBPLibraryElement(folder, false) };
@@ -653,25 +625,18 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
return null;
}
- private BPListElement[] opensExtSourceFolderDialog(BPListElement existing,
- IEnvironment environment) {
+ private BPListElement[] opensExtSourceFolderDialog(BPListElement existing, IEnvironment environment) {
if (existing == null) {
- IPath[] selected = BuildpathDialogAccess
- .chooseExtSourceFolderEntries(getShell(), fCurrJProject
- .getPath(), getUsedContainers(existing),
- environment);
+ IPath[] selected = BuildpathDialogAccess.chooseExtSourceFolderEntries(getShell(), fCurrJProject.getPath(), getUsedContainers(existing), environment);
if (selected != null) {
// IWorkspaceRoot root =
// fCurrJProject.getProject().getWorkspace().getRoot();
ArrayList res = new ArrayList();
for (int i = 0; i < selected.length; i++) {
// IPath curr = selected[i];
- res.add(new BPListElement(fCurrJProject,
- IBuildpathEntry.BPE_LIBRARY, selected[i], null,
- true));
+ res.add(new BPListElement(fCurrJProject, IBuildpathEntry.BPE_LIBRARY, selected[i], null, true));
}
- return (BPListElement[]) res.toArray(new BPListElement[res
- .size()]);
+ return (BPListElement[]) res.toArray(new BPListElement[res.size()]);
}
} else {
// disabled
@@ -681,12 +646,9 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
private BPListElement[] opensSourceFolderDialog(BPListElement existing) {
if (existing == null) {
- IPath[] selected = BuildpathDialogAccess.chooseSourceFolderEntries(
- getShell(), fCurrJProject.getPath(),
- getUsedContainers(existing));
+ IPath[] selected = BuildpathDialogAccess.chooseSourceFolderEntries(getShell(), fCurrJProject.getPath(), getUsedContainers(existing));
if (selected != null) {
- IWorkspaceRoot root = fCurrJProject.getProject().getWorkspace()
- .getRoot();
+ IWorkspaceRoot root = fCurrJProject.getProject().getWorkspace().getRoot();
ArrayList res = new ArrayList();
for (int i = 0; i < selected.length; i++) {
IPath curr = selected[i];
@@ -695,8 +657,7 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
res.add(newBPLibraryElement(resource, false));
}
}
- return (BPListElement[]) res.toArray(new BPListElement[res
- .size()]);
+ return (BPListElement[]) res.toArray(new BPListElement[res.size()]);
}
} else {
// disabled
@@ -705,12 +666,9 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
}
private BPListElement[] openZipFileDialog(BPListElement existing) {
- IWorkspaceRoot root = fCurrJProject.getProject().getWorkspace()
- .getRoot();
+ IWorkspaceRoot root = fCurrJProject.getProject().getWorkspace().getRoot();
if (existing == null) {
- IPath[] selected = BuildpathDialogAccess.chooseArchiveEntries(
- getShell(), fCurrJProject.getPath(),
- getUsedArchiveFiles(existing));
+ IPath[] selected = BuildpathDialogAccess.chooseArchiveEntries(getShell(), fCurrJProject.getPath(), getUsedArchiveFiles(existing));
if (selected != null) {
ArrayList res = new ArrayList();
for (int i = 0; i < selected.length; i++) {
@@ -720,18 +678,14 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
res.add(newBPLibraryElement(resource, false));
}
}
- return (BPListElement[]) res.toArray(new BPListElement[res
- .size()]);
+ return (BPListElement[]) res.toArray(new BPListElement[res.size()]);
}
} else {
- IPath configured = BuildpathDialogAccess.configureArchiveEntry(
- getShell(), existing.getPath(),
- getUsedArchiveFiles(existing));
+ IPath configured = BuildpathDialogAccess.configureArchiveEntry(getShell(), existing.getPath(), getUsedArchiveFiles(existing));
if (configured != null) {
IResource resource = root.findMember(configured);
if (resource instanceof IFile) {
- return new BPListElement[] { newBPLibraryElement(resource,
- false) };
+ return new BPListElement[] { newBPLibraryElement(resource, false) };
}
}
}
@@ -743,11 +697,9 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
List cplist = fLibrariesList.getElements();
for (int i = 0; i < cplist.size(); i++) {
BPListElement elem = (BPListElement) cplist.get(i);
- if (elem.getEntryKind() == IBuildpathEntry.BPE_LIBRARY
- && (elem != existing)) {
+ if (elem.getEntryKind() == IBuildpathEntry.BPE_LIBRARY && (elem != existing)) {
IResource resource = elem.getResource();
- if (resource instanceof IContainer
- && !resource.equals(existing)) {
+ if (resource instanceof IContainer && !resource.equals(existing)) {
res.add(resource.getFullPath());
}
}
@@ -760,8 +712,7 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
List cplist = fLibrariesList.getElements();
for (int i = 0; i < cplist.size(); i++) {
BPListElement elem = (BPListElement) cplist.get(i);
- if (elem.getEntryKind() == IBuildpathEntry.BPE_LIBRARY
- && (elem != existing)) {
+ if (elem.getEntryKind() == IBuildpathEntry.BPE_LIBRARY && (elem != existing)) {
IResource resource = elem.getResource();
if (resource instanceof IFile) {
res.add(resource.getFullPath());
@@ -772,32 +723,23 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
}
private BPListElement newBPLibraryElement(IResource res, boolean external) {
- return new BPListElement(fCurrJProject, IBuildpathEntry.BPE_LIBRARY,
- res.getFullPath(), res, external);
+ return new BPListElement(fCurrJProject, IBuildpathEntry.BPE_LIBRARY, res.getFullPath(), res, external);
}
- private BPListElement[] openExtZipFileDialog(BPListElement existing,
- IEnvironment environment) {
+ private BPListElement[] openExtZipFileDialog(BPListElement existing, IEnvironment environment) {
if (existing == null) {
- IPath[] selected = BuildpathDialogAccess
- .chooseExternalArchiveEntries(getShell(), environment);
+ IPath[] selected = BuildpathDialogAccess.chooseExternalArchiveEntries(getShell(), environment);
if (selected != null) {
ArrayList res = new ArrayList();
for (int i = 0; i < selected.length; i++) {
- res.add(new BPListElement(fCurrJProject,
- IBuildpathEntry.BPE_LIBRARY, selected[i], null,
- true));
+ res.add(new BPListElement(fCurrJProject, IBuildpathEntry.BPE_LIBRARY, selected[i], null, true));
}
- return (BPListElement[]) res.toArray(new BPListElement[res
- .size()]);
+ return (BPListElement[]) res.toArray(new BPListElement[res.size()]);
}
} else {
- IPath configured = BuildpathDialogAccess
- .configureExternalArchiveEntry(getShell(), existing
- .getPath());
+ IPath configured = BuildpathDialogAccess.configureExternalArchiveEntry(getShell(), existing.getPath());
if (configured != null) {
- return new BPListElement[] { new BPListElement(fCurrJProject,
- IBuildpathEntry.BPE_LIBRARY, configured, null, true) };
+ return new BPListElement[] { new BPListElement(fCurrJProject, IBuildpathEntry.BPE_LIBRARY, configured, null, true) };
}
}
return null;
@@ -805,26 +747,18 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
private BPListElement[] openContainerSelectionDialog(BPListElement existing) {
if (existing == null) {
- IBuildpathEntry[] created = BuildpathDialogAccess
- .chooseContainerEntries(getShell(), fCurrJProject,
- getRawBuildpath());
+ IBuildpathEntry[] created = BuildpathDialogAccess.chooseContainerEntries(getShell(), fCurrJProject, getRawBuildpath());
if (created != null) {
BPListElement[] res = new BPListElement[created.length];
for (int i = 0; i < res.length; i++) {
- res[i] = new BPListElement(fCurrJProject,
- IBuildpathEntry.BPE_CONTAINER,
- created[i].getPath(), null, false);
+ res[i] = new BPListElement(fCurrJProject, IBuildpathEntry.BPE_CONTAINER, created[i].getPath(), null, false);
}
return res;
}
} else {
- IBuildpathEntry created = BuildpathDialogAccess
- .configureContainerEntry(getShell(), existing
- .getBuildpathEntry(), fCurrJProject,
- getRawBuildpath());
+ IBuildpathEntry created = BuildpathDialogAccess.configureContainerEntry(getShell(), existing.getBuildpathEntry(), fCurrJProject, getRawBuildpath());
if (created != null) {
- BPListElement elem = BPListElement.createFromExisting(created,
- fCurrJProject);
+ BPListElement elem = BPListElement.createFromExisting(created, fCurrJProject);
return new BPListElement[] { elem };
}
}
@@ -832,8 +766,7 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
}
private IBuildpathEntry[] getRawBuildpath() {
- IBuildpathEntry[] currEntries = new IBuildpathEntry[fBuildPathList
- .getSize()];
+ IBuildpathEntry[] currEntries = new IBuildpathEntry[fBuildPathList.getSize()];
for (int i = 0; i < currEntries.length; i++) {
BPListElement curr = (BPListElement) fBuildPathList.getElement(i);
currEntries[i] = curr.getBuildpathEntry();
@@ -842,8 +775,7 @@ public class PHPLibrariesWorkbookPage extends BuildPathBasePage {
}
public boolean isEntryKind(int kind) {
- return kind == IBuildpathEntry.BPE_LIBRARY
- || kind == IBuildpathEntry.BPE_CONTAINER;
+ return kind == IBuildpathEntry.BPE_LIBRARY || kind == IBuildpathEntry.BPE_CONTAINER;
}
/*
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPSourceContainerWorkbookPage.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPSourceContainerWorkbookPage.java
index 1e70c6559..90742d1b9 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPSourceContainerWorkbookPage.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPSourceContainerWorkbookPage.java
@@ -23,6 +23,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.dltk.core.IBuildpathEntry;
import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ModelException;
import org.eclipse.dltk.internal.corext.buildpath.BuildpathModifier;
import org.eclipse.dltk.internal.ui.wizards.NewWizardMessages;
import org.eclipse.dltk.internal.ui.wizards.buildpath.*;
@@ -35,12 +36,15 @@ import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
+import org.eclipse.php.internal.core.PHPCorePlugin;
+import org.eclipse.php.internal.core.buildpath.BuildPathUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.internal.IChangeListener;
public class PHPSourceContainerWorkbookPage extends BuildPathBasePage {
@@ -134,6 +138,8 @@ public class PHPSourceContainerWorkbookPage extends BuildPathBasePage {
private final int IDX_ADD_LINK = 1;
private final int IDX_EDIT = 3;
private final int IDX_REMOVE = 4;
+
+ protected List<IChangeListener> addedElementListeners = new ArrayList<IChangeListener>(1);
protected int getIDX_ADD() {
return IDX_ADD;
@@ -633,4 +639,16 @@ public class PHPSourceContainerWorkbookPage extends BuildPathBasePage {
}
}
+ public void registerAddedElementListener(IChangeListener listener) {
+ if (listener != null) {
+ addedElementListeners.add(listener);
+ }
+ }
+
+ public void unregisterAddedElementListener(IChangeListener listener) {
+ if (listener != null) {
+ addedElementListeners.remove(listener);
+ }
+ }
+
}

Back to the top