Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 157711 Details for
Bug 237211
[Build Path] Add the option to set variables as include path entry + preferences action
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch
237211.txt (text/plain), 19.56 KB, created by
Zhongwei Zhao
on 2010-01-31 04:50:13 EST
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Zhongwei Zhao
Created:
2010-01-31 04:50:13 EST
Size:
19.56 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.php.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.pdt/plugins/org.eclipse.php.ui/plugin.xml,v >retrieving revision 1.229 >diff -u -r1.229 plugin.xml >--- plugin.xml 29 Jan 2010 01:46:57 -0000 1.229 >+++ plugin.xml 31 Jan 2010 09:48:21 -0000 >@@ -1803,4 +1803,18 @@ > target="org.eclipse.php.core.phpsource"> > </highlighting> > </extension> >+ >+ <extension point="org.eclipse.ui.preferencePages"> >+ <page category="org.eclipse.php.ui.preferences.PHPBasePreferencePage" >+ class="org.eclipse.dltk.ui.preferences.BuildpathVariablesPreferencePage" >+ id="org.eclipse.dltk.ui.preferences.BuildpathVariablesPreferencePage" >+ name="Buildpath Variables"> >+ <keywordReference id="org.eclipse.php.ui.buildpathVariables" /> >+ </page> >+ </extension> >+ >+ <extension point="org.eclipse.ui.keywords"> >+ <keyword id="org.eclipse.php.ui.buildpathVariables" label="Buildpath Variables"> >+ </keyword> >+ </extension> > </plugin> >Index: src/org/eclipse/php/internal/ui/preferences/includepath/PHPBuildpathDialogAccess.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.pdt/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPBuildpathDialogAccess.java,v >retrieving revision 1.2 >diff -u -r1.2 PHPBuildpathDialogAccess.java >--- src/org/eclipse/php/internal/ui/preferences/includepath/PHPBuildpathDialogAccess.java 30 Oct 2009 21:59:35 -0000 1.2 >+++ src/org/eclipse/php/internal/ui/preferences/includepath/PHPBuildpathDialogAccess.java 31 Jan 2010 09:48:21 -0000 >@@ -230,4 +230,26 @@ > return Path.fromOSString(res).makeAbsolute(); > } > >+ /** >+ * Shows the UI for selecting new variable classpath entries. See {@link IClasspathEntry#CPE_VARIABLE} for >+ * details about variable classpath entries. >+ * The dialog returns an array of the selected variable entries or <code>null</code> if the dialog has >+ * been canceled. The dialog does not apply any changes. >+ * >+ * @param shell The parent shell for the dialog. >+ * @param existingPaths An array of paths that are already on the classpath and therefore should not be >+ * selected again. >+ * @return Returns an non empty array of the selected variable entries or <code>null</code> if the dialog has >+ * been canceled. >+ */ >+ public static IPath[] chooseVariableEntries(Shell shell, IEnvironment environment) { >+// if (existingPaths == null) { >+// throw new IllegalArgumentException(); >+// } >+ NewVariableEntryDialog dialog= new NewVariableEntryDialog(shell,environment); >+ if (dialog.open() == Window.OK) { >+ return dialog.getResult(); >+ } >+ return null; >+ } > } >Index: src/org/eclipse/php/internal/ui/preferences/includepath/PHPLibrariesWorkbookPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.pdt/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/includepath/PHPLibrariesWorkbookPage.java,v >retrieving revision 1.7 >diff -u -r1.7 PHPLibrariesWorkbookPage.java >--- src/org/eclipse/php/internal/ui/preferences/includepath/PHPLibrariesWorkbookPage.java 30 Oct 2009 21:59:35 -0000 1.7 >+++ src/org/eclipse/php/internal/ui/preferences/includepath/PHPLibrariesWorkbookPage.java 31 Jan 2010 09:48:21 -0000 >@@ -22,6 +22,7 @@ > import org.eclipse.dltk.compiler.util.Util; > import org.eclipse.dltk.core.*; > import org.eclipse.dltk.core.environment.EnvironmentManager; >+import org.eclipse.dltk.core.environment.EnvironmentPathUtils; > import org.eclipse.dltk.core.environment.IEnvironment; > import org.eclipse.dltk.internal.ui.actions.WorkbenchRunnableAdapter; > import org.eclipse.dltk.internal.ui.wizards.BuildpathDialogAccess; >@@ -53,7 +54,7 @@ > private final int IDX_ADDZIP = 0; > private final int IDX_ADDEXT = 1; > private final int IDX_ADDLIB = 2; >- // private final int IDX_ADDFOL = 3; >+ private final int IDX_ADDFOL = 4; > private final int IDX_ADDEXTFOL = 3; > private final int IDX_EDIT = 5; > private final int IDX_REMOVE = 6; >@@ -86,7 +87,8 @@ > NewWizardMessages.LibrariesWorkbookPage_libraries_addlibrary_button, > // NewWizardMessages.LibrariesWorkbookPage_libraries_add_source_folder_button, > NewWizardMessages.LibrariesWorkbookPage_libraries_add_external_source_folder_button, >- /* */null, >+// /* */null, >+ "Add Variables...", > NewWizardMessages.LibrariesWorkbookPage_libraries_edit_button, > NewWizardMessages.LibrariesWorkbookPage_libraries_remove_button, > /* */null, >@@ -95,7 +97,8 @@ > NewWizardMessages.LibrariesWorkbookPage_libraries_addlibrary_button, > // NewWizardMessages.LibrariesWorkbookPage_libraries_add_source_folder_button, > NewWizardMessages.LibrariesWorkbookPage_libraries_add_external_source_folder_button, >- /* */null, >+// /* */null, >+ "Add Variables...", > NewWizardMessages.LibrariesWorkbookPage_libraries_edit_button, > NewWizardMessages.LibrariesWorkbookPage_libraries_remove_button }; > String[] buttonLabels; >@@ -250,9 +253,9 @@ > case IDX_ADDEXTFOL: /* add folder */ > libentries = opensExtSourceFolderDialog(null, environment); > break; >- // case IDX_ADDFOL: /* add folder */ >- // libentries = opensSourceFolderDialog(null); >- // break; >+ case IDX_ADDFOL: /* add variables */ >+ libentries = addVariablesDialog(null, environment); >+ break; > case IDX_EDIT: /* edit */ > editEntry(); > return; >@@ -286,6 +289,25 @@ > } > } > >+ private BPListElement[] addVariablesDialog(BPListElement existing, IEnvironment environment) { >+ if (existing == null) { >+ IPath[] selected = PHPBuildpathDialogAccess >+ .chooseVariableEntries(getShell(), environment); >+ if (selected != null) { >+ ArrayList res = new ArrayList(); >+ for (int i = 0; i < selected.length; i++) { >+ IPath path = EnvironmentPathUtils.getFullPath(environment, DLTKCore.getBuildpathVariable(selected[i].toString())); >+ res.add(new BPListElement(fCurrJProject, >+ IBuildpathEntry.BPE_LIBRARY, path, null, >+ true)); >+ } >+ return (BPListElement[]) res.toArray(new BPListElement[res >+ .size()]); >+ } >+ } >+ return null; >+ } >+ > public void addElement(BPListElement element) { > fLibrariesList.addElement(element); > fLibrariesList.postSetSelection(new StructuredSelection(element)); >@@ -589,7 +611,7 @@ > fLibrariesList.enableButton(IDX_REPLACE + IDX_ADD, > getSelectedProjectFragment() != null); > } >- // fLibrariesList.enableButton(IDX_ADDFOL+IDX_ADD, noAttributes); >+ fLibrariesList.enableButton(IDX_ADDFOL+IDX_ADD, noAttributes); > fLibrariesList.enableButton(IDX_ADDLIB + IDX_ADD, noAttributes); > } > >Index: src/org/eclipse/php/internal/ui/preferences/includepath/NewVariableEntryDialog.java >=================================================================== >RCS file: src/org/eclipse/php/internal/ui/preferences/includepath/NewVariableEntryDialog.java >diff -N src/org/eclipse/php/internal/ui/preferences/includepath/NewVariableEntryDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/php/internal/ui/preferences/includepath/NewVariableEntryDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,379 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.php.internal.ui.preferences.includepath; >+ >+import java.io.File; >+import java.util.*; >+ >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.dltk.core.DLTKCore; >+import org.eclipse.dltk.core.IScriptProject; >+import org.eclipse.dltk.core.environment.EnvironmentManager; >+import org.eclipse.dltk.core.environment.IEnvironment; >+import org.eclipse.dltk.internal.ui.wizards.NewWizardMessages; >+import org.eclipse.dltk.internal.ui.wizards.buildpath.BPVariableElement; >+import org.eclipse.dltk.internal.ui.wizards.buildpath.BPVariableElementLabelProvider; >+import org.eclipse.dltk.ui.preferences.BuildpathVariablesPreferencePage; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.jface.dialogs.IDialogSettings; >+import org.eclipse.jface.dialogs.StatusDialog; >+import org.eclipse.jface.resource.JFaceResources; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.ViewerComparator; >+import org.eclipse.jface.window.Window; >+import org.eclipse.php.internal.ui.PHPUiPlugin; >+import org.eclipse.php.internal.ui.util.Messages; >+import org.eclipse.php.internal.ui.util.StatusInfo; >+import org.eclipse.php.internal.ui.wizards.fields.*; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.CLabel; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+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.dialogs.PreferencesUtil; >+import org.eclipse.wst.jsdt.internal.ui.IJavaHelpContextIds; >+import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.JARFileSelectionDialog; >+ >+public class NewVariableEntryDialog extends StatusDialog { >+ >+ private class VariablesAdapter implements IDialogFieldListener, >+ IListAdapter { >+ >+ // -------- IListAdapter -------- >+ >+ public void customButtonPressed(ListDialogField field, int index) { >+ switch (index) { >+ case IDX_EXTEND: /* extend */ >+ extendButtonPressed(); >+ break; >+ } >+ } >+ >+ public void selectionChanged(ListDialogField field) { >+ doSelectionChanged(); >+ } >+ >+ public void doubleClicked(ListDialogField field) { >+ doDoubleClick(); >+ } >+ >+ // ---------- IDialogFieldListener -------- >+ >+ public void dialogFieldChanged(DialogField field) { >+ if (field == fConfigButton) { >+ configButtonPressed(); >+ } >+ >+ } >+ >+ } >+ >+ private final int IDX_EXTEND = 0; >+ >+ private ListDialogField fVariablesList; >+ private boolean fCanExtend; >+ private boolean fIsValidSelection; >+ >+ private IPath[] fResultPaths; >+ >+ private SelectionButtonDialogField fConfigButton; >+ >+ private CLabel fWarning; >+ IEnvironment environment; >+ >+ public NewVariableEntryDialog(Shell parent, IEnvironment environment) { >+ super(parent); >+ setTitle(NewWizardMessages.NewVariableEntryDialog_title); >+ this.environment = environment; >+ updateStatus(new StatusInfo(IStatus.ERROR, "")); //$NON-NLS-1$ >+ >+ String[] buttonLabels = new String[] { NewWizardMessages.NewVariableEntryDialog_vars_extend, }; >+ >+ VariablesAdapter adapter = new VariablesAdapter(); >+ >+ BPVariableElementLabelProvider labelProvider = new BPVariableElementLabelProvider( >+ false); >+ >+ fVariablesList = new ListDialogField(adapter, buttonLabels, >+ labelProvider); >+ fVariablesList.setDialogFieldListener(adapter); >+ fVariablesList >+ .setLabelText(NewWizardMessages.NewVariableEntryDialog_vars_label); >+ >+ fVariablesList.enableButton(IDX_EXTEND, false); >+ >+ // fVariablesList.setViewerComparator(new ViewerComparator() { >+ // public int compare(Viewer viewer, Object e1, Object e2) { >+ // if (e1 instanceof BPVariableElement && e2 instanceof >+ // BPVariableElement) { >+ // return getComparator().compare(((BPVariableElement)e1).getName(), >+ // ((BPVariableElement)e2).getName()); >+ // } >+ // return super.compare(viewer, e1, e2); >+ // } >+ // }); >+ >+ fConfigButton = new SelectionButtonDialogField(SWT.PUSH); >+ fConfigButton >+ .setLabelText(NewWizardMessages.NewVariableEntryDialog_configbutton_label); >+ fConfigButton.setDialogFieldListener(adapter); >+ >+ initializeElements(); >+ >+ fCanExtend = false; >+ fIsValidSelection = false; >+ fResultPaths = null; >+ >+ fVariablesList.selectFirstElement(); >+ } >+ >+ /* >+ * @see org.eclipse.jface.dialogs.Dialog#isResizable() >+ * >+ * @since 3.4 >+ */ >+ protected boolean isResizable() { >+ return true; >+ } >+ >+ private void initializeElements() { >+ String[] entries = DLTKCore.getBuildpathVariableNames(); >+ ArrayList elements = new ArrayList(entries.length); >+ for (int i = 0; i < entries.length; i++) { >+ String name = entries[i]; >+ IPath entryPath = DLTKCore.getBuildpathVariable(name); >+ if (entryPath != null) { >+ elements.add(new BPVariableElement(name, entryPath)); >+ } >+ } >+ >+ fVariablesList.setElements(elements); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see Window#configureShell(Shell) >+ */ >+ protected void configureShell(Shell shell) { >+ super.configureShell(shell); >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, >+ IJavaHelpContextIds.NEW_VARIABLE_ENTRY_DIALOG); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings() >+ */ >+ protected IDialogSettings getDialogBoundsSettings() { >+ return PHPUiPlugin.getDefault().getDialogSettings()/* >+ * getDialogSettingsSection( >+ * getClass >+ * ().getName()) >+ */; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets >+ * .Composite) >+ */ >+ protected Control createDialogArea(Composite parent) { >+ initializeDialogUnits(parent); >+ >+ Composite composite = (Composite) super.createDialogArea(parent); >+ GridLayout layout = (GridLayout) composite.getLayout(); >+ layout.numColumns = 2; >+ >+ fVariablesList.doFillIntoGrid(composite, 3); >+ >+ LayoutUtil.setHorizontalSpan(fVariablesList.getLabelControl(null), 2); >+ >+ GridData listData = (GridData) fVariablesList.getListControl(null) >+ .getLayoutData(); >+ listData.grabExcessHorizontalSpace = true; >+ listData.heightHint = convertHeightInCharsToPixels(10); >+ listData.widthHint = convertWidthInCharsToPixels(70); >+ >+ fWarning = new CLabel(composite, SWT.NONE); >+ fWarning.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, >+ fVariablesList.getNumberOfControls() - 1, 1)); >+ >+ Composite lowerComposite = new Composite(composite, SWT.NONE); >+ lowerComposite.setLayoutData(new GridData( >+ GridData.HORIZONTAL_ALIGN_FILL)); >+ >+ layout = new GridLayout(); >+ layout.marginHeight = 0; >+ layout.marginWidth = 0; >+ lowerComposite.setLayout(layout); >+ >+ fConfigButton.doFillIntoGrid(lowerComposite, 1); >+ >+ applyDialogFont(composite); >+ return composite; >+ } >+ >+ public IPath[] getResult() { >+ return fResultPaths; >+ } >+ >+ /* >+ * @see IDoubleClickListener#doubleClick(DoubleClickEvent) >+ */ >+ private void doDoubleClick() { >+ if (fIsValidSelection) { >+ okPressed(); >+ } else if (fCanExtend) { >+ extendButtonPressed(); >+ } >+ } >+ >+ private void doSelectionChanged() { >+ boolean isValidSelection = true; >+ boolean canExtend = false; >+ StatusInfo status = new StatusInfo(); >+ >+ List selected = fVariablesList.getSelectedElements(); >+ int nSelected = selected.size(); >+ >+ if (nSelected > 0) { >+ fResultPaths = new Path[nSelected]; >+ for (int i = 0; i < nSelected; i++) { >+ BPVariableElement curr = (BPVariableElement) selected.get(i); >+ fResultPaths[i] = new Path(curr.getName()); >+ File file = curr.getPath().toFile(); >+ if (!file.exists()) { >+ status >+ .setError(NewWizardMessages.NewVariableEntryDialog_info_notexists); >+ isValidSelection = false; >+ break; >+ } >+ if (file.isDirectory()) { >+ canExtend = true; >+ } >+ } >+ } else { >+ isValidSelection = false; >+ status >+ .setInfo(NewWizardMessages.NewVariableEntryDialog_info_noselection); >+ } >+ if (isValidSelection && nSelected > 1) { >+ String str = Messages.format( >+ NewWizardMessages.NewVariableEntryDialog_info_selected, >+ String.valueOf(nSelected)); >+ status.setInfo(str); >+ } >+ fCanExtend = nSelected == 1 && canExtend; >+ fVariablesList.enableButton(0, fCanExtend); >+ >+ updateStatus(status); >+ fIsValidSelection = isValidSelection; >+ Button okButton = getButton(IDialogConstants.OK_ID); >+ if (okButton != null && !okButton.isDisposed()) { >+ okButton.setEnabled(isValidSelection); >+ } >+ updateDeprecationWarning(); >+ } >+ >+ private void updateDeprecationWarning() { >+ // TODO >+ // if (fWarning == null || fWarning.isDisposed()) >+ // return; >+ // >+ // for (Iterator iter= fVariablesList.getSelectedElements().iterator(); >+ // iter.hasNext();) { >+ // BPVariableElement element= (BPVariableElement) iter.next(); >+ // String deprecationMessage= element.getDeprecationMessage(); >+ // if (deprecationMessage != null) { >+ // fWarning.setText(deprecationMessage); >+ // fWarning.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); >+ // return; >+ // } >+ // } >+ // fWarning.setText(null); >+ // fWarning.setImage(null); >+ } >+ >+ private IPath[] chooseExtensions(BPVariableElement elem) { >+ File file = elem.getPath().toFile(); >+ IPath[] selected = PHPBuildpathDialogAccess >+ .chooseExternalArchiveEntries(getShell(), environment); >+ // JARFileSelectionDialog dialog= new JARFileSelectionDialog(getShell(), >+ // true, true, true); >+ // dialog.setTitle(NewWizardMessages.NewVariableEntryDialog_ExtensionDialog_title); >+ // dialog.setMessage(Messages.format(NewWizardMessages.NewVariableEntryDialog_ExtensionDialog_description, >+ // elem.getName())); >+ // dialog.setInput(file); >+ // if (dialog.open() == Window.OK) { >+ // Object[] selected= dialog.getResult(); >+ IPath[] paths = new IPath[selected.length]; >+ for (int i = 0; i < selected.length; i++) { >+ IPath filePath = Path.fromOSString(((File) selected[i]).getPath()); >+ IPath resPath = new Path(elem.getName()); >+ for (int k = elem.getPath().segmentCount(); k < filePath >+ .segmentCount(); k++) { >+ resPath = resPath.append(filePath.segment(k)); >+ } >+ paths[i] = resPath; >+ } >+ return paths; >+ // } >+ // return null; >+ } >+ >+ protected final void extendButtonPressed() { >+ List selected = fVariablesList.getSelectedElements(); >+ if (selected.size() == 1) { >+ IPath[] extendedPaths = chooseExtensions((BPVariableElement) selected >+ .get(0)); >+ if (extendedPaths != null) { >+ fResultPaths = extendedPaths; >+ super.buttonPressed(IDialogConstants.OK_ID); >+ } >+ } >+ } >+ >+ protected final void configButtonPressed() { >+ String id = BuildpathVariablesPreferencePage.ID; >+ Map options = new HashMap(); >+ List selected = fVariablesList.getSelectedElements(); >+ if (!selected.isEmpty()) { >+ String varName = ((BPVariableElement) selected.get(0)).getName(); >+ options.put(BuildpathVariablesPreferencePage.DATA_SELECT_VARIABLE, >+ varName); >+ } >+ PreferencesUtil.createPreferenceDialogOn(getShell(), id, >+ new String[] { id }, options).open(); >+ >+ List oldElements = fVariablesList.getElements(); >+ initializeElements(); >+ List newElements = fVariablesList.getElements(); >+ newElements.removeAll(oldElements); >+ if (!newElements.isEmpty()) { >+ fVariablesList.selectElements(new StructuredSelection(newElements)); >+ } else if (fVariablesList.getSelectedElements().isEmpty()) { >+ fVariablesList.selectFirstElement(); >+ } >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 237211
: 157711 |
171277