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 131469 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 III
clipboard.txt (text/plain), 180.34 KB, created by
Curtis Windatt
on 2009-04-09 18:03:08 EDT
(
hide
)
Description:
Work in progress III
Filename:
MIME Type:
Creator:
Curtis Windatt
Created:
2009-04-09 18:03:08 EDT
Size:
180.34 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 9 Apr 2009 22:03:04 -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); > } > >@@ -66,7 +63,7 @@ > IBundleContainer container = (IBundleContainer) element; > if (container.isResolved()) { > IStatus status = container.getBundleStatus(); >- if (status.getSeverity() == IStatus.WARNING) { >+ if (status.getSeverity() == IStatus.WARNING || status.getSeverity() == IStatus.INFO) { > flag = SharedLabelProvider.F_WARNING; > } else if (status.getSeverity() == IStatus.ERROR) { > flag = SharedLabelProvider.F_ERROR; >@@ -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 9 Apr 2009 22:03:04 -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: src/org/eclipse/pde/internal/ui/shared/target/BundleContainerTable.java >diff -N src/org/eclipse/pde/internal/ui/shared/target/BundleContainerTable.java >--- src/org/eclipse/pde/internal/ui/shared/target/BundleContainerTable.java 27 Feb 2009 19:25:32 -0000 1.16 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,525 +0,0 @@ >-/******************************************************************************* >- * 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.lang.reflect.InvocationTargetException; >-import java.util.ArrayList; >-import org.eclipse.core.runtime.*; >-import org.eclipse.core.runtime.jobs.Job; >-import org.eclipse.jface.operation.IRunnableWithProgress; >-import org.eclipse.jface.viewers.*; >-import org.eclipse.jface.window.Window; >-import org.eclipse.jface.wizard.WizardDialog; >-import org.eclipse.pde.internal.core.target.provisional.*; >-import org.eclipse.pde.internal.ui.PDEPlugin; >-import org.eclipse.pde.internal.ui.SWTFactory; >-import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >-import org.eclipse.pde.internal.ui.editor.targetdefinition.TargetEditor; >-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.layout.GridLayout; >-import org.eclipse.swt.widgets.*; >-import org.eclipse.ui.forms.widgets.FormToolkit; >-import org.eclipse.ui.progress.UIJob; >- >-/** >- * UI part that can be added to a dialog or to a form editor. Contains a table displaying >- * the bundle containers of a target definition. Also has buttons to add, edit and remove >- * bundle containers of varying types. >- * >- * @see TargetEditor >- * @see ITargetDefinition >- * @see IBundleContainer >- */ >-public class BundleContainerTable { >- >- private TreeViewer fTreeViewer; >- private Button fAddButton; >- private Button fEditButton; >- private Button fRemoveButton; >- private Button fRemoveAllButton; >- private Label fShowLabel; >- private Button fShowPluginsButton; >- private Button fShowSourceButton; >- private ViewerFilter fPluginFilter; >- private ViewerFilter fSourceFilter; >- >- private ITargetDefinition fTarget; >- private IBundleContainerTableReporter fReporter; >- >- /** >- * Creates this part using the form toolkit and adds it to the given composite. >- * >- * @param parent parent composite >- * @param toolkit toolkit to create the widgets with >- * @param reporter reporter implementation that will handle resolving and changes to the containers >- * @return generated instance of the table part >- */ >- public static BundleContainerTable createTableInForm(Composite parent, FormToolkit toolkit, IBundleContainerTableReporter reporter) { >- BundleContainerTable contentTable = new BundleContainerTable(reporter); >- contentTable.createFormContents(parent, toolkit); >- return contentTable; >- } >- >- /** >- * Creates this part using standard dialog widgets and adds it to the given composite. >- * >- * @param parent parent composite >- * @param reporter reporter implementation that will handle resolving and changes to the containers >- * @return generated instance of the table part >- */ >- public static BundleContainerTable createTableInDialog(Composite parent, IBundleContainerTableReporter reporter) { >- BundleContainerTable contentTable = new BundleContainerTable(reporter); >- contentTable.createDialogContents(parent); >- return contentTable; >- } >- >- /** >- * Private constructor, use one of {@link #createTableInDialog(Composite, IBundleContainerTableReporter)} >- * or {@link #createTableInForm(Composite, FormToolkit, IBundleContainerTableReporter)}. >- * >- * @param reporter reporter implementation that will handle resolving and changes to the containers >- */ >- private BundleContainerTable(IBundleContainerTableReporter reporter) { >- fReporter = reporter; >- } >- >- /** >- * Creates the part contents from a toolkit >- * @param parent parent composite >- * @param toolkit form toolkit to create widgets >- */ >- private void createFormContents(Composite parent, FormToolkit toolkit) { >- Composite comp = toolkit.createComposite(parent); >- comp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2)); >- comp.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL)); >- >- Tree atree = toolkit.createTree(comp, SWT.V_SCROLL | SWT.H_SCROLL); >- atree.setLayout(new GridLayout()); >- GridData gd = new GridData(GridData.FILL_BOTH); >- atree.setLayoutData(gd); >- >- Composite buttonComp = toolkit.createComposite(comp); >- GridLayout layout = new GridLayout(); >- layout.marginWidth = layout.marginHeight = 0; >- buttonComp.setLayout(layout); >- buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL)); >- >- fAddButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_0, SWT.PUSH); >- fEditButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_1, SWT.PUSH); >- fRemoveButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_2, SWT.PUSH); >- fRemoveAllButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_3, SWT.PUSH); >- >- Composite filterComp = toolkit.createComposite(buttonComp); >- layout = new GridLayout(); >- layout.marginWidth = layout.marginHeight = 0; >- filterComp.setLayout(layout); >- filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true)); >- >- fShowLabel = toolkit.createLabel(filterComp, Messages.BundleContainerTable_9); >- fShowPluginsButton = toolkit.createButton(filterComp, Messages.BundleContainerTable_14, SWT.CHECK); >- fShowSourceButton = toolkit.createButton(filterComp, Messages.BundleContainerTable_15, SWT.CHECK); >- >- initializeTreeViewer(atree); >- initializeButtons(); >- initializeFilters(); >- >- toolkit.paintBordersFor(comp); >- } >- >- /** >- * Creates the part contents using SWTFactory >- * @param parent parent composite >- */ >- private void createDialogContents(Composite parent) { >- Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0); >- >- Tree atree = new Tree(comp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); >- atree.setLayout(new GridLayout()); >- GridData gd = new GridData(GridData.FILL_BOTH); >- gd.widthHint = 200; >- atree.setLayoutData(gd); >- >- Composite buttonComp = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_BOTH); >- GridLayout layout = new GridLayout(); >- layout.marginHeight = 0; >- layout.marginWidth = 0; >- buttonComp.setLayout(layout); >- buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL)); >- >- fAddButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_0, null); >- fEditButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_1, null); >- fRemoveButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_2, null); >- fRemoveAllButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_3, null); >- >- Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, GridData.BEGINNING, 0, 0); >- filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true)); >- >- fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1); >- fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1); >- fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1); >- >- initializeTreeViewer(atree); >- initializeButtons(); >- initializeFilters(); >- } >- >- /** >- * Sets up the tree viewer using the given tree >- * @param tree >- */ >- private void initializeTreeViewer(Tree tree) { >- fTreeViewer = new TreeViewer(tree); >- fTreeViewer.setContentProvider(new BundleContainerContentProvider()); >- fTreeViewer.setLabelProvider(new BundleContainerLabelProvider()); >- fTreeViewer.setComparator(new ViewerComparator()); >- fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { >- public void selectionChanged(SelectionChangedEvent event) { >- updateButtons(); >- } >- }); >- fTreeViewer.addDoubleClickListener(new IDoubleClickListener() { >- public void doubleClick(DoubleClickEvent event) { >- if (!event.getSelection().isEmpty()) { >- handleEdit(); >- } >- } >- }); >- fTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); >- } >- >- /** >- * Sets up the buttons, the button fields must already be created before calling this method >- */ >- private void initializeButtons() { >- fAddButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- handleAdd(); >- } >- }); >- fAddButton.setLayoutData(new GridData()); >- SWTFactory.setButtonDimensionHint(fAddButton); >- >- fEditButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- handleEdit(); >- } >- }); >- fEditButton.setLayoutData(new GridData()); >- fEditButton.setEnabled(false); >- SWTFactory.setButtonDimensionHint(fEditButton); >- >- fRemoveButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- handleRemove(); >- } >- }); >- fRemoveButton.setLayoutData(new GridData()); >- fRemoveButton.setEnabled(false); >- SWTFactory.setButtonDimensionHint(fRemoveButton); >- >- fRemoveAllButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- handleRemoveAll(); >- } >- }); >- fRemoveAllButton.setLayoutData(new GridData()); >- SWTFactory.setButtonDimensionHint(fRemoveAllButton); >- >- fShowPluginsButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- if (!fShowPluginsButton.getSelection()) { >- fTreeViewer.addFilter(fPluginFilter); >- } else { >- fTreeViewer.removeFilter(fPluginFilter); >- } >- } >- }); >- fShowPluginsButton.setSelection(true); >- GridData gd = new GridData(); >- gd.horizontalIndent = 10; >- fShowPluginsButton.setLayoutData(gd); >- >- fShowSourceButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- if (!fShowSourceButton.getSelection()) { >- fTreeViewer.addFilter(fSourceFilter); >- } else { >- fTreeViewer.removeFilter(fSourceFilter); >- } >- } >- }); >- fShowSourceButton.setSelection(true); >- gd = new GridData(); >- gd.horizontalIndent = 10; >- fShowSourceButton.setLayoutData(gd); >- } >- >- 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; >- } >- }; >- } >- >- /** >- * Sets the target definition model to use as input for the tree, can be called with different >- * models to change the tree's input. >- * @param target target model >- */ >- public void setInput(ITargetDefinition target) { >- fTarget = target; >- refresh(); >- } >- >- /** >- * Refreshes the contents of the table >- */ >- public void refresh() { >- if (!fTarget.isResolved()) { >- fReporter.runResolveOperation(new ResolveContainersOperation()); >- } else { >- fTreeViewer.setInput(fTarget); >- fTreeViewer.refresh(); >- updateButtons(); >- } >- } >- >- private void setEnabled(boolean enablement) { >- fTreeViewer.getControl().setEnabled(enablement); >- fAddButton.setEnabled(enablement); >- >- fShowLabel.setEnabled(enablement); >- fShowPluginsButton.setEnabled(enablement); >- fShowSourceButton.setEnabled(enablement); >- >- if (enablement) { >- updateButtons(); >- } else { >- fRemoveButton.setEnabled(enablement); >- fRemoveAllButton.setEnabled(enablement); >- fEditButton.setEnabled(enablement); >- } >- } >- >- private void handleAdd() { >- AddBundleContainerWizard wizard = new AddBundleContainerWizard(fTarget); >- Shell parent = fTreeViewer.getTree().getShell(); >- WizardDialog dialog = new WizardDialog(parent, wizard); >- if (dialog.open() != Window.CANCEL) { >- refresh(); >- contentsChanged(); >- } >- } >- >- private void handleEdit() { >- IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection(); >- if (!selection.isEmpty()) { >- Object selected = selection.getFirstElement(); >- IBundleContainer oldContainer = null; >- if (selected instanceof IBundleContainer) { >- oldContainer = (IBundleContainer) selected; >- } else if (selected instanceof IResolvedBundle) { >- TreeItem[] treeSelection = fTreeViewer.getTree().getSelection(); >- if (treeSelection.length > 0) { >- Object parent = treeSelection[0].getParentItem().getData(); >- if (parent instanceof IBundleContainer) { >- oldContainer = (IBundleContainer) parent; >- } >- } >- } >- if (oldContainer != null) { >- Shell parent = fTreeViewer.getTree().getShell(); >- EditBundleContainerWizard wizard = new EditBundleContainerWizard(fTarget, oldContainer); >- WizardDialog dialog = new WizardDialog(parent, wizard); >- if (dialog.open() == Window.OK) { >- // Replace the old container with the new one >- IBundleContainer newContainer = wizard.getBundleContainer(); >- if (newContainer != null) { >- IBundleContainer[] containers = fTarget.getBundleContainers(); >- java.util.List newContainers = new ArrayList(containers.length); >- for (int i = 0; i < containers.length; i++) { >- if (!containers[i].equals(oldContainer)) { >- newContainers.add(containers[i]); >- } >- } >- newContainers.add(newContainer); >- fTarget.setBundleContainers((IBundleContainer[]) newContainers.toArray(new IBundleContainer[newContainers.size()])); >- >- // Update the table >- refresh(); >- contentsChanged(); >- fTreeViewer.setSelection(new StructuredSelection(newContainer), true); >- } >- } >- } >- } >- } >- >- private void handleRemove() { >- IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection(); >- if (!selection.isEmpty()) { >- Object selected = selection.getFirstElement(); >- IBundleContainer container = null; >- if (selected instanceof IBundleContainer) { >- container = (IBundleContainer) selected; >- IBundleContainer[] currentContainers = fTarget.getBundleContainers(); >- ArrayList newBundleContainers = new ArrayList(currentContainers.length); >- for (int i = 0; i < currentContainers.length; i++) { >- if (!currentContainers[i].equals(container)) { >- newBundleContainers.add(currentContainers[i]); >- } >- } >- fTarget.setBundleContainers((IBundleContainer[]) newBundleContainers.toArray(new IBundleContainer[newBundleContainers.size()])); >- contentsChanged(); >- refresh(); >- } >- } >- } >- >- private void handleRemoveAll() { >- fTarget.setBundleContainers(null); >- contentsChanged(); >- refresh(); >- } >- >- private void updateButtons() { >- IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection(); >- fEditButton.setEnabled(!selection.isEmpty() && (selection.getFirstElement() instanceof IBundleContainer || selection.getFirstElement() instanceof IResolvedBundle)); >- fRemoveButton.setEnabled(!selection.isEmpty() && selection.getFirstElement() instanceof IBundleContainer); >- fRemoveAllButton.setEnabled(fTarget.getBundleContainers() != null && fTarget.getBundleContainers().length > 0); >- } >- >- /** >- * Informs the reporter for this table that something has changed >- * and is dirty. >- */ >- private void contentsChanged() { >- fReporter.contentsChanged(); >- } >- >- /** >- * Runnable that resolves the target. Disables the table while running >- */ >- class ResolveContainersOperation implements IRunnableWithProgress { >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) >- */ >- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >- Job job = new UIJob(Messages.BundleContainerTable_16) { >- public IStatus runInUIThread(IProgressMonitor monitor) { >- if (!fTreeViewer.getControl().isDisposed()) { >- setEnabled(false); >- fTreeViewer.setInput(Messages.BundleContainerTable_17); >- fTreeViewer.refresh(); >- } >- return Status.OK_STATUS; >- } >- }; >- job.setSystem(true); >- job.schedule(); >- fTarget.resolve(monitor); >- if (!monitor.isCanceled()) { >- job = new UIJob(Messages.BundleContainerTable_18) { >- public IStatus runInUIThread(IProgressMonitor monitor) { >- if (!fTreeViewer.getControl().isDisposed()) { >- setEnabled(true); >- fTreeViewer.setInput(fTarget); >- fTreeViewer.refresh(); >- updateButtons(); >- } >- return Status.OK_STATUS; >- } >- }; >- job.setSystem(true); >- job.schedule(); >- } >- } >- } >- >- /** >- * Content provider for the tree, primary input is a ITargetDefinition, children are IBundleContainers >- */ >- class BundleContainerContentProvider implements ITreeContentProvider { >- >- public Object[] getChildren(Object parentElement) { >- if (parentElement instanceof ITargetDefinition) { >- IBundleContainer[] containers = ((ITargetDefinition) parentElement).getBundleContainers(); >- return containers != null ? containers : new Object[0]; >- } else if (parentElement instanceof IBundleContainer) { >- IBundleContainer container = (IBundleContainer) parentElement; >- if (container.isResolved()) { >- IStatus status = container.getBundleStatus(); >- if (!status.isOK() && !status.isMultiStatus()) { >- return new Object[] {status}; >- } >- return container.getBundles(); >- } >- // We should only be populating the table if the containers are resolved, but just in case >- return new Object[] {new Status(IStatus.ERROR, PDEPlugin.getPluginId(), Messages.BundleContainerTable_19)}; >- } else if (parentElement instanceof IResolvedBundle) { >- IStatus status = ((IResolvedBundle) parentElement).getStatus(); >- if (!status.isOK()) { >- return new Object[] {status}; >- } >- } >- return new Object[0]; >- } >- >- public Object getParent(Object element) { >- return null; >- } >- >- public boolean hasChildren(Object element) { >- // Since we are already resolved we can't be more efficient >- return getChildren(element).length > 0; >- } >- >- public Object[] getElements(Object inputElement) { >- if (inputElement instanceof ITargetDefinition) { >- IBundleContainer[] containers = ((ITargetDefinition) inputElement).getBundleContainers(); >- if (containers != null) { >- return containers; >- } >- } else if (inputElement instanceof String) { >- return new Object[] {inputElement}; >- } >- return new Object[0]; >- } >- >- public void dispose() { >- } >- >- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >- } >- >- } >- >-} >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 9 Apr 2009 22:03:04 -0000 >@@ -15,7 +15,6 @@ > AddDirectoryContainerPage_4=Directory > AddDirectoryContainerPage_5=Select a directory containing one or more plug-ins. > AddDirectoryContainerPage_6=Location directory does not exist >-AddDirectoryContainerPage_7=< no plug-ins found in the current location > > AddDirectoryContainerPage_9=Could not acquire the target platform service to create the new container. > AddFeatureContainerPage_0=Add Features > AddFeatureContainerPage_1=Select features from a directory. >@@ -61,15 +60,11 @@ > BundleContainerTable_16=Disable Target Contents > BundleContainerTable_17=Resolving the contents of the target... > BundleContainerTable_18=Enable Target Contents >-BundleContainerTable_19=Container has not been resolved >-# label provider error messages >-# {0} is the error message > BundleContainerTable_4=Error creating label: {0} > BundleContainerTable_9=Show: > 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 >@@ -77,7 +72,6 @@ > EditFeatureContainerPage_3=Feature Version: > EditFeatureContainerPage_4=Unspecified > EditFeatureContainerPage_5=Location: >-EditProfileContainerPage_0=Configuration Location > EditProfileContainerPage_1=Var&iables... > EditProfileContainerPage_2=Select a configuration directory > EditProfileContainerPage_3=Edit Installation >@@ -91,8 +85,6 @@ > IncludedBundlesTree_3=Dese&lect All > IncludedBundlesTree_4=Select Re&quired > # {0}: count of checked plug-ins {1}: total number of plug-ins example: 12 of 15 included >-IncludedBundlesTree_5={0} of {1} selected >-IncludedBundlesTree_6=Group Plug-ins by location > RestrictionsListSelectionDialog_0=Select the plug-ins to include in the target: > RestrictionsListSelectionDialog_1=Plug-in Selection > RestrictionsListSelectionDialog_2=Use specific plug-in version (versus highest available version) >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 9 Apr 2009 22:03:04 -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/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 9 Apr 2009 22:03:04 -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) >@@ -88,7 +87,7 @@ > protected void createLocationArea(Composite parent) { > super.createLocationArea(parent); > >- Group configComp = SWTFactory.createGroup(parent, Messages.EditProfileContainerPage_0, 2, 1, GridData.FILL_HORIZONTAL); >+ Composite configComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL, 0, 0); > > fUseDefaultConfig = new Button(configComp, SWT.CHECK | SWT.RIGHT); > GridData gd = new GridData(); >@@ -103,6 +102,7 @@ > }); > > fConfigLabel = SWTFactory.createLabel(configComp, Messages.AddProfileContainerPage_3, 1); >+ ((GridData) fConfigLabel.getLayoutData()).horizontalIndent = 15; > > fConfigLocation = SWTFactory.createCombo(configComp, SWT.BORDER, 1, getConfigComboItems()); > fConfigLocation.addModifyListener(new ModifyListener() { >@@ -241,9 +241,7 @@ > 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,12 +251,9 @@ > > // Check that the directory exists > if (!configLocation.isDirectory()) { >- fBundleTree.setInput(null); > setMessage(Messages.AddProfileContainerPage_8, IMessageProvider.WARNING); >- setPageComplete(true); > } else { > setMessage(getDefaultMessage()); >- setPageComplete(true); > } > } > } >@@ -268,7 +263,7 @@ > /* (non-Javadoc) > * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#refreshContainer(org.eclipse.pde.internal.core.target.provisional.IBundleContainer) > */ >- protected IBundleContainer refreshContainer(IBundleContainer previous) throws CoreException { >+ protected IBundleContainer createContainer(IBundleContainer previous) throws CoreException { > IBundleContainer container = getTargetPlatformService().newProfileContainer(fInstallLocation.getText(), fConfigLocation.isEnabled() ? fConfigLocation.getText() : null); > if (previous instanceof ProfileBundleContainer) { > container.setIncludedBundles(previous.getIncludedBundles()); >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 9 Apr 2009 22:03:04 -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) >@@ -80,7 +79,7 @@ > /* (non-Javadoc) > * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#refreshContainer(org.eclipse.pde.internal.core.target.provisional.IBundleContainer) > */ >- protected IBundleContainer refreshContainer(IBundleContainer previous) throws CoreException { >+ protected IBundleContainer createContainer(IBundleContainer previous) throws CoreException { > return getBundleContainer(); > } > >Index: src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerWizard.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerWizard.java,v >retrieving revision 1.2 >diff -u -r1.2 AddBundleContainerWizard.java >--- src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerWizard.java 24 Jan 2009 02:08:56 -0000 1.2 >+++ src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerWizard.java 9 Apr 2009 22:03:04 -0000 >@@ -18,7 +18,7 @@ > * Wizard for adding a bundle container to a target. Provides a selection page > * where the user can choose the type of container to create. > * >- * @see BundleContainerTable >+ * @see TargetLocationsGroup > * @see IBundleContainer > */ > public class AddBundleContainerWizard extends Wizard { >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 9 Apr 2009 22:03:04 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.ui.shared.target; > >+import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; > import org.eclipse.jface.viewers.LabelProvider; >@@ -18,6 +19,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. >@@ -57,7 +60,16 @@ > } > return buf.toString(); > } else if (element instanceof IResolvedBundle) { >- return getText(((IResolvedBundle) element).getBundleInfo()); >+ IResolvedBundle bundle = ((IResolvedBundle) element); >+ if (!bundle.getStatus().isOK()) { >+ // TODO Better error message for missing bundles >+ return bundle.getStatus().getMessage(); >+ } >+ return getText(bundle.getBundleInfo()); >+ } else if (element instanceof IStatus) { >+ return ((IStatus) element).getMessage(); >+ } else if (element instanceof IPath) { >+ return ((IPath) element).removeFirstSegments(1).toString(); > } > return super.getText(element); > } >@@ -69,7 +81,7 @@ > if (element instanceof IResolvedBundle) { > IResolvedBundle bundle = (IResolvedBundle) element; > int flag = 0; >- if (bundle.getStatus().getSeverity() == IStatus.WARNING) { >+ if (bundle.getStatus().getSeverity() == IStatus.WARNING || bundle.getStatus().getSeverity() == IStatus.INFO) { > flag = SharedLabelProvider.F_WARNING; > } else if (bundle.getStatus().getSeverity() == IStatus.ERROR) { > flag = SharedLabelProvider.F_ERROR; >@@ -84,6 +96,15 @@ > } > } 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 || severity == IStatus.INFO) { >+ 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); >+ } >+ } else if (element instanceof IPath) { >+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); > } > return super.getImage(element); > } >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 9 Apr 2009 22:03:04 -0000 >@@ -21,7 +21,6 @@ > public static String AddDirectoryContainerPage_4; > public static String AddDirectoryContainerPage_5; > public static String AddDirectoryContainerPage_6; >- public static String AddDirectoryContainerPage_7; > public static String AddDirectoryContainerPage_9; > public static String AddFeatureContainerPage_0; > public static String AddFeatureContainerPage_1; >@@ -52,7 +51,6 @@ > public static String BundleContainerTable_16; > public static String BundleContainerTable_17; > public static String BundleContainerTable_18; >- public static String BundleContainerTable_19; > public static String BundleContainerTable_2; > public static String BundleContainerTable_3; > public static String BundleContainerTable_4; >@@ -63,7 +61,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; >@@ -71,7 +68,6 @@ > public static String EditFeatureContainerPage_3; > public static String EditFeatureContainerPage_4; > public static String EditFeatureContainerPage_5; >- public static String EditProfileContainerPage_0; > public static String EditProfileContainerPage_1; > public static String EditProfileContainerPage_2; > public static String EditProfileContainerPage_3; >@@ -84,8 +80,6 @@ > public static String IncludedBundlesTree_2; > public static String IncludedBundlesTree_3; > public static String IncludedBundlesTree_4; >- public static String IncludedBundlesTree_5; >- public static String IncludedBundlesTree_6; > public static String RestrictionsListSelectionDialog_0; > public static String RestrictionsListSelectionDialog_1; > public static String RestrictionsListSelectionDialog_2; >Index: src/org/eclipse/pde/internal/ui/shared/target/IncludedBundlesTree.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/shared/target/IncludedBundlesTree.java >diff -N src/org/eclipse/pde/internal/ui/shared/target/IncludedBundlesTree.java >--- src/org/eclipse/pde/internal/ui/shared/target/IncludedBundlesTree.java 30 Mar 2009 21:17:09 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,598 +0,0 @@ >-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; >- } >-} >Index: src/org/eclipse/pde/internal/ui/shared/target/IBundleContainerTableReporter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/shared/target/IBundleContainerTableReporter.java >diff -N src/org/eclipse/pde/internal/ui/shared/target/IBundleContainerTableReporter.java >--- src/org/eclipse/pde/internal/ui/shared/target/IBundleContainerTableReporter.java 13 Feb 2009 22:30:32 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,40 +0,0 @@ >-/******************************************************************************* >- * 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 org.eclipse.jface.operation.IRunnableWithProgress; >- >-/** >- * Does container specific actions for the BundleContainerTable. Allows the resolve >- * operation to run differently (job or dialog) if the table is being used in an editor >- * or a wizard page. Allows changes to the bundle containers to be reported properly. >- * >- * @see BundleContainerTable >- */ >-public interface IBundleContainerTableReporter { >- >- /** >- * Runs the given operation in a container appropriate fashion. >- * <p> >- * This method may be called from the UI thread so implementors should >- * not block. >- * </p> >- * @param operation the operation to run >- */ >- public void runResolveOperation(IRunnableWithProgress operation); >- >- /** >- * Informs the container that the contents of the target's bundle >- * containers have changed. Used to mark the editor dirty. >- */ >- public void contentsChanged(); >- >-} >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 9 Apr 2009 22:03:04 -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/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 9 Apr 2009 22:03:04 -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,9 +298,7 @@ > 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,12 +308,9 @@ > > // Check if directory exists > if (!location.isDirectory()) { >- fBundleTree.setInput(null); > setMessage(Messages.AddDirectoryContainerPage_6, IMessageProvider.WARNING); >- setPageComplete(true); > } else { > setMessage(getDefaultMessage()); >- setPageComplete(true); > } > return true; > } >@@ -332,7 +324,7 @@ > * @return a new or modified bundle container > * @throws CoreException > */ >- protected IBundleContainer refreshContainer(IBundleContainer previous) throws CoreException { >+ protected IBundleContainer createContainer(IBundleContainer previous) throws CoreException { > IBundleContainer container = getTargetPlatformService().newDirectoryContainer(fInstallLocation.getText()); > if (previous instanceof DirectoryBundleContainer) { > container.setIncludedBundles(previous.getIncludedBundles()); >@@ -356,24 +348,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); > } > >@@ -386,34 +362,15 @@ > // Validate the location and any other text fields > 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(); >- } >+ fContainer = createContainer(fContainer); >+ 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/pderesources.properties >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties,v >retrieving revision 1.1067 >diff -u -r1.1067 pderesources.properties >--- src/org/eclipse/pde/internal/ui/pderesources.properties 30 Mar 2009 20:47:19 -0000 1.1067 >+++ src/org/eclipse/pde/internal/ui/pderesources.properties 9 Apr 2009 22:03:04 -0000 >@@ -686,7 +686,7 @@ > ContentPage_fGroup = Fragment Properties > ContentPage_parentPluginGroup = Host Plug-in > ContentSection_0=Content >-ContentSection_1=This table lists the plug-ins and source bundles that will be included in the target. Locations to look for plug-ins can be added, edited and removed. In addition, a location can be modified to only include a subset of bundles. >+ContentSection_1=List of plug-ins to include in this target. Only the plug-ins checked below will be included in the target platform. > ContentSection_selectedOnly=Include only plug-ins designated below > ContentSection_targetContent=Target Content > ContentPage_pClassGroup = Plug-in Options >@@ -1687,11 +1687,7 @@ > OverviewPage_extensionPageMessageTitle=Extension pages hidden > OverviewPage_extensionPageMessageBody=The Extension and Extension Point pages are currently hidden, would you like to display them now? > OverviewPage_environmentDescription=<form>\ >-<p>The <a href="environment">Environment</a> section contains the following environment and setup information:</p>\ >-<li>Environment settings including locale, processor architecture, operating system and windowing system.</li>\ >-<li>Java runtime environment.</li>\ >-<li>Program and VM arguments.</li>\ >-<li>Implicit plug-ins, which should always be taken into account when calculating dependencies.</li>\ >+<p>The <a href="environment">Environment</a> section contains additional settings including: locale, operating system, java runtime, arguments and implicit dependencies.</p>\ > </form> > OverviewPage_fExtensionContent=<form>\ > <p>This fragment may define extensions and extension points:</p>\ >@@ -1699,8 +1695,7 @@ > <li style="image" value="page" bindent="5"><a href="ex-points">Extension Points</a>: declares new function points this fragment adds to the platform.</li>\ > </form> > OverviewPage_contentDescription=<form>\ >-<p>The <a href="content">Content</a> section specifies the make-up of the target platform in terms of plug-ins, features or both.</p>\ >-<p>An option is also available to simply include all plug-ins from the specified locations into the target platform.</p>\ >+<p>The <a href="content">Content</a> section specifies the set of plug-ins that will be included in the target platform.</p>\ > </form> > OverviewPage_buildTitle=Build Configuration > ClassAttributeRow_dialogTitle=Select Type >Index: src/org/eclipse/pde/internal/ui/PDEPluginImages.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPluginImages.java,v >retrieving revision 1.110 >diff -u -r1.110 PDEPluginImages.java >--- src/org/eclipse/pde/internal/ui/PDEPluginImages.java 1 Apr 2009 22:15:00 -0000 1.110 >+++ src/org/eclipse/pde/internal/ui/PDEPluginImages.java 9 Apr 2009 22:03:04 -0000 >@@ -128,6 +128,8 @@ > public static final ImageDescriptor DESC_COMGROUP_OBJ = create(PATH_OBJ, "keygroups_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_GENCOM_OBJ = create(PATH_OBJ, "command_obj.gif"); //$NON-NLS-1$ > >+ public static final ImageDescriptor DESC_REPOSITORY_OBJ = create(PATH_OBJ, "metadata_repo_obj.gif"); //$NON-NLS-1$ >+ > public static final ImageDescriptor DESC_PLUGIN_OBJ = create(PATH_OBJ, "plugin_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_PLUGIN_DIS_OBJ = create(PATH_OBJ, "plugin_dis_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_OPERATING_SYSTEM_OBJ = create(PATH_OBJ, "operating_system_obj.gif"); //$NON-NLS-1$ >Index: src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java,v >retrieving revision 1.8 >diff -u -r1.8 TargetEditor.java >--- src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java 30 Mar 2009 20:47:19 -0000 1.8 >+++ src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java 9 Apr 2009 22:03:04 -0000 >@@ -14,6 +14,8 @@ > import java.util.List; > import org.eclipse.core.resources.*; > import org.eclipse.core.runtime.*; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.core.runtime.jobs.JobChangeAdapter; > import org.eclipse.jface.action.Action; > import org.eclipse.jface.action.ControlContribution; > import org.eclipse.jface.dialogs.IMessageProvider; >@@ -21,6 +23,7 @@ > import org.eclipse.pde.internal.core.target.impl.WorkspaceFileTargetHandle; > import org.eclipse.pde.internal.core.target.provisional.*; > import org.eclipse.pde.internal.ui.*; >+import org.eclipse.pde.internal.ui.shared.target.*; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.BusyIndicator; > import org.eclipse.swt.widgets.*; >@@ -32,6 +35,7 @@ > import org.eclipse.ui.forms.events.IHyperlinkListener; > import org.eclipse.ui.forms.widgets.*; > import org.eclipse.ui.part.FileEditorInput; >+import org.eclipse.ui.progress.UIJob; > > /** > * Editor for target definition (*.target) files. Interacts with the ITargetDefinition model >@@ -46,6 +50,7 @@ > private ITargetDefinition fTarget; > private List fManagedFormPages = new ArrayList(2); > private FileInputListener fInputListener; >+ private TargetChangedListener fTargetChangedListener; > > /* (non-Javadoc) > * @see org.eclipse.ui.forms.editor.FormEditor#createToolkit(org.eclipse.swt.widgets.Display) >@@ -62,6 +67,7 @@ > setActiveEditor(this); > setPartName(getEditorInput().getName()); > addPage(new DefinitionPage(this)); >+ addPage(new ContentPage(this)); > addPage(new EnvironmentPage(this)); > } catch (PartInitException e) { > PDEPlugin.log(e); >@@ -147,6 +153,7 @@ > if (input instanceof IFileEditorInput) { > fInputListener = new FileInputListener(((IFileEditorInput) input).getFile()); > PDEPlugin.getWorkspace().addResourceChangeListener(fInputListener); >+ getTargetChangedListener().contentsChanged(getTarget(), true); > } > } > >@@ -198,6 +205,16 @@ > } > > /** >+ * @return a shared listener that will refresh UI components when the target is modified >+ */ >+ public TargetChangedListener getTargetChangedListener() { >+ if (fTargetChangedListener == null) { >+ fTargetChangedListener = new TargetChangedListener(); >+ } >+ return fTargetChangedListener; >+ } >+ >+ /** > * Handles the revert action > */ > public void doRevert() { >@@ -303,4 +320,66 @@ > } > } > >+ class TargetChangedListener implements ITargetChangedListener { >+ private TargetLocationsGroup fLocationTree; >+ private TargetContentsGroup fContentTree; >+ >+ public void setLocationTree(TargetLocationsGroup locationTree) { >+ fLocationTree = locationTree; >+ } >+ >+ public void setContentTree(TargetContentsGroup contentTree) { >+ fContentTree = contentTree; >+ } >+ >+ public void contentsChanged(ITargetDefinition definition, boolean resolve) { >+ if (resolve) { >+ if (definition.isResolved()) { >+ if (fContentTree != null) { >+ fContentTree.setInput(getTarget()); >+ } >+ if (fLocationTree != null) { >+ fLocationTree.setInput(getTarget()); >+ } >+ } else { >+ if (fContentTree != null) { >+ fContentTree.setEnabled(false); >+ } >+ if (fLocationTree != null) { >+ fLocationTree.setInput(null); >+ } >+ // TODO Cancel any other started jobs? Bad if we do this every time a checkbox changes >+ Job resolveJob = new Job("Resolving Target") { >+ protected IStatus run(IProgressMonitor monitor) { >+ getTarget().resolve(monitor); >+ if (monitor.isCanceled()) { >+ return Status.CANCEL_STATUS; >+ } >+ // Don't return any problems because we don't want an error dialog >+ return Status.OK_STATUS; >+ } >+ }; >+ resolveJob.addJobChangeListener(new JobChangeAdapter() { >+ public void done(org.eclipse.core.runtime.jobs.IJobChangeEvent event) { >+ UIJob job = new UIJob("Refresh UI") { >+ public IStatus runInUIThread(IProgressMonitor monitor) { >+ if (fContentTree != null) { >+ fContentTree.setInput(getTarget()); >+ } >+ if (fLocationTree != null) { >+ fLocationTree.setInput(getTarget()); >+ } >+ return Status.OK_STATUS; >+ } >+ }; >+ job.setSystem(true); >+ job.schedule(); >+ } >+ }); >+ resolveJob.schedule(); >+ } >+ } >+ } >+ } >+ > } >Index: src/org/eclipse/pde/internal/ui/editor/targetdefinition/ContentSection.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/ContentSection.java,v >retrieving revision 1.3 >diff -u -r1.3 ContentSection.java >--- src/org/eclipse/pde/internal/ui/editor/targetdefinition/ContentSection.java 13 Feb 2009 22:30:32 -0000 1.3 >+++ src/org/eclipse/pde/internal/ui/editor/targetdefinition/ContentSection.java 9 Apr 2009 22:03:04 -0000 >@@ -10,16 +10,11 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.ui.editor.targetdefinition; > >-import java.lang.reflect.InvocationTargetException; >-import org.eclipse.core.runtime.*; >-import org.eclipse.core.runtime.jobs.Job; >-import org.eclipse.jface.operation.IRunnableWithProgress; > import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; >-import org.eclipse.pde.internal.ui.PDEPlugin; > import org.eclipse.pde.internal.ui.PDEUIMessages; > import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >-import org.eclipse.pde.internal.ui.shared.target.BundleContainerTable; >-import org.eclipse.pde.internal.ui.shared.target.IBundleContainerTableReporter; >+import org.eclipse.pde.internal.ui.shared.target.ITargetChangedListener; >+import org.eclipse.pde.internal.ui.shared.target.TargetContentsGroup; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.ui.forms.SectionPart; >@@ -33,7 +28,7 @@ > */ > public class ContentSection extends SectionPart { > >- private BundleContainerTable fTable; >+ private TargetContentsGroup fContentGroup; > private TargetEditor fEditor; > > public ContentSection(FormPage page, Composite parent) { >@@ -67,26 +62,11 @@ > client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1)); > client.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL)); > >- fTable = BundleContainerTable.createTableInForm(client, toolkit, new IBundleContainerTableReporter() { >- public void runResolveOperation(final IRunnableWithProgress operation) { >- Job job = new Job(PDEUIMessages.TargetDefinitionContentPage_0) { >- protected IStatus run(IProgressMonitor monitor) { >- try { >- >- operation.run(monitor); >- return Status.OK_STATUS; >- } catch (InvocationTargetException e) { >- return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), PDEUIMessages.TargetDefinitionContentPage_5, e); >- } catch (InterruptedException e) { >- return Status.CANCEL_STATUS; >- } >- } >- }; >- job.setUser(true); >- job.schedule(); >- } >- >- public void contentsChanged() { >+ fContentGroup = TargetContentsGroup.createInForm(client, toolkit); >+ fEditor.getTargetChangedListener().setContentTree(fContentGroup); >+ fContentGroup.addTargetChangedListener(fEditor.getTargetChangedListener()); >+ fContentGroup.addTargetChangedListener(new ITargetChangedListener() { >+ public void contentsChanged(ITargetDefinition definition, boolean resolve) { > markDirty(); > } > }); >@@ -100,7 +80,7 @@ > * @see org.eclipse.ui.forms.AbstractFormPart#refresh() > */ > public void refresh() { >- fTable.setInput(getTarget()); >+ fContentGroup.setInput(getTarget()); > super.refresh(); > } > >Index: src/org/eclipse/pde/internal/ui/editor/targetdefinition/DefinitionPage.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/DefinitionPage.java,v >retrieving revision 1.6 >diff -u -r1.6 DefinitionPage.java >--- src/org/eclipse/pde/internal/ui/editor/targetdefinition/DefinitionPage.java 3 Mar 2009 21:11:14 -0000 1.6 >+++ src/org/eclipse/pde/internal/ui/editor/targetdefinition/DefinitionPage.java 9 Apr 2009 22:03:04 -0000 >@@ -10,26 +10,33 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.ui.editor.targetdefinition; > >+import org.eclipse.jface.action.IStatusLineManager; > import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; > import org.eclipse.pde.internal.ui.*; > import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >+import org.eclipse.pde.internal.ui.editor.target.ContentPage; >+import org.eclipse.pde.internal.ui.editor.target.EnvironmentPage; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.SWTException; >+import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.forms.IManagedForm; > import org.eclipse.ui.forms.editor.FormPage; >-import org.eclipse.ui.forms.widgets.FormToolkit; >-import org.eclipse.ui.forms.widgets.ScrolledForm; >+import org.eclipse.ui.forms.events.HyperlinkEvent; >+import org.eclipse.ui.forms.events.IHyperlinkListener; >+import org.eclipse.ui.forms.widgets.*; > > /** > * First page in the target definition editor. Allows for editing of the name, > * description and content of the target. > * @see TargetEditor > * @see InformationSection >- * @see ContentSection >+ * @see LocationSection > */ >-public class DefinitionPage extends FormPage { >+public class DefinitionPage extends FormPage implements IHyperlinkListener { > >- public static final String PAGE_ID = "overview"; //$NON-NLS-1$ >+ public static final String PAGE_ID = "definition"; //$NON-NLS-1$ > > public DefinitionPage(TargetEditor editor) { > super(editor, PAGE_ID, PDEUIMessages.DefinitionPage_0); >@@ -73,7 +80,66 @@ > Composite body = managedForm.getForm().getBody(); > body.setLayout(FormLayoutFactory.createFormGridLayout(true, 1)); > managedForm.addPart(new InformationSection(this, body)); >- managedForm.addPart(new ContentSection(this, body)); >+ managedForm.addPart(new LocationSection(this, body)); >+ Composite linkComposite = toolkit.createComposite(body); >+ linkComposite.setLayout(FormLayoutFactory.createFormGridLayout(true, 2)); >+ linkComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ createContentsSection(linkComposite, toolkit); >+ createEnvironmentSection(linkComposite, toolkit); >+ } >+ >+ private void createContentsSection(Composite parent, FormToolkit toolkit) { >+ Section section = createSection(parent, toolkit, PDEUIMessages.OverviewPage_contentTitle); >+ createText(section, PDEUIMessages.OverviewPage_contentDescription, toolkit); >+ } >+ >+ private void createEnvironmentSection(Composite parent, FormToolkit toolkit) { >+ Section section = createSection(parent, toolkit, PDEUIMessages.OverviewPage_environmentTitle); >+ createText(section, PDEUIMessages.OverviewPage_environmentDescription, toolkit); >+ } >+ >+ private Section createSection(Composite parent, FormToolkit toolkit, String title) { >+ Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR); >+ section.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING; >+ section.setText(title); >+ section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1)); >+ section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); >+ return section; >+ } >+ >+ private FormText createText(Section section, String content, FormToolkit toolkit) { >+ Composite container = toolkit.createComposite(section, SWT.NONE); >+ container.setLayout(FormLayoutFactory.createSectionClientTableWrapLayout(false, 1)); >+ section.setClient(container); >+ FormText text = toolkit.createFormText(container, true); >+ try { >+ text.setText(content, true, false); >+ } catch (SWTException e) { >+ text.setText(e.getMessage(), false, false); >+ } >+ TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB); >+ data.maxWidth = 250; >+ text.setLayoutData(data); >+ text.addHyperlinkListener(this); >+ return text; >+ } >+ >+ public void linkActivated(HyperlinkEvent e) { >+ String href = (String) e.getHref(); >+ if (href.equals("content")) //$NON-NLS-1$ >+ getEditor().setActivePage(ContentPage.PAGE_ID); >+ else if (href.equals("environment")) //$NON-NLS-1$ >+ getEditor().setActivePage(EnvironmentPage.PAGE_ID); >+ } >+ >+ public void linkEntered(HyperlinkEvent e) { >+ IStatusLineManager mng = getEditor().getEditorSite().getActionBars().getStatusLineManager(); >+ mng.setMessage(e.getLabel()); >+ } >+ >+ public void linkExited(HyperlinkEvent e) { >+ IStatusLineManager mng = getEditor().getEditorSite().getActionBars().getStatusLineManager(); >+ mng.setMessage(null); > } > > // TODO Hook up help toolbar action >Index: src/org/eclipse/pde/internal/ui/wizards/target/TargetDefinitionContentPage.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/target/TargetDefinitionContentPage.java,v >retrieving revision 1.12 >diff -u -r1.12 TargetDefinitionContentPage.java >--- src/org/eclipse/pde/internal/ui/wizards/target/TargetDefinitionContentPage.java 3 Mar 2009 20:41:12 -0000 1.12 >+++ src/org/eclipse/pde/internal/ui/wizards/target/TargetDefinitionContentPage.java 9 Apr 2009 22:03:04 -0000 >@@ -10,8 +10,6 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.ui.wizards.target; > >-import org.eclipse.pde.internal.ui.PDEUIMessages; >- > import java.lang.reflect.InvocationTargetException; > import java.util.*; > import java.util.List; >@@ -41,6 +39,8 @@ > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.*; >+import org.eclipse.ui.ISharedImages; >+import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.dialogs.ElementListSelectionDialog; > import org.eclipse.ui.progress.UIJob; > >@@ -55,7 +55,9 @@ > private static final String EMPTY_STRING = ""; //$NON-NLS-1$ > > private Text fNameText; >- private BundleContainerTable fTable; >+ private TabItem fLocationTab; >+ private TargetLocationsGroup fLocationTree; >+ private TargetContentsGroup fContentTree; > > // Environment pull-downs > private Combo fOSCombo; >@@ -125,45 +127,20 @@ > TabFolder tabs = new TabFolder(comp, SWT.NONE); > tabs.setLayoutData(new GridData(GridData.FILL_BOTH)); > >- TabItem pluginsTab = new TabItem(tabs, SWT.NONE); >- pluginsTab.setText(PDEUIMessages.TargetDefinitionContentPage_6); >+ fLocationTab = new TabItem(tabs, SWT.NONE); >+ fLocationTab.setText("Locations"); > > Composite pluginTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH); >- >- SWTFactory.createWrapLabel(pluginTabContainer, PDEUIMessages.ContentSection_1, 2, 400); >- >- fTable = BundleContainerTable.createTableInDialog(pluginTabContainer, new IBundleContainerTableReporter() { >- public void runResolveOperation(final IRunnableWithProgress operation) { >- if (isControlCreated()) { >- try { >- getContainer().run(true, false, operation); >- } catch (InvocationTargetException e) { >- PDEPlugin.log(e); >- } catch (InterruptedException e) { >- // TODO Cancel the wizard? >- } >- } else { >- // If the page isn't open yet, try running a UI job so the dialog has time to finish opening >- new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) { >- public IStatus runInUIThread(IProgressMonitor monitor) { >- try { >- getContainer().run(true, false, operation); >- return Status.OK_STATUS; >- } catch (InvocationTargetException e) { >- return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), PDEUIMessages.TargetDefinitionContentPage_5, e); >- } catch (InterruptedException e) { >- return Status.CANCEL_STATUS; >- } >- } >- }.schedule(); >- } >- } >- >- public void contentsChanged() { >- // Do nothing, as wizard will always save when finish is pressed >- } >- }); >- pluginsTab.setControl(pluginTabContainer); >+ SWTFactory.createWrapLabel(pluginTabContainer, "List of locations to look for plug-ins to add to this target.", 2, 400); >+ fLocationTree = TargetLocationsGroup.createInDialog(pluginTabContainer); >+ fLocationTab.setControl(pluginTabContainer); >+ >+ TabItem contentTab = new TabItem(tabs, SWT.NONE); >+ contentTab.setText(PDEUIMessages.TargetDefinitionContentPage_6); >+ Composite contentTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH); >+ SWTFactory.createWrapLabel(contentTabContainer, PDEUIMessages.ContentSection_1, 2, 400); >+ fContentTree = TargetContentsGroup.createInDialog(contentTabContainer); >+ contentTab.setControl(contentTabContainer); > > TabItem envTab = new TabItem(tabs, SWT.NONE); > envTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_3); >@@ -180,10 +157,74 @@ > depTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_5); > depTab.setControl(createImplicitTabContents(tabs)); > >+ initializeListeners(); > targetChanged(getTargetDefinition()); > setControl(comp); > } > >+ private void initializeListeners() { >+ ITargetChangedListener listener = new ITargetChangedListener() { >+ public void contentsChanged(ITargetDefinition definition, boolean resolve) { >+ if (resolve) { >+ if (!definition.isResolved()) { >+ try { >+ getContainer().run(true, true, new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >+ getTargetDefinition().resolve(monitor); >+ if (monitor.isCanceled()) { >+ throw new InterruptedException(); >+ } >+ } >+ }); >+ } catch (InvocationTargetException e) { >+ PDECore.log(e); >+ } catch (InterruptedException e) { >+ // Do nothing, op cancelled >+ } >+ } >+ fContentTree.setInput(definition); >+ fLocationTree.setInput(definition); >+ if (definition.isResolved() && definition.getBundleStatus().getSeverity() == IStatus.ERROR) { >+ fLocationTab.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK)); >+ } else { >+ fLocationTab.setImage(null); >+ } >+ } >+ } >+ }; >+ fContentTree.addTargetChangedListener(listener); >+ fLocationTree.addTargetChangedListener(listener); >+ // When If the page isn't open yet, try running a UI job so the dialog has time to finish opening >+ new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) { >+ public IStatus runInUIThread(IProgressMonitor monitor) { >+ try { >+ getContainer().run(true, true, new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >+ getTargetDefinition().resolve(monitor); >+ if (monitor.isCanceled()) { >+ throw new InterruptedException(); >+ } >+ } >+ }); >+ } catch (InvocationTargetException e) { >+ PDECore.log(e); >+ } catch (InterruptedException e) { >+ return Status.CANCEL_STATUS; >+ } >+ ITargetDefinition definition = getTargetDefinition(); >+ fContentTree.setInput(definition); >+ fLocationTree.setInput(definition); >+ if (definition.isResolved() && definition.getBundleStatus().getSeverity() == IStatus.ERROR) { >+ fLocationTab.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK)); >+ } else { >+ fLocationTab.setImage(null); >+ } >+ return Status.OK_STATUS; >+ } >+ }.schedule(); >+ >+ } >+ > /* (non-Javadoc) > * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged() > */ >@@ -200,7 +241,8 @@ > else > setMessage(PDEUIMessages.TargetDefinitionContentPage_8); > >- fTable.setInput(definition); >+ fLocationTree.setInput(definition); >+ fContentTree.setInput(definition); > > String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS(); > fOSCombo.setText(presetValue); >Index: src/org/eclipse/pde/internal/ui/util/PDEJavaHelperUI.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/util/PDEJavaHelperUI.java,v >retrieving revision 1.7 >diff -u -r1.7 PDEJavaHelperUI.java >--- src/org/eclipse/pde/internal/ui/util/PDEJavaHelperUI.java 1 Apr 2009 16:51:01 -0000 1.7 >+++ src/org/eclipse/pde/internal/ui/util/PDEJavaHelperUI.java 9 Apr 2009 22:03:04 -0000 >@@ -237,7 +237,7 @@ > // Set auto activation character to be a '.' > char[] autoActivationChars = new char[] {TypeContentProposalProvider.F_DOT}; > // Create the adapter >- ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(text, textContentAdapter, proposalProvider, IWorkbenchCommandConstants.EDIT_CONTENT_ASSIST, autoActivationChars); >+ ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(text, textContentAdapter, proposalProvider, IWorkbenchCommandConstants.EDIT_CONTENTASSIST, autoActivationChars); > // Configure the adapter > // Add label provider > ILabelProvider labelProvider = new TypeProposalLabelProvider(); >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/plugin.xml,v >retrieving revision 1.462 >diff -u -r1.462 plugin.xml >--- plugin.xml 2 Apr 2009 22:25:06 -0000 1.462 >+++ plugin.xml 9 Apr 2009 22:03:04 -0000 >@@ -69,6 +69,18 @@ > id="org.eclipse.pde.ui.TargetPlatformPreferencePage"> > </keywordReference> > </page> >+ <page >+ category="org.eclipse.pde.ui.MainPreferencePage" >+ class="org.eclipse.pde.internal.ui.preferences.TargetPlatformPreferencePage" >+ id="org.eclipse.pde.ui.TargetPlatformPreferencePage" >+ name="Target 2"> >+ <keywordReference >+ id="org.eclipse.pde.ui.pde"> >+ </keywordReference> >+ <keywordReference >+ id="org.eclipse.pde.ui.TargetPlatformPreferencePage"> >+ </keywordReference> >+ </page> > </extension> > <extension > point="org.eclipse.ui.keywords"> >Index: src/org/eclipse/pde/internal/ui/shared/target/ITargetChangedListener.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/shared/target/ITargetChangedListener.java >diff -N src/org/eclipse/pde/internal/ui/shared/target/ITargetChangedListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/shared/target/ITargetChangedListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * 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 org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; >+import org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionContentPage; >+ >+/** >+ * Listener for UI components that modify the contents of target definitions. >+ * Whenever the contents of the target changes the listener will be called so >+ * the target can be resolved and the UI updated. >+ * >+ * @see TargetLocationsGroup >+ * @see TargetContentsGroup >+ * @see TargetDefinitionContentPage >+ */ >+public interface ITargetChangedListener { >+ >+ /** >+ * Informs the listener that the contents of the target have changed >+ * and UI elements may need to be refreshed. >+ * @param definition target definition whose contents have changed or <code>null</code> if the definition is not available >+ * @param resolve whether the definition must be resolved to catch up to all changes >+ */ >+ public void contentsChanged(ITargetDefinition definition, boolean resolve); >+ >+} >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,175 @@ >+/******************************************************************************* >+ * 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.*; >+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(), 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/editor/targetdefinition/ContentPage.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/targetdefinition/ContentPage.java >diff -N src/org/eclipse/pde/internal/ui/editor/targetdefinition/ContentPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/targetdefinition/ContentPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,83 @@ >+/******************************************************************************* >+ * 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.editor.targetdefinition; >+ >+import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; >+import org.eclipse.pde.internal.ui.PDEPlugin; >+import org.eclipse.pde.internal.ui.PDEPluginImages; >+import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.forms.IManagedForm; >+import org.eclipse.ui.forms.editor.FormPage; >+import org.eclipse.ui.forms.widgets.FormToolkit; >+import org.eclipse.ui.forms.widgets.ScrolledForm; >+ >+/** >+ * First page in the target definition editor. Allows for editing of the name, >+ * description and content of the target. >+ * @see TargetEditor >+ * @see InformationSection >+ * @see LocationSection >+ */ >+public class ContentPage extends FormPage { >+ >+ public static final String PAGE_ID = "content"; //$NON-NLS-1$ >+ >+ public ContentPage(TargetEditor editor) { >+ super(editor, PAGE_ID, "Content"); >+ } >+ >+ /** >+ * @return The target model backing this editor >+ */ >+ public ITargetDefinition getTarget() { >+ return ((TargetEditor) getEditor()).getTarget(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#createFormContent(org.eclipse.ui.forms.IManagedForm) >+ */ >+ protected void createFormContent(IManagedForm managedForm) { >+ super.createFormContent(managedForm); >+ ScrolledForm form = managedForm.getForm(); >+ FormToolkit toolkit = managedForm.getToolkit(); >+ form.setText("Target Content"); >+ PDEPlugin.getDefault().getLabelProvider().connect(this); >+ form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_TARGET_DEFINITION)); >+ toolkit.decorateFormHeading(form.getForm()); >+ fillBody(managedForm, toolkit); >+ // TODO Finish help >+ ((TargetEditor) getEditor()).contributeToToolbar(managedForm.getForm(), ""); //$NON-NLS-1$ >+ ((TargetEditor) getEditor()).addForm(managedForm); >+ form.updateToolBar(); >+// PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.TARGET_OVERVIEW_PAGE); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.editor.FormPage#dispose() >+ */ >+ public void dispose() { >+ PDEPlugin.getDefault().getLabelProvider().disconnect(this); >+ super.dispose(); >+ } >+ >+ private void fillBody(IManagedForm managedForm, FormToolkit toolkit) { >+ Composite body = managedForm.getForm().getBody(); >+ body.setLayout(FormLayoutFactory.createFormGridLayout(true, 1)); >+ managedForm.addPart(new ContentSection(this, body)); >+ } >+ >+ // TODO Hook up help toolbar action >+// protected String getHelpResource() { >+// return "/org.eclipse.pde.doc.user/guide/tools/editors/target_definition_editor/overview.htm"; //$NON-NLS-1$ >+// } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/targetdefinition/LocationSection.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/targetdefinition/LocationSection.java >diff -N src/org/eclipse/pde/internal/ui/editor/targetdefinition/LocationSection.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/targetdefinition/LocationSection.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,86 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 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.editor.targetdefinition; >+ >+import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >+import org.eclipse.pde.internal.ui.shared.target.ITargetChangedListener; >+import org.eclipse.pde.internal.ui.shared.target.TargetLocationsGroup; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.forms.SectionPart; >+import org.eclipse.ui.forms.editor.FormPage; >+import org.eclipse.ui.forms.widgets.*; >+ >+/** >+ * Section for editing the content of the target (bundle containers) in the target definition editor >+ * @see DefinitionPage >+ * @see TargetEditor >+ */ >+public class LocationSection extends SectionPart { >+ >+ private TargetLocationsGroup fContainerGroup; >+ private TargetEditor fEditor; >+ >+ public LocationSection(FormPage page, Composite parent) { >+ super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR); >+ fEditor = (TargetEditor) page.getEditor(); >+ createClient(getSection(), page.getEditor().getToolkit()); >+ } >+ >+ /** >+ * @return The target model backing this editor >+ */ >+ private ITargetDefinition getTarget() { >+ return fEditor.getTarget(); >+ } >+ >+ /** >+ * Creates the UI for this section. >+ * >+ * @param section section the UI is being added to >+ * @param toolkit form toolkit used to create the widgets >+ */ >+ protected void createClient(Section section, FormToolkit toolkit) { >+ section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1)); >+ GridData sectionData = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL); >+ sectionData.horizontalSpan = 2; >+ section.setLayoutData(sectionData); >+ section.setText("Locations"); >+ >+ section.setDescription(PDEUIMessages.ContentSection_1); >+ Composite client = toolkit.createComposite(section); >+ client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1)); >+ client.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL)); >+ >+ fContainerGroup = TargetLocationsGroup.createInForm(client, toolkit); >+ fEditor.getTargetChangedListener().setLocationTree(fContainerGroup); >+ fContainerGroup.addTargetChangedListener(fEditor.getTargetChangedListener()); >+ fContainerGroup.addTargetChangedListener(new ITargetChangedListener() { >+ public void contentsChanged(ITargetDefinition definition, boolean resolve) { >+ markDirty(); >+ } >+ }); >+ >+ toolkit.paintBordersFor(client); >+ section.setClient(client); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.AbstractFormPart#refresh() >+ */ >+ public void refresh() { >+ fContainerGroup.setInput(getTarget()); >+ super.refresh(); >+ } >+ >+} >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,95 @@ >+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.pde.internal.ui.SWTFactory; >+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) { >+ Composite composite = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH); >+ SWTFactory.createLabel(composite, "Plug-ins:", 1); >+ fPreviewTable = new TableViewer(composite); >+ fPreviewTable.setLabelProvider(new BundleInfoLabelProvider(true)); >+ fPreviewTable.setContentProvider(ArrayContentProvider.getInstance()); >+ fPreviewTable.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); >+ setControl(composite); >+ } >+ >+ /** >+ * 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()); >+ } >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/shared/target/TargetContentsGroup.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/shared/target/TargetContentsGroup.java >diff -N src/org/eclipse/pde/internal/ui/shared/target/TargetContentsGroup.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/shared/target/TargetContentsGroup.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,762 @@ >+package org.eclipse.pde.internal.ui.shared.target; >+ >+import com.ibm.icu.text.MessageFormat; >+import java.net.URI; >+import java.util.*; >+import java.util.List; >+import org.eclipse.core.runtime.*; >+import org.eclipse.core.runtime.jobs.*; >+import org.eclipse.jface.viewers.*; >+import org.eclipse.pde.internal.core.target.provisional.*; >+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; >+import org.eclipse.ui.forms.widgets.FormToolkit; >+import org.eclipse.ui.progress.UIJob; >+ >+public class TargetContentsGroup 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 Label fGroupLabel; >+ private Combo fGroupCombo; >+ >+ private ViewerFilter fSourceFilter; >+ private ViewerFilter fPluginFilter; >+ >+ private List fAllBundles; >+ private Set fAllChecked; >+ private Map fContainerBundles; >+ private Map fContainerChecked; >+ private Map fFileBundles; >+ private Map fFileChecked; >+ >+ private ITargetDefinition fTargetDefinition; >+ >+ private int fGrouping; >+ private static final int GROUP_BY_NONE = 0; >+ private static final int GROUP_BY_FILE_LOC = 1; >+ private static final int GROUP_BY_CONTAINER = 2; >+ private ListenerList fChangeListeners = new ListenerList(); >+ >+ public static TargetContentsGroup createInForm(Composite parent, FormToolkit toolkit) { >+ // TODO Should we be using the tooklit to create the controls? >+ TargetContentsGroup control = new TargetContentsGroup(parent); >+ return control; >+ } >+ >+ public static TargetContentsGroup createInDialog(Composite parent) { >+ TargetContentsGroup control = new TargetContentsGroup(parent); >+ return control; >+ } >+ >+ private TargetContentsGroup(Composite parent) { >+ super(parent, SWT.BORDER | SWT.MULTI, new PatternFilter(), true); >+ } >+ >+ /** >+ * Adds a listener to the set of listeners that will be notified when the bundle containers >+ * are modified. This method has no effect if the listener has already been added. >+ * >+ * @param listener target changed listener to add >+ */ >+ public void addTargetChangedListener(ITargetChangedListener listener) { >+ fChangeListeners.add(listener); >+ } >+ >+ /** >+ * Informs the target content listeners that check state has changed >+ */ >+ public void contentChanged() { >+ // TODO Save the included bundles >+ Object[] listeners = fChangeListeners.getListeners(); >+ for (int i = 0; i < listeners.length; i++) { >+ ((ITargetChangedListener) listeners[i]).contentsChanged(fTargetDefinition, false); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.dialogs.FilteredTree#createTreeControl(org.eclipse.swt.widgets.Composite, int) >+ */ >+ protected Control createTreeControl(Composite parent, int style) { >+ fGrouping = GROUP_BY_NONE; >+ Composite treeComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0); >+ super.createTreeControl(treeComp, style); >+ ((GridData) fTree.getControl().getLayoutData()).heightHint = 300; >+ createButtons(treeComp); >+ createOptions(treeComp); >+ >+ updateButtons(); >+ initializeFilters(); >+ return treeComp; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.dialogs.FilteredTree#doCreateTreeViewer(org.eclipse.swt.widgets.Composite, int) >+ */ >+ 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(new TreeContentProvider()); >+ fTree.setLabelProvider(new BundleContainerLabelProvider()); >+ fTree.addDoubleClickListener(new IDoubleClickListener() { >+ public void doubleClick(DoubleClickEvent event) { >+ IStructuredSelection selection = (IStructuredSelection) event.getSelection(); >+ Object first = selection.getFirstElement(); >+ handleCheck(new Object[] {selection.getFirstElement()}, !fTree.getChecked(first)); >+ } >+ }); >+ fTree.addCheckStateListener(new ICheckStateListener() { >+ public void checkStateChanged(CheckStateChangedEvent event) { >+ handleCheck(new Object[] {event.getElement()}, fTree.getChecked(event.getElement())); >+ } >+ }); >+ fTree.addSelectionChangedListener(new ISelectionChangedListener() { >+ public void selectionChanged(SelectionChangedEvent event) { >+ updateButtons(); >+ } >+ }); >+ fTree.setSorter(new ViewerSorter() { >+ public int compare(Viewer viewer, Object e1, Object e2) { >+ if (e1 instanceof IResolvedBundle && e2 instanceof IResolvedBundle) { >+ IStatus status1 = ((IResolvedBundle) e1).getStatus(); >+ IStatus status2 = ((IResolvedBundle) e2).getStatus(); >+ if (!status1.isOK() && status2.isOK()) { >+ return -1; >+ } >+ if (status1.isOK() && !status2.isOK()) { >+ return 1; >+ } >+ } >+ return super.compare(viewer, e1, e2); >+ } >+ >+ }); >+ return fTree; >+ } >+ >+ private void createButtons(Composite parent) { >+ Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0); >+ >+ 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(); >+ handleCheck(selected, true); >+ } >+ } >+ }); >+ 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(); >+ handleCheck(selected, false); >+ } >+ } >+ }); >+ >+ createEmptySpace(buttonComp); >+ >+ fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null); >+ fSelectAllButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ // TODO >+// Object[] elements = ((ITreeContentProvider) fTree.getContentProvider()).getElements(fTree.getInput()); >+// fTree.setGrayedElements(new Object[0]); >+// for (int i = 0; i < elements.length; i++) { >+// fTree.setSubtreeChecked(elements[i], true); >+// } >+// updateParentCheckState(elements); >+// contentChanged(); >+// updateButtons(); >+ } >+ }); >+ fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null); >+ fDeselectAllButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ // TODO >+// Object[] elements = ((ITreeContentProvider) fTree.getContentProvider()).getElements(fTree.getInput()); >+// fTree.setGrayedElements(new Object[0]); >+// for (int i = 0; i < elements.length; i++) { >+// fTree.setSubtreeChecked(elements[i], false); >+// } >+// updateParentCheckState(elements); >+// contentChanged(); >+// 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)); >+ >+ 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); >+ } >+ >+ private void createOptions(Composite parent) { >+ Composite comp = SWTFactory.createComposite(parent, 2, 2, GridData.FILL_HORIZONTAL, 0, 0); >+ >+ fGroupLabel = SWTFactory.createLabel(comp, "Group by:", 1); >+ fGroupCombo = SWTFactory.createCombo(comp, SWT.READ_ONLY, 1, new String[] {"None", "File Path", "Plug-in Container"}); >+ fGroupCombo.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ handleGroupChange(); >+ } >+ }); >+ >+ fCountLabel = SWTFactory.createLabel(comp, "", 2); //$NON-NLS-1$ >+ } >+ >+ 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 IPath getParentPath(IResolvedBundle bundle) { >+ URI location = bundle.getBundleInfo().getLocation(); >+ if (location == null) { >+ return new Path("Unknown"); >+ } >+ IPath path = new Path(URIUtil.toUnencodedString(location)); >+ path = path.removeLastSegments(1); >+ return path; >+ } >+ >+ private void handleCheck(Object[] changedElements, boolean checkState) { >+ if (changedElements.length > 0) { >+ if (changedElements[0] instanceof IResolvedBundle) { >+ Set parentsToUpdate = new HashSet(); >+ for (int i = 0; i < changedElements.length; i++) { >+ Object parent = ((IResolvedBundle) changedElements[i]).getParentContainer(); >+ if (fGrouping == GROUP_BY_CONTAINER) { >+ parentsToUpdate.add(parent); >+ } >+ Set containerChecked = ((Set) fContainerChecked.get(parent)); >+ >+ parent = getParentPath((IResolvedBundle) changedElements[i]); >+ if (fGrouping == GROUP_BY_FILE_LOC) { >+ parentsToUpdate.add(parent); >+ } >+ Set fileChecked = ((Set) fContainerChecked.get(parent)); >+ >+ if (checkState) { >+ fAllChecked.add(changedElements[i]); >+ containerChecked.add(changedElements[i]); >+ fileChecked.add(changedElements[i]); >+ } else { >+ fAllChecked.remove(changedElements[i]); >+ containerChecked.remove(changedElements[i]); >+ fileChecked.remove(changedElements[i]); >+ } >+ fTree.setChecked(changedElements, checkState); >+ } >+ for (Iterator iterator = parentsToUpdate.iterator(); iterator.hasNext();) { >+ Object parent = iterator.next(); >+ if (getChecked(parent).size() == 0) { >+ fTree.setGrayChecked(parent, false); >+ } else if (getChecked(parent).size() == getBundleChildren(parent).size()) { >+ fTree.setGrayed(parent, false); >+ fTree.setChecked(parent, true); >+ } else { >+ fTree.setGrayChecked(parent, true); >+ } >+ } >+ } else { >+ for (int i = 0; i < changedElements.length; i++) { >+ fTree.setGrayed(changedElements[i], false); >+ fTree.setChecked(changedElements[i], checkState); >+ fTree.setSubtreeChecked(changedElements[i], checkState); >+ >+ fgetChecked(changedElements[i]). >+ } >+ } >+ } >+ } >+ >+ /** >+ * Update the check state of parent elements when there is grouping. The list of changed elements must be >+ * all IResolvedBundles. >+ * >+ * @param changedElements array of IResolvedBundles that have changed >+ */ >+ private void updateParentCheckState(Object[] changedElements) { >+ if (fGrouping != GROUP_BY_NONE && changedElements.length > 0) { >+ Set changedParents = new HashSet(); >+ if (changedElements[0] instanceof IResolvedBundle) { >+ if (fGrouping == GROUP_BY_FILE_LOC) { >+ for (int i = 0; i < changedElements.length; i++) { >+ changedParents.add(getParentPath((IResolvedBundle) changedElements[i])); >+ } >+ } else if (fGrouping == GROUP_BY_CONTAINER) { >+ for (int i = 0; i < changedElements.length; i++) { >+ changedParents.add(((IResolvedBundle) changedElements[i]).getParentContainer()); >+ } >+ } >+ } else { >+ changedParents.addAll(Arrays.asList(changedElements)); >+ } >+ if (fGrouping == GROUP_BY_FILE_LOC) { >+ for (Iterator iterator = changedParents.iterator(); iterator.hasNext();) { >+ IPath currentParent = (IPath) iterator.next(); >+ List children = (List) getFileLocationMap().get(currentParent); >+ updateGrayChecked(currentParent, children); >+ } >+ } else if (fGrouping == GROUP_BY_CONTAINER) { >+ for (Iterator iterator = changedParents.iterator(); iterator.hasNext();) { >+ IBundleContainer currentParent = (IBundleContainer) iterator.next(); >+ List children = Arrays.asList(currentParent.getAllBundles()); >+ // TODO Get plug-in errors (missing bundles) >+ updateGrayChecked(currentParent, children); >+ } >+ } >+ } >+ } >+ >+ /** >+ * Updates the children of the changed parent elements. Also removed the gray state >+ * of the parent. >+ * >+ * @param changedElements list of changed parents >+ * @param state whether the parents are being checked or unchecked >+ */ >+ private void updateChildrenCheckState(Object[] changedElements, boolean state) { >+ for (int i = 0; i < changedElements.length; i++) { >+ fTree.setSubtreeChecked(changedElements[i], state); >+ fTree.setGrayed(changedElements[i], false); >+ fTree.setChecked(changedElements[i], state); >+ } >+ } >+ >+ private void updateGrayChecked(Object parent, List children) { >+ boolean allChecked = true; >+ boolean noneChecked = true; >+ for (Iterator iterator2 = children.iterator(); iterator2.hasNext();) { >+ boolean checked = fTree.getChecked(iterator2.next()); >+ if (checked) { >+ noneChecked = false; >+ } else { >+ allChecked = false; >+ } >+ if (!noneChecked && !allChecked) { >+ break; >+ } >+ } >+ if (!noneChecked && !allChecked) { >+ fTree.setGrayChecked(parent, true); >+ } else if (allChecked) { >+ fTree.setChecked(parent, true); >+ fTree.setGrayed(parent, false); >+ } else { >+ fTree.setChecked(parent, false); >+ fTree.setGrayed(parent, false); >+ } >+ } >+ >+ private void handleGroupChange() { >+ // TODO >+ fGrouping = fGroupCombo.getSelectionIndex(); >+ Object[] checked = fTree.getCheckedElements(); >+ fTree.getControl().setRedraw(false); >+ fTree.refresh(false); >+ fTree.setCheckedElements(checked); >+ if (fGrouping == GROUP_BY_CONTAINER) { >+ updateParentCheckState(fTargetDefinition.getBundleContainers()); >+ } else if (fGrouping == GROUP_BY_FILE_LOC) { >+ updateParentCheckState(getFileLocationMap().keySet().toArray()); >+ } >+ fTree.getControl().setRedraw(true); >+ updateButtons(); >+ } >+ >+ private void updateButtons() { >+ if (fTargetDefinition != null && !fTree.getSelection().isEmpty()) { >+ Object[] selection = ((IStructuredSelection) fTree.getSelection()).toArray(); >+ boolean hasResolveBundle = false; >+ boolean hasParent = false; >+ boolean allSelected = true; >+ boolean noneSelected = true; >+ for (int i = 0; i < selection.length; i++) { >+ if (!hasResolveBundle || !hasParent) { >+ if (selection[i] instanceof IResolvedBundle) { >+ hasResolveBundle = true; >+ } else { >+ hasParent = true; >+ } >+ } >+ boolean checked = fTree.getChecked(selection[i]); >+ if (checked) { >+ noneSelected = false; >+ } else { >+ allSelected = false; >+ } >+ } >+ // Selection is available is not everything is already selected and not both a parent and child item are selected >+ fSelectButton.setEnabled(!allSelected && !(hasResolveBundle && hasParent)); >+ fDeselectButton.setEnabled(!noneSelected && !(hasResolveBundle && hasParent)); >+// fSelectRequiredButton.setEnabled(true); >+ } else { >+ fSelectButton.setEnabled(false); >+ fDeselectButton.setEnabled(false); >+// fSelectRequiredButton.setEnabled(false); >+ } >+ >+ // TODO how to handle filtered case >+ if (fGrouping == GROUP_BY_FILE_LOC) { >+ boolean allChecked = true; >+ boolean noneChecked = true; >+ if (fTree.getGrayedElements().length > 0) { >+ allChecked = false; >+ noneChecked = false; >+ } else { >+ for (Iterator iterator = getFileLocationMap().keySet().iterator(); iterator.hasNext();) { >+ boolean checked = fTree.getChecked(iterator.next()); >+ if (checked) { >+ noneChecked = false; >+ } else { >+ allChecked = false; >+ } >+ if (!noneChecked && !allChecked) { >+ break; >+ } >+ } >+ } >+ fSelectAllButton.setEnabled(fTargetDefinition != null && !allChecked); >+ fDeselectAllButton.setEnabled(fTargetDefinition != null && !noneChecked); >+ } else { >+ int checked = fTree.getCheckedElements().length; >+ fSelectAllButton.setEnabled(fTargetDefinition != null && checked != fTree.getTree().getItemCount()); >+ fDeselectAllButton.setEnabled(fTargetDefinition != null && checked != 0); >+ } >+ >+ if (fTargetDefinition != null) { >+ fCountLabel.setText(MessageFormat.format("{0} of {1} selected", new String[] {Integer.toString(fAllChecked.size()), Integer.toString(fAllBundles.size())})); >+ } 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) { >+ fTargetDefinition = input; >+ >+ if (input == null || !input.isResolved()) { >+ fTree.setInput("Resolving..."); >+ setEnabled(false); >+ return; >+ } >+ >+ IResolvedBundle[] allResolvedBundles = input.getAllBundles(); >+ if (allResolvedBundles == null || allResolvedBundles.length == 0) { >+ fTree.setInput("< no plug-ins found in the target >"); >+ setEnabled(false); >+ return; >+ } >+ >+ fTree.setInput("Initializing..."); >+ setEnabled(false); >+ Job initJob = new InitalizeJob(); >+ initJob.addJobChangeListener(new JobChangeAdapter() { >+ public void done(IJobChangeEvent event) { >+ Job refreshJob = new UIJob("Refreshing Tree") { >+ public IStatus runInUIThread(IProgressMonitor monitor) { >+ fTree.setInput(fTargetDefinition); >+ // For now we always start with no grouping >+ fTree.setCheckedElements(getChecked(null).toArray()); >+ setEnabled(true); >+ return Status.OK_STATUS; >+ } >+ }; >+ refreshJob.setSystem(true); >+ refreshJob.schedule(); >+ } >+ }); >+ initJob.schedule(); >+ } >+ >+ private class InitalizeJob extends Job { >+ >+ public InitalizeJob() { >+ super("Initializing Tree"); >+ setSystem(true); >+ } >+ >+ protected IStatus run(IProgressMonitor monitor) { >+ fAllBundles = new ArrayList(); >+ fAllChecked = new HashSet(); >+ fContainerBundles = new HashMap(); >+ fContainerChecked = new HashMap(); >+ IBundleContainer[] containers = fTargetDefinition.getBundleContainers(); >+ // Iterate through each container, adding bundles to the map and list >+ for (int i = 0; i < containers.length; i++) { >+ List containerBundles = Arrays.asList(containers[i].getAllBundles()); >+ fAllBundles.addAll(containerBundles); >+ fContainerBundles.put(containers[i], containerBundles); >+ >+ // Determine which of the bundles are checked (included) >+ if (containers[i].getIncludedBundles() == null) { >+ // Everything is included >+ Set checked = new HashSet(); >+ checked.addAll(containerBundles); >+ fContainerChecked.put(containers[i], checked); >+ fAllChecked.addAll(checked); >+ } else { >+ // Mark the included bundles as checked >+ List includedBundles = Arrays.asList(containers[i].getBundles()); >+ // If an included bundle has errors it must be explicitly added to the bundle list as getAllBundles does not return it. >+ for (Iterator iterator = includedBundles.iterator(); iterator.hasNext();) { >+ IResolvedBundle currentIncluded = (IResolvedBundle) iterator.next(); >+ if (!currentIncluded.getStatus().isOK()) { >+ ((List) fContainerBundles.get(containers[i])).add(currentIncluded); >+ fAllBundles.add(currentIncluded); >+ } >+ } >+ Set checked = new HashSet(); >+ checked.addAll(includedBundles); >+ fContainerChecked.put(containers[i], checked); >+ fAllChecked.addAll(checked); >+ } >+ } >+ >+ // Map the bundles into their file locations >+ fFileBundles = new HashMap(); >+ fFileChecked = new HashMap(); >+ Set allChecked = new HashSet(); >+ allChecked.addAll(fAllChecked); >+ for (Iterator iterator = fAllBundles.iterator(); iterator.hasNext();) { >+ IResolvedBundle currentBundle = (IResolvedBundle) iterator.next(); >+ IPath parentPath = getParentPath(currentBundle); >+ List bundles = (List) fFileBundles.get(parentPath); >+ if (bundles == null) { >+ bundles = new ArrayList(); >+ bundles.add(currentBundle); >+ fFileBundles.put(parentPath, bundles); >+ } else { >+ bundles.add(currentBundle); >+ } >+ // Determine whether the current bundle is checked >+ if (allChecked.contains(currentBundle)) { >+ Set checked = (Set) fFileChecked.get(parentPath); >+ if (checked == null) { >+ checked = new HashSet(); >+ checked.add(currentBundle); >+ fFileChecked.put(parentPath, checked); >+ } else { >+ checked.add(currentBundle); >+ } >+ } >+ } >+ >+ return Status.OK_STATUS; >+ } >+ } >+ >+ private Set getChecked(Object parent) { >+ Set result = null; >+ if (parent == null) { >+ result = fAllChecked; >+ } else if (fGrouping == GROUP_BY_CONTAINER) { >+ result = (Set) fContainerChecked.get(parent); >+ } else if (fGrouping == GROUP_BY_FILE_LOC) { >+ result = (Set) fFileChecked.get(parent); >+ } >+ if (result == null) { >+ return new HashSet(0); >+ } >+ return result; >+ } >+ >+ private List getBundleChildren(Object parent) { >+ List result = null; >+ if (parent == null) { >+ result = fAllBundles; >+ } else if (fGrouping == GROUP_BY_CONTAINER) { >+ result = (List) fContainerBundles.get(parent); >+ } else if (fGrouping == GROUP_BY_FILE_LOC) { >+ result = (List) fFileBundles.get(parent); >+ } >+ if (result == null) { >+ return new ArrayList(0); >+ } >+ return result; >+ } >+ >+ /* (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); >+ fGroupLabel.setEnabled(enabled); >+ fGroupCombo.setEnabled(enabled); >+ super.setEnabled(enabled); >+ } >+ >+ public void saveIncludedBundleState() { >+ // TODO Simplify with bundle containers >+// IBundleContainer[] containers = fTargetDefinition.getBundleContainers(); >+// for (int i = 0; i < containers.length; i++) { >+// IResolvedBundle[] allBundles = containers[i].getAllBundles(); >+// List included = new ArrayList(allBundles.length); >+// for (int j = 0; j < allBundles.length; j++) { >+// if (fTree.getChecked(allBundles[j])) { >+// included.add(new BundleInfo(allBundles[j].getBundleInfo().getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false)); >+// } >+// } >+// if (included.size() == allBundles.length) { >+// containers[i].setIncludedBundles(null); >+// } else { >+// containers[i].setIncludedBundles((BundleInfo[]) included.toArray(new BundleInfo[included.size()])); >+// } >+// } >+ // TODO Handle plug-in errors (missing bundles) >+ } >+ >+ class TreeContentProvider implements ITreeContentProvider { >+ public Object[] getChildren(Object parentElement) { >+ return getBundleChildren(parentElement).toArray(); >+ } >+ >+ public Object getParent(Object element) { >+// if (fGrouping == GROUP_BY_CONTAINER && element instanceof IResolvedBundle) { >+// return ((IResolvedBundle) element).getParentContainer(); >+// } else if (fGrouping == GROUP_BY_FILE_LOC && element instanceof IResolvedBundle) { >+// return getParentPath((IResolvedBundle) element); >+// } >+ return null; >+ } >+ >+ public boolean hasChildren(Object element) { >+ if (fGrouping == GROUP_BY_NONE || element instanceof IResolvedBundle) { >+ return false; >+ } >+ if (element instanceof IBundleContainer || element instanceof IPath) { >+ return getBundleChildren(element).size() > 0; >+ } >+ return false; >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ if (inputElement instanceof ITargetDefinition) { >+ if (fGrouping == GROUP_BY_NONE) { >+ return fAllBundles.toArray(); >+ } else if (fGrouping == GROUP_BY_CONTAINER) { >+ return fContainerBundles.keySet().toArray(); >+ } else { >+ return fFileBundles.keySet().toArray(); >+ } >+ } >+ return new Object[] {inputElement}; >+ } >+ >+ public void dispose() { >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java >diff -N src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,421 @@ >+/******************************************************************************* >+ * 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.util.ArrayList; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.ListenerList; >+import org.eclipse.jface.viewers.*; >+import org.eclipse.jface.window.Window; >+import org.eclipse.jface.wizard.WizardDialog; >+import org.eclipse.pde.internal.core.target.provisional.*; >+import org.eclipse.pde.internal.ui.SWTFactory; >+import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; >+import org.eclipse.pde.internal.ui.editor.targetdefinition.TargetEditor; >+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.layout.GridLayout; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.ui.forms.widgets.FormToolkit; >+ >+/** >+ * UI part that can be added to a dialog or to a form editor. Contains a table displaying >+ * the bundle containers of a target definition. Also has buttons to add, edit and remove >+ * bundle containers of varying types. >+ * >+ * @see TargetEditor >+ * @see ITargetDefinition >+ * @see IBundleContainer >+ */ >+public class TargetLocationsGroup { >+ >+ private TreeViewer fTreeViewer; >+ private Button fAddButton; >+ private Button fEditButton; >+ private Button fRemoveButton; >+ private Button fRemoveAllButton; >+ private Button fShowContentButton; >+ >+ private ITargetDefinition fTarget; >+ private ListenerList fChangeListeners = new ListenerList(); >+ >+ /** >+ * Creates this part using the form toolkit and adds it to the given composite. >+ * >+ * @param parent parent composite >+ * @param toolkit toolkit to create the widgets with >+ * @param reporter reporter implementation that will handle resolving and changes to the containers >+ * @return generated instance of the table part >+ */ >+ public static TargetLocationsGroup createInForm(Composite parent, FormToolkit toolkit) { >+ TargetLocationsGroup contentTable = new TargetLocationsGroup(); >+ contentTable.createFormContents(parent, toolkit); >+ return contentTable; >+ } >+ >+ /** >+ * Creates this part using standard dialog widgets and adds it to the given composite. >+ * >+ * @param parent parent composite >+ * @param reporter reporter implementation that will handle resolving and changes to the containers >+ * @return generated instance of the table part >+ */ >+ public static TargetLocationsGroup createInDialog(Composite parent) { >+ TargetLocationsGroup contentTable = new TargetLocationsGroup(); >+ contentTable.createDialogContents(parent); >+ return contentTable; >+ } >+ >+ /** >+ * Private constructor, use one of {@link #createTableInDialog(Composite, ITargetChangedListener)} >+ * or {@link #createTableInForm(Composite, FormToolkit, ITargetChangedListener)}. >+ * >+ * @param reporter reporter implementation that will handle resolving and changes to the containers >+ */ >+ private TargetLocationsGroup() { >+ >+ } >+ >+ /** >+ * Adds a listener to the set of listeners that will be notified when the bundle containers >+ * are modified. This method has no effect if the listener has already been added. >+ * >+ * @param listener target changed listener to add >+ */ >+ public void addTargetChangedListener(ITargetChangedListener listener) { >+ fChangeListeners.add(listener); >+ } >+ >+ /** >+ * Creates the part contents from a toolkit >+ * @param parent parent composite >+ * @param toolkit form toolkit to create widgets >+ */ >+ private void createFormContents(Composite parent, FormToolkit toolkit) { >+ Composite comp = toolkit.createComposite(parent); >+ comp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2)); >+ comp.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL)); >+ >+ Tree atree = toolkit.createTree(comp, SWT.V_SCROLL | SWT.H_SCROLL); >+ atree.setLayout(new GridLayout()); >+ GridData gd = new GridData(GridData.FILL_BOTH); >+ atree.setLayoutData(gd); >+ >+ Composite buttonComp = toolkit.createComposite(comp); >+ GridLayout layout = new GridLayout(); >+ layout.marginWidth = layout.marginHeight = 0; >+ buttonComp.setLayout(layout); >+ buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL)); >+ >+ fAddButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_0, SWT.PUSH); >+ fEditButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_1, SWT.PUSH); >+ fRemoveButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_2, SWT.PUSH); >+ fRemoveAllButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_3, SWT.PUSH); >+ >+ fShowContentButton = toolkit.createButton(comp, "Show plug-in content", SWT.CHECK); >+ >+ initializeTreeViewer(atree); >+ initializeButtons(); >+ >+ toolkit.paintBordersFor(comp); >+ } >+ >+ /** >+ * Creates the part contents using SWTFactory >+ * @param parent parent composite >+ */ >+ private void createDialogContents(Composite parent) { >+ Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0); >+ >+ Tree atree = new Tree(comp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); >+ atree.setLayout(new GridLayout()); >+ GridData gd = new GridData(GridData.FILL_BOTH); >+ gd.widthHint = 200; >+ atree.setLayoutData(gd); >+ >+ Composite buttonComp = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_BOTH); >+ GridLayout layout = new GridLayout(); >+ layout.marginHeight = 0; >+ layout.marginWidth = 0; >+ buttonComp.setLayout(layout); >+ buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL)); >+ >+ fAddButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_0, null); >+ fEditButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_1, null); >+ fRemoveButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_2, null); >+ fRemoveAllButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_3, null); >+ >+ fShowContentButton = SWTFactory.createCheckButton(comp, "Show Plug-in Content", null, false, 2); >+ >+ initializeTreeViewer(atree); >+ initializeButtons(); >+ } >+ >+ /** >+ * Sets up the tree viewer using the given tree >+ * @param tree >+ */ >+ private void initializeTreeViewer(Tree tree) { >+ fTreeViewer = new TreeViewer(tree); >+ fTreeViewer.setContentProvider(new BundleContainerContentProvider()); >+ fTreeViewer.setLabelProvider(new BundleContainerLabelProvider()); >+ fTreeViewer.setComparator(new ViewerComparator()); >+ fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { >+ public void selectionChanged(SelectionChangedEvent event) { >+ updateButtons(); >+ } >+ }); >+ fTreeViewer.addDoubleClickListener(new IDoubleClickListener() { >+ public void doubleClick(DoubleClickEvent event) { >+ if (!event.getSelection().isEmpty()) { >+ handleEdit(); >+ } >+ } >+ }); >+ fTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); >+ } >+ >+ /** >+ * Sets up the buttons, the button fields must already be created before calling this method >+ */ >+ private void initializeButtons() { >+ fAddButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ handleAdd(); >+ } >+ }); >+ fAddButton.setLayoutData(new GridData()); >+ SWTFactory.setButtonDimensionHint(fAddButton); >+ >+ fEditButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ handleEdit(); >+ } >+ }); >+ fEditButton.setLayoutData(new GridData()); >+ fEditButton.setEnabled(false); >+ SWTFactory.setButtonDimensionHint(fEditButton); >+ >+ fRemoveButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ handleRemove(); >+ } >+ }); >+ fRemoveButton.setLayoutData(new GridData()); >+ fRemoveButton.setEnabled(false); >+ SWTFactory.setButtonDimensionHint(fRemoveButton); >+ >+ fRemoveAllButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ handleRemoveAll(); >+ } >+ }); >+ fRemoveAllButton.setLayoutData(new GridData()); >+ SWTFactory.setButtonDimensionHint(fRemoveAllButton); >+ >+ fShowContentButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ fTreeViewer.refresh(); >+ fTreeViewer.expandAll(); >+ } >+ }); >+ fShowContentButton.setLayoutData(new GridData()); >+ SWTFactory.setButtonDimensionHint(fShowContentButton); >+ } >+ >+ /** >+ * Sets the target definition model to use as input for the tree, can be called with different >+ * models to change the tree's input. >+ * @param target target model >+ */ >+ public void setInput(ITargetDefinition target) { >+ fTarget = target; >+ refresh(); >+ } >+ >+ /** >+ * Refreshes the contents of the table >+ */ >+ public void refresh() { >+ fTreeViewer.setInput(fTarget); >+ updateButtons(); >+ } >+ >+// private void setEnabled(boolean enablement) { >+// fTreeViewer.getControl().setEnabled(enablement); >+// fAddButton.setEnabled(enablement); >+// >+// if (enablement) { >+// updateButtons(); >+// } else { >+// fRemoveButton.setEnabled(enablement); >+// fRemoveAllButton.setEnabled(enablement); >+// fEditButton.setEnabled(enablement); >+// } >+// } >+ >+ private void handleAdd() { >+ AddBundleContainerWizard wizard = new AddBundleContainerWizard(fTarget); >+ Shell parent = fTreeViewer.getTree().getShell(); >+ WizardDialog dialog = new WizardDialog(parent, wizard); >+ if (dialog.open() != Window.CANCEL) { >+ contentsChanged(); >+ } >+ } >+ >+ private void handleEdit() { >+ IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection(); >+ if (!selection.isEmpty()) { >+ Object selected = selection.getFirstElement(); >+ IBundleContainer oldContainer = null; >+ if (selected instanceof IBundleContainer) { >+ oldContainer = (IBundleContainer) selected; >+ } else if (selected instanceof IResolvedBundle) { >+ TreeItem[] treeSelection = fTreeViewer.getTree().getSelection(); >+ if (treeSelection.length > 0) { >+ Object parent = treeSelection[0].getParentItem().getData(); >+ if (parent instanceof IBundleContainer) { >+ oldContainer = (IBundleContainer) parent; >+ } >+ } >+ } >+ if (oldContainer != null) { >+ Shell parent = fTreeViewer.getTree().getShell(); >+ EditBundleContainerWizard wizard = new EditBundleContainerWizard(oldContainer); >+ WizardDialog dialog = new WizardDialog(parent, wizard); >+ if (dialog.open() == Window.OK) { >+ // Replace the old container with the new one >+ IBundleContainer newContainer = wizard.getBundleContainer(); >+ if (newContainer != null) { >+ IBundleContainer[] containers = fTarget.getBundleContainers(); >+ java.util.List newContainers = new ArrayList(containers.length); >+ for (int i = 0; i < containers.length; i++) { >+ if (!containers[i].equals(oldContainer)) { >+ newContainers.add(containers[i]); >+ } >+ } >+ newContainers.add(newContainer); >+ fTarget.setBundleContainers((IBundleContainer[]) newContainers.toArray(new IBundleContainer[newContainers.size()])); >+ >+ // Update the table >+ contentsChanged(); >+ fTreeViewer.setSelection(new StructuredSelection(newContainer), true); >+ } >+ } >+ } >+ } >+ } >+ >+ private void handleRemove() { >+ IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection(); >+ if (!selection.isEmpty()) { >+ Object selected = selection.getFirstElement(); >+ IBundleContainer container = null; >+ if (selected instanceof IBundleContainer) { >+ container = (IBundleContainer) selected; >+ IBundleContainer[] currentContainers = fTarget.getBundleContainers(); >+ ArrayList newBundleContainers = new ArrayList(currentContainers.length); >+ for (int i = 0; i < currentContainers.length; i++) { >+ if (!currentContainers[i].equals(container)) { >+ newBundleContainers.add(currentContainers[i]); >+ } >+ } >+ fTarget.setBundleContainers((IBundleContainer[]) newBundleContainers.toArray(new IBundleContainer[newBundleContainers.size()])); >+ contentsChanged(); >+ } >+ } >+ } >+ >+ private void handleRemoveAll() { >+ fTarget.setBundleContainers(null); >+ contentsChanged(); >+ } >+ >+ private void updateButtons() { >+ IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection(); >+ fEditButton.setEnabled(!selection.isEmpty() && selection.getFirstElement() instanceof IBundleContainer); >+ fRemoveButton.setEnabled(!selection.isEmpty() && selection.getFirstElement() instanceof IBundleContainer); >+ fRemoveAllButton.setEnabled(fTarget != null && fTarget.getBundleContainers() != null && fTarget.getBundleContainers().length > 0); >+ } >+ >+ /** >+ * Informs the reporter for this table that something has changed >+ * and is dirty. >+ */ >+ private void contentsChanged() { >+ Object[] listeners = fChangeListeners.getListeners(); >+ for (int i = 0; i < listeners.length; i++) { >+ ((ITargetChangedListener) listeners[i]).contentsChanged(fTarget, true); >+ } >+ refresh(); >+ } >+ >+ /** >+ * Content provider for the tree, primary input is a ITargetDefinition, children are IBundleContainers >+ */ >+ class BundleContainerContentProvider implements ITreeContentProvider { >+ >+ public Object[] getChildren(Object parentElement) { >+ if (parentElement instanceof ITargetDefinition) { >+ IBundleContainer[] containers = ((ITargetDefinition) parentElement).getBundleContainers(); >+ return containers != null ? containers : new Object[0]; >+ } else if (parentElement instanceof IBundleContainer) { >+ IBundleContainer container = (IBundleContainer) parentElement; >+ if (container.isResolved()) { >+ IStatus status = container.getBundleStatus(); >+ if (!status.isOK() && !status.isMultiStatus()) { >+ return new Object[] {status}; >+ } >+ if (fShowContentButton.getSelection()) { >+ return container.getBundles(); >+ } else if (!status.isOK()) { >+ // Show multi-status children so user can easily see problems >+ if (status.isMultiStatus()) { >+ return status.getChildren(); >+ } >+ } >+ } >+ } >+ return new Object[0]; >+ } >+ >+ public Object getParent(Object element) { >+ return null; >+ } >+ >+ public boolean hasChildren(Object element) { >+ // Since we are already resolved we can't be more efficient >+ return getChildren(element).length > 0; >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ if (inputElement instanceof ITargetDefinition) { >+ IBundleContainer[] containers = ((ITargetDefinition) inputElement).getBundleContainers(); >+ if (containers != null) { >+ return containers; >+ } >+ } else if (inputElement instanceof String) { >+ return new Object[] {inputElement}; >+ } >+ return new Object[0]; >+ } >+ >+ public void dispose() { >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } >+ >+ } >+ >+} >#P org.eclipse.pde.core >Index: src/org/eclipse/pde/internal/core/target/provisional/IResolvedBundle.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/provisional/IResolvedBundle.java,v >retrieving revision 1.1 >diff -u -r1.1 IResolvedBundle.java >--- src/org/eclipse/pde/internal/core/target/provisional/IResolvedBundle.java 5 Feb 2009 14:40:07 -0000 1.1 >+++ src/org/eclipse/pde/internal/core/target/provisional/IResolvedBundle.java 9 Apr 2009 22:03:06 -0000 >@@ -47,6 +47,13 @@ > public BundleInfo getBundleInfo(); > > /** >+ * Returns the parent bundle container that this bundle belongs to. >+ * >+ * @return parent bundle container >+ */ >+ public IBundleContainer getParentContainer(); >+ >+ /** > * Returns <code>true</code> if this bundle is a source bundle and > * <code>false</code> if this bundle is an executable bundle. > * >Index: src/org/eclipse/pde/internal/core/target/impl/Messages.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/impl/Messages.java,v >retrieving revision 1.10 >diff -u -r1.10 Messages.java >--- src/org/eclipse/pde/internal/core/target/impl/Messages.java 24 Feb 2009 03:10:32 -0000 1.10 >+++ src/org/eclipse/pde/internal/core/target/impl/Messages.java 9 Apr 2009 22:03:06 -0000 >@@ -22,7 +22,6 @@ > public static String AbstractBundleContainer_2; > public static String AbstractBundleContainer_3; > public static String AbstractBundleContainer_4; >- public static String AbstractBundleContainer_5; > public static String DirectoryBundleContainer_0; > public static String DirectoryBundleContainer_1; > public static String DirectoryBundleContainer_2; >Index: src/org/eclipse/pde/internal/core/target/impl/ResolvedBundle.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/impl/ResolvedBundle.java,v >retrieving revision 1.2 >diff -u -r1.2 ResolvedBundle.java >--- src/org/eclipse/pde/internal/core/target/impl/ResolvedBundle.java 2 Mar 2009 19:31:09 -0000 1.2 >+++ src/org/eclipse/pde/internal/core/target/impl/ResolvedBundle.java 9 Apr 2009 22:03:06 -0000 >@@ -13,6 +13,7 @@ > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; > import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; >+import org.eclipse.pde.internal.core.target.provisional.IBundleContainer; > import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle; > > /** >@@ -23,6 +24,7 @@ > public class ResolvedBundle implements IResolvedBundle { > > private BundleInfo fInfo; >+ private IBundleContainer fContainer; > private boolean fIsSource = false; > private IStatus fStatus; > private boolean fIsOptional = false; >@@ -39,8 +41,9 @@ > * @param optional whether the bundle is optional > * @param whether the bundle is a fragment > */ >- ResolvedBundle(BundleInfo info, IStatus status, boolean source, boolean optional, boolean fragment) { >+ ResolvedBundle(BundleInfo info, IBundleContainer parentContainer, IStatus status, boolean source, boolean optional, boolean fragment) { > fInfo = info; >+ fContainer = parentContainer; > if (status == null) { > fStatus = Status.OK_STATUS; > } else { >@@ -59,6 +62,13 @@ > } > > /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.target.provisional.IResolvedBundle#getParentContainer() >+ */ >+ public IBundleContainer getParentContainer() { >+ return fContainer; >+ } >+ >+ /* (non-Javadoc) > * @see org.eclipse.pde.internal.core.target.provisional.IResolvedBundle#getStatus() > */ > public IStatus getStatus() { >@@ -113,4 +123,15 @@ > public String getSourcePath() { > return fSourcePath; > } >+ >+ /* (non-Javadoc) >+ * @see java.lang.Object#toString() >+ */ >+ public String toString() { >+ StringBuffer result = new StringBuffer().append(fInfo.toString()); >+ if (fStatus != null && !fStatus.isOK()) { >+ result = result.append(' ').append(fStatus.toString()); >+ } >+ return result.toString(); >+ } > } >Index: src/org/eclipse/pde/internal/core/target/impl/AbstractBundleContainer.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/impl/AbstractBundleContainer.java,v >retrieving revision 1.19 >diff -u -r1.19 AbstractBundleContainer.java >--- src/org/eclipse/pde/internal/core/target/impl/AbstractBundleContainer.java 30 Mar 2009 17:26:10 -0000 1.19 >+++ src/org/eclipse/pde/internal/core/target/impl/AbstractBundleContainer.java 9 Apr 2009 22:03:06 -0000 >@@ -299,7 +299,7 @@ > sev = IStatus.INFO; > message = NLS.bind(Messages.AbstractBundleContainer_2, new Object[] {info.getVersion(), info.getSymbolicName()}); > } >- return new ResolvedBundle(info, new Status(sev, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_VERSION_DOES_NOT_EXIST, message, null), false, optional, false); >+ return new ResolvedBundle(info, null, new Status(sev, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_VERSION_DOES_NOT_EXIST, message, null), false, optional, false); > } > // DOES NOT EXIST > int sev = IStatus.ERROR; >@@ -308,7 +308,7 @@ > sev = IStatus.INFO; > message = NLS.bind(Messages.AbstractBundleContainer_4, info.getSymbolicName()); > } >- return new ResolvedBundle(info, new Status(sev, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_DOES_NOT_EXIST, message, null), false, optional, false); >+ return new ResolvedBundle(info, null, new Status(sev, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_DOES_NOT_EXIST, message, null), false, optional, false); > } > > /** >@@ -405,9 +405,9 @@ > } > return ManifestElement.parseBundleManifest(manifestStream, new Hashtable(10)); > } catch (BundleException e) { >- throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_INVALID_MANIFEST, Messages.AbstractBundleContainer_5, e)); >+ throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_INVALID_MANIFEST, NLS.bind(Messages.DirectoryBundleContainer_3, bundle.getSymbolicName()), e)); > } catch (IOException e) { >- throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_INVALID_MANIFEST, Messages.AbstractBundleContainer_5, e)); >+ throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_INVALID_MANIFEST, NLS.bind(Messages.DirectoryBundleContainer_3, bundle.getSymbolicName()), e)); > } finally { > closeZipFileAndStream(manifestStream, jarFile); > } >@@ -501,7 +501,7 @@ > } catch (CoreException e) { > status = e.getStatus(); > } >- return new ResolvedBundle(info, status, source, false, fragment); >+ return new ResolvedBundle(info, this, status, source, false, fragment); > } > > /** >@@ -542,7 +542,7 @@ > } > boolean source = isSourceBundle(file, name, manifest); > boolean fragment = manifest.containsKey(Constants.FRAGMENT_HOST); >- ResolvedBundle rb = new ResolvedBundle(info, null, source, false, fragment); >+ ResolvedBundle rb = new ResolvedBundle(info, this, null, source, false, fragment); > rb.setSourcePath(fSourcePath); > return rb; > } >Index: src/org/eclipse/pde/internal/core/target/impl/Messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/impl/Messages.properties,v >retrieving revision 1.13 >diff -u -r1.13 Messages.properties >--- src/org/eclipse/pde/internal/core/target/impl/Messages.properties 9 Mar 2009 17:13:56 -0000 1.13 >+++ src/org/eclipse/pde/internal/core/target/impl/Messages.properties 9 Apr 2009 22:03:06 -0000 >@@ -10,11 +10,10 @@ > ############################################################################### > > AbstractBundleContainer_0=Problems occurred while resolving plug-ins in the target >-AbstractBundleContainer_2=Missing version {0} of optional plug-in: {1} >-AbstractBundleContainer_3=Missing required plug-in: {0} >-AbstractBundleContainer_4=Missing optional plug-in: {0} >-AbstractBundleContainer_5=Error reading bundle manifest >-AbstractBundleContainer_1=Missing required version {0} of plug-in: {1} >+AbstractBundleContainer_2=Optional plug-in with version {0} could not be found: {1} >+AbstractBundleContainer_3=Required plug-in could not be found: {0} >+AbstractBundleContainer_4=Optional plug-in could not be found: {0} >+AbstractBundleContainer_1=Required plug-in with version {0} not found: {1} > DirectoryBundleContainer_0=Reading bundles... > DirectoryBundleContainer_1=Directory does not exist: {0} > DirectoryBundleContainer_2=Error converting manifest for {0} >Index: src/org/eclipse/pde/internal/core/target/impl/ProfileBundleContainer.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/impl/ProfileBundleContainer.java,v >retrieving revision 1.18 >diff -u -r1.18 ProfileBundleContainer.java >--- src/org/eclipse/pde/internal/core/target/impl/ProfileBundleContainer.java 6 Mar 2009 15:33:57 -0000 1.18 >+++ src/org/eclipse/pde/internal/core/target/impl/ProfileBundleContainer.java 9 Apr 2009 22:03:06 -0000 >@@ -89,11 +89,16 @@ > * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#resolveBundles(org.eclipse.pde.internal.core.target.provisional.ITargetDefinition, org.eclipse.core.runtime.IProgressMonitor) > */ > protected IResolvedBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor) throws CoreException { >- URL configUrl = getConfigurationArea(); > String home = resolveHomeLocation().toOSString(); > if (!new File(home).isDirectory()) { > throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind(Messages.ProfileBundleContainer_0, home))); > } >+ >+ URL configUrl = getConfigurationArea(); >+ if (!new File(configUrl.getFile()).isDirectory()) { >+ throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind("Configuration directory does not exist: {0}", home))); >+ } >+ > BundleInfo[] infos = P2Utils.readBundles(home, configUrl); > if (infos == null) { > IResolvedBundle[] platformXML = resolvePlatformXML(definition, home, monitor); >Index: src/org/eclipse/pde/internal/core/plugin/PluginObject.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginObject.java,v >retrieving revision 1.46 >diff -u -r1.46 PluginObject.java >--- src/org/eclipse/pde/internal/core/plugin/PluginObject.java 2 Jan 2008 15:56:16 -0000 1.46 >+++ src/org/eclipse/pde/internal/core/plugin/PluginObject.java 9 Apr 2009 22:03:06 -0000 >@@ -13,20 +13,9 @@ > import java.io.PrintWriter; > import java.io.Serializable; > import java.util.Vector; >- >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.PlatformObject; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.pde.core.IModel; >-import org.eclipse.pde.core.IModelChangeProvider; >-import org.eclipse.pde.core.IModelChangedEvent; >-import org.eclipse.pde.core.ISourceObject; >-import org.eclipse.pde.core.ModelChangedEvent; >-import org.eclipse.pde.core.plugin.IPluginBase; >-import org.eclipse.pde.core.plugin.IPluginModelBase; >-import org.eclipse.pde.core.plugin.IPluginObject; >-import org.eclipse.pde.core.plugin.ISharedPluginModel; >+import org.eclipse.core.runtime.*; >+import org.eclipse.pde.core.*; >+import org.eclipse.pde.core.plugin.*; > import org.eclipse.pde.internal.core.PDECore; > import org.eclipse.pde.internal.core.PDECoreMessages; > import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelProvider; >@@ -184,8 +173,16 @@ > } > > public String toString() { >- if (fName != null) >- return fName; >+ String result = null; >+ if (fName != null) { >+ result = fName; >+ } >+ if ((result == null || result.indexOf('%') >= 0) && fModel != null) { >+ result = fModel.toString(); >+ } >+ if (result != null) { >+ return result; >+ } > return super.toString(); > } > >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF,v >retrieving revision 1.45 >diff -u -r1.45 MANIFEST.MF >--- META-INF/MANIFEST.MF 23 Feb 2009 18:01:59 -0000 1.45 >+++ META-INF/MANIFEST.MF 9 Apr 2009 22:03:06 -0000 >@@ -58,7 +58,11 @@ > org.eclipse.ant.core;bundle-version="[3.1.0,4.0.0)", > org.eclipse.equinox.simpleconfigurator.manipulator;bundle-version="[1.0.100,2.0.0)", > org.eclipse.equinox.frameworkadmin;bundle-version="[1.0.100,2.0.0)", >- org.eclipse.debug.core;bundle-version="[3.5.0,4.0.0)" >+ org.eclipse.debug.core;bundle-version="[3.5.0,4.0.0)", >+ org.eclipse.equinox.p2.metadata;bundle-version="[1.0.0,2.0.0)", >+ org.eclipse.equinox.p2.director;bundle-version="[1.0.100,2.0.0)", >+ org.eclipse.equinox.p2.core;bundle-version="[1.0.100,2.0.0)", >+ org.eclipse.equinox.p2.repository.tools;bundle-version="[1.0.0,2.0.0)" > Eclipse-LazyStart: true > Bundle-RequiredExecutionEnvironment: J2SE-1.4 > Import-Package: com.ibm.icu.util >Index: src/org/eclipse/pde/internal/core/target/impl/P2BundleContainer.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/core/target/impl/P2BundleContainer.java >diff -N src/org/eclipse/pde/internal/core/target/impl/P2BundleContainer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/core/target/impl/P2BundleContainer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,92 @@ >+package org.eclipse.pde.internal.core.target.impl; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.equinox.internal.p2.director.PermissiveSlicer; >+import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; >+import org.eclipse.equinox.p2.internal.repository.tools.Repo2Runnable; >+import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor; >+import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle; >+import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; >+ >+public class P2BundleContainer extends AbstractBundleContainer { >+ >+ /** >+ * Constant describing the type of bundle container >+ */ >+ public static final String TYPE = "P2Repo"; //$NON-NLS-1$ >+ >+ private IInstallableUnit[] fUnits; >+ private String fDownloadDir; >+ private String[] fSourceRepos = null; >+ >+ public P2BundleContainer() { >+ fDownloadDir = "/home/cwindatt/Desktop/Export"; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#getLocation(boolean) >+ */ >+ public String getLocation(boolean resolve) throws CoreException { >+ // TODO We are breaking getVMArguments and other places this method is used >+ return fDownloadDir; >+ } >+ >+ public String[] getSourceRepos() { >+ return fSourceRepos; >+ } >+ >+ public void setSourceRepos(String[] sourceRepos) { >+ fSourceRepos = sourceRepos; >+ } >+ >+ public IInstallableUnit[] getRequiredUnits() { >+ return fUnits; >+ } >+ >+ public void setRequiredUnits(IInstallableUnit[] units) { >+ fUnits = units; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#getType() >+ */ >+ public String getType() { >+ return TYPE; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#resolveBundles(org.eclipse.pde.internal.core.target.provisional.ITargetDefinition, org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ protected IResolvedBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor) throws CoreException { >+ // Create queryable for all source repos >+ >+ // Use the slicer to get the complete list of ius to grab >+ PermissiveSlicer slicer = new PermissiveSlicer(null, null, true, true, true, true); >+ slicer.slice(fUnits, monitor); >+ >+ // We need to get the features as well' >+// org.eclipse.update.install.features=true >+ >+ // Download artifacts to the folder >+ Repo2Runnable runnable = new Repo2Runnable(); >+ runnable.addDestination(new RepositoryDescriptor()); >+ runnable.run(monitor); >+ >+// try { >+// Repo2Runnable tool = new Repo2Runnable(); >+// tool.setDestinationArtifactRepository(fInstallDir.toString()); >+// tool.setDestinationMetadataRepository(fInstallDir.toString()); >+// tool.setSourceIUs(Arrays.asList(fUnits)); >+// IStatus result = tool.run(SubMonitor.convert(monitor, 1)); >+// if (result.matches(IStatus.ERROR)) >+// throw new ProvisionException(result); >+// fLocations = new File[] {fInstallDir}; >+// } catch (ProvisionException e) { >+// throw new InvocationTargetException(e); >+// } >+ >+ // Use the iu's to create resolved bundles >+ return new IResolvedBundle[0]; >+ } >+}
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