Révision 385
tmp/org.txm.rcp.p2.ui/.classpath (revision 385) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> |
|
4 |
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> |
|
5 |
<classpathentry kind="src" path="src"/> |
|
6 |
<classpathentry kind="output" path="bin"/> |
|
7 |
</classpath> |
|
0 | 8 |
tmp/org.txm.rcp.p2.ui/META-INF/MANIFEST.MF (revision 385) | ||
---|---|---|
1 |
Manifest-Version: 1.0 |
|
2 |
Bundle-ManifestVersion: 2 |
|
3 |
Bundle-Name: Ui |
|
4 |
Bundle-SymbolicName: org.txm.rcp.p2.ui |
|
5 |
Bundle-Version: 1.0.0.qualifier |
|
6 |
Fragment-Host: org.eclipse.equinox.p2.ui;bundle-version="2.3.0" |
|
7 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 |
|
8 |
Eclipse-PatchFragment: true |
|
9 |
Bundle-ClassPath: library.jar, |
|
10 |
. |
|
0 | 11 |
tmp/org.txm.rcp.p2.ui/tmp/UpdateWizardPage.java (revision 385) | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* Copyright (c) 2007, 2010 IBM Corporation and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* IBM Corporation - initial API and implementation |
|
10 |
*******************************************************************************/ |
|
11 |
package org.eclipse.equinox.internal.p2.ui.dialogs; |
|
12 |
|
|
13 |
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages; |
|
14 |
import org.eclipse.equinox.internal.p2.ui.model.IUElementListRoot; |
|
15 |
import org.eclipse.equinox.p2.metadata.IInstallableUnit; |
|
16 |
import org.eclipse.equinox.p2.metadata.IUpdateDescriptor; |
|
17 |
import org.eclipse.equinox.p2.operations.UpdateOperation; |
|
18 |
import org.eclipse.equinox.p2.ui.ProvisioningUI; |
|
19 |
import org.eclipse.jface.viewers.IContentProvider; |
|
20 |
import org.eclipse.swt.widgets.TreeItem; |
|
21 |
|
|
22 |
public class UpdateWizardPage extends SizeComputingWizardPage { |
|
23 |
|
|
24 |
public UpdateWizardPage(ProvisioningUI ui, ProvisioningOperationWizard wizard, IUElementListRoot root, UpdateOperation operation) { |
|
25 |
super(ui, wizard, root, operation); |
|
26 |
//System.out.println("Init, root="+Arrays.asList(root)); |
|
27 |
setTitle(ProvUIMessages.UpdateWizardPage_Title); |
|
28 |
setDescription(ProvUIMessages.UpdateWizardPage_Description); |
|
29 |
} |
|
30 |
|
|
31 |
/** |
|
32 |
* Specialized version for TXM that shows the feature description instead of the product description |
|
33 |
*/ |
|
34 |
protected String getIUDescription(IInstallableUnit iu) { |
|
35 |
|
|
36 |
if (iu != null) { |
|
37 |
//System.out.println("IInstallableUnit.getId() " +iu.getId()); |
|
38 |
if (iu.getId().equals("org.txm.rcpapplication.product")) { // TXM product is selected |
|
39 |
//System.out.println("TXM product is selected"); |
|
40 |
TreeItem[] treeitems = treeViewer.getTree().getSelection(); |
|
41 |
for (TreeItem item : treeitems) { // find it in the Tree selection |
|
42 |
Object data = item.getData(); |
|
43 |
//System.out.println("TreeElem: "+data+" class="+data.getClass()); |
|
44 |
if (data instanceof org.eclipse.equinox.internal.p2.ui.model.AvailableUpdateElement) { |
|
45 |
org.eclipse.equinox.internal.p2.ui.model.AvailableUpdateElement iunit = (org.eclipse.equinox.internal.p2.ui.model.AvailableUpdateElement) data; |
|
46 |
//System.out.println(" iunit found "+iunit); |
|
47 |
if (iunit.getIU().getId().equals(iu.getId())) { // this is the TXM product |
|
48 |
//System.out.println(" TXM product found in Tree "+iunit); |
|
49 |
//System.out.println("Input: "+treeViewer.getInput()); |
|
50 |
IContentProvider cp = treeViewer.getContentProvider(); |
|
51 |
//System.out.println("content provider: "+treeViewer.getContentProvider()); |
|
52 |
org.eclipse.equinox.internal.p2.ui.viewers.ProvElementContentProvider pecp = (org.eclipse.equinox.internal.p2.ui.viewers.ProvElementContentProvider)cp; |
|
53 |
Object[] children = pecp.getChildren(data); |
|
54 |
//System.out.println("Children: "+Arrays.asList(children)); |
|
55 |
for (Object child : children) { |
|
56 |
//System.out.println("Child: "+child); |
|
57 |
//if (child != null) System.out.println("Child class: "+child.getClass()); |
|
58 |
if (child instanceof org.eclipse.equinox.internal.p2.ui.model.AvailableIUElement) { |
|
59 |
org.eclipse.equinox.internal.p2.ui.model.AvailableIUElement riu = (org.eclipse.equinox.internal.p2.ui.model.AvailableIUElement) child; |
|
60 |
//System.out.println("riu found "+riu); |
|
61 |
if (riu.getIU().getId().equals("org.txm.rcp.feature.feature.group")) { |
|
62 |
//System.out.println("org.txm.rcp.feature.feature.group description found "+riu.getIU().getUpdateDescriptor().getDescription()); |
|
63 |
String desc = riu.getIU().getUpdateDescriptor().getDescription(); |
|
64 |
if (desc != null) { |
|
65 |
return desc; |
|
66 |
} else { |
|
67 |
return super.getIUDescription(riu.getIU()); |
|
68 |
} |
|
69 |
} |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
|
|
74 |
} |
|
75 |
} |
|
76 |
} |
|
77 |
} else { |
|
78 |
IUpdateDescriptor updateDescriptor = iu.getUpdateDescriptor(); |
|
79 |
if (updateDescriptor != null && updateDescriptor.getDescription() != null && updateDescriptor.getDescription().length() > 0) { |
|
80 |
return updateDescriptor.getDescription(); |
|
81 |
} |
|
82 |
} |
|
83 |
} |
|
84 |
//String defaultDesc = super.getIUDescription(iu); |
|
85 |
return super.getIUDescription(iu); |
|
86 |
} |
|
87 |
|
|
88 |
protected String getOperationLabel() { |
|
89 |
return ProvUIMessages.UpdateIUOperationLabel; |
|
90 |
} |
|
91 |
|
|
92 |
protected String getOperationTaskName() { |
|
93 |
return ProvUIMessages.UpdateIUOperationTask; |
|
94 |
} |
|
95 |
} |
|
0 | 96 |
tmp/org.txm.rcp.p2.ui/tmp/ResolutionResultsWizardPage.java (revision 385) | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* Copyright (c) 2007, 2013 IBM Corporation and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* IBM Corporation - initial API and implementation |
|
10 |
* EclipseSource - ongoing development |
|
11 |
* Sonatype, Inc. - ongoing development |
|
12 |
* Red Hat, Inc. - support for remediation page |
|
13 |
*******************************************************************************/ |
|
14 |
package org.eclipse.equinox.internal.p2.ui.dialogs; |
|
15 |
|
|
16 |
import java.util.Collection; |
|
17 |
import org.eclipse.core.runtime.*; |
|
18 |
import org.eclipse.equinox.internal.p2.ui.*; |
|
19 |
import org.eclipse.equinox.internal.p2.ui.model.*; |
|
20 |
import org.eclipse.equinox.internal.p2.ui.viewers.*; |
|
21 |
import org.eclipse.equinox.p2.engine.IProvisioningPlan; |
|
22 |
import org.eclipse.equinox.p2.metadata.IInstallableUnit; |
|
23 |
import org.eclipse.equinox.p2.operations.ProfileChangeOperation; |
|
24 |
import org.eclipse.equinox.p2.operations.ProvisioningJob; |
|
25 |
import org.eclipse.equinox.p2.query.IQueryable; |
|
26 |
import org.eclipse.equinox.p2.ui.ProvisioningUI; |
|
27 |
import org.eclipse.jface.dialogs.Dialog; |
|
28 |
import org.eclipse.jface.dialogs.IDialogConstants; |
|
29 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
|
30 |
import org.eclipse.jface.viewers.*; |
|
31 |
import org.eclipse.swt.SWT; |
|
32 |
import org.eclipse.swt.custom.SashForm; |
|
33 |
import org.eclipse.swt.graphics.Image; |
|
34 |
import org.eclipse.swt.layout.*; |
|
35 |
import org.eclipse.swt.widgets.*; |
|
36 |
import org.eclipse.ui.statushandlers.StatusManager; |
|
37 |
|
|
38 |
/** |
|
39 |
* A wizard page that shows detailed information about a resolved install |
|
40 |
* operation. It allows drill down into the elements that will be installed. |
|
41 |
* |
|
42 |
* @since 3.4 |
|
43 |
* |
|
44 |
*/ |
|
45 |
public abstract class ResolutionResultsWizardPage extends ResolutionStatusPage { |
|
46 |
|
|
47 |
private static final String DIALOG_SETTINGS_SECTION = "ResolutionResultsPage"; //$NON-NLS-1$ |
|
48 |
|
|
49 |
protected IUElementListRoot input; |
|
50 |
ProfileChangeOperation resolvedOperation; |
|
51 |
TreeViewer treeViewer; |
|
52 |
ProvElementContentProvider contentProvider; |
|
53 |
IUDetailsLabelProvider labelProvider; |
|
54 |
protected Display display; |
|
55 |
private IUDetailsGroup iuDetailsGroup; |
|
56 |
SashForm sashForm; |
|
57 |
|
|
58 |
protected ResolutionResultsWizardPage(ProvisioningUI ui, ProvisioningOperationWizard wizard, IUElementListRoot input, ProfileChangeOperation operation) { |
|
59 |
super("ResolutionPage", ui, wizard); //$NON-NLS-1$ |
|
60 |
this.resolvedOperation = operation; |
|
61 |
if (input == null) |
|
62 |
this.input = new IUElementListRoot(); |
|
63 |
else |
|
64 |
this.input = input; |
|
65 |
} |
|
66 |
|
|
67 |
/* |
|
68 |
* (non-Javadoc) |
|
69 |
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) |
|
70 |
*/ |
|
71 |
public void createControl(Composite parent) { |
|
72 |
display = parent.getDisplay(); |
|
73 |
sashForm = new SashForm(parent, SWT.VERTICAL); |
|
74 |
FillLayout layout = new FillLayout(); |
|
75 |
sashForm.setLayout(layout); |
|
76 |
GridData data = new GridData(GridData.FILL_BOTH); |
|
77 |
sashForm.setLayoutData(data); |
|
78 |
initializeDialogUnits(sashForm); |
|
79 |
|
|
80 |
Composite composite = new Composite(sashForm, SWT.NONE); |
|
81 |
GridLayout gridLayout = new GridLayout(); |
|
82 |
gridLayout.marginWidth = 0; |
|
83 |
gridLayout.marginHeight = 0; |
|
84 |
composite.setLayout(gridLayout); |
|
85 |
|
|
86 |
treeViewer = createTreeViewer(composite); |
|
87 |
data = new GridData(GridData.FILL_BOTH); |
|
88 |
data.heightHint = convertHeightInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_HEIGHT); |
|
89 |
data.widthHint = convertWidthInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_WIDTH); |
|
90 |
Tree tree = treeViewer.getTree(); |
|
91 |
tree.setLayoutData(data); |
|
92 |
tree.setHeaderVisible(true); |
|
93 |
activateCopy(tree); |
|
94 |
TreeViewerColumn nameColumn = new TreeViewerColumn(treeViewer, SWT.LEFT); |
|
95 |
nameColumn.getColumn().setText(ProvUIMessages.ProvUI_NameColumnTitle); |
|
96 |
nameColumn.getColumn().setWidth(400); |
|
97 |
nameColumn.getColumn().setMoveable(true); |
|
98 |
nameColumn.setLabelProvider(new ColumnLabelProvider() { |
|
99 |
public String getText(Object element) { |
|
100 |
IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class); |
|
101 |
String label = iu.getProperty(IInstallableUnit.PROP_NAME, null); |
|
102 |
if (label == null) |
|
103 |
label = iu.getId(); |
|
104 |
return label; |
|
105 |
} |
|
106 |
|
|
107 |
public Image getImage(Object element) { |
|
108 |
if (element instanceof ProvElement) |
|
109 |
return ((ProvElement) element).getImage(element); |
|
110 |
if (ProvUI.getAdapter(element, IInstallableUnit.class) != null) |
|
111 |
return ProvUIImages.getImage(ProvUIImages.IMG_IU); |
|
112 |
return null; |
|
113 |
} |
|
114 |
|
|
115 |
public String getToolTipText(Object element) { |
|
116 |
if (element instanceof AvailableIUElement && ((AvailableIUElement) element).getImageOverlayId(null) == ProvUIImages.IMG_INFO) |
|
117 |
return ProvUIMessages.RemedyElementNotHighestVersion; |
|
118 |
return super.getToolTipText(element); |
|
119 |
} |
|
120 |
}); |
|
121 |
TreeViewerColumn versionColumn = new TreeViewerColumn(treeViewer, SWT.LEFT); |
|
122 |
versionColumn.getColumn().setText(ProvUIMessages.ProvUI_VersionColumnTitle); |
|
123 |
versionColumn.getColumn().setWidth(200); |
|
124 |
versionColumn.setLabelProvider(new ColumnLabelProvider() { |
|
125 |
public String getText(Object element) { |
|
126 |
IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class); |
|
127 |
if (element instanceof IIUElement) { |
|
128 |
if (((IIUElement) element).shouldShowVersion()) |
|
129 |
return iu.getVersion().toString(); |
|
130 |
return ""; //$NON-NLS-1$ |
|
131 |
} |
|
132 |
return iu.getVersion().toString(); |
|
133 |
} |
|
134 |
}); |
|
135 |
TreeViewerColumn idColumn = new TreeViewerColumn(treeViewer, SWT.LEFT); |
|
136 |
idColumn.getColumn().setText(ProvUIMessages.ProvUI_IdColumnTitle); |
|
137 |
idColumn.getColumn().setWidth(200); |
|
138 |
|
|
139 |
idColumn.setLabelProvider(new ColumnLabelProvider() { |
|
140 |
public String getText(Object element) { |
|
141 |
IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class); |
|
142 |
return iu.getId(); |
|
143 |
} |
|
144 |
}); |
|
145 |
|
|
146 |
// Filters and sorters before establishing content, so we don't refresh unnecessarily. |
|
147 |
IUComparator comparator = new IUComparator(IUComparator.IU_NAME); |
|
148 |
comparator.useColumnConfig(getColumnConfig()); |
|
149 |
treeViewer.setComparator(comparator); |
|
150 |
treeViewer.setComparer(new ProvElementComparer()); |
|
151 |
ColumnViewerToolTipSupport.enableFor(treeViewer); |
|
152 |
contentProvider = new ProvElementContentProvider(); |
|
153 |
treeViewer.setContentProvider(contentProvider); |
|
154 |
// labelProvider = new IUDetailsLabelProvider(null, getColumnConfig(), getShell()); |
|
155 |
// treeViewer.setLabelProvider(labelProvider); |
|
156 |
|
|
157 |
// Optional area to show the size |
|
158 |
createSizingInfo(composite); |
|
159 |
|
|
160 |
// The text area shows a description of the selected IU, or error detail if applicable. |
|
161 |
iuDetailsGroup = new IUDetailsGroup(sashForm, treeViewer, 2*convertWidthInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_WIDTH), true); |
|
162 |
|
|
163 |
setControl(sashForm); |
|
164 |
sashForm.setWeights(getSashWeights()); |
|
165 |
Dialog.applyDialogFont(sashForm); |
|
166 |
|
|
167 |
// Controls for filtering/presentation/site selection |
|
168 |
Composite controlsComposite = new Composite(composite, SWT.NONE); |
|
169 |
gridLayout = new GridLayout(); |
|
170 |
gridLayout.marginWidth = 0; |
|
171 |
gridLayout.marginHeight = 0; |
|
172 |
gridLayout.numColumns = 2; |
|
173 |
gridLayout.makeColumnsEqualWidth = true; |
|
174 |
gridLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); |
|
175 |
controlsComposite.setLayout(layout); |
|
176 |
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false); |
|
177 |
controlsComposite.setLayoutData(gd); |
|
178 |
|
|
179 |
final Runnable runnable = new Runnable() { |
|
180 |
public void run() { |
|
181 |
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
|
182 |
public void selectionChanged(SelectionChangedEvent event) { |
|
183 |
setDetailText(resolvedOperation); |
|
184 |
} |
|
185 |
}); |
|
186 |
setDrilldownElements(input, resolvedOperation); |
|
187 |
treeViewer.setInput(input); |
|
188 |
} |
|
189 |
}; |
|
190 |
|
|
191 |
if (resolvedOperation != null && !resolvedOperation.hasResolved()) { |
|
192 |
try { |
|
193 |
getContainer().run(true, false, new IRunnableWithProgress() { |
|
194 |
public void run(IProgressMonitor monitor) { |
|
195 |
resolvedOperation.resolveModal(monitor); |
|
196 |
display.asyncExec(runnable); |
|
197 |
} |
|
198 |
}); |
|
199 |
} catch (Exception e) { |
|
200 |
StatusManager.getManager().handle(new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e)); |
|
201 |
} |
|
202 |
} else { |
|
203 |
runnable.run(); |
|
204 |
} |
|
205 |
} |
|
206 |
|
|
207 |
@Override |
|
208 |
public void updateStatus(IUElementListRoot newRoot, ProfileChangeOperation op) { |
|
209 |
super.updateStatus(newRoot, op); |
|
210 |
} |
|
211 |
|
|
212 |
protected void createSizingInfo(Composite parent) { |
|
213 |
// Default is to do nothing |
|
214 |
} |
|
215 |
|
|
216 |
public boolean performFinish() { |
|
217 |
if (resolvedOperation.getResolutionResult().getSeverity() != IStatus.ERROR) { |
|
218 |
getProvisioningUI().schedule(resolvedOperation.getProvisioningJob(null), StatusManager.SHOW | StatusManager.LOG); |
|
219 |
return true; |
|
220 |
} |
|
221 |
return false; |
|
222 |
} |
|
223 |
|
|
224 |
protected TreeViewer getTreeViewer() { |
|
225 |
return treeViewer; |
|
226 |
} |
|
227 |
|
|
228 |
public IProvisioningPlan getCurrentPlan() { |
|
229 |
if (resolvedOperation != null) |
|
230 |
return resolvedOperation.getProvisioningPlan(); |
|
231 |
return null; |
|
232 |
} |
|
233 |
|
|
234 |
protected Object[] getSelectedElements() { |
|
235 |
return ((IStructuredSelection) treeViewer.getSelection()).toArray(); |
|
236 |
} |
|
237 |
|
|
238 |
protected IInstallableUnit getSelectedIU() { |
|
239 |
java.util.List<IInstallableUnit> units = ElementUtils.elementsToIUs(getSelectedElements()); |
|
240 |
if (units.size() == 0) |
|
241 |
return null; |
|
242 |
return units.get(0); |
|
243 |
} |
|
244 |
|
|
245 |
protected boolean shouldCompleteOnCancel() { |
|
246 |
return false; |
|
247 |
} |
|
248 |
|
|
249 |
protected Collection<IInstallableUnit> getIUs() { |
|
250 |
return ElementUtils.elementsToIUs(input.getChildren(input)); |
|
251 |
} |
|
252 |
|
|
253 |
void setDrilldownElements(IUElementListRoot root, ProfileChangeOperation operation) { |
|
254 |
if (operation == null || operation.getProvisioningPlan() == null) |
|
255 |
return; |
|
256 |
Object[] elements = root.getChildren(root); |
|
257 |
for (int i = 0; i < elements.length; i++) { |
|
258 |
if (elements[i] instanceof QueriedElement) { |
|
259 |
((QueriedElement) elements[i]).setQueryable(getQueryable(operation.getProvisioningPlan())); |
|
260 |
} |
|
261 |
} |
|
262 |
} |
|
263 |
|
|
264 |
protected abstract String getOperationLabel(); |
|
265 |
|
|
266 |
/** |
|
267 |
* Returns the restart policy for this operation. |
|
268 |
* |
|
269 |
* @return an integer constant describing whether the running profile |
|
270 |
* needs to be restarted. |
|
271 |
* |
|
272 |
* @see ProvisioningJob#RESTART_NONE |
|
273 |
* @see ProvisioningJob#RESTART_ONLY |
|
274 |
* @see ProvisioningJob#RESTART_OR_APPLY |
|
275 |
* |
|
276 |
*/ |
|
277 |
protected int getRestartPolicy() { |
|
278 |
return ProvisioningJob.RESTART_OR_APPLY; |
|
279 |
} |
|
280 |
|
|
281 |
/** |
|
282 |
* Returns the task name for this operation, or <code>null</code> to display |
|
283 |
* a generic task name. |
|
284 |
*/ |
|
285 |
protected String getOperationTaskName() { |
|
286 |
return null; |
|
287 |
} |
|
288 |
|
|
289 |
protected TreeViewer createTreeViewer(Composite parent) { |
|
290 |
return new TreeViewer(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); |
|
291 |
} |
|
292 |
|
|
293 |
protected abstract IQueryable<IInstallableUnit> getQueryable(IProvisioningPlan plan); |
|
294 |
|
|
295 |
protected String getClipboardText(Control control) { |
|
296 |
return CopyUtils.getIndentedClipboardText(getSelectedElements(), labelProvider); |
|
297 |
} |
|
298 |
|
|
299 |
protected IUDetailsGroup getDetailsGroup() { |
|
300 |
return iuDetailsGroup; |
|
301 |
} |
|
302 |
|
|
303 |
protected boolean isCreated() { |
|
304 |
return treeViewer != null; |
|
305 |
} |
|
306 |
|
|
307 |
protected void updateCaches(IUElementListRoot newRoot, ProfileChangeOperation op) { |
|
308 |
resolvedOperation = op; |
|
309 |
if (newRoot != null) { |
|
310 |
setDrilldownElements(newRoot, resolvedOperation); |
|
311 |
if (treeViewer != null) { |
|
312 |
if (input != newRoot) |
|
313 |
treeViewer.setInput(newRoot); |
|
314 |
else |
|
315 |
treeViewer.refresh(); |
|
316 |
} |
|
317 |
input = newRoot; |
|
318 |
} |
|
319 |
} |
|
320 |
|
|
321 |
protected String getDialogSettingsName() { |
|
322 |
return getWizard().getClass().getName() + "." + DIALOG_SETTINGS_SECTION; //$NON-NLS-1$ |
|
323 |
} |
|
324 |
|
|
325 |
protected int getColumnWidth(int index) { |
|
326 |
return treeViewer.getTree().getColumn(index).getWidth(); |
|
327 |
} |
|
328 |
|
|
329 |
protected SashForm getSashForm() { |
|
330 |
return sashForm; |
|
331 |
} |
|
332 |
} |
|
0 | 333 |
tmp/org.txm.rcp.p2.ui/tmp/UpdateWizard.java (revision 385) | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* Copyright (c) 2007, 2013 IBM Corporation and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* IBM Corporation - initial API and implementation |
|
10 |
* Genuitec, LLC - added license support |
|
11 |
* Sonatype, Inc. - ongoing development |
|
12 |
* Red Hat, Inc. - support for remediation page |
|
13 |
*******************************************************************************/ |
|
14 |
package org.eclipse.equinox.internal.p2.ui.dialogs; |
|
15 |
|
|
16 |
import java.util.*; |
|
17 |
import org.eclipse.core.runtime.Assert; |
|
18 |
import org.eclipse.equinox.internal.p2.ui.ProvUIImages; |
|
19 |
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages; |
|
20 |
import org.eclipse.equinox.internal.p2.ui.model.*; |
|
21 |
import org.eclipse.equinox.p2.engine.IProfile; |
|
22 |
import org.eclipse.equinox.p2.engine.IProfileRegistry; |
|
23 |
import org.eclipse.equinox.p2.metadata.IInstallableUnit; |
|
24 |
import org.eclipse.equinox.p2.operations.*; |
|
25 |
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob; |
|
26 |
import org.eclipse.equinox.p2.ui.ProvisioningUI; |
|
27 |
import org.eclipse.jface.wizard.IWizardPage; |
|
28 |
|
|
29 |
/** |
|
30 |
* @since 3.4 |
|
31 |
*/ |
|
32 |
public class UpdateWizard extends WizardWithLicenses { |
|
33 |
IInstallableUnit[] iusToReplace; |
|
34 |
boolean skipSelectionsPage = false; |
|
35 |
IUElementListRoot firstPageRoot; |
|
36 |
Update[] initialSelections; |
|
37 |
|
|
38 |
public static Collection<IInstallableUnit> getIUsToReplace(Object[] elements) { |
|
39 |
Set<IInstallableUnit> iusToReplace = new HashSet<IInstallableUnit>(); |
|
40 |
for (int i = 0; i < elements.length; i++) { |
|
41 |
if (elements[i] instanceof AvailableUpdateElement) { |
|
42 |
iusToReplace.add(((AvailableUpdateElement) elements[i]).getIUToBeUpdated()); |
|
43 |
} |
|
44 |
} |
|
45 |
return iusToReplace; |
|
46 |
} |
|
47 |
|
|
48 |
public static IInstallableUnit[] getReplacementIUs(Object[] elements) { |
|
49 |
Set<IInstallableUnit> replacements = new HashSet<IInstallableUnit>(); |
|
50 |
for (int i = 0; i < elements.length; i++) { |
|
51 |
if (elements[i] instanceof AvailableUpdateElement) { |
|
52 |
replacements.add(((AvailableUpdateElement) elements[i]).getIU()); |
|
53 |
} |
|
54 |
} |
|
55 |
return replacements.toArray(new IInstallableUnit[replacements.size()]); |
|
56 |
} |
|
57 |
|
|
58 |
public static Update[] makeUpdatesFromElements(Object[] elements) { |
|
59 |
Set<Update> updates = new HashSet<Update>(); |
|
60 |
for (int i = 0; i < elements.length; i++) { |
|
61 |
if (elements[i] instanceof AvailableUpdateElement) { |
|
62 |
updates.add(((AvailableUpdateElement) elements[i]).getUpdate()); |
|
63 |
} |
|
64 |
} |
|
65 |
return updates.toArray(new Update[updates.size()]); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* Open an update wizard. For update wizards, the operation must have been resolved in advanced. |
|
70 |
* This prevents searching for updates in the UI thread. |
|
71 |
* |
|
72 |
* @param ui the provisioning UI |
|
73 |
* @param operation the update operation. Must already be resolved! |
|
74 |
* @param initialSelections initial selections for the wizard (can be null) |
|
75 |
* @param preloadJob a job that has been used to preload metadata repositories (can be null) |
|
76 |
*/ |
|
77 |
public UpdateWizard(ProvisioningUI ui, UpdateOperation operation, Object[] initialSelections, LoadMetadataRepositoryJob preloadJob) { |
|
78 |
super(ui, operation, initialSelections, preloadJob); |
|
79 |
this.initialSelections = (Update[]) initialSelections; |
|
80 |
Assert.isLegal(operation.hasResolved(), "Cannot create an update wizard on an unresolved operation"); //$NON-NLS-1$ |
|
81 |
setWindowTitle(ProvUIMessages.UpdateAction_UpdatesAvailableTitle); |
|
82 |
setDefaultPageImageDescriptor(ProvUIImages.getImageDescriptor(ProvUIImages.WIZARD_BANNER_UPDATE)); |
|
83 |
} |
|
84 |
|
|
85 |
private boolean isLocked(IProfile profile, IInstallableUnit iuToBeUpdated) { |
|
86 |
return Boolean.valueOf(profile.getInstallableUnitProperty(iuToBeUpdated, IProfile.PROP_PROFILE_LOCKED_IU)).booleanValue(); |
|
87 |
} |
|
88 |
|
|
89 |
public void deselectLockedIUs() { |
|
90 |
IProfileRegistry profileRegistry = (IProfileRegistry) ui.getSession().getProvisioningAgent().getService(IProfileRegistry.SERVICE_NAME); |
|
91 |
IProfile profile = profileRegistry.getProfile(ui.getProfileId()); |
|
92 |
|
|
93 |
ArrayList<Update> newSelection = new ArrayList<Update>(initialSelections.length); |
|
94 |
for (int i = 0; i < initialSelections.length; i++) { |
|
95 |
if (!isLocked(profile, initialSelections[i].toUpdate)) { |
|
96 |
newSelection.add(initialSelections[i]); |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
((UpdateOperation) operation).setSelectedUpdates(newSelection.toArray(new Update[newSelection.size()])); |
|
101 |
recomputePlan(getContainer()); |
|
102 |
} |
|
103 |
|
|
104 |
protected ISelectableIUsPage createMainPage(IUElementListRoot input, Object[] selections) { |
|
105 |
mainPage = new SelectableIUsPage(ui, this, getAllPossibleUpdatesRoot(), selections); |
|
106 |
mainPage.setTitle(ProvUIMessages.UpdateAction_UpdatesAvailableTitle+" - TXM"); |
|
107 |
mainPage.setDescription(ProvUIMessages.UpdateAction_UpdatesAvailableMessage); |
|
108 |
((SelectableIUsPage) mainPage).updateStatus(getAllPossibleUpdatesRoot(), operation); |
|
109 |
return mainPage; |
|
110 |
} |
|
111 |
|
|
112 |
protected ResolutionResultsWizardPage createResolutionPage() { |
|
113 |
return new UpdateWizardPage(ui, this, root, (UpdateOperation) operation); |
|
114 |
} |
|
115 |
|
|
116 |
protected void initializeResolutionModelElements(Object[] selectedElements) { |
|
117 |
if (selectedElements == null) |
|
118 |
return; |
|
119 |
root = new IUElementListRoot(); |
|
120 |
if (operation instanceof RemediationOperation) { |
|
121 |
AvailableIUElement[] elements = ElementUtils.requestToElement(((RemediationOperation) operation).getCurrentRemedy(), false); |
|
122 |
root.setChildren(elements); |
|
123 |
//planSelections = elements; |
|
124 |
} else { |
|
125 |
ArrayList<AvailableUpdateElement> list = new ArrayList<AvailableUpdateElement>(selectedElements.length); |
|
126 |
ArrayList<AvailableUpdateElement> selected = new ArrayList<AvailableUpdateElement>(selectedElements.length); |
|
127 |
for (int i = 0; i < selectedElements.length; i++) { |
|
128 |
if (selectedElements[i] instanceof AvailableUpdateElement) { |
|
129 |
AvailableUpdateElement element = (AvailableUpdateElement) selectedElements[i]; |
|
130 |
AvailableUpdateElement newElement = new AvailableUpdateElement(root, element.getIU(), element.getIUToBeUpdated(), getProfileId(), shouldShowProvisioningPlanChildren()); |
|
131 |
list.add(newElement); |
|
132 |
selected.add(newElement); |
|
133 |
} else if (selectedElements[i] instanceof Update) { |
|
134 |
Update update = (Update) selectedElements[i]; |
|
135 |
AvailableUpdateElement newElement = new AvailableUpdateElement(root, update.replacement, update.toUpdate, getProfileId(), shouldShowProvisioningPlanChildren()); |
|
136 |
list.add(newElement); |
|
137 |
selected.add(newElement); |
|
138 |
} |
|
139 |
} |
|
140 |
root.setChildren(list.toArray()); |
|
141 |
planSelections = selected.toArray(); |
|
142 |
} |
|
143 |
} |
|
144 |
|
|
145 |
protected IResolutionErrorReportingPage createErrorReportingPage() { |
|
146 |
return (SelectableIUsPage) mainPage; |
|
147 |
} |
|
148 |
|
|
149 |
public void setSkipSelectionsPage(boolean skipSelectionsPage) { |
|
150 |
this.skipSelectionsPage = skipSelectionsPage; |
|
151 |
} |
|
152 |
|
|
153 |
public IWizardPage getStartingPage() { |
|
154 |
//if (skipSelectionsPage) { |
|
155 |
// TODO see https://bugs.eclipse.org/bugs/show_bug.cgi?id=276963 |
|
156 |
IWizardPage page = getNextPage(mainPage); |
|
157 |
if (page != null) |
|
158 |
return page; |
|
159 |
else |
|
160 |
return mainPage; |
|
161 |
// } |
|
162 |
// return mainPage; |
|
163 |
} |
|
164 |
|
|
165 |
/* (non-Javadoc) |
|
166 |
* @see org.eclipse.equinox.internal.p2.ui.dialogs.ProvisioningOperationWizard#getProfileChangeOperation(java.lang.Object[]) |
|
167 |
*/ |
|
168 |
protected ProfileChangeOperation getProfileChangeOperation(Object[] elements) { |
|
169 |
if (operation == null) { |
|
170 |
operation = new UpdateOperation(ui.getSession(), getIUsToReplace(elements)); |
|
171 |
operation.setProfileId(getProfileId()); |
|
172 |
// operation.setRootMarkerKey(getRootMarkerKey()); |
|
173 |
} else { |
|
174 |
((UpdateOperation) operation).setSelectedUpdates(makeUpdatesFromElements(elements)); |
|
175 |
} |
|
176 |
return operation; |
|
177 |
} |
|
178 |
|
|
179 |
private IUElementListRoot getAllPossibleUpdatesRoot() { |
|
180 |
if (firstPageRoot == null) { |
|
181 |
firstPageRoot = new IUElementListRoot(); |
|
182 |
if (operation != null && operation instanceof UpdateOperation) { |
|
183 |
Update[] updates; |
|
184 |
if (getPolicy().getShowLatestVersionsOnly()) { |
|
185 |
updates = ((UpdateOperation) operation).getSelectedUpdates(); |
|
186 |
} else { |
|
187 |
updates = ((UpdateOperation) operation).getPossibleUpdates(); |
|
188 |
} |
|
189 |
ArrayList<AvailableUpdateElement> allPossible = new ArrayList<AvailableUpdateElement>(updates.length); |
|
190 |
for (int i = 0; i < updates.length; i++) { |
|
191 |
AvailableUpdateElement newElement = new AvailableUpdateElement(firstPageRoot, updates[i].replacement, updates[i].toUpdate, getProfileId(), shouldShowProvisioningPlanChildren()); |
|
192 |
allPossible.add(newElement); |
|
193 |
} |
|
194 |
firstPageRoot.setChildren(allPossible.toArray()); |
|
195 |
} |
|
196 |
} |
|
197 |
return firstPageRoot; |
|
198 |
} |
|
199 |
|
|
200 |
@Override |
|
201 |
protected RemediationPage createRemediationPage() { |
|
202 |
remediationPage = new RemediationPage(ui, this, root, operation); |
|
203 |
return remediationPage; |
|
204 |
} |
|
205 |
|
|
206 |
} |
|
0 | 207 |
tmp/org.txm.rcp.p2.ui/.project (revision 385) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>org.txm.rcp.p2.ui</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
<buildCommand> |
|
14 |
<name>org.eclipse.pde.ManifestBuilder</name> |
|
15 |
<arguments> |
|
16 |
</arguments> |
|
17 |
</buildCommand> |
|
18 |
<buildCommand> |
|
19 |
<name>org.eclipse.pde.SchemaBuilder</name> |
|
20 |
<arguments> |
|
21 |
</arguments> |
|
22 |
</buildCommand> |
|
23 |
</buildSpec> |
|
24 |
<natures> |
|
25 |
<nature>org.eclipse.pde.PluginNature</nature> |
|
26 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
27 |
</natures> |
|
28 |
</projectDescription> |
|
0 | 29 |
tmp/org.txm.rcp.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUDetailsGroup.java (revision 385) | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* Copyright (c) 2009, 2010 EclipseSource and others. All rights reserved. This |
|
3 |
* program and the accompanying materials are made available under the terms of |
|
4 |
* the Eclipse Public License v1.0 which accompanies this distribution, and is |
|
5 |
* available at http://www.eclipse.org/legal/epl-v10.html |
|
6 |
* |
|
7 |
* Contributors: |
|
8 |
* EclipseSource - initial API and implementation |
|
9 |
* IBM Corporation - ongoing development |
|
10 |
******************************************************************************/ |
|
11 |
package org.eclipse.equinox.internal.p2.ui.dialogs; |
|
12 |
|
|
13 |
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages; |
|
14 |
import org.eclipse.equinox.internal.p2.ui.actions.PropertyDialogAction; |
|
15 |
import org.eclipse.jface.action.IAction; |
|
16 |
import org.eclipse.jface.dialogs.Dialog; |
|
17 |
import org.eclipse.jface.dialogs.IDialogConstants; |
|
18 |
import org.eclipse.jface.resource.JFaceResources; |
|
19 |
import org.eclipse.jface.viewers.ISelectionProvider; |
|
20 |
import org.eclipse.jface.window.SameShellProvider; |
|
21 |
import org.eclipse.swt.SWT; |
|
22 |
import org.eclipse.swt.browser.Browser; |
|
23 |
import org.eclipse.swt.events.KeyEvent; |
|
24 |
import org.eclipse.swt.events.KeyListener; |
|
25 |
import org.eclipse.swt.graphics.FontMetrics; |
|
26 |
import org.eclipse.swt.graphics.GC; |
|
27 |
import org.eclipse.swt.layout.GridData; |
|
28 |
import org.eclipse.swt.layout.GridLayout; |
|
29 |
import org.eclipse.swt.widgets.*; |
|
30 |
|
|
31 |
/** |
|
32 |
* Creates a details group for a list of IUs. |
|
33 |
*/ |
|
34 |
public class IUDetailsGroup { |
|
35 |
|
|
36 |
private static final String LINKACTION = "linkAction"; //$NON-NLS-1$ |
|
37 |
|
|
38 |
private GridLayout layout; |
|
39 |
private Browser detailsArea; |
|
40 |
private GridData gd; |
|
41 |
private Link propLink; |
|
42 |
private ISelectionProvider selectionProvider; |
|
43 |
private int widthHint; |
|
44 |
private boolean scrollable; |
|
45 |
private String lastText; |
|
46 |
|
|
47 |
/** |
|
48 |
* |
|
49 |
*/ |
|
50 |
public IUDetailsGroup(Composite parent, ISelectionProvider selectionProvider, int widthHint, boolean scrollable) { |
|
51 |
this.selectionProvider = selectionProvider; |
|
52 |
this.widthHint = widthHint; |
|
53 |
this.scrollable = scrollable; |
|
54 |
createGroupComposite(parent); |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* Creates the group composite that holds the details area |
|
59 |
* @param parent The parent composite |
|
60 |
*/ |
|
61 |
void createGroupComposite(Composite parent) { |
|
62 |
Group detailsComposite = new Group(parent, SWT.NONE); |
|
63 |
GC gc = new GC(parent); |
|
64 |
gc.setFont(JFaceResources.getDialogFont()); |
|
65 |
FontMetrics fontMetrics = gc.getFontMetrics(); |
|
66 |
gc.dispose(); |
|
67 |
|
|
68 |
detailsComposite.setText(ProvUIMessages.ProfileModificationWizardPage_DetailsLabel); |
|
69 |
layout = new GridLayout(); |
|
70 |
layout.marginWidth = 0; |
|
71 |
layout.marginHeight = 0; |
|
72 |
detailsComposite.setLayout(layout); |
|
73 |
gd = new GridData(SWT.FILL, SWT.FILL, true, true); |
|
74 |
detailsComposite.setLayoutData(gd); |
|
75 |
|
|
76 |
gd = new GridData(SWT.FILL, SWT.FILL, true, true); |
|
77 |
gd.verticalIndent = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING); |
|
78 |
gd.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, ILayoutConstants.DEFAULT_DESCRIPTION_HEIGHT); |
|
79 |
gd.minimumHeight = Dialog.convertHeightInCharsToPixels(fontMetrics, ILayoutConstants.MINIMUM_DESCRIPTION_HEIGHT); |
|
80 |
gd.widthHint = widthHint; |
|
81 |
if (scrollable) |
|
82 |
detailsArea = new Browser(detailsComposite, SWT.WRAP); |
|
83 |
else |
|
84 |
detailsArea = new Browser(detailsComposite, SWT.WRAP); |
|
85 |
|
|
86 |
detailsArea.setLayoutData(gd); |
|
87 |
detailsArea.addKeyListener(new KeyListener() { |
|
88 |
@Override |
|
89 |
public void keyReleased(KeyEvent e) { } |
|
90 |
|
|
91 |
@Override |
|
92 |
public void keyPressed(KeyEvent e) { |
|
93 |
//System.out.println("key: "+e); |
|
94 |
if (e.keyCode == SWT.BS || e.keyCode == SWT.F5) { |
|
95 |
detailsArea.setText(lastText); |
|
96 |
} |
|
97 |
} |
|
98 |
}); |
|
99 |
|
|
100 |
gd = new GridData(SWT.END, SWT.BOTTOM, true, false); |
|
101 |
gd.horizontalIndent = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_MARGIN); |
|
102 |
propLink = createLink(detailsComposite, new PropertyDialogAction(new SameShellProvider(parent.getShell()), selectionProvider), ProvUIMessages.AvailableIUsPage_GotoProperties); |
|
103 |
propLink.setLayoutData(gd); |
|
104 |
|
|
105 |
// set the initial state based on selection |
|
106 |
propLink.setVisible(!selectionProvider.getSelection().isEmpty()); |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* Set the detail text |
|
111 |
*/ |
|
112 |
public void setDetailText(String text) { |
|
113 |
// If the string is the same but the user has scrolled, the text |
|
114 |
// widget will reset the selection. This makes it look like the text |
|
115 |
// has changed when it hasn't. For this reason, we check equality first. |
|
116 |
|
|
117 |
// MD removed :) |
|
118 |
//if (lastText == null || !lastText.equals(text)) |
|
119 |
detailsArea.setText(text); |
|
120 |
lastText = text; |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* Toggles the property link for the details area. |
|
125 |
*/ |
|
126 |
public void enablePropertyLink(boolean enable) { |
|
127 |
propLink.setVisible(enable); |
|
128 |
} |
|
129 |
|
|
130 |
private Link createLink(Composite parent, IAction action, String text) { |
|
131 |
Link link = new Link(parent, SWT.PUSH); |
|
132 |
link.setText(text); |
|
133 |
|
|
134 |
link.addListener(SWT.Selection, new Listener() { |
|
135 |
public void handleEvent(Event event) { |
|
136 |
IAction linkAction = getLinkAction(event.widget); |
|
137 |
if (linkAction != null) { |
|
138 |
linkAction.runWithEvent(event); |
|
139 |
} |
|
140 |
} |
|
141 |
}); |
|
142 |
link.setToolTipText(action.getToolTipText()); |
|
143 |
link.setData(LINKACTION, action); |
|
144 |
return link; |
|
145 |
} |
|
146 |
|
|
147 |
IAction getLinkAction(Widget widget) { |
|
148 |
Object data = widget.getData(LINKACTION); |
|
149 |
if (data == null || !(data instanceof IAction)) { |
|
150 |
return null; |
|
151 |
} |
|
152 |
return (IAction) data; |
|
153 |
} |
|
154 |
|
|
155 |
} |
|
0 | 156 |
tmp/org.txm.rcp.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateWizardPage.java (revision 385) | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* Copyright (c) 2007, 2010 IBM Corporation and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* IBM Corporation - initial API and implementation |
|
10 |
*******************************************************************************/ |
|
11 |
package org.eclipse.equinox.internal.p2.ui.dialogs; |
|
12 |
|
|
13 |
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages; |
|
14 |
import org.eclipse.equinox.internal.p2.ui.model.IUElementListRoot; |
|
15 |
import org.eclipse.equinox.p2.metadata.IInstallableUnit; |
|
16 |
import org.eclipse.equinox.p2.metadata.IUpdateDescriptor; |
|
17 |
import org.eclipse.equinox.p2.operations.UpdateOperation; |
|
18 |
import org.eclipse.equinox.p2.ui.ProvisioningUI; |
|
19 |
import org.eclipse.jface.viewers.IContentProvider; |
|
20 |
import org.eclipse.swt.widgets.TreeItem; |
|
21 |
|
|
22 |
public class UpdateWizardPage extends SizeComputingWizardPage { |
|
23 |
|
|
24 |
public UpdateWizardPage(ProvisioningUI ui, ProvisioningOperationWizard wizard, IUElementListRoot root, UpdateOperation operation) { |
|
25 |
super(ui, wizard, root, operation); |
|
26 |
//System.out.println("Init, root="+Arrays.asList(root)); |
|
27 |
setTitle(ProvUIMessages.UpdateWizardPage_Title); |
|
28 |
setDescription(ProvUIMessages.UpdateWizardPage_Description); |
|
29 |
} |
|
30 |
|
|
31 |
/** |
|
32 |
* Specialized version for TXM that shows the feature description instead of the product description |
|
33 |
*/ |
|
34 |
protected String getIUDescription(IInstallableUnit iu) { |
|
35 |
//TODO Sélectionner TXM product par défaut |
|
36 |
if (iu != null) { |
|
37 |
//System.out.println("IInstallableUnit.getId() " +iu.getId()); |
|
38 |
if (iu.getId().equals("org.txm.rcp.product")) { // TXM product is selected |
|
39 |
//System.out.println("TXM product is selected"); |
|
40 |
TreeItem[] treeitems = treeViewer.getTree().getSelection(); |
|
41 |
for (TreeItem item : treeitems) { // find it in the Tree selection |
|
42 |
Object data = item.getData(); |
|
43 |
//System.out.println("TreeElem: "+data+" class="+data.getClass()); |
|
44 |
if (data instanceof org.eclipse.equinox.internal.p2.ui.model.AvailableUpdateElement) { |
|
45 |
org.eclipse.equinox.internal.p2.ui.model.AvailableUpdateElement iunit = (org.eclipse.equinox.internal.p2.ui.model.AvailableUpdateElement) data; |
|
46 |
//System.out.println(" iunit found "+iunit); |
|
47 |
if (iunit.getIU().getId().equals(iu.getId())) { // this is the TXM product |
|
48 |
//System.out.println(" TXM product found in Tree "+iunit); |
|
49 |
//System.out.println("Input: "+treeViewer.getInput()); |
|
50 |
IContentProvider cp = treeViewer.getContentProvider(); |
|
51 |
//System.out.println("content provider: "+treeViewer.getContentProvider()); |
|
52 |
org.eclipse.equinox.internal.p2.ui.viewers.ProvElementContentProvider pecp = (org.eclipse.equinox.internal.p2.ui.viewers.ProvElementContentProvider)cp; |
|
53 |
Object[] children = pecp.getChildren(data); |
|
54 |
//System.out.println("Children: "+Arrays.asList(children)); |
|
55 |
for (Object child : children) { |
|
56 |
//System.out.println("Child: "+child); |
|
57 |
//if (child != null) System.out.println("Child class: "+child.getClass()); |
|
58 |
if (child instanceof org.eclipse.equinox.internal.p2.ui.model.AvailableIUElement) { |
|
59 |
org.eclipse.equinox.internal.p2.ui.model.AvailableIUElement riu = (org.eclipse.equinox.internal.p2.ui.model.AvailableIUElement) child; |
|
60 |
//System.out.println("riu found "+riu); |
|
61 |
if (riu.getIU().getId().equals("org.txm.rcp.feature.feature.group")) { |
|
62 |
//System.out.println("org.txm.rcp.feature.feature.group description found "+riu.getIU().getUpdateDescriptor().getDescription()); |
|
63 |
String desc = riu.getIU().getUpdateDescriptor().getDescription(); |
|
64 |
if (desc != null) { |
|
65 |
return desc; |
|
66 |
} else { |
|
67 |
return super.getIUDescription(riu.getIU()); |
|
68 |
} |
|
69 |
} |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
|
|
74 |
} |
|
75 |
} |
|
76 |
} |
|
77 |
} else { |
|
78 |
IUpdateDescriptor updateDescriptor = iu.getUpdateDescriptor(); |
|
79 |
if (updateDescriptor != null && updateDescriptor.getDescription() != null && updateDescriptor.getDescription().length() > 0) { |
|
80 |
return updateDescriptor.getDescription(); |
|
81 |
} |
|
82 |
} |
|
83 |
} |
|
84 |
//String defaultDesc = super.getIUDescription(iu); |
|
85 |
return super.getIUDescription(iu); |
|
86 |
} |
|
87 |
|
|
88 |
protected String getOperationLabel() { |
|
89 |
return ProvUIMessages.UpdateIUOperationLabel; |
|
90 |
} |
|
91 |
|
|
92 |
protected String getOperationTaskName() { |
|
93 |
return ProvUIMessages.UpdateIUOperationTask; |
|
94 |
} |
|
95 |
} |
|
0 | 96 |
tmp/org.txm.rcp.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ILayoutConstants.java (revision 385) | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* Copyright (c) 2008, 2009 IBM Corporation and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* IBM Corporation - initial API and implementation |
|
10 |
*******************************************************************************/ |
|
11 |
package org.eclipse.equinox.internal.p2.ui.dialogs; |
|
12 |
|
|
13 |
/** |
|
14 |
* ILayoutConstants defines common dialog constants used when laying |
|
15 |
* out dialogs. Units of measurement are character widths and heights |
|
16 |
* unless otherwise specified. |
|
17 |
* |
|
18 |
* This interface is not intended to be implemented |
|
19 |
* |
|
20 |
* @noimplement This interface is not intended to be implemented by clients. |
|
21 |
* @noextend This interface is not intended to be extended by clients. |
|
22 |
* @since 3.5 |
|
23 |
*/ |
|
24 |
public interface ILayoutConstants { |
|
25 |
public static final int DEFAULT_DESCRIPTION_HEIGHT = 4; |
|
26 |
public static final int MINIMUM_DESCRIPTION_HEIGHT = 1; |
|
27 |
public static final int DEFAULT_SITEDETAILS_HEIGHT = 2; |
|
28 |
public static final int DEFAULT_PRIMARY_COLUMN_WIDTH = 60; |
|
29 |
public static final int DEFAULT_COLUMN_WIDTH = 40; |
|
30 |
public static final int DEFAULT_SMALL_COLUMN_WIDTH = 20; |
|
31 |
public static final int DEFAULT_TABLE_HEIGHT = 10; |
|
32 |
public static final int DEFAULT_TABLE_WIDTH = 80; |
|
33 |
public static final int[] IUS_TO_DETAILS_WEIGHTS = new int[] {50, 50}; |
|
34 |
} |
|
0 | 35 |
tmp/org.txm.rcp.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionResultsWizardPage.java (revision 385) | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* Copyright (c) 2007, 2013 IBM Corporation and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* IBM Corporation - initial API and implementation |
|
10 |
* EclipseSource - ongoing development |
|
11 |
* Sonatype, Inc. - ongoing development |
|
12 |
* Red Hat, Inc. - support for remediation page |
|
13 |
*******************************************************************************/ |
|
14 |
package org.eclipse.equinox.internal.p2.ui.dialogs; |
|
15 |
|
|
16 |
import java.util.Collection; |
|
17 |
|
|
18 |
import org.eclipse.core.runtime.*; |
|
19 |
import org.eclipse.equinox.internal.p2.ui.*; |
|
20 |
import org.eclipse.equinox.internal.p2.ui.model.*; |
|
21 |
import org.eclipse.equinox.internal.p2.ui.viewers.*; |
|
22 |
import org.eclipse.equinox.p2.engine.IProvisioningPlan; |
|
23 |
import org.eclipse.equinox.p2.metadata.IInstallableUnit; |
|
24 |
import org.eclipse.equinox.p2.operations.ProfileChangeOperation; |
|
25 |
import org.eclipse.equinox.p2.operations.ProvisioningJob; |
|
26 |
import org.eclipse.equinox.p2.query.IQueryable; |
|
27 |
import org.eclipse.equinox.p2.ui.ProvisioningUI; |
|
28 |
import org.eclipse.jface.dialogs.Dialog; |
|
29 |
import org.eclipse.jface.dialogs.IDialogConstants; |
|
30 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
|
31 |
import org.eclipse.jface.viewers.*; |
|
32 |
import org.eclipse.swt.SWT; |
|
33 |
import org.eclipse.swt.custom.SashForm; |
|
34 |
import org.eclipse.swt.graphics.Image; |
|
35 |
import org.eclipse.swt.layout.*; |
|
36 |
import org.eclipse.swt.widgets.*; |
|
37 |
import org.eclipse.ui.statushandlers.StatusManager; |
|
38 |
|
|
39 |
import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor.SetterOnlyReflection; |
|
40 |
|
|
41 |
/** |
|
42 |
* A wizard page that shows detailed information about a resolved install |
|
43 |
* operation. It allows drill down into the elements that will be installed. |
|
44 |
* |
|
45 |
* @since 3.4 |
|
46 |
* |
|
47 |
*/ |
|
48 |
public abstract class ResolutionResultsWizardPage extends ResolutionStatusPage { |
|
49 |
|
|
50 |
private static final String DIALOG_SETTINGS_SECTION = "ResolutionResultsPage"; //$NON-NLS-1$ |
|
51 |
|
|
52 |
protected IUElementListRoot input; |
|
53 |
ProfileChangeOperation resolvedOperation; |
|
54 |
TreeViewer treeViewer; |
|
55 |
ProvElementContentProvider contentProvider; |
|
56 |
IUDetailsLabelProvider labelProvider; |
|
57 |
protected Display display; |
|
58 |
private IUDetailsGroup iuDetailsGroup; |
|
59 |
SashForm sashForm; |
|
60 |
|
|
61 |
protected ResolutionResultsWizardPage(ProvisioningUI ui, ProvisioningOperationWizard wizard, IUElementListRoot input, ProfileChangeOperation operation) { |
|
62 |
super("ResolutionPage", ui, wizard); //$NON-NLS-1$ |
|
63 |
this.resolvedOperation = operation; |
|
64 |
if (input == null) |
|
65 |
this.input = new IUElementListRoot(); |
|
66 |
else |
|
67 |
this.input = input; |
|
68 |
} |
|
69 |
|
|
70 |
/* |
|
71 |
* (non-Javadoc) |
|
72 |
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) |
|
73 |
*/ |
|
74 |
public void createControl(Composite parent) { |
|
75 |
display = parent.getDisplay(); |
|
76 |
sashForm = new SashForm(parent, SWT.VERTICAL); |
|
77 |
FillLayout layout = new FillLayout(); |
|
78 |
sashForm.setLayout(layout); |
|
79 |
GridData data = new GridData(GridData.FILL_BOTH); |
|
80 |
sashForm.setLayoutData(data); |
|
81 |
initializeDialogUnits(sashForm); |
|
82 |
|
|
83 |
Composite composite = new Composite(sashForm, SWT.NONE); |
|
84 |
GridLayout gridLayout = new GridLayout(); |
|
85 |
gridLayout.marginWidth = 0; |
|
86 |
gridLayout.marginHeight = 0; |
|
87 |
composite.setLayout(gridLayout); |
|
88 |
|
|
89 |
treeViewer = createTreeViewer(composite); |
|
90 |
data = new GridData(GridData.FILL_BOTH); |
|
91 |
data.heightHint = convertHeightInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_HEIGHT); |
|
92 |
data.widthHint = convertWidthInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_WIDTH); |
|
93 |
Tree tree = treeViewer.getTree(); |
|
94 |
tree.setLayoutData(data); |
|
95 |
tree.setHeaderVisible(true); |
|
96 |
activateCopy(tree); |
|
97 |
TreeViewerColumn nameColumn = new TreeViewerColumn(treeViewer, SWT.LEFT); |
|
98 |
nameColumn.getColumn().setText(ProvUIMessages.ProvUI_NameColumnTitle); |
|
99 |
nameColumn.getColumn().setWidth(400); |
|
100 |
nameColumn.getColumn().setMoveable(true); |
|
101 |
nameColumn.setLabelProvider(new ColumnLabelProvider() { |
|
102 |
public String getText(Object element) { |
|
103 |
IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class); |
|
104 |
String label = iu.getProperty(IInstallableUnit.PROP_NAME, null); |
|
105 |
if (label == null) |
|
106 |
label = iu.getId(); |
|
107 |
return label; |
|
108 |
} |
|
109 |
|
|
110 |
public Image getImage(Object element) { |
|
111 |
if (element instanceof ProvElement) |
|
112 |
return ((ProvElement) element).getImage(element); |
|
113 |
if (ProvUI.getAdapter(element, IInstallableUnit.class) != null) |
|
114 |
return ProvUIImages.getImage(ProvUIImages.IMG_IU); |
|
115 |
return null; |
|
116 |
} |
|
117 |
|
|
118 |
public String getToolTipText(Object element) { |
|
119 |
if (element instanceof AvailableIUElement && ((AvailableIUElement) element).getImageOverlayId(null) == ProvUIImages.IMG_INFO) |
|
120 |
return ProvUIMessages.RemedyElementNotHighestVersion; |
|
121 |
return super.getToolTipText(element); |
|
122 |
} |
|
123 |
}); |
|
124 |
TreeViewerColumn versionColumn = new TreeViewerColumn(treeViewer, SWT.LEFT); |
|
125 |
versionColumn.getColumn().setText(ProvUIMessages.ProvUI_VersionColumnTitle); |
|
126 |
versionColumn.getColumn().setWidth(200); |
|
127 |
versionColumn.setLabelProvider(new ColumnLabelProvider() { |
|
128 |
public String getText(Object element) { |
|
129 |
IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class); |
|
130 |
if (element instanceof IIUElement) { |
|
131 |
if (((IIUElement) element).shouldShowVersion()) |
|
132 |
return iu.getVersion().toString(); |
|
133 |
return ""; //$NON-NLS-1$ |
|
134 |
} |
|
135 |
return iu.getVersion().toString(); |
|
136 |
} |
|
137 |
}); |
|
138 |
TreeViewerColumn idColumn = new TreeViewerColumn(treeViewer, SWT.LEFT); |
|
139 |
idColumn.getColumn().setText(ProvUIMessages.ProvUI_IdColumnTitle); |
|
140 |
idColumn.getColumn().setWidth(200); |
|
141 |
|
|
142 |
idColumn.setLabelProvider(new ColumnLabelProvider() { |
|
143 |
public String getText(Object element) { |
|
144 |
IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class); |
|
145 |
return iu.getId(); |
|
146 |
} |
|
147 |
}); |
|
148 |
|
|
149 |
// Filters and sorters before establishing content, so we don't refresh unnecessarily. |
|
150 |
IUComparator comparator = new IUComparator(IUComparator.IU_NAME); |
|
151 |
comparator.useColumnConfig(getColumnConfig()); |
|
152 |
treeViewer.setComparator(comparator); |
|
153 |
treeViewer.setComparer(new ProvElementComparer()); |
|
154 |
ColumnViewerToolTipSupport.enableFor(treeViewer); |
|
155 |
contentProvider = new ProvElementContentProvider(); |
|
156 |
treeViewer.setContentProvider(contentProvider); |
|
157 |
// labelProvider = new IUDetailsLabelProvider(null, getColumnConfig(), getShell()); |
|
158 |
// treeViewer.setLabelProvider(labelProvider); |
|
159 |
|
|
160 |
// Optional area to show the size |
|
161 |
createSizingInfo(composite); |
|
162 |
|
|
163 |
// The text area shows a description of the selected IU, or error detail if applicable. |
|
164 |
iuDetailsGroup = new IUDetailsGroup(sashForm, treeViewer, 2*convertWidthInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_WIDTH), true); |
|
165 |
|
|
166 |
setControl(sashForm); |
|
167 |
sashForm.setWeights(getSashWeights()); |
|
168 |
Dialog.applyDialogFont(sashForm); |
|
169 |
|
|
170 |
// Controls for filtering/presentation/site selection |
|
171 |
Composite controlsComposite = new Composite(composite, SWT.NONE); |
|
172 |
gridLayout = new GridLayout(); |
|
173 |
gridLayout.marginWidth = 0; |
|
174 |
gridLayout.marginHeight = 0; |
|
175 |
gridLayout.numColumns = 2; |
|
176 |
gridLayout.makeColumnsEqualWidth = true; |
|
177 |
gridLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); |
|
178 |
controlsComposite.setLayout(layout); |
|
179 |
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false); |
|
180 |
controlsComposite.setLayoutData(gd); |
|
181 |
|
|
182 |
final Runnable runnable = new Runnable() { |
|
183 |
public void run() { |
|
184 |
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
|
185 |
public void selectionChanged(SelectionChangedEvent event) { |
|
186 |
setDetailText(resolvedOperation); |
|
187 |
} |
|
188 |
}); |
|
189 |
setDrilldownElements(input, resolvedOperation); |
|
190 |
treeViewer.setInput(input); |
|
191 |
// treeViewer.expandAll(); |
|
192 |
// for (TreeItem item : treeViewer.getTree().getItems()) { |
|
193 |
// System.out.println("SELECT FIRST ITEM for: "+item.getData()); |
|
194 |
// |
|
195 |
// treeViewer.getTree().select(item); |
|
196 |
// getIUDescription(item.getData()); |
|
197 |
// } |
|
198 |
setDetailText(resolvedOperation); |
|
199 |
} |
|
200 |
}; |
|
201 |
|
|
202 |
if (resolvedOperation != null && !resolvedOperation.hasResolved()) { |
|
203 |
try { |
|
204 |
getContainer().run(true, false, new IRunnableWithProgress() { |
|
205 |
public void run(IProgressMonitor monitor) { |
|
206 |
resolvedOperation.resolveModal(monitor); |
|
207 |
display.asyncExec(runnable); |
|
208 |
} |
|
209 |
}); |
|
210 |
} catch (Exception e) { |
|
211 |
StatusManager.getManager().handle(new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e)); |
|
212 |
} |
|
213 |
} else { |
|
214 |
runnable.run(); |
|
215 |
} |
|
216 |
} |
|
217 |
|
|
218 |
@Override |
|
219 |
public void updateStatus(IUElementListRoot newRoot, ProfileChangeOperation op) { |
|
220 |
super.updateStatus(newRoot, op); |
|
221 |
} |
|
222 |
|
|
223 |
protected void createSizingInfo(Composite parent) { |
|
224 |
// Default is to do nothing |
|
225 |
} |
|
226 |
|
|
227 |
public boolean performFinish() { |
|
228 |
if (resolvedOperation.getResolutionResult().getSeverity() != IStatus.ERROR) { |
|
229 |
getProvisioningUI().schedule(resolvedOperation.getProvisioningJob(null), StatusManager.SHOW | StatusManager.LOG); |
|
230 |
return true; |
|
231 |
} |
|
232 |
return false; |
|
233 |
} |
|
234 |
|
|
235 |
protected TreeViewer getTreeViewer() { |
|
236 |
return treeViewer; |
|
237 |
} |
|
238 |
|
|
239 |
public IProvisioningPlan getCurrentPlan() { |
|
240 |
if (resolvedOperation != null) |
|
241 |
return resolvedOperation.getProvisioningPlan(); |
|
242 |
return null; |
|
243 |
} |
|
244 |
|
|
245 |
protected Object[] getSelectedElements() { |
|
246 |
return ((IStructuredSelection) treeViewer.getSelection()).toArray(); |
|
247 |
} |
|
248 |
|
|
249 |
protected IInstallableUnit getSelectedIU() { |
|
250 |
java.util.List<IInstallableUnit> units = ElementUtils.elementsToIUs(getSelectedElements()); |
|
251 |
if (units.size() == 0) |
|
252 |
return null; |
|
253 |
return units.get(0); |
|
254 |
} |
|
255 |
|
|
256 |
protected boolean shouldCompleteOnCancel() { |
|
257 |
return false; |
|
258 |
} |
|
259 |
|
|
260 |
protected Collection<IInstallableUnit> getIUs() { |
|
261 |
return ElementUtils.elementsToIUs(input.getChildren(input)); |
|
262 |
} |
|
263 |
|
|
264 |
void setDrilldownElements(IUElementListRoot root, ProfileChangeOperation operation) { |
|
265 |
if (operation == null || operation.getProvisioningPlan() == null) |
|
266 |
return; |
|
267 |
Object[] elements = root.getChildren(root); |
|
268 |
for (int i = 0; i < elements.length; i++) { |
|
269 |
if (elements[i] instanceof QueriedElement) { |
|
270 |
((QueriedElement) elements[i]).setQueryable(getQueryable(operation.getProvisioningPlan())); |
|
271 |
} |
|
272 |
} |
|
273 |
} |
|
274 |
|
|
275 |
protected abstract String getOperationLabel(); |
|
276 |
|
|
277 |
/** |
|
278 |
* Returns the restart policy for this operation. |
|
279 |
* |
|
280 |
* @return an integer constant describing whether the running profile |
|
281 |
* needs to be restarted. |
|
282 |
* |
|
283 |
* @see ProvisioningJob#RESTART_NONE |
|
284 |
* @see ProvisioningJob#RESTART_ONLY |
|
285 |
* @see ProvisioningJob#RESTART_OR_APPLY |
|
286 |
* |
|
287 |
*/ |
|
288 |
protected int getRestartPolicy() { |
|
289 |
return ProvisioningJob.RESTART_OR_APPLY; |
|
290 |
} |
|
291 |
|
|
292 |
/** |
|
293 |
* Returns the task name for this operation, or <code>null</code> to display |
|
294 |
* a generic task name. |
|
295 |
*/ |
|
296 |
protected String getOperationTaskName() { |
|
297 |
return null; |
|
298 |
} |
|
299 |
|
|
300 |
protected TreeViewer createTreeViewer(Composite parent) { |
|
301 |
return new TreeViewer(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION) { |
|
302 |
// public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
|
303 |
// for (TreeItem item : treeViewer.getTree().getItems()) { |
|
304 |
// System.out.println("SELECT FIRST ITEM for: "+item.getData()); |
|
305 |
// treeViewer.getTree().select(item); |
|
306 |
// getIUDescription(item.getData()); |
|
307 |
// } |
|
308 |
// } |
|
309 |
}; |
|
310 |
} |
|
311 |
|
|
312 |
protected abstract IQueryable<IInstallableUnit> getQueryable(IProvisioningPlan plan); |
|
313 |
|
|
314 |
protected String getClipboardText(Control control) { |
|
315 |
return CopyUtils.getIndentedClipboardText(getSelectedElements(), labelProvider); |
|
316 |
} |
|
317 |
|
|
318 |
protected IUDetailsGroup getDetailsGroup() { |
|
319 |
return iuDetailsGroup; |
|
320 |
} |
|
321 |
|
|
322 |
protected boolean isCreated() { |
|
323 |
return treeViewer != null; |
|
324 |
} |
|
325 |
|
|
326 |
protected void updateCaches(IUElementListRoot newRoot, ProfileChangeOperation op) { |
|
327 |
resolvedOperation = op; |
|
328 |
if (newRoot != null) { |
|
329 |
setDrilldownElements(newRoot, resolvedOperation); |
|
330 |
if (treeViewer != null) { |
|
331 |
if (input != newRoot) |
|
332 |
treeViewer.setInput(newRoot); |
|
333 |
else |
|
334 |
treeViewer.refresh(); |
|
335 |
} |
|
336 |
input = newRoot; |
|
337 |
} |
|
338 |
} |
|
339 |
|
|
340 |
protected String getDialogSettingsName() { |
|
341 |
return getWizard().getClass().getName() + "." + DIALOG_SETTINGS_SECTION; //$NON-NLS-1$ |
|
342 |
} |
|
343 |
|
|
344 |
protected int getColumnWidth(int index) { |
|
345 |
return treeViewer.getTree().getColumn(index).getWidth(); |
|
346 |
} |
|
347 |
|
|
348 |
protected SashForm getSashForm() { |
|
349 |
return sashForm; |
|
350 |
} |
|
351 |
} |
|
0 | 352 |
tmp/org.txm.rcp.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateWizard.java (revision 385) | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* Copyright (c) 2007, 2013 IBM Corporation and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* IBM Corporation - initial API and implementation |
|
10 |
* Genuitec, LLC - added license support |
|
11 |
* Sonatype, Inc. - ongoing development |
|
12 |
* Red Hat, Inc. - support for remediation page |
|
13 |
*******************************************************************************/ |
|
14 |
package org.eclipse.equinox.internal.p2.ui.dialogs; |
|
15 |
|
|
16 |
import java.util.*; |
|
17 |
import org.eclipse.core.runtime.Assert; |
|
18 |
import org.eclipse.equinox.internal.p2.ui.ProvUIImages; |
|
19 |
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages; |
|
20 |
import org.eclipse.equinox.internal.p2.ui.model.*; |
|
21 |
import org.eclipse.equinox.p2.engine.IProfile; |
|
22 |
import org.eclipse.equinox.p2.engine.IProfileRegistry; |
|
23 |
import org.eclipse.equinox.p2.metadata.IInstallableUnit; |
|
24 |
import org.eclipse.equinox.p2.operations.*; |
|
25 |
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob; |
|
26 |
import org.eclipse.equinox.p2.ui.ProvisioningUI; |
|
27 |
import org.eclipse.jface.wizard.IWizardPage; |
|
28 |
|
|
29 |
/** |
|
30 |
* @since 3.4 |
|
31 |
*/ |
|
32 |
public class UpdateWizard extends WizardWithLicenses { |
|
33 |
IInstallableUnit[] iusToReplace; |
|
34 |
boolean skipSelectionsPage = false; |
|
35 |
IUElementListRoot firstPageRoot; |
|
36 |
Update[] initialSelections; |
|
37 |
|
|
38 |
public static Collection<IInstallableUnit> getIUsToReplace(Object[] elements) { |
|
39 |
Set<IInstallableUnit> iusToReplace = new HashSet<IInstallableUnit>(); |
|
40 |
for (int i = 0; i < elements.length; i++) { |
|
41 |
if (elements[i] instanceof AvailableUpdateElement) { |
|
42 |
iusToReplace.add(((AvailableUpdateElement) elements[i]).getIUToBeUpdated()); |
|
43 |
} |
|
44 |
} |
|
45 |
return iusToReplace; |
|
46 |
} |
|
47 |
|
|
48 |
public static IInstallableUnit[] getReplacementIUs(Object[] elements) { |
|
49 |
Set<IInstallableUnit> replacements = new HashSet<IInstallableUnit>(); |
|
50 |
for (int i = 0; i < elements.length; i++) { |
|
51 |
if (elements[i] instanceof AvailableUpdateElement) { |
|
52 |
replacements.add(((AvailableUpdateElement) elements[i]).getIU()); |
|
53 |
} |
|
54 |
} |
|
55 |
return replacements.toArray(new IInstallableUnit[replacements.size()]); |
|
56 |
} |
|
57 |
|
|
58 |
public static Update[] makeUpdatesFromElements(Object[] elements) { |
|
59 |
Set<Update> updates = new HashSet<Update>(); |
|
60 |
for (int i = 0; i < elements.length; i++) { |
|
61 |
if (elements[i] instanceof AvailableUpdateElement) { |
|
62 |
updates.add(((AvailableUpdateElement) elements[i]).getUpdate()); |
|
63 |
} |
|
64 |
} |
|
65 |
return updates.toArray(new Update[updates.size()]); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* Open an update wizard. For update wizards, the operation must have been resolved in advanced. |
|
70 |
* This prevents searching for updates in the UI thread. |
|
71 |
* |
Formats disponibles : Unified diff