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 130475 Details for
Bug 270626
[target] Change UI to separate content and location tabs
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]
Work In Progress
clipboard.txt (text/plain), 76.95 KB, created by
Curtis Windatt
on 2009-03-31 17:45:00 EDT
(
hide
)
Description:
Work In Progress
Filename:
MIME Type:
Creator:
Curtis Windatt
Created:
2009-03-31 17:45:00 EDT
Size:
76.95 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.ui >Index: src/org/eclipse/pde/internal/ui/shared/target/BundleContainerLabelProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/BundleContainerLabelProvider.java,v >retrieving revision 1.3 >diff -u -r1.3 BundleContainerLabelProvider.java >--- src/org/eclipse/pde/internal/ui/shared/target/BundleContainerLabelProvider.java 26 Feb 2009 16:17:55 -0000 1.3 >+++ src/org/eclipse/pde/internal/ui/shared/target/BundleContainerLabelProvider.java 31 Mar 2009 21:45:08 -0000 >@@ -51,9 +51,6 @@ > } catch (CoreException e) { > return MessageFormat.format(Messages.BundleContainerTable_4, new String[] {e.getMessage()}); > } >- if (element instanceof IStatus) { >- return ((IStatus) element).getMessage(); >- } > return super.getText(element); > } > >@@ -80,15 +77,7 @@ > } else if (element instanceof ProfileBundleContainer) { > return PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PRODUCT_DEFINITION, flag); > } >- } else if (element instanceof IStatus) { >- int severity = ((IStatus) element).getSeverity(); >- if (severity == IStatus.WARNING) { >- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK); >- } else if (severity == IStatus.ERROR) { >- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); >- } > } >- > return super.getImage(element); > } > >Index: src/org/eclipse/pde/internal/ui/shared/target/EditBundleContainerWizard.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/EditBundleContainerWizard.java,v >retrieving revision 1.1 >diff -u -r1.1 EditBundleContainerWizard.java >--- src/org/eclipse/pde/internal/ui/shared/target/EditBundleContainerWizard.java 25 Feb 2009 17:16:22 -0000 1.1 >+++ src/org/eclipse/pde/internal/ui/shared/target/EditBundleContainerWizard.java 31 Mar 2009 21:45:08 -0000 >@@ -4,17 +4,14 @@ > import org.eclipse.jface.wizard.Wizard; > import org.eclipse.pde.internal.core.target.impl.*; > import org.eclipse.pde.internal.core.target.provisional.IBundleContainer; >-import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; > import org.eclipse.pde.internal.ui.PDEPlugin; > > public class EditBundleContainerWizard extends Wizard { > >- private ITargetDefinition fTarget; > private IBundleContainer fContainer; > private EditDirectoryContainerPage fPage; > >- public EditBundleContainerWizard(ITargetDefinition target, IBundleContainer container) { >- fTarget = target; >+ public EditBundleContainerWizard(IBundleContainer container) { > fContainer = container; > IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(AddBundleContainerSelectionPage.SETTINGS_SECTION); > if (settings == null) { >@@ -26,19 +23,20 @@ > > public void addPages() { > if (fContainer instanceof DirectoryBundleContainer) { >- fPage = new EditDirectoryContainerPage(fTarget, fContainer); >+ fPage = new EditDirectoryContainerPage(fContainer); > addPage(fPage); > } else if (fContainer instanceof ProfileBundleContainer) { >- fPage = new EditProfileContainerPage(fTarget, fContainer); >+ fPage = new EditProfileContainerPage(fContainer); > addPage(fPage); > } else if (fContainer instanceof FeatureBundleContainer) { >- fPage = new EditFeatureContainerPage(fTarget, fContainer); >+ fPage = new EditFeatureContainerPage(fContainer); > addPage(fPage); > } > } > > public boolean performFinish() { > if (fPage != null) { >+ fPage.storeSettings(); > fContainer = fPage.getBundleContainer(); > return true; > } >Index: src/org/eclipse/pde/internal/ui/shared/target/BundleContainerTable.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/BundleContainerTable.java,v >retrieving revision 1.16 >diff -u -r1.16 BundleContainerTable.java >--- src/org/eclipse/pde/internal/ui/shared/target/BundleContainerTable.java 27 Feb 2009 19:25:32 -0000 1.16 >+++ src/org/eclipse/pde/internal/ui/shared/target/BundleContainerTable.java 31 Mar 2009 21:45:08 -0000 >@@ -356,7 +356,7 @@ > } > if (oldContainer != null) { > Shell parent = fTreeViewer.getTree().getShell(); >- EditBundleContainerWizard wizard = new EditBundleContainerWizard(fTarget, oldContainer); >+ EditBundleContainerWizard wizard = new EditBundleContainerWizard(oldContainer); > WizardDialog dialog = new WizardDialog(parent, wizard); > if (dialog.open() == Window.OK) { > // Replace the old container with the new one >Index: src/org/eclipse/pde/internal/ui/shared/target/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties,v >retrieving revision 1.11 >diff -u -r1.11 messages.properties >--- src/org/eclipse/pde/internal/ui/shared/target/messages.properties 30 Mar 2009 21:17:09 -0000 1.11 >+++ src/org/eclipse/pde/internal/ui/shared/target/messages.properties 31 Mar 2009 21:45:08 -0000 >@@ -69,7 +69,6 @@ > EditBundleContainerWizard_0=Edit Content > EditDirectoryContainerPage_0=Edit Directory > EditDirectoryContainerPage_1=&Variables... >-EditDirectoryContainerPage_2=Included Plug-ins > EditDirectoryContainerPage_3=Resolve Container Job > EditFeatureContainerPage_0=Edit Feature > EditFeatureContainerPage_1=Edit the plug-ins included in this feature >Index: src/org/eclipse/pde/internal/ui/shared/target/Messages.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java,v >retrieving revision 1.9 >diff -u -r1.9 Messages.java >--- src/org/eclipse/pde/internal/ui/shared/target/Messages.java 30 Mar 2009 21:17:09 -0000 1.9 >+++ src/org/eclipse/pde/internal/ui/shared/target/Messages.java 31 Mar 2009 21:45:08 -0000 >@@ -63,7 +63,6 @@ > public static String EditBundleContainerWizard_0; > public static String EditDirectoryContainerPage_0; > public static String EditDirectoryContainerPage_1; >- public static String EditDirectoryContainerPage_2; > public static String EditDirectoryContainerPage_3; > public static String EditFeatureContainerPage_0; > public static String EditFeatureContainerPage_1; >Index: src/org/eclipse/pde/internal/ui/shared/target/IncludedBundlesTree.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/IncludedBundlesTree.java,v >retrieving revision 1.2 >diff -u -r1.2 IncludedBundlesTree.java >--- src/org/eclipse/pde/internal/ui/shared/target/IncludedBundlesTree.java 30 Mar 2009 21:17:09 -0000 1.2 >+++ src/org/eclipse/pde/internal/ui/shared/target/IncludedBundlesTree.java 31 Mar 2009 21:45:08 -0000 >@@ -1,598 +1,598 @@ >-package org.eclipse.pde.internal.ui.shared.target; >- >-import com.ibm.icu.text.MessageFormat; >-import java.io.File; >-import java.util.*; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; >-import org.eclipse.jface.viewers.*; >-import org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer; >-import org.eclipse.pde.internal.core.target.provisional.IBundleContainer; >-import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle; >-import org.eclipse.pde.internal.ui.PDEPlugin; >-import org.eclipse.pde.internal.ui.SWTFactory; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.SelectionAdapter; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.widgets.*; >-import org.eclipse.ui.dialogs.FilteredTree; >-import org.eclipse.ui.dialogs.PatternFilter; >- >-public class IncludedBundlesTree extends FilteredTree { >- >- private CheckboxTreeViewer fTree; >- private Button fSelectButton; >- private Button fDeselectButton; >- private Button fSelectAllButton; >- private Button fDeselectAllButton; >-// private Button fSelectRequiredButton; >- private Label fShowLabel; >- private Button fShowSourceButton; >- private Button fShowPluginsButton; >- private Label fCountLabel; >- private ViewerFilter fSourceFilter; >- private ViewerFilter fPluginFilter; >- private IResolvedBundle[] fAllBundles; >- private Button fGroupPlugins; >- private HashMap fTreeViewerContents; >- private boolean fIsGroupedByLocation; >- >- public IncludedBundlesTree(Composite parent) { >- super(parent, SWT.BORDER | SWT.MULTI, new PatternFilter(), true); >- } >- >- protected Control createTreeControl(Composite parent, int style) { >- fIsGroupedByLocation = false; >- Composite treeComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0); >- super.createTreeControl(treeComp, style); >- ((GridData) fTree.getControl().getLayoutData()).heightHint = 300; >- createButtons(treeComp); >- fCountLabel = SWTFactory.createLabel(treeComp, "", 2); //$NON-NLS-1$ >- updateButtons(); >- initializeFilters(); >- initializeTreeContents(fAllBundles); >- return treeComp; >- } >- >- protected void createButtons(Composite parent) { >- Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0); >- >- // TODO Add Mnemonics >- fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null); >- fSelectButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- if (!fTree.getSelection().isEmpty()) { >- Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray(); >- for (int i = 0; i < selected.length; i++) { >- if (fIsGroupedByLocation) { >- handleCheck(selected[i], true); >- } else { >- fTree.setChecked(selected[i], true); >- } >- } >- updateButtons(); >- } >- } >- }); >- fDeselectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null); >- fDeselectButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- if (!fTree.getSelection().isEmpty()) { >- Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray(); >- for (int i = 0; i < selected.length; i++) { >- if (fIsGroupedByLocation) { >- handleCheck(selected[i], false); >- } else { >- fTree.setChecked(selected[i], false); >- } >- } >- updateButtons(); >- } >- } >- }); >- >- createEmptySpace(buttonComp); >- >- fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null); >- fSelectAllButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- if (fIsGroupedByLocation) { >- Iterator iter = fTreeViewerContents.keySet().iterator(); >- while (iter.hasNext()) { >- handleCheck(iter.next(), true); >- } >- >- } else { >- // We only want to check visible >- fTree.setAllChecked(true); >- } >- >- updateButtons(); >- } >- }); >- fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null); >- fDeselectAllButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- >- if (fIsGroupedByLocation) { >- Iterator iter = fTreeViewerContents.keySet().iterator(); >- while (iter.hasNext()) { >- handleCheck(iter.next(), false); >- } >- >- } else { >- // We only want to uncheck visible >- fTree.setAllChecked(false); >- } >- updateButtons(); >- } >- }); >- >- createEmptySpace(buttonComp); >- >- // TODO Support selecting required. >-// fSelectRequiredButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_4, null); >-// fSelectRequiredButton.addSelectionListener(new SelectionAdapter() { >-// public void widgetSelected(SelectionEvent e) { >-// updateButtons(); >-// } >-// }); >- >- Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0); >- filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true)); >- >- fGroupPlugins = SWTFactory.createCheckButton(filterComp, Messages.IncludedBundlesTree_6, null, false, 1); >- fGroupPlugins.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- setEnabled(false); >- fIsGroupedByLocation = fGroupPlugins.getSelection(); >- Object[] checkedElements = fTree.getCheckedElements(); >- fTree.setContentProvider(getContentProviderForTree()); >- >- if (fIsGroupedByLocation) { >- fTree.expandAll(); >- fTree.setCheckedElements(checkedElements); >- Iterator iter = fTreeViewerContents.keySet().iterator(); >- HashMap bundles = null; >- Object key = null; >- >- while (iter.hasNext()) { >- key = iter.next(); >- bundles = (HashMap) fTreeViewerContents.get(key); >- >- Iterator childIter = bundles.keySet().iterator(); >- boolean allChilrenSelected = true; >- boolean noneChildrenSelected = true; >- while (childIter.hasNext()) { >- Object bundle = childIter.next(); >- boolean checkedState = ((Boolean) bundles.get(bundle)).booleanValue(); >- allChilrenSelected = allChilrenSelected && checkedState; >- noneChildrenSelected = noneChildrenSelected && !checkedState; >- >- } >- fTree.setChecked(key, !noneChildrenSelected); >- fTree.setGrayed(key, !allChilrenSelected && !noneChildrenSelected); >- } >- } >- updateButtons(); >- setEnabled(true); >- } >- }); >- fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1); >- >- fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1); >- fShowPluginsButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- if (!fShowPluginsButton.getSelection()) { >- fTree.addFilter(fPluginFilter); >- } else { >- fTree.removeFilter(fPluginFilter); >- } >- updateButtons(); >- } >- }); >- fShowPluginsButton.setSelection(true); >- GridData gd = new GridData(); >- gd.horizontalIndent = 10; >- fShowPluginsButton.setLayoutData(gd); >- >- fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1); >- fShowSourceButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- if (!fShowSourceButton.getSelection()) { >- fTree.addFilter(fSourceFilter); >- } else { >- fTree.removeFilter(fSourceFilter); >- } >- updateButtons(); >- } >- }); >- fShowSourceButton.setSelection(true); >- gd = new GridData(); >- gd.horizontalIndent = 10; >- fShowSourceButton.setLayoutData(gd); >- >- } >- >- /** >- * returns a HashMap which contains all the new File objects representing a new location >- */ >- protected HashMap initializeTreeContents(IResolvedBundle[] allBundles) { >- HashMap parents = new HashMap(); >- if (allBundles == null) >- return null; >- >- if (fTreeViewerContents == null) >- fTreeViewerContents = new HashMap(); >- else >- fTreeViewerContents.clear(); >- >- for (int i = 0; i < allBundles.length; i++) { >- IResolvedBundle bundle = allBundles[i]; >- >- String path = bundle.getBundleInfo().getLocation().getRawPath(); >- if (path != null) { >- File installFile = new File(path); >- File parentFile = installFile.getParentFile(); >- HashMap bundles = (HashMap) fTreeViewerContents.get(parentFile); >- if (bundles == null) { >- bundles = new HashMap(); >- bundles.put(bundle, new Boolean(fTree.getChecked(bundle))); >- fTreeViewerContents.put(parentFile, bundles); >- parents.put(parentFile, Boolean.FALSE); >- } else { >- bundles.put(bundle, new Boolean(fTree.getChecked(bundle))); >- } >- } >- } >- >- return parents; >- } >- >- private void initializeFilters() { >- fSourceFilter = new ViewerFilter() { >- public boolean select(Viewer viewer, Object parentElement, Object element) { >- if (element instanceof IResolvedBundle) { >- if (((IResolvedBundle) element).isSourceBundle()) { >- return false; >- } >- } >- return true; >- } >- }; >- fPluginFilter = new ViewerFilter() { >- public boolean select(Viewer viewer, Object parentElement, Object element) { >- if (element instanceof IResolvedBundle) { >- if (!((IResolvedBundle) element).isSourceBundle()) { >- return false; >- } >- } >- return true; >- } >- }; >- } >- >- private Label createEmptySpace(Composite parent) { >- Label label = new Label(parent, SWT.NONE); >- GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); >- gd.widthHint = gd.heightHint = 5; >- label.setLayoutData(gd); >- return label; >- } >- >- private void updateButtons() { >- if (fAllBundles != null && !fTree.getSelection().isEmpty()) { >- Object[] selection = ((IStructuredSelection) fTree.getSelection()).toArray(); >- boolean allSelected = true; >- boolean noneSelected = true; >- for (int i = 0; i < selection.length; i++) { >- boolean checked = fTree.getChecked(selection[i]); >- if (checked) { >- noneSelected = false; >- } else { >- allSelected = false; >- } >- } >- fSelectButton.setEnabled(!allSelected); >- fDeselectButton.setEnabled(!noneSelected); >-// fSelectRequiredButton.setEnabled(true); >- } else { >- fSelectButton.setEnabled(false); >- fDeselectButton.setEnabled(false); >-// fSelectRequiredButton.setEnabled(false); >- } >- >- int checked; >- if (fIsGroupedByLocation) { >- checked = fTree.getCheckedElements().length; >- Iterator iter = fTreeViewerContents.keySet().iterator(); >- while (iter.hasNext()) { >- if (fTree.getChecked(iter.next())) { >- --checked; >- } >- } >- } else { >- checked = fTree.getCheckedElements().length; >- } >- fSelectAllButton.setEnabled(fAllBundles != null && checked != fTree.getTree().getItemCount()); >- fDeselectAllButton.setEnabled(fAllBundles != null && checked != 0); >- >- if (fAllBundles != null) { >- fCountLabel.setText(MessageFormat.format(Messages.IncludedBundlesTree_5, new String[] {Integer.toString(checked), Integer.toString(fAllBundles.length)})); >- } else { >- fCountLabel.setText(""); //$NON-NLS-1$ >- } >- } >- >- /** >- * Set the container to display in the tree or <code>null</code> to disable the tree >- * @param input bundle container or <code>null</code> >- */ >- public void setInput(IBundleContainer input) { >- fAllBundles = null; >- >- // Check that the input is a container with valid, resolved bundles >- if (!(input instanceof AbstractBundleContainer)) { >- fTree.setInput(Messages.AddDirectoryContainerPage_7); >- setEnabled(false); >- return; >- } >- if (!input.isResolved()) { >- fTree.setInput(new Status(IStatus.ERROR, PDEPlugin.getPluginId(), Messages.BundleContainerTable_19)); >- setEnabled(false); >- return; >- } >- IStatus status = input.getBundleStatus(); >- if (!status.isOK() && !status.isMultiStatus()) { >- fTree.setInput(status); >- setEnabled(false); >- return; >- } >- IResolvedBundle[] allResolvedBundles = ((AbstractBundleContainer) input).getAllBundles(); >- if (allResolvedBundles == null || allResolvedBundles.length == 0) { >- fTree.setInput(Messages.AddDirectoryContainerPage_7); >- setEnabled(false); >- return; >- } >- >- // Input is valid, setup the tree >- fAllBundles = allResolvedBundles; >- fTree.setInput(allResolvedBundles); >- >- // Check the included bundles >- BundleInfo[] included = input.getIncludedBundles(); >- if (included == null) { >- fTree.setCheckedElements(fAllBundles); >- } else { >- Set includedBundles = new HashSet(); >- for (int i = 0; i < included.length; i++) { >- includedBundles.add(included[i].getSymbolicName()); >- } >- java.util.List toCheck = new ArrayList(includedBundles.size()); >- for (int i = 0; i < allResolvedBundles.length; i++) { >- if (includedBundles.contains(allResolvedBundles[i].getBundleInfo().getSymbolicName())) { >- toCheck.add(allResolvedBundles[i]); >- } >- } >- fTree.setCheckedElements(toCheck.toArray()); >- } >- >- // Enable the tree and update the buttons >- setEnabled(true); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.swt.widgets.Control#setEnabled(boolean) >- */ >- public void setEnabled(boolean enabled) { >- super.setEnabled(enabled); >- if (enabled) { >- updateButtons(); >- } else { >- fSelectButton.setEnabled(false); >- fSelectAllButton.setEnabled(false); >- fDeselectButton.setEnabled(false); >- fDeselectAllButton.setEnabled(false); >-// fSelectRequiredButton.setEnabled(false); >- fCountLabel.setText(""); //$NON-NLS-1$ >- } >- fShowLabel.setEnabled(enabled); >- fShowPluginsButton.setEnabled(enabled); >- fShowSourceButton.setEnabled(enabled); >- super.setEnabled(enabled); >- } >- >- protected TreeViewer doCreateTreeViewer(Composite parent, int style) { >- fTree = new CheckboxTreeViewer(parent, style) { >- public void refresh(boolean updateLabels) { >- super.refresh(updateLabels); >- if (updateLabels) { >- // We want to update the labels and buttons as users change the filtering >- updateButtons(); >- } >- } >- }; >- fTree.setContentProvider(getContentProviderForTree()); >- fTree.setLabelProvider(new BundleInfoLabelProvider(false)); >- fTree.addDoubleClickListener(new IDoubleClickListener() { >- public void doubleClick(DoubleClickEvent event) { >- IStructuredSelection selection = (IStructuredSelection) event.getSelection(); >- fTree.setChecked(selection.getFirstElement(), !fTree.getChecked(selection.getFirstElement())); >- updateButtons(); >- } >- }); >- fTree.addCheckStateListener(new ICheckStateListener() { >- >- public void checkStateChanged(CheckStateChangedEvent event) { >- if (fIsGroupedByLocation) { >- handleCheck(event.getElement(), event.getChecked()); >- updateButtons(); >- } >- } >- }); >- fTree.addSelectionChangedListener(new ISelectionChangedListener() { >- public void selectionChanged(SelectionChangedEvent event) { >- updateButtons(); >- } >- }); >- fTree.setSorter(new ViewerSorter()); >- return fTree; >- } >- >- /** >- * Marks the check state of <code>element</code> to <code>state</code> when plug-ins are grouped by location >- */ >- private void handleCheck(Object element, boolean state) { >- if (fTreeViewerContents.containsKey(element)) { >- >- HashMap bundles = (HashMap) fTreeViewerContents.get(element); >- Iterator iter = bundles.keySet().iterator(); >- while (iter.hasNext()) { >- Object key = iter.next(); >- bundles.put(key, new Boolean(state)); >- fTree.setChecked(key, state); >- } >- fTree.setChecked(element, state); >- fTree.setGrayed(element, false); >- return; >- } >- Iterator iter = fTreeViewerContents.keySet().iterator(); >- HashMap bundles = null; >- Object key = null; >- while (iter.hasNext()) { >- key = iter.next(); >- bundles = (HashMap) fTreeViewerContents.get(key); >- if (bundles.containsKey(element)) { >- bundles.put(element, new Boolean(state)); >- break; >- } >- } >- iter = bundles.keySet().iterator(); >- boolean allChilrenSelected = true; >- boolean noneChildrenSelected = true; >- while (iter.hasNext()) { >- Object bundle = iter.next(); >- boolean checkedState = ((Boolean) bundles.get(bundle)).booleanValue(); >- allChilrenSelected = allChilrenSelected && checkedState; >- noneChildrenSelected = noneChildrenSelected && !checkedState; >- } >- fTree.setChecked(element, state); >- fTree.setChecked(key, !noneChildrenSelected); >- fTree.setGrayed(key, !allChilrenSelected && !noneChildrenSelected); >- } >- >- private ITreeContentProvider getContentProviderForTree() { >- if (fIsGroupedByLocation) { >- >- //Content provider for grouped by location >- return (new ITreeContentProvider() { >- >- public Object[] getChildren(Object parentElement) { >- if (parentElement instanceof File) { >- HashMap files = (HashMap) fTreeViewerContents.get(parentElement); >- if (files != null) { >- Object[] result = files.keySet().toArray(); >- return result; >- } >- } >- return new Object[0]; >- } >- >- public Object getParent(Object element) { >- if (element instanceof IResolvedBundle) { >- IResolvedBundle bundle = (IResolvedBundle) element; >- String installPath = bundle.getBundleInfo().getLocation().getPath(); >- if (installPath != null) >- return new File(installPath).getParentFile(); >- } >- return null; >- } >- >- public boolean hasChildren(Object element) { >- if (element instanceof File) >- return fTreeViewerContents.containsKey(element); >- return false; >- } >- >- public Object[] getElements(Object inputElement) { >- if (fTreeViewerContents == null) >- return initializeTreeContents(fAllBundles).keySet().toArray(); >- return fTreeViewerContents.keySet().toArray(); >- } >- >- public void dispose() { >- } >- >- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >- } >- }); >- } >- >- //ungrouped content provider >- return (new ITreeContentProvider() { >- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >- } >- >- public void dispose() { >- } >- >- public Object[] getElements(Object inputElement) { >- if (inputElement instanceof IResolvedBundle[]) { >- return (IResolvedBundle[]) inputElement; >- } >- return new Object[] {inputElement}; >- } >- >- public boolean hasChildren(Object element) { >- return false; >- } >- >- public Object getParent(Object element) { >- return null; >- } >- >- public Object[] getChildren(Object parentElement) { >- return new Object[0]; >- } >- }); >- } >- >- /** >- * Return the set of bundles to include in this bundle container based on what is >- * checked in the tree. If all bundles in the container are checked or there was >- * a problem getting the bundles from the container, this method will return >- * <code>null</code> >- * >- * @return set of bundles to include or <code>null</code> >- */ >- public BundleInfo[] getIncludedBundles() { >- if (fTree.getControl().isEnabled() && fAllBundles != null) { >- Object[] checked = fTree.getCheckedElements(); >- if (fIsGroupedByLocation) { >- int count = fTree.getCheckedElements().length; >- Iterator iter = fTreeViewerContents.keySet().iterator(); >- while (iter.hasNext()) { >- if (fTree.getChecked(iter.next())) { >- --count; >- } >- } >- if (count == fAllBundles.length) >- return null; >- >- } else if (checked.length == fAllBundles.length) { >- return null; >- } >- >- java.util.List included = new ArrayList(checked.length); >- for (int i = 0; i < checked.length; i++) { >- if (checked[i] instanceof IResolvedBundle) { >- included.add(new BundleInfo(((IResolvedBundle) checked[i]).getBundleInfo().getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false)); >- } >- } >- return (BundleInfo[]) included.toArray(new BundleInfo[included.size()]); >- } >- return null; >- } >-} >+package org.eclipse.pde.internal.ui.shared.target; >+ >+import com.ibm.icu.text.MessageFormat; >+import java.io.File; >+import java.util.*; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; >+import org.eclipse.jface.viewers.*; >+import org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer; >+import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle; >+import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; >+import org.eclipse.pde.internal.ui.PDEPlugin; >+import org.eclipse.pde.internal.ui.SWTFactory; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.ui.dialogs.FilteredTree; >+import org.eclipse.ui.dialogs.PatternFilter; >+ >+public class IncludedBundlesTree extends FilteredTree { >+ >+ private CheckboxTreeViewer fTree; >+ private Button fSelectButton; >+ private Button fDeselectButton; >+ private Button fSelectAllButton; >+ private Button fDeselectAllButton; >+// private Button fSelectRequiredButton; >+ private Label fShowLabel; >+ private Button fShowSourceButton; >+ private Button fShowPluginsButton; >+ private Label fCountLabel; >+ private ViewerFilter fSourceFilter; >+ private ViewerFilter fPluginFilter; >+ private IResolvedBundle[] fAllBundles; >+ private Button fGroupPlugins; >+ private HashMap fTreeViewerContents; >+ private boolean fIsGroupedByLocation; >+ >+ public IncludedBundlesTree(Composite parent) { >+ super(parent, SWT.BORDER | SWT.MULTI, new PatternFilter(), true); >+ } >+ >+ protected Control createTreeControl(Composite parent, int style) { >+ fIsGroupedByLocation = false; >+ Composite treeComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0); >+ super.createTreeControl(treeComp, style); >+ ((GridData) fTree.getControl().getLayoutData()).heightHint = 300; >+ createButtons(treeComp); >+ fCountLabel = SWTFactory.createLabel(treeComp, "", 2); //$NON-NLS-1$ >+ updateButtons(); >+ initializeFilters(); >+ initializeTreeContents(fAllBundles); >+ return treeComp; >+ } >+ >+ protected void createButtons(Composite parent) { >+ Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0); >+ >+ // TODO Add Mnemonics >+ fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null); >+ fSelectButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ if (!fTree.getSelection().isEmpty()) { >+ Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray(); >+ for (int i = 0; i < selected.length; i++) { >+ if (fIsGroupedByLocation) { >+ handleCheck(selected[i], true); >+ } else { >+ fTree.setChecked(selected[i], true); >+ } >+ } >+ updateButtons(); >+ } >+ } >+ }); >+ fDeselectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null); >+ fDeselectButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ if (!fTree.getSelection().isEmpty()) { >+ Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray(); >+ for (int i = 0; i < selected.length; i++) { >+ if (fIsGroupedByLocation) { >+ handleCheck(selected[i], false); >+ } else { >+ fTree.setChecked(selected[i], false); >+ } >+ } >+ updateButtons(); >+ } >+ } >+ }); >+ >+ createEmptySpace(buttonComp); >+ >+ fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null); >+ fSelectAllButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ if (fIsGroupedByLocation) { >+ Iterator iter = fTreeViewerContents.keySet().iterator(); >+ while (iter.hasNext()) { >+ handleCheck(iter.next(), true); >+ } >+ >+ } else { >+ // We only want to check visible >+ fTree.setAllChecked(true); >+ } >+ >+ updateButtons(); >+ } >+ }); >+ fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null); >+ fDeselectAllButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ >+ if (fIsGroupedByLocation) { >+ Iterator iter = fTreeViewerContents.keySet().iterator(); >+ while (iter.hasNext()) { >+ handleCheck(iter.next(), false); >+ } >+ >+ } else { >+ // We only want to uncheck visible >+ fTree.setAllChecked(false); >+ } >+ updateButtons(); >+ } >+ }); >+ >+ createEmptySpace(buttonComp); >+ >+ // TODO Support selecting required. >+// fSelectRequiredButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_4, null); >+// fSelectRequiredButton.addSelectionListener(new SelectionAdapter() { >+// public void widgetSelected(SelectionEvent e) { >+// updateButtons(); >+// } >+// }); >+ >+ Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0); >+ filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true)); >+ >+ fGroupPlugins = SWTFactory.createCheckButton(filterComp, Messages.IncludedBundlesTree_6, null, false, 1); >+ fGroupPlugins.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ setEnabled(false); >+ fIsGroupedByLocation = fGroupPlugins.getSelection(); >+ Object[] checkedElements = fTree.getCheckedElements(); >+ fTree.setContentProvider(getContentProviderForTree()); >+ >+ if (fIsGroupedByLocation) { >+ fTree.expandAll(); >+ fTree.setCheckedElements(checkedElements); >+ Iterator iter = fTreeViewerContents.keySet().iterator(); >+ HashMap bundles = null; >+ Object key = null; >+ >+ while (iter.hasNext()) { >+ key = iter.next(); >+ bundles = (HashMap) fTreeViewerContents.get(key); >+ >+ Iterator childIter = bundles.keySet().iterator(); >+ boolean allChilrenSelected = true; >+ boolean noneChildrenSelected = true; >+ while (childIter.hasNext()) { >+ Object bundle = childIter.next(); >+ boolean checkedState = ((Boolean) bundles.get(bundle)).booleanValue(); >+ allChilrenSelected = allChilrenSelected && checkedState; >+ noneChildrenSelected = noneChildrenSelected && !checkedState; >+ >+ } >+ fTree.setChecked(key, !noneChildrenSelected); >+ fTree.setGrayed(key, !allChilrenSelected && !noneChildrenSelected); >+ } >+ } >+ updateButtons(); >+ setEnabled(true); >+ } >+ }); >+ fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1); >+ >+ fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1); >+ fShowPluginsButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ if (!fShowPluginsButton.getSelection()) { >+ fTree.addFilter(fPluginFilter); >+ } else { >+ fTree.removeFilter(fPluginFilter); >+ } >+ updateButtons(); >+ } >+ }); >+ fShowPluginsButton.setSelection(true); >+ GridData gd = new GridData(); >+ gd.horizontalIndent = 10; >+ fShowPluginsButton.setLayoutData(gd); >+ >+ fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1); >+ fShowSourceButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ if (!fShowSourceButton.getSelection()) { >+ fTree.addFilter(fSourceFilter); >+ } else { >+ fTree.removeFilter(fSourceFilter); >+ } >+ updateButtons(); >+ } >+ }); >+ fShowSourceButton.setSelection(true); >+ gd = new GridData(); >+ gd.horizontalIndent = 10; >+ fShowSourceButton.setLayoutData(gd); >+ >+ } >+ >+ /** >+ * returns a HashMap which contains all the new File objects representing a new location >+ */ >+ protected HashMap initializeTreeContents(IResolvedBundle[] allBundles) { >+ HashMap parents = new HashMap(); >+ if (allBundles == null) >+ return null; >+ >+ if (fTreeViewerContents == null) >+ fTreeViewerContents = new HashMap(); >+ else >+ fTreeViewerContents.clear(); >+ >+ for (int i = 0; i < allBundles.length; i++) { >+ IResolvedBundle bundle = allBundles[i]; >+ >+ String path = bundle.getBundleInfo().getLocation().getRawPath(); >+ if (path != null) { >+ File installFile = new File(path); >+ File parentFile = installFile.getParentFile(); >+ HashMap bundles = (HashMap) fTreeViewerContents.get(parentFile); >+ if (bundles == null) { >+ bundles = new HashMap(); >+ bundles.put(bundle, new Boolean(fTree.getChecked(bundle))); >+ fTreeViewerContents.put(parentFile, bundles); >+ parents.put(parentFile, Boolean.FALSE); >+ } else { >+ bundles.put(bundle, new Boolean(fTree.getChecked(bundle))); >+ } >+ } >+ } >+ >+ return parents; >+ } >+ >+ private void initializeFilters() { >+ fSourceFilter = new ViewerFilter() { >+ public boolean select(Viewer viewer, Object parentElement, Object element) { >+ if (element instanceof IResolvedBundle) { >+ if (((IResolvedBundle) element).isSourceBundle()) { >+ return false; >+ } >+ } >+ return true; >+ } >+ }; >+ fPluginFilter = new ViewerFilter() { >+ public boolean select(Viewer viewer, Object parentElement, Object element) { >+ if (element instanceof IResolvedBundle) { >+ if (!((IResolvedBundle) element).isSourceBundle()) { >+ return false; >+ } >+ } >+ return true; >+ } >+ }; >+ } >+ >+ private Label createEmptySpace(Composite parent) { >+ Label label = new Label(parent, SWT.NONE); >+ GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); >+ gd.widthHint = gd.heightHint = 5; >+ label.setLayoutData(gd); >+ return label; >+ } >+ >+ private void updateButtons() { >+ if (fAllBundles != null && !fTree.getSelection().isEmpty()) { >+ Object[] selection = ((IStructuredSelection) fTree.getSelection()).toArray(); >+ boolean allSelected = true; >+ boolean noneSelected = true; >+ for (int i = 0; i < selection.length; i++) { >+ boolean checked = fTree.getChecked(selection[i]); >+ if (checked) { >+ noneSelected = false; >+ } else { >+ allSelected = false; >+ } >+ } >+ fSelectButton.setEnabled(!allSelected); >+ fDeselectButton.setEnabled(!noneSelected); >+// fSelectRequiredButton.setEnabled(true); >+ } else { >+ fSelectButton.setEnabled(false); >+ fDeselectButton.setEnabled(false); >+// fSelectRequiredButton.setEnabled(false); >+ } >+ >+ int checked; >+ if (fIsGroupedByLocation) { >+ checked = fTree.getCheckedElements().length; >+ Iterator iter = fTreeViewerContents.keySet().iterator(); >+ while (iter.hasNext()) { >+ if (fTree.getChecked(iter.next())) { >+ --checked; >+ } >+ } >+ } else { >+ checked = fTree.getCheckedElements().length; >+ } >+ fSelectAllButton.setEnabled(fAllBundles != null && checked != fTree.getTree().getItemCount()); >+ fDeselectAllButton.setEnabled(fAllBundles != null && checked != 0); >+ >+ if (fAllBundles != null) { >+ fCountLabel.setText(MessageFormat.format(Messages.IncludedBundlesTree_5, new String[] {Integer.toString(checked), Integer.toString(fAllBundles.length)})); >+ } else { >+ fCountLabel.setText(""); //$NON-NLS-1$ >+ } >+ } >+ >+ /** >+ * Set the container to display in the tree or <code>null</code> to disable the tree >+ * @param input bundle container or <code>null</code> >+ */ >+ public void setInput(ITargetDefinition input) { >+ fAllBundles = null; >+ >+ // Check that the input is a container with valid, resolved bundles >+ if (!(input instanceof AbstractBundleContainer)) { >+ fTree.setInput(Messages.AddDirectoryContainerPage_7); >+ setEnabled(false); >+ return; >+ } >+ if (!input.isResolved()) { >+ fTree.setInput(new Status(IStatus.ERROR, PDEPlugin.getPluginId(), Messages.BundleContainerTable_19)); >+ setEnabled(false); >+ return; >+ } >+ IStatus status = input.getBundleStatus(); >+ if (!status.isOK() && !status.isMultiStatus()) { >+ fTree.setInput(status); >+ setEnabled(false); >+ return; >+ } >+ IResolvedBundle[] allResolvedBundles = ((AbstractBundleContainer) input).getAllBundles(); >+ if (allResolvedBundles == null || allResolvedBundles.length == 0) { >+ fTree.setInput(Messages.AddDirectoryContainerPage_7); >+ setEnabled(false); >+ return; >+ } >+ >+ // Input is valid, setup the tree >+ fAllBundles = allResolvedBundles; >+ fTree.setInput(allResolvedBundles); >+ >+ // Check the included bundles >+ BundleInfo[] included = input.getIncludedBundles(); >+ if (included == null) { >+ fTree.setCheckedElements(fAllBundles); >+ } else { >+ Set includedBundles = new HashSet(); >+ for (int i = 0; i < included.length; i++) { >+ includedBundles.add(included[i].getSymbolicName()); >+ } >+ java.util.List toCheck = new ArrayList(includedBundles.size()); >+ for (int i = 0; i < allResolvedBundles.length; i++) { >+ if (includedBundles.contains(allResolvedBundles[i].getBundleInfo().getSymbolicName())) { >+ toCheck.add(allResolvedBundles[i]); >+ } >+ } >+ fTree.setCheckedElements(toCheck.toArray()); >+ } >+ >+ // Enable the tree and update the buttons >+ setEnabled(true); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.swt.widgets.Control#setEnabled(boolean) >+ */ >+ public void setEnabled(boolean enabled) { >+ super.setEnabled(enabled); >+ if (enabled) { >+ updateButtons(); >+ } else { >+ fSelectButton.setEnabled(false); >+ fSelectAllButton.setEnabled(false); >+ fDeselectButton.setEnabled(false); >+ fDeselectAllButton.setEnabled(false); >+// fSelectRequiredButton.setEnabled(false); >+ fCountLabel.setText(""); //$NON-NLS-1$ >+ } >+ fShowLabel.setEnabled(enabled); >+ fShowPluginsButton.setEnabled(enabled); >+ fShowSourceButton.setEnabled(enabled); >+ super.setEnabled(enabled); >+ } >+ >+ protected TreeViewer doCreateTreeViewer(Composite parent, int style) { >+ fTree = new CheckboxTreeViewer(parent, style) { >+ public void refresh(boolean updateLabels) { >+ super.refresh(updateLabels); >+ if (updateLabels) { >+ // We want to update the labels and buttons as users change the filtering >+ updateButtons(); >+ } >+ } >+ }; >+ fTree.setContentProvider(getContentProviderForTree()); >+ fTree.setLabelProvider(new BundleInfoLabelProvider(false)); >+ fTree.addDoubleClickListener(new IDoubleClickListener() { >+ public void doubleClick(DoubleClickEvent event) { >+ IStructuredSelection selection = (IStructuredSelection) event.getSelection(); >+ fTree.setChecked(selection.getFirstElement(), !fTree.getChecked(selection.getFirstElement())); >+ updateButtons(); >+ } >+ }); >+ fTree.addCheckStateListener(new ICheckStateListener() { >+ >+ public void checkStateChanged(CheckStateChangedEvent event) { >+ if (fIsGroupedByLocation) { >+ handleCheck(event.getElement(), event.getChecked()); >+ updateButtons(); >+ } >+ } >+ }); >+ fTree.addSelectionChangedListener(new ISelectionChangedListener() { >+ public void selectionChanged(SelectionChangedEvent event) { >+ updateButtons(); >+ } >+ }); >+ fTree.setSorter(new ViewerSorter()); >+ return fTree; >+ } >+ >+ /** >+ * Marks the check state of <code>element</code> to <code>state</code> when plug-ins are grouped by location >+ */ >+ private void handleCheck(Object element, boolean state) { >+ if (fTreeViewerContents.containsKey(element)) { >+ >+ HashMap bundles = (HashMap) fTreeViewerContents.get(element); >+ Iterator iter = bundles.keySet().iterator(); >+ while (iter.hasNext()) { >+ Object key = iter.next(); >+ bundles.put(key, new Boolean(state)); >+ fTree.setChecked(key, state); >+ } >+ fTree.setChecked(element, state); >+ fTree.setGrayed(element, false); >+ return; >+ } >+ Iterator iter = fTreeViewerContents.keySet().iterator(); >+ HashMap bundles = null; >+ Object key = null; >+ while (iter.hasNext()) { >+ key = iter.next(); >+ bundles = (HashMap) fTreeViewerContents.get(key); >+ if (bundles.containsKey(element)) { >+ bundles.put(element, new Boolean(state)); >+ break; >+ } >+ } >+ iter = bundles.keySet().iterator(); >+ boolean allChilrenSelected = true; >+ boolean noneChildrenSelected = true; >+ while (iter.hasNext()) { >+ Object bundle = iter.next(); >+ boolean checkedState = ((Boolean) bundles.get(bundle)).booleanValue(); >+ allChilrenSelected = allChilrenSelected && checkedState; >+ noneChildrenSelected = noneChildrenSelected && !checkedState; >+ } >+ fTree.setChecked(element, state); >+ fTree.setChecked(key, !noneChildrenSelected); >+ fTree.setGrayed(key, !allChilrenSelected && !noneChildrenSelected); >+ } >+ >+ private ITreeContentProvider getContentProviderForTree() { >+ if (fIsGroupedByLocation) { >+ >+ //Content provider for grouped by location >+ return (new ITreeContentProvider() { >+ >+ public Object[] getChildren(Object parentElement) { >+ if (parentElement instanceof File) { >+ HashMap files = (HashMap) fTreeViewerContents.get(parentElement); >+ if (files != null) { >+ Object[] result = files.keySet().toArray(); >+ return result; >+ } >+ } >+ return new Object[0]; >+ } >+ >+ public Object getParent(Object element) { >+ if (element instanceof IResolvedBundle) { >+ IResolvedBundle bundle = (IResolvedBundle) element; >+ String installPath = bundle.getBundleInfo().getLocation().getPath(); >+ if (installPath != null) >+ return new File(installPath).getParentFile(); >+ } >+ return null; >+ } >+ >+ public boolean hasChildren(Object element) { >+ if (element instanceof File) >+ return fTreeViewerContents.containsKey(element); >+ return false; >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ if (fTreeViewerContents == null) >+ return initializeTreeContents(fAllBundles).keySet().toArray(); >+ return fTreeViewerContents.keySet().toArray(); >+ } >+ >+ public void dispose() { >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } >+ }); >+ } >+ >+ //ungrouped content provider >+ return (new ITreeContentProvider() { >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } >+ >+ public void dispose() { >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ if (inputElement instanceof IResolvedBundle[]) { >+ return (IResolvedBundle[]) inputElement; >+ } >+ return new Object[] {inputElement}; >+ } >+ >+ public boolean hasChildren(Object element) { >+ return false; >+ } >+ >+ public Object getParent(Object element) { >+ return null; >+ } >+ >+ public Object[] getChildren(Object parentElement) { >+ return new Object[0]; >+ } >+ }); >+ } >+ >+ /** >+ * Return the set of bundles to include in this bundle container based on what is >+ * checked in the tree. If all bundles in the container are checked or there was >+ * a problem getting the bundles from the container, this method will return >+ * <code>null</code> >+ * >+ * @return set of bundles to include or <code>null</code> >+ */ >+ public BundleInfo[] getIncludedBundles() { >+ if (fTree.getControl().isEnabled() && fAllBundles != null) { >+ Object[] checked = fTree.getCheckedElements(); >+ if (fIsGroupedByLocation) { >+ int count = fTree.getCheckedElements().length; >+ Iterator iter = fTreeViewerContents.keySet().iterator(); >+ while (iter.hasNext()) { >+ if (fTree.getChecked(iter.next())) { >+ --count; >+ } >+ } >+ if (count == fAllBundles.length) >+ return null; >+ >+ } else if (checked.length == fAllBundles.length) { >+ return null; >+ } >+ >+ java.util.List included = new ArrayList(checked.length); >+ for (int i = 0; i < checked.length; i++) { >+ if (checked[i] instanceof IResolvedBundle) { >+ included.add(new BundleInfo(((IResolvedBundle) checked[i]).getBundleInfo().getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false)); >+ } >+ } >+ return (BundleInfo[]) included.toArray(new BundleInfo[included.size()]); >+ } >+ return null; >+ } >+} >Index: src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerSelectionPage.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerSelectionPage.java,v >retrieving revision 1.10 >diff -u -r1.10 AddBundleContainerSelectionPage.java >--- src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerSelectionPage.java 4 Mar 2009 17:56:28 -0000 1.10 >+++ src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerSelectionPage.java 31 Mar 2009 21:45:08 -0000 >@@ -163,18 +163,24 @@ > standardChoices.add(new AbstractBundleContainerNode(Messages.AddBundleContainerSelectionPage_3, Messages.AddBundleContainerSelectionPage_4, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER)) { > public IWizard createWizard() { > Wizard wizard = new Wizard() { >+ private EditDirectoryContainerPage fPage1; >+ > public void addPages() { > IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION); > if (settings == null) { > settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION); > } > setDialogSettings(settings); >- addPage(new EditDirectoryContainerPage(fTarget)); >+ fPage1 = new EditDirectoryContainerPage(); >+ addPage(fPage1); >+ addPage(new PreviewContainerPage(fTarget, fPage1)); >+ setNeedsProgressMonitor(true); > } > > public boolean performFinish() { >- IBundleContainer container = ((EditDirectoryContainerPage) getPages()[0]).getBundleContainer(); >+ IBundleContainer container = fPage1.getBundleContainer(); > if (container != null) { >+ fPage1.storeSettings(); > IBundleContainer[] oldContainers = fTarget.getBundleContainers(); > if (oldContainers == null) { > fTarget.setBundleContainers(new IBundleContainer[] {container}); >@@ -195,18 +201,25 @@ > standardChoices.add(new AbstractBundleContainerNode(Messages.AddBundleContainerSelectionPage_6, Messages.AddBundleContainerSelectionPage_7, PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PRODUCT_DEFINITION)) { > public IWizard createWizard() { > Wizard wizard = new Wizard() { >+ private EditDirectoryContainerPage fPage1; >+ > public void addPages() { > IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION); > if (settings == null) { > settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION); > } > setDialogSettings(settings); >- addPage(new EditProfileContainerPage(fTarget)); >+ setDialogSettings(settings); >+ fPage1 = new EditProfileContainerPage(); >+ addPage(fPage1); >+ addPage(new PreviewContainerPage(fTarget, fPage1)); >+ setNeedsProgressMonitor(true); > } > > public boolean performFinish() { > IBundleContainer container = ((EditProfileContainerPage) getPages()[0]).getBundleContainer(); > if (container != null) { >+ ((EditProfileContainerPage) getPages()[0]).storeSettings(); > IBundleContainer[] oldContainers = fTarget.getBundleContainers(); > if (oldContainers == null) { > fTarget.setBundleContainers(new IBundleContainer[] {container}); >@@ -233,13 +246,14 @@ > settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION); > } > setDialogSettings(settings); >- addPage(new AddFeatureContainersPage(fTarget)); >+ addPage(new AddFeatureContainersPage()); > } > > public boolean performFinish() { > try { > IBundleContainer[] containers = ((AddFeatureContainersPage) getPages()[0]).getBundleContainers(); > if (containers != null) { >+ ((AddFeatureContainersPage) getPages()[0]).storeSettings(); > IBundleContainer[] oldContainers = fTarget.getBundleContainers(); > // TODO: show progress as resolving > for (int i = 0; i < containers.length; i++) { >@@ -266,6 +280,38 @@ > return wizard; > } > }); >+// standardChoices.add(new AbstractBundleContainerNode("Repository or Update Site", "Download plug-ins from a p2 repository or update site.", PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_REPOSITORY_OBJ)) { >+// public IWizard createWizard() { >+// Wizard wizard = new Wizard() { >+// public void addPages() { >+// IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION); >+// if (settings == null) { >+// settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION); >+// } >+// setDialogSettings(settings); >+// addPage(new AddP2ContainerPage()); >+// } >+// >+// public boolean performFinish() { >+// IBundleContainer container = ((AddP2ContainerPage) getPages()[0]).getBundleContainer(); >+// if (container != null) { >+// IBundleContainer[] oldContainers = fTarget.getBundleContainers(); >+// if (oldContainers == null) { >+// fTarget.setBundleContainers(new IBundleContainer[] {container}); >+// } else { >+// IBundleContainer[] newContainers = new IBundleContainer[oldContainers.length + 1]; >+// System.arraycopy(oldContainers, 0, newContainers, 0, oldContainers.length); >+// newContainers[newContainers.length - 1] = container; >+// fTarget.setBundleContainers(newContainers); >+// } >+// } >+// return true; >+// } >+// }; >+// wizard.setWindowTitle(Messages.AddBundleContainerSelectionPage_1); >+// return wizard; >+// } >+// }); > return standardChoices; > } > >Index: src/org/eclipse/pde/internal/ui/shared/target/AddFeatureContainersPage.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/AddFeatureContainersPage.java,v >retrieving revision 1.3 >diff -u -r1.3 AddFeatureContainersPage.java >--- src/org/eclipse/pde/internal/ui/shared/target/AddFeatureContainersPage.java 6 Mar 2009 17:30:32 -0000 1.3 >+++ src/org/eclipse/pde/internal/ui/shared/target/AddFeatureContainersPage.java 31 Mar 2009 21:45:08 -0000 >@@ -21,7 +21,6 @@ > import org.eclipse.pde.internal.core.feature.ExternalFeatureModel; > import org.eclipse.pde.internal.core.ifeature.IFeatureModel; > import org.eclipse.pde.internal.core.target.provisional.IBundleContainer; >-import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; > import org.eclipse.pde.internal.ui.*; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.SelectionAdapter; >@@ -44,10 +43,6 @@ > private Button fIncludeVersionButton; > private CheckboxTableViewer fFeatureTable; > >- protected AddFeatureContainersPage(ITargetDefinition target) { >- super(target); >- } >- > /* (non-Javadoc) > * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#getDefaultTitle() > */ >@@ -63,11 +58,21 @@ > } > > /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#createLocationArea(org.eclipse.swt.widgets.Composite) >+ */ >+ protected void createLocationArea(Composite parent) { >+ super.createLocationArea(parent); >+ createTableArea(parent); >+ } >+ >+ /* (non-Javadoc) > * @see org.eclipse.pde.internal.ui.shared.target.AddDirectoryContainerPage#createTableArea(org.eclipse.swt.widgets.Composite) > */ > protected void createTableArea(Composite parent) { > Composite tableComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0); > >+ SWTFactory.createLabel(tableComp, "Features:", 2); >+ > fFeatureTable = CheckboxTableViewer.newCheckList(tableComp, SWT.BORDER); > // Connect the label provider > PDEPlugin.getDefault().getLabelProvider().connect(this); >Index: src/org/eclipse/pde/internal/ui/shared/target/EditDirectoryContainerPage.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/EditDirectoryContainerPage.java,v >retrieving revision 1.3 >diff -u -r1.3 EditDirectoryContainerPage.java >--- src/org/eclipse/pde/internal/ui/shared/target/EditDirectoryContainerPage.java 6 Mar 2009 17:30:32 -0000 1.3 >+++ src/org/eclipse/pde/internal/ui/shared/target/EditDirectoryContainerPage.java 31 Mar 2009 21:45:08 -0000 >@@ -23,11 +23,11 @@ > import org.eclipse.pde.internal.core.PDECore; > import org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer; > import org.eclipse.pde.internal.core.target.impl.DirectoryBundleContainer; >-import org.eclipse.pde.internal.core.target.provisional.*; >+import org.eclipse.pde.internal.core.target.provisional.IBundleContainer; >+import org.eclipse.pde.internal.core.target.provisional.ITargetPlatformService; > import org.eclipse.pde.internal.ui.PDEPlugin; > import org.eclipse.pde.internal.ui.SWTFactory; > import org.eclipse.swt.SWT; >-import org.eclipse.swt.custom.BusyIndicator; > import org.eclipse.swt.events.*; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.widgets.*; >@@ -42,12 +42,14 @@ > */ > public class EditDirectoryContainerPage extends WizardPage { > >- protected static final int TYPING_DELAY = 600; >+ /** >+ * How long to wait before validating the directory >+ */ >+ protected static final int TYPING_DELAY = 200; >+ > private static ITargetPlatformService fTargetService; > protected Combo fInstallLocation; >- protected IncludedBundlesTree fBundleTree; > protected IBundleContainer fContainer; >- private ITargetDefinition fTarget; > private Job fTextChangedJob; > > /** >@@ -65,14 +67,13 @@ > */ > private static final String SETTINGS_LOCATION_3 = "location3"; //$NON-NLS-1$ > >- protected EditDirectoryContainerPage(ITargetDefinition target, IBundleContainer container) { >- this(target); >+ protected EditDirectoryContainerPage(IBundleContainer container) { >+ this(); > fContainer = container; > } > >- protected EditDirectoryContainerPage(ITargetDefinition target) { >+ protected EditDirectoryContainerPage() { > super("EditDirectoryContainer"); //$NON-NLS-1$ >- fTarget = target; > } > > /* (non-Javadoc) >@@ -81,9 +82,9 @@ > public void createControl(Composite parent) { > setMessage(getDefaultMessage()); > setTitle(getDefaultTitle()); >+ setPageComplete(false); > Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0); > createLocationArea(comp); >- createTableArea(comp); > setControl(comp); > initializeInputFields(fContainer); > } >@@ -171,18 +172,6 @@ > } > > /** >- * Creates the area at the bottom of the page. Contains a table intended to display >- * the current resolved bundles. This class may be overridden by subclasses to >- * provide custom widgets. >- * @param parent parent composite >- */ >- protected void createTableArea(Composite parent) { >- Group tableGroup = SWTFactory.createGroup(parent, Messages.EditDirectoryContainerPage_2, 2, 1, GridData.FILL_BOTH); >- fBundleTree = new IncludedBundlesTree(tableGroup); >- fBundleTree.setInput(null); >- } >- >- /** > * Initializes the fields use to describe the container. They should be filled in using > * the given container or set to default values if the container is <code>null</code>. > * @param container bundle container being edited, possibly <code>null</code> >@@ -246,6 +235,7 @@ > > /** > * Store all of the dialog settings for this page >+ * Should be explicitly called during the perform finish call of the wizard > */ > protected void storeSettings() { > String newLocation = fInstallLocation.getText().trim(); >@@ -275,6 +265,13 @@ > } > > /** >+ * @return bundle container created/edited in this wizard or <code>null</code> >+ */ >+ public IBundleContainer getBundleContainer() { >+ return fContainer; >+ } >+ >+ /** > * Called whenever the location or another aspect of the container has changed > * in the UI. Will schedule a UIJob to verify and resolve the container > * reporting any problems to the user. If a previous job is running or sleeping >@@ -284,7 +281,7 @@ > */ > protected void containerChanged(long delay) { > if (fTextChangedJob == null) { >- fTextChangedJob = new ResolveJob(getShell().getDisplay(), Messages.EditDirectoryContainerPage_3); >+ fTextChangedJob = new CreateContainerJob(getShell().getDisplay(), Messages.EditDirectoryContainerPage_3); > } else { > fTextChangedJob.cancel(); > } >@@ -301,7 +298,6 @@ > protected boolean validateInput() throws CoreException { > // Check if the text field is blank > if (fInstallLocation.getText().trim().length() == 0) { >- fBundleTree.setInput(null); > setMessage(getDefaultMessage()); > setPageComplete(false); > return false; >@@ -313,7 +309,6 @@ > > // Check if directory exists > if (!location.isDirectory()) { >- fBundleTree.setInput(null); > setMessage(Messages.AddDirectoryContainerPage_6, IMessageProvider.WARNING); > setPageComplete(true); > } else { >@@ -356,24 +351,8 @@ > return fTargetService; > } > >- /** >- * Returns the bundle container created by this wizard page with the >- * included bundles set on it based on what is checked in the tree. >- * Will return <code>null</code> if there was a problem creating the >- * bundle container. >- * >- * @return bundle container or <code>null</code> >- * >- */ >- public IBundleContainer getBundleContainer() { >- if (fBundleTree != null) { >- fContainer.setIncludedBundles(fBundleTree.getIncludedBundles()); >- } >- return fContainer; >- } >- >- private class ResolveJob extends UIJob { >- public ResolveJob(Display jobDisplay, String name) { >+ private class CreateContainerJob extends UIJob { >+ public CreateContainerJob(Display jobDisplay, String name) { > super(jobDisplay, name); > } > >@@ -387,33 +366,14 @@ > if (validateInput()) { > // Create a container from the input > fContainer = refreshContainer(fContainer); >- if (fContainer != null) { >- // Resolve the container >- BusyIndicator.showWhile(getDisplay(), new Runnable() { >- public void run() { >- IStatus result = fContainer.isResolved() ? Status.OK_STATUS : fContainer.resolve(fTarget, null); >- >- if (!result.isOK() && !result.isMultiStatus()) { >- // There was a specific problem preventing the resolution, warn the user >- fBundleTree.setInput(null); >- setMessage(result.getMessage(), IMessageProvider.WARNING); >- } else { >- // Resolution was successful >- fBundleTree.setInput(fContainer); >- setPageComplete(true); >- } >- } >- }); >- // Store the input into dialog settings as it is valid >- storeSettings(); >- } >+ setPageComplete(true); > } else { > fContainer = null; >+ setPageComplete(false); > } > return Status.OK_STATUS; > } catch (CoreException e) { > fContainer = null; >- fBundleTree.setInput(null); > setErrorMessage(e.getMessage()); > setPageComplete(false); > return e.getStatus(); >Index: src/org/eclipse/pde/internal/ui/shared/target/EditFeatureContainerPage.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/EditFeatureContainerPage.java,v >retrieving revision 1.2 >diff -u -r1.2 EditFeatureContainerPage.java >--- src/org/eclipse/pde/internal/ui/shared/target/EditFeatureContainerPage.java 4 Mar 2009 17:56:28 -0000 1.2 >+++ src/org/eclipse/pde/internal/ui/shared/target/EditFeatureContainerPage.java 31 Mar 2009 21:45:08 -0000 >@@ -3,7 +3,6 @@ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.pde.internal.core.target.impl.FeatureBundleContainer; > import org.eclipse.pde.internal.core.target.provisional.IBundleContainer; >-import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; > import org.eclipse.pde.internal.ui.PDEPlugin; > import org.eclipse.pde.internal.ui.SWTFactory; > import org.eclipse.swt.SWT; >@@ -13,8 +12,8 @@ > > public class EditFeatureContainerPage extends EditDirectoryContainerPage { > >- public EditFeatureContainerPage(ITargetDefinition target, IBundleContainer container) { >- super(target, container); >+ public EditFeatureContainerPage(IBundleContainer container) { >+ super(container); > } > > /* (non-Javadoc) >Index: src/org/eclipse/pde/internal/ui/shared/target/EditProfileContainerPage.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/EditProfileContainerPage.java,v >retrieving revision 1.3 >diff -u -r1.3 EditProfileContainerPage.java >--- src/org/eclipse/pde/internal/ui/shared/target/EditProfileContainerPage.java 6 Mar 2009 17:30:32 -0000 1.3 >+++ src/org/eclipse/pde/internal/ui/shared/target/EditProfileContainerPage.java 31 Mar 2009 21:45:08 -0000 >@@ -20,7 +20,6 @@ > import org.eclipse.jface.dialogs.IMessageProvider; > import org.eclipse.pde.internal.core.target.impl.ProfileBundleContainer; > import org.eclipse.pde.internal.core.target.provisional.IBundleContainer; >-import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; > import org.eclipse.pde.internal.ui.SWTFactory; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.*; >@@ -57,12 +56,12 @@ > */ > private static final String SETTINGS_CONFIG_3 = "config3"; //$NON-NLS-1$ > >- public EditProfileContainerPage(ITargetDefinition target) { >- super(target); >+ public EditProfileContainerPage() { >+ super(); > } > >- public EditProfileContainerPage(ITargetDefinition target, IBundleContainer container) { >- super(target, container); >+ public EditProfileContainerPage(IBundleContainer container) { >+ super(container); > } > > /* (non-Javadoc) >@@ -241,7 +240,6 @@ > if (fConfigLocation.isEnabled()) { > // Check if the text field is blank > if (fConfigLocation.getText().trim().length() == 0) { >- fBundleTree.setInput(null); > setMessage(Messages.EditProfileContainerPage_2); > setPageComplete(false); > return false; >@@ -253,7 +251,6 @@ > > // Check that the directory exists > if (!configLocation.isDirectory()) { >- fBundleTree.setInput(null); > setMessage(Messages.AddProfileContainerPage_8, IMessageProvider.WARNING); > setPageComplete(true); > } else { >Index: src/org/eclipse/pde/internal/ui/shared/target/BundleInfoLabelProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/BundleInfoLabelProvider.java,v >retrieving revision 1.6 >diff -u -r1.6 BundleInfoLabelProvider.java >--- src/org/eclipse/pde/internal/ui/shared/target/BundleInfoLabelProvider.java 3 Mar 2009 21:11:14 -0000 1.6 >+++ src/org/eclipse/pde/internal/ui/shared/target/BundleInfoLabelProvider.java 31 Mar 2009 21:45:08 -0000 >@@ -18,6 +18,8 @@ > import org.eclipse.pde.internal.ui.PDEPluginImages; > import org.eclipse.pde.internal.ui.util.SharedLabelProvider; > import org.eclipse.swt.graphics.Image; >+import org.eclipse.ui.ISharedImages; >+import org.eclipse.ui.PlatformUI; > > /** > * Provides text and image labels for BundleInfo and IResolveBundle objects. >@@ -58,6 +60,8 @@ > return buf.toString(); > } else if (element instanceof IResolvedBundle) { > return getText(((IResolvedBundle) element).getBundleInfo()); >+ } else if (element instanceof IStatus) { >+ return ((IStatus) element).getMessage(); > } > return super.getText(element); > } >@@ -84,6 +88,13 @@ > } > } else if (element instanceof BundleInfo) { > return PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PLUGIN_OBJ); >+ } else if (element instanceof IStatus) { >+ int severity = ((IStatus) element).getSeverity(); >+ if (severity == IStatus.WARNING) { >+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK); >+ } else if (severity == IStatus.ERROR) { >+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); >+ } > } > return super.getImage(element); > } >Index: src/org/eclipse/pde/internal/ui/shared/target/AddP2ContainerPage.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/shared/target/AddP2ContainerPage.java >diff -N src/org/eclipse/pde/internal/ui/shared/target/AddP2ContainerPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/shared/target/AddP2ContainerPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,177 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 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.pde.internal.ui.shared.target; >+ >+import java.net.URI; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; >+import org.eclipse.equinox.internal.provisional.p2.ui.actions.PropertyDialogAction; >+import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.AvailableIUGroup; >+import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.RepositorySelectionGroup; >+import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.RepositorySelectionGroup.IRepositorySelectionListener; >+import org.eclipse.equinox.internal.provisional.p2.ui.policy.IUViewQueryContext; >+import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.viewers.CheckStateChangedEvent; >+import org.eclipse.jface.viewers.ICheckStateListener; >+import org.eclipse.jface.window.SameShellProvider; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.pde.internal.core.target.impl.P2BundleContainer; >+import org.eclipse.pde.internal.core.target.provisional.IBundleContainer; >+import org.eclipse.pde.internal.ui.*; >+import org.eclipse.pde.internal.ui.wizards.provisioner.p2.ProvisionerMessages; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * Wizard page allowing users to select which IUs they would like to download >+ * >+ * @since 3.5 >+ */ >+public class AddP2ContainerPage extends WizardPage { >+ >+ static final IStatus BAD_IU_SELECTION = new Status(IStatus.ERROR, PDEPlugin.getPluginId(), ProvisionerMessages.P2TargetProvisionerWizardPage_1); >+ IStatus fSelectedIUStatus = BAD_IU_SELECTION; >+ >+ P2BundleContainer fContainer; >+ IUViewQueryContext fQueryContext; >+ >+ RepositorySelectionGroup fRepoSelector; >+ AvailableIUGroup fAvailableIUGroup; >+ >+ Button fPropertiesButton; >+ private IAction fPropertyAction; >+ >+ protected AddP2ContainerPage() { >+ super("AddP2Container"); //$NON-NLS-1$ >+ // TODO Use the target service to create? >+ fContainer = new P2BundleContainer(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createControl(Composite parent) { >+ setMessage("Select content from a repository to be downloaded and added to your target"); >+ setTitle("Add Repository or Update Site"); >+ Composite composite = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0); >+ >+ createQueryContext(); >+ createRepositoryComboArea(composite); >+ createAvailableIUArea(composite); >+ createDetailsArea(composite); >+ createCheckboxArea(composite); >+ >+ setPageComplete(false); >+ restoreWidgetState(); >+ setControl(composite); >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.P2_PROVISIONING_PAGE); >+ } >+ >+ private void createCheckboxArea(Composite parent) { >+ // Categories, provisioning context/store sites/ >+ Composite checkComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL, 0, 0); >+ // TODO Update labels with mnemonics >+ SWTFactory.createCheckButton(checkComp, "Group by Category", null, true, 1); >+ SWTFactory.createCheckButton(checkComp, "Show only the latest version", null, true, 1); >+ SWTFactory.createCheckButton(checkComp, "Download all dependencies", null, true, 1); >+ SWTFactory.createCheckButton(checkComp, "Include the repo location in the target", null, true, 1); >+ >+ } >+ >+ private void createQueryContext() { >+ fQueryContext = Policy.getDefault().getQueryContext(); >+ } >+ >+ private void createRepositoryComboArea(Composite parent) { >+ RepositorySelectionGroup repoSelector = new RepositorySelectionGroup(getContainer(), parent, Policy.getDefault().getRepositoryManipulator(), fQueryContext); >+ repoSelector.addRepositorySelectionListener(new IRepositorySelectionListener() { >+ public void repositorySelectionChanged(int repoChoice, URI repoLocation) { >+ fAvailableIUGroup.setRepositoryFilter(repoChoice, repoLocation); >+ } >+ }); >+ } >+ >+ /** >+ * Create the UI area where the user will be able to select which IUs they >+ * would like to download. There will also be buttons to see properties for >+ * the selection and open the manage sites dialog. >+ * >+ * @param parent parent composite >+ */ >+ private void createAvailableIUArea(Composite parent) { >+ fAvailableIUGroup = new AvailableIUGroup(parent); >+ fAvailableIUGroup.getCheckboxTreeViewer().addCheckStateListener(new ICheckStateListener() { >+ public void checkStateChanged(CheckStateChangedEvent event) { >+ IInstallableUnit[] units = fAvailableIUGroup.getCheckedLeafIUs(); >+ fPropertiesButton.setEnabled(units.length > 0); >+ if (units.length > 0) { >+ fSelectedIUStatus = Status.OK_STATUS; >+ fContainer.setRequiredUnits(units); >+ } else { >+ fSelectedIUStatus = BAD_IU_SELECTION; >+ fContainer.setRequiredUnits(null); >+ } >+ pageChanged(); >+ } >+ }); >+ fAvailableIUGroup.setUseBoldFontForFilteredItems(true); >+ GridData data = (GridData) fAvailableIUGroup.getStructuredViewer().getControl().getLayoutData(); >+ data.heightHint = 200; >+ } >+ >+ private void createDetailsArea(Composite parent) { >+ Group detailsGroup = SWTFactory.createGroup(parent, "Details", 1, 1, GridData.FILL_HORIZONTAL); >+ >+ fPropertiesButton = new Button(detailsGroup, SWT.PUSH); >+ fPropertiesButton.setText(ProvisionerMessages.P2TargetProvisionerWizardPage_10); >+ fPropertiesButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ fPropertiesButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent event) { >+ fPropertyAction.run(); >+ } >+ }); >+ fPropertyAction = new PropertyDialogAction(new SameShellProvider(getShell()), fAvailableIUGroup.getStructuredViewer()); >+ } >+ >+ /** >+ * Checks if the page is complete, updating messages and finish button. >+ */ >+ void pageChanged() { >+ if (fSelectedIUStatus.getSeverity() == IStatus.ERROR) { >+ setErrorMessage(fSelectedIUStatus.getMessage()); >+ setPageComplete(false); >+ } else { >+ setErrorMessage(null); >+ setPageComplete(true); >+ } >+ } >+ >+ /** >+ * Restores the state of the wizard from previous invocations >+ */ >+ private void restoreWidgetState() { >+ // TODO Init check boxes >+ } >+ >+ /** >+ * @return bundle container created by this wizard or <code>null</code> >+ */ >+ public IBundleContainer getBundleContainer() { >+ return fContainer; >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/shared/target/PreviewContainerPage.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/shared/target/PreviewContainerPage.java >diff -N src/org/eclipse/pde/internal/ui/shared/target/PreviewContainerPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/shared/target/PreviewContainerPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,92 @@ >+package org.eclipse.pde.internal.ui.shared.target; >+ >+import java.lang.reflect.InvocationTargetException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.jface.viewers.ArrayContentProvider; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.pde.internal.core.target.provisional.IBundleContainer; >+import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; >+import org.eclipse.pde.internal.ui.PDEPlugin; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+ >+public class PreviewContainerPage extends WizardPage { >+ >+ private ITargetDefinition fTarget; >+ private EditDirectoryContainerPage fPage1; >+ protected TableViewer fPreviewTable; >+ protected Object fInput; >+ >+ protected PreviewContainerPage(ITargetDefinition definition, EditDirectoryContainerPage page1) { >+ super("ContainerPreviewPage"); >+ setTitle("Preview Contents"); >+ setMessage("The plug-ins found in the container are visible below"); >+ fTarget = definition; >+ fPage1 = page1; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createControl(Composite parent) { >+ fPreviewTable = new TableViewer(parent); >+ fPreviewTable.setLabelProvider(new BundleInfoLabelProvider(false)); >+ fPreviewTable.setContentProvider(new ArrayContentProvider()); >+ fPreviewTable.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); >+ setControl(fPreviewTable.getControl()); >+ } >+ >+ /** >+ * Refreshes the contents of the preview table, possible resolving the container >+ * @param resolve whether the current container should be resolved if it hasn't been already >+ */ >+ protected void setInput(final IBundleContainer container) { >+ if (container == null) { >+ fInput = null; >+ fPreviewTable.setInput(null); >+ return; >+ } >+ >+ if (container.isResolved()) { >+ fInput = container.getAllBundles(); >+ fPreviewTable.setInput(fInput); >+ return; >+ } >+ >+ try { >+ getContainer().run(true, true, new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >+ IStatus result = container.resolve(fTarget, monitor); >+ if (monitor.isCanceled()) { >+ fInput = null; >+ } else if (!result.isOK() && !result.isMultiStatus()) { >+ fInput = new Object[] {result}; >+ } else { >+ fInput = container.getAllBundles(); >+ } >+ >+ } >+ }); >+ fPreviewTable.setInput(fInput); >+ } catch (InvocationTargetException e) { >+ PDEPlugin.log(e); >+ setErrorMessage(e.getMessage()); >+ } catch (InterruptedException e) { >+ } >+ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean) >+ */ >+ public void setVisible(boolean visible) { >+ super.setVisible(visible); >+ if (visible) { >+ setInput(fPage1.getBundleContainer()); >+ } >+ } >+ >+}
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 270626
: 130475 |
130476
|
130605
|
130865
|
130866
|
131469
|
131554
|
131718
|
131719