blob: a6d87fa28d69eaa2d383edad891e2b66c71e7676 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/*******************************************************************************
* Copyright (c) 2009, 2011 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 java.util.List;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.pde.core.target.ITargetDefinition;
import org.eclipse.pde.core.target.ITargetLocation;
import org.eclipse.pde.internal.core.target.*;
import org.eclipse.pde.internal.ui.PDEPlugin;
/**
* Wizard that opens an appropriate page for editing a specific type of bundle container
*
*/
public class EditBundleContainerWizard extends Wizard {
private ITargetDefinition fTarget;
private ITargetLocation fContainer;
private IEditBundleContainerPage fPage;
public EditBundleContainerWizard(ITargetDefinition target, ITargetLocation container) {
fTarget = target;
fContainer = container;
IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(AddBundleContainerSelectionPage.SETTINGS_SECTION);
if (settings == null) {
settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(AddBundleContainerSelectionPage.SETTINGS_SECTION);
}
setDialogSettings(settings);
setWindowTitle(Messages.EditBundleContainerWizard_0);
}
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#addPages()
*/
public void addPages() {
if (fContainer instanceof DirectoryBundleContainer) {
fPage = new EditDirectoryContainerPage(fContainer);
} else if (fContainer instanceof ProfileBundleContainer) {
fPage = new EditProfileContainerPage(fContainer);
} else if (fContainer instanceof FeatureBundleContainer) {
fPage = new EditFeatureContainerPage(fContainer);
} else if (fContainer instanceof IUBundleContainer) {
fPage = new EditIUContainerPage((IUBundleContainer) fContainer, fTarget);
}
if (fPage != null) {
addPage(fPage);
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
public boolean performFinish() {
if (fPage != null) {
fPage.storeSettings();
// Add the new container or replace the old one
ITargetLocation newContainer = fPage.getBundleContainer();
if (newContainer != null) {
ITargetLocation[] containers = fTarget.getTargetLocations();
List<ITargetLocation> newContainers = new ArrayList<ITargetLocation>(containers.length);
for (int i = 0; i < containers.length; i++) {
if (!containers[i].equals(fContainer)) {
newContainers.add(containers[i]);
}
}
newContainers.add(newContainer);
fTarget.setTargetLocations(newContainers.toArray(new ITargetLocation[newContainers.size()]));
}
return true;
}
return false;
}
}
|