|
Lines 1-712
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2009 IBM Corporation and others. |
2 |
* Copyright (c) 2009 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
7 |
* |
| 8 |
* Contributors: |
8 |
* Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
| 10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.pde.internal.ui.wizards.target; |
11 |
package org.eclipse.pde.internal.ui.wizards.target; |
| 12 |
|
12 |
|
| 13 |
import org.eclipse.pde.internal.ui.PDEUIMessages; |
13 |
import java.lang.reflect.InvocationTargetException; |
| 14 |
|
14 |
import java.util.*; |
| 15 |
import java.lang.reflect.InvocationTargetException; |
15 |
import java.util.List; |
| 16 |
import java.util.*; |
16 |
import org.eclipse.core.runtime.*; |
| 17 |
import java.util.List; |
17 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
| 18 |
import org.eclipse.core.runtime.*; |
18 |
import org.eclipse.core.runtime.preferences.InstanceScope; |
| 19 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
19 |
import org.eclipse.debug.ui.StringVariableSelectionDialog; |
| 20 |
import org.eclipse.core.runtime.preferences.InstanceScope; |
20 |
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; |
| 21 |
import org.eclipse.debug.ui.StringVariableSelectionDialog; |
21 |
import org.eclipse.jdt.launching.JavaRuntime; |
| 22 |
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; |
22 |
import org.eclipse.jdt.launching.environments.IExecutionEnvironment; |
| 23 |
import org.eclipse.jdt.launching.JavaRuntime; |
23 |
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager; |
| 24 |
import org.eclipse.jdt.launching.environments.IExecutionEnvironment; |
24 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
| 25 |
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager; |
25 |
import org.eclipse.jface.viewers.*; |
| 26 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
26 |
import org.eclipse.jface.window.Window; |
| 27 |
import org.eclipse.jface.viewers.*; |
27 |
import org.eclipse.pde.internal.core.ICoreConstants; |
| 28 |
import org.eclipse.jface.window.Window; |
28 |
import org.eclipse.pde.internal.core.PDECore; |
| 29 |
import org.eclipse.pde.internal.core.ICoreConstants; |
29 |
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle; |
| 30 |
import org.eclipse.pde.internal.core.PDECore; |
30 |
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; |
| 31 |
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle; |
31 |
import org.eclipse.pde.internal.core.util.VMUtil; |
| 32 |
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition; |
32 |
import org.eclipse.pde.internal.ui.*; |
| 33 |
import org.eclipse.pde.internal.core.util.VMUtil; |
33 |
import org.eclipse.pde.internal.ui.elements.DefaultTableProvider; |
| 34 |
import org.eclipse.pde.internal.ui.*; |
34 |
import org.eclipse.pde.internal.ui.shared.target.*; |
| 35 |
import org.eclipse.pde.internal.ui.elements.DefaultTableProvider; |
35 |
import org.eclipse.pde.internal.ui.util.LocaleUtil; |
| 36 |
import org.eclipse.pde.internal.ui.shared.target.*; |
36 |
import org.eclipse.pde.internal.ui.util.SWTUtil; |
| 37 |
import org.eclipse.pde.internal.ui.util.LocaleUtil; |
37 |
import org.eclipse.swt.SWT; |
| 38 |
import org.eclipse.pde.internal.ui.util.SWTUtil; |
38 |
import org.eclipse.swt.events.*; |
| 39 |
import org.eclipse.swt.SWT; |
39 |
import org.eclipse.swt.layout.GridData; |
| 40 |
import org.eclipse.swt.events.*; |
40 |
import org.eclipse.swt.layout.GridLayout; |
| 41 |
import org.eclipse.swt.layout.GridData; |
41 |
import org.eclipse.swt.widgets.*; |
| 42 |
import org.eclipse.swt.layout.GridLayout; |
42 |
import org.eclipse.ui.ISharedImages; |
| 43 |
import org.eclipse.swt.widgets.*; |
43 |
import org.eclipse.ui.PlatformUI; |
| 44 |
import org.eclipse.ui.dialogs.ElementListSelectionDialog; |
44 |
import org.eclipse.ui.dialogs.ElementListSelectionDialog; |
| 45 |
import org.eclipse.ui.progress.UIJob; |
45 |
import org.eclipse.ui.progress.UIJob; |
| 46 |
|
46 |
|
| 47 |
/** |
47 |
/** |
| 48 |
* Wizard page for editing the content of a target platform using a tab layout |
48 |
* Wizard page for editing the content of a target platform using a tab layout |
| 49 |
* |
49 |
* |
| 50 |
* @see NewTargetDefinitionWizard2 |
50 |
* @see NewTargetDefinitionWizard2 |
| 51 |
* @see EditTargetDefinitionWizard |
51 |
* @see EditTargetDefinitionWizard |
| 52 |
*/ |
52 |
*/ |
| 53 |
public class TargetDefinitionContentPage extends TargetDefinitionPage { |
53 |
public class TargetDefinitionContentPage extends TargetDefinitionPage { |
| 54 |
|
54 |
|
| 55 |
private static final String EMPTY_STRING = ""; //$NON-NLS-1$ |
55 |
private static final String EMPTY_STRING = ""; //$NON-NLS-1$ |
| 56 |
|
56 |
|
| 57 |
private Text fNameText; |
57 |
private Text fNameText; |
| 58 |
private BundleContainerTable fTable; |
58 |
private TabItem fLocationTab; |
| 59 |
|
59 |
private TargetLocationsGroup fLocationTree; |
| 60 |
// Environment pull-downs |
60 |
private TargetContentsGroup fContentTree; |
| 61 |
private Combo fOSCombo; |
61 |
|
| 62 |
private Combo fWSCombo; |
62 |
// Environment pull-downs |
| 63 |
private Combo fArchCombo; |
63 |
private Combo fOSCombo; |
| 64 |
private Combo fNLCombo; |
64 |
private Combo fWSCombo; |
| 65 |
|
65 |
private Combo fArchCombo; |
| 66 |
// Choices for each pull-down |
66 |
private Combo fNLCombo; |
| 67 |
private TreeSet fNLChoices; |
67 |
|
| 68 |
private TreeSet fOSChoices; |
68 |
// Choices for each pull-down |
| 69 |
private TreeSet fWSChoices; |
69 |
private TreeSet fNLChoices; |
| 70 |
private TreeSet fArchChoices; |
70 |
private TreeSet fOSChoices; |
| 71 |
|
71 |
private TreeSet fWSChoices; |
| 72 |
// JRE section |
72 |
private TreeSet fArchChoices; |
| 73 |
private Button fDefaultJREButton; |
73 |
|
| 74 |
private Button fNamedJREButton; |
74 |
// JRE section |
| 75 |
private Button fExecEnvButton; |
75 |
private Button fDefaultJREButton; |
| 76 |
private Combo fNamedJREsCombo; |
76 |
private Button fNamedJREButton; |
| 77 |
private Combo fExecEnvsCombo; |
77 |
private Button fExecEnvButton; |
| 78 |
private TreeSet fExecEnvChoices; |
78 |
private Combo fNamedJREsCombo; |
| 79 |
|
79 |
private Combo fExecEnvsCombo; |
| 80 |
// argument controls |
80 |
private TreeSet fExecEnvChoices; |
| 81 |
private Text fProgramArgs; |
81 |
|
| 82 |
private Text fVMArgs; |
82 |
// argument controls |
| 83 |
|
83 |
private Text fProgramArgs; |
| 84 |
// implicit dependencies tab |
84 |
private Text fVMArgs; |
| 85 |
private TableViewer fElementViewer; |
85 |
|
| 86 |
private Button fAddButton; |
86 |
// implicit dependencies tab |
| 87 |
private Button fRemoveButton; |
87 |
private TableViewer fElementViewer; |
| 88 |
private Button fRemoveAllButton; |
88 |
private Button fAddButton; |
| 89 |
|
89 |
private Button fRemoveButton; |
| 90 |
/** |
90 |
private Button fRemoveAllButton; |
| 91 |
* @param pageName |
91 |
|
| 92 |
*/ |
92 |
/** |
| 93 |
public TargetDefinitionContentPage(ITargetDefinition target) { |
93 |
* @param pageName |
| 94 |
super("targetContent", target); //$NON-NLS-1$ |
94 |
*/ |
| 95 |
setTitle(PDEUIMessages.TargetDefinitionContentPage_1); |
95 |
public TargetDefinitionContentPage(ITargetDefinition target) { |
| 96 |
setDescription(PDEUIMessages.TargetDefinitionContentPage_2); |
96 |
super("targetContent", target); //$NON-NLS-1$ |
| 97 |
setImageDescriptor(PDEPluginImages.DESC_TARGET_WIZ); |
97 |
setTitle(PDEUIMessages.TargetDefinitionContentPage_1); |
| 98 |
} |
98 |
setDescription(PDEUIMessages.TargetDefinitionContentPage_2); |
| 99 |
|
99 |
setImageDescriptor(PDEPluginImages.DESC_TARGET_WIZ); |
| 100 |
/* (non-Javadoc) |
100 |
} |
| 101 |
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) |
101 |
|
| 102 |
*/ |
102 |
/* (non-Javadoc) |
| 103 |
public void createControl(Composite parent) { |
103 |
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) |
| 104 |
Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0); |
104 |
*/ |
| 105 |
|
105 |
public void createControl(Composite parent) { |
| 106 |
Composite nameComp = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_HORIZONTAL, 0, 0); |
106 |
Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0); |
| 107 |
|
107 |
|
| 108 |
SWTFactory.createLabel(nameComp, PDEUIMessages.TargetDefinitionContentPage_4, 1); |
108 |
Composite nameComp = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_HORIZONTAL, 0, 0); |
| 109 |
|
109 |
|
| 110 |
fNameText = SWTFactory.createSingleText(nameComp, 1); |
110 |
SWTFactory.createLabel(nameComp, PDEUIMessages.TargetDefinitionContentPage_4, 1); |
| 111 |
fNameText.addModifyListener(new ModifyListener() { |
111 |
|
| 112 |
public void modifyText(ModifyEvent e) { |
112 |
fNameText = SWTFactory.createSingleText(nameComp, 1); |
| 113 |
String name = fNameText.getText().trim(); |
113 |
fNameText.addModifyListener(new ModifyListener() { |
| 114 |
if (name.length() == 0) { |
114 |
public void modifyText(ModifyEvent e) { |
| 115 |
setErrorMessage(PDEUIMessages.TargetDefinitionContentPage_7); |
115 |
String name = fNameText.getText().trim(); |
| 116 |
} else { |
116 |
if (name.length() == 0) { |
| 117 |
setErrorMessage(null); |
117 |
setErrorMessage(PDEUIMessages.TargetDefinitionContentPage_7); |
| 118 |
setMessage(PDEUIMessages.TargetDefinitionContentPage_2); |
118 |
} else { |
| 119 |
} |
119 |
setErrorMessage(null); |
| 120 |
getTargetDefinition().setName(name); |
120 |
setMessage(PDEUIMessages.TargetDefinitionContentPage_2); |
| 121 |
setPageComplete(isPageComplete()); |
121 |
} |
| 122 |
} |
122 |
getTargetDefinition().setName(name); |
| 123 |
}); |
123 |
setPageComplete(isPageComplete()); |
| 124 |
|
124 |
} |
| 125 |
TabFolder tabs = new TabFolder(comp, SWT.NONE); |
125 |
}); |
| 126 |
tabs.setLayoutData(new GridData(GridData.FILL_BOTH)); |
126 |
|
| 127 |
|
127 |
TabFolder tabs = new TabFolder(comp, SWT.NONE); |
| 128 |
TabItem pluginsTab = new TabItem(tabs, SWT.NONE); |
128 |
tabs.setLayoutData(new GridData(GridData.FILL_BOTH)); |
| 129 |
pluginsTab.setText(PDEUIMessages.TargetDefinitionContentPage_6); |
129 |
|
| 130 |
|
130 |
fLocationTab = new TabItem(tabs, SWT.NONE); |
| 131 |
Composite pluginTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH); |
131 |
fLocationTab.setText("Locations"); |
| 132 |
|
132 |
|
| 133 |
SWTFactory.createWrapLabel(pluginTabContainer, PDEUIMessages.ContentSection_1, 2, 400); |
133 |
Composite pluginTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH); |
| 134 |
|
134 |
SWTFactory.createWrapLabel(pluginTabContainer, "List of locations to look for plug-ins to add to this target.", 2, 400); |
| 135 |
fTable = BundleContainerTable.createTableInDialog(pluginTabContainer, new IBundleContainerTableReporter() { |
135 |
fLocationTree = TargetLocationsGroup.createInDialog(pluginTabContainer); |
| 136 |
public void runResolveOperation(final IRunnableWithProgress operation) { |
136 |
fLocationTab.setControl(pluginTabContainer); |
| 137 |
if (isControlCreated()) { |
137 |
|
| 138 |
try { |
138 |
TabItem contentTab = new TabItem(tabs, SWT.NONE); |
| 139 |
getContainer().run(true, false, operation); |
139 |
contentTab.setText(PDEUIMessages.TargetDefinitionContentPage_6); |
| 140 |
} catch (InvocationTargetException e) { |
140 |
Composite contentTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH); |
| 141 |
PDEPlugin.log(e); |
141 |
SWTFactory.createWrapLabel(contentTabContainer, PDEUIMessages.ContentSection_1, 2, 400); |
| 142 |
} catch (InterruptedException e) { |
142 |
fContentTree = TargetContentsGroup.createInDialog(contentTabContainer); |
| 143 |
// TODO Cancel the wizard? |
143 |
contentTab.setControl(contentTabContainer); |
| 144 |
} |
144 |
|
| 145 |
} else { |
145 |
TabItem envTab = new TabItem(tabs, SWT.NONE); |
| 146 |
// If the page isn't open yet, try running a UI job so the dialog has time to finish opening |
146 |
envTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_3); |
| 147 |
new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) { |
147 |
Composite envTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH); |
| 148 |
public IStatus runInUIThread(IProgressMonitor monitor) { |
148 |
createTargetEnvironmentGroup(envTabContainer); |
| 149 |
try { |
149 |
createJREGroup(envTabContainer); |
| 150 |
getContainer().run(true, false, operation); |
150 |
envTab.setControl(envTabContainer); |
| 151 |
return Status.OK_STATUS; |
151 |
|
| 152 |
} catch (InvocationTargetException e) { |
152 |
TabItem argsTab = new TabItem(tabs, SWT.NONE); |
| 153 |
return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), PDEUIMessages.TargetDefinitionContentPage_5, e); |
153 |
argsTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_4); |
| 154 |
} catch (InterruptedException e) { |
154 |
argsTab.setControl(createArgumentsGroup(tabs)); |
| 155 |
return Status.CANCEL_STATUS; |
155 |
|
| 156 |
} |
156 |
TabItem depTab = new TabItem(tabs, SWT.NONE); |
| 157 |
} |
157 |
depTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_5); |
| 158 |
}.schedule(); |
158 |
depTab.setControl(createImplicitTabContents(tabs)); |
| 159 |
} |
159 |
|
| 160 |
} |
160 |
initializeListeners(); |
| 161 |
|
161 |
targetChanged(getTargetDefinition()); |
| 162 |
public void contentsChanged() { |
162 |
setControl(comp); |
| 163 |
// Do nothing, as wizard will always save when finish is pressed |
163 |
} |
| 164 |
} |
164 |
|
| 165 |
}); |
165 |
private void initializeListeners() { |
| 166 |
pluginsTab.setControl(pluginTabContainer); |
166 |
ITargetChangedListener listener = new ITargetChangedListener() { |
| 167 |
|
167 |
public void contentsChanged(ITargetDefinition definition, boolean resolve) { |
| 168 |
TabItem envTab = new TabItem(tabs, SWT.NONE); |
168 |
if (resolve) { |
| 169 |
envTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_3); |
169 |
if (!definition.isResolved()) { |
| 170 |
Composite envTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH); |
170 |
try { |
| 171 |
createTargetEnvironmentGroup(envTabContainer); |
171 |
getContainer().run(true, true, new IRunnableWithProgress() { |
| 172 |
createJREGroup(envTabContainer); |
172 |
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { |
| 173 |
envTab.setControl(envTabContainer); |
173 |
getTargetDefinition().resolve(monitor); |
| 174 |
|
174 |
if (monitor.isCanceled()) { |
| 175 |
TabItem argsTab = new TabItem(tabs, SWT.NONE); |
175 |
throw new InterruptedException(); |
| 176 |
argsTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_4); |
176 |
} |
| 177 |
argsTab.setControl(createArgumentsGroup(tabs)); |
177 |
} |
| 178 |
|
178 |
}); |
| 179 |
TabItem depTab = new TabItem(tabs, SWT.NONE); |
179 |
} catch (InvocationTargetException e) { |
| 180 |
depTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_5); |
180 |
PDECore.log(e); |
| 181 |
depTab.setControl(createImplicitTabContents(tabs)); |
181 |
} catch (InterruptedException e) { |
| 182 |
|
182 |
// Do nothing, op cancelled |
| 183 |
targetChanged(getTargetDefinition()); |
183 |
} |
| 184 |
setControl(comp); |
184 |
} |
| 185 |
} |
185 |
fContentTree.setInput(definition); |
| 186 |
|
186 |
fLocationTree.setInput(definition); |
| 187 |
/* (non-Javadoc) |
187 |
if (definition.isResolved() && definition.getBundleStatus().getSeverity() == IStatus.ERROR) { |
| 188 |
* @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged() |
188 |
fLocationTab.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK)); |
| 189 |
*/ |
189 |
} else { |
| 190 |
protected void targetChanged(ITargetDefinition definition) { |
190 |
fLocationTab.setImage(null); |
| 191 |
super.targetChanged(definition); |
191 |
} |
| 192 |
if (definition != null) { |
192 |
} |
| 193 |
String name = definition.getName(); |
193 |
} |
| 194 |
if (name == null) { |
194 |
}; |
| 195 |
name = EMPTY_STRING; |
195 |
fContentTree.addTargetChangedListener(listener); |
| 196 |
} |
196 |
fLocationTree.addTargetChangedListener(listener); |
| 197 |
|
197 |
// When If the page isn't open yet, try running a UI job so the dialog has time to finish opening |
| 198 |
if (name.trim().length() > 0) |
198 |
new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) { |
| 199 |
fNameText.setText(name); |
199 |
public IStatus runInUIThread(IProgressMonitor monitor) { |
| 200 |
else |
200 |
try { |
| 201 |
setMessage(PDEUIMessages.TargetDefinitionContentPage_8); |
201 |
getContainer().run(true, true, new IRunnableWithProgress() { |
| 202 |
|
202 |
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { |
| 203 |
fTable.setInput(definition); |
203 |
getTargetDefinition().resolve(monitor); |
| 204 |
|
204 |
if (monitor.isCanceled()) { |
| 205 |
String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS(); |
205 |
throw new InterruptedException(); |
| 206 |
fOSCombo.setText(presetValue); |
206 |
} |
| 207 |
presetValue = (definition.getWS() == null) ? EMPTY_STRING : definition.getWS(); |
207 |
} |
| 208 |
fWSCombo.setText(presetValue); |
208 |
}); |
| 209 |
presetValue = (definition.getArch() == null) ? EMPTY_STRING : definition.getArch(); |
209 |
} catch (InvocationTargetException e) { |
| 210 |
fArchCombo.setText(presetValue); |
210 |
PDECore.log(e); |
| 211 |
presetValue = (definition.getNL() == null) ? EMPTY_STRING : LocaleUtil.expandLocaleName(definition.getNL()); |
211 |
} catch (InterruptedException e) { |
| 212 |
fNLCombo.setText(presetValue); |
212 |
return Status.CANCEL_STATUS; |
| 213 |
|
213 |
} |
| 214 |
IPath jrePath = definition.getJREContainer(); |
214 |
ITargetDefinition definition = getTargetDefinition(); |
| 215 |
if (jrePath == null || jrePath.equals(JavaRuntime.newDefaultJREContainerPath())) { |
215 |
fContentTree.setInput(definition); |
| 216 |
fDefaultJREButton.setSelection(true); |
216 |
fLocationTree.setInput(definition); |
| 217 |
} else { |
217 |
if (definition.isResolved() && definition.getBundleStatus().getSeverity() == IStatus.ERROR) { |
| 218 |
String ee = JavaRuntime.getExecutionEnvironmentId(jrePath); |
218 |
fLocationTab.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK)); |
| 219 |
if (ee != null) { |
219 |
} else { |
| 220 |
fExecEnvButton.setSelection(true); |
220 |
fLocationTab.setImage(null); |
| 221 |
fExecEnvsCombo.select(fExecEnvsCombo.indexOf(ee)); |
221 |
} |
| 222 |
} else { |
222 |
return Status.OK_STATUS; |
| 223 |
String vm = JavaRuntime.getVMInstallName(jrePath); |
223 |
} |
| 224 |
if (vm != null) { |
224 |
}.schedule(); |
| 225 |
fNamedJREButton.setSelection(true); |
225 |
|
| 226 |
fNamedJREsCombo.select(fNamedJREsCombo.indexOf(vm)); |
226 |
} |
| 227 |
} |
227 |
|
| 228 |
} |
228 |
/* (non-Javadoc) |
| 229 |
} |
229 |
* @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged() |
| 230 |
|
230 |
*/ |
| 231 |
if (fExecEnvsCombo.getSelectionIndex() == -1) |
231 |
protected void targetChanged(ITargetDefinition definition) { |
| 232 |
fExecEnvsCombo.setText(fExecEnvChoices.first().toString()); |
232 |
super.targetChanged(definition); |
| 233 |
|
233 |
if (definition != null) { |
| 234 |
if (fNamedJREsCombo.getSelectionIndex() == -1) |
234 |
String name = definition.getName(); |
| 235 |
fNamedJREsCombo.setText(VMUtil.getDefaultVMInstallName()); |
235 |
if (name == null) { |
| 236 |
|
236 |
name = EMPTY_STRING; |
| 237 |
updateJREWidgets(); |
237 |
} |
| 238 |
|
238 |
|
| 239 |
presetValue = (definition.getProgramArguments() == null) ? EMPTY_STRING : definition.getProgramArguments(); |
239 |
if (name.trim().length() > 0) |
| 240 |
fProgramArgs.setText(presetValue); |
240 |
fNameText.setText(name); |
| 241 |
presetValue = (definition.getVMArguments() == null) ? EMPTY_STRING : definition.getVMArguments(); |
241 |
else |
| 242 |
fVMArgs.setText(presetValue); |
242 |
setMessage(PDEUIMessages.TargetDefinitionContentPage_8); |
| 243 |
|
243 |
|
| 244 |
fElementViewer.refresh(); |
244 |
fLocationTree.setInput(definition); |
| 245 |
} |
245 |
fContentTree.setInput(definition); |
| 246 |
} |
246 |
|
| 247 |
|
247 |
String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS(); |
| 248 |
private void createTargetEnvironmentGroup(Composite container) { |
248 |
fOSCombo.setText(presetValue); |
| 249 |
Group group = SWTFactory.createGroup(container, PDEUIMessages.EnvironmentBlock_targetEnv, 2, 1, GridData.FILL_HORIZONTAL); |
249 |
presetValue = (definition.getWS() == null) ? EMPTY_STRING : definition.getWS(); |
| 250 |
|
250 |
fWSCombo.setText(presetValue); |
| 251 |
initializeChoices(); |
251 |
presetValue = (definition.getArch() == null) ? EMPTY_STRING : definition.getArch(); |
| 252 |
|
252 |
fArchCombo.setText(presetValue); |
| 253 |
SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_os, 1); |
253 |
presetValue = (definition.getNL() == null) ? EMPTY_STRING : LocaleUtil.expandLocaleName(definition.getNL()); |
| 254 |
|
254 |
fNLCombo.setText(presetValue); |
| 255 |
fOSCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fOSChoices.toArray(new String[fOSChoices.size()])); |
255 |
|
| 256 |
fOSCombo.addModifyListener(new ModifyListener() { |
256 |
IPath jrePath = definition.getJREContainer(); |
| 257 |
public void modifyText(ModifyEvent e) { |
257 |
if (jrePath == null || jrePath.equals(JavaRuntime.newDefaultJREContainerPath())) { |
| 258 |
getTargetDefinition().setOS(getModelValue(fOSCombo.getText())); |
258 |
fDefaultJREButton.setSelection(true); |
| 259 |
} |
259 |
} else { |
| 260 |
}); |
260 |
String ee = JavaRuntime.getExecutionEnvironmentId(jrePath); |
| 261 |
|
261 |
if (ee != null) { |
| 262 |
SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_ws, 1); |
262 |
fExecEnvButton.setSelection(true); |
| 263 |
|
263 |
fExecEnvsCombo.select(fExecEnvsCombo.indexOf(ee)); |
| 264 |
fWSCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fWSChoices.toArray(new String[fWSChoices.size()])); |
264 |
} else { |
| 265 |
fWSCombo.addModifyListener(new ModifyListener() { |
265 |
String vm = JavaRuntime.getVMInstallName(jrePath); |
| 266 |
public void modifyText(ModifyEvent e) { |
266 |
if (vm != null) { |
| 267 |
getTargetDefinition().setWS(getModelValue(fWSCombo.getText())); |
267 |
fNamedJREButton.setSelection(true); |
| 268 |
} |
268 |
fNamedJREsCombo.select(fNamedJREsCombo.indexOf(vm)); |
| 269 |
}); |
269 |
} |
| 270 |
|
270 |
} |
| 271 |
SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_arch, 1); |
271 |
} |
| 272 |
|
272 |
|
| 273 |
fArchCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fArchChoices.toArray(new String[fArchChoices.size()])); |
273 |
if (fExecEnvsCombo.getSelectionIndex() == -1) |
| 274 |
fArchCombo.addModifyListener(new ModifyListener() { |
274 |
fExecEnvsCombo.setText(fExecEnvChoices.first().toString()); |
| 275 |
public void modifyText(ModifyEvent e) { |
275 |
|
| 276 |
getTargetDefinition().setArch(getModelValue(fArchCombo.getText())); |
276 |
if (fNamedJREsCombo.getSelectionIndex() == -1) |
| 277 |
} |
277 |
fNamedJREsCombo.setText(VMUtil.getDefaultVMInstallName()); |
| 278 |
}); |
278 |
|
| 279 |
|
279 |
updateJREWidgets(); |
| 280 |
SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_nl, 1); |
280 |
|
| 281 |
|
281 |
presetValue = (definition.getProgramArguments() == null) ? EMPTY_STRING : definition.getProgramArguments(); |
| 282 |
fNLCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fNLChoices.toArray(new String[fNLChoices.size()])); |
282 |
fProgramArgs.setText(presetValue); |
| 283 |
fNLCombo.addModifyListener(new ModifyListener() { |
283 |
presetValue = (definition.getVMArguments() == null) ? EMPTY_STRING : definition.getVMArguments(); |
| 284 |
public void modifyText(ModifyEvent e) { |
284 |
fVMArgs.setText(presetValue); |
| 285 |
String value = fNLCombo.getText(); |
285 |
|
| 286 |
int index = value.indexOf("-"); //$NON-NLS-1$ |
286 |
fElementViewer.refresh(); |
| 287 |
if (index > 0) |
287 |
} |
| 288 |
value = value.substring(0, index); |
288 |
} |
| 289 |
getTargetDefinition().setNL(getModelValue(value)); |
289 |
|
| 290 |
} |
290 |
private void createTargetEnvironmentGroup(Composite container) { |
| 291 |
}); |
291 |
Group group = SWTFactory.createGroup(container, PDEUIMessages.EnvironmentBlock_targetEnv, 2, 1, GridData.FILL_HORIZONTAL); |
| 292 |
|
292 |
|
| 293 |
} |
293 |
initializeChoices(); |
| 294 |
|
294 |
|
| 295 |
/** |
295 |
SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_os, 1); |
| 296 |
* Returns the given string or <code>null</code> if the string is empty. |
296 |
|
| 297 |
* Used when setting a value in the target definition. |
297 |
fOSCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fOSChoices.toArray(new String[fOSChoices.size()])); |
| 298 |
* |
298 |
fOSCombo.addModifyListener(new ModifyListener() { |
| 299 |
* @param value |
299 |
public void modifyText(ModifyEvent e) { |
| 300 |
* @return trimmed value or <code>null</code> |
300 |
getTargetDefinition().setOS(getModelValue(fOSCombo.getText())); |
| 301 |
*/ |
301 |
} |
| 302 |
private String getModelValue(String value) { |
302 |
}); |
| 303 |
if (value != null) { |
303 |
|
| 304 |
value = value.trim(); |
304 |
SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_ws, 1); |
| 305 |
if (value.length() == 0) { |
305 |
|
| 306 |
return null; |
306 |
fWSCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fWSChoices.toArray(new String[fWSChoices.size()])); |
| 307 |
} |
307 |
fWSCombo.addModifyListener(new ModifyListener() { |
| 308 |
} |
308 |
public void modifyText(ModifyEvent e) { |
| 309 |
return value; |
309 |
getTargetDefinition().setWS(getModelValue(fWSCombo.getText())); |
| 310 |
} |
310 |
} |
| 311 |
|
311 |
}); |
| 312 |
/** |
312 |
|
| 313 |
* Delimits a comma separated preference and add the items to the given set |
313 |
SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_arch, 1); |
| 314 |
* @param set |
314 |
|
| 315 |
* @param preference |
315 |
fArchCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fArchChoices.toArray(new String[fArchChoices.size()])); |
| 316 |
*/ |
316 |
fArchCombo.addModifyListener(new ModifyListener() { |
| 317 |
private void addExtraChoices(Set set, String preference) { |
317 |
public void modifyText(ModifyEvent e) { |
| 318 |
StringTokenizer tokenizer = new StringTokenizer(preference, ","); //$NON-NLS-1$ |
318 |
getTargetDefinition().setArch(getModelValue(fArchCombo.getText())); |
| 319 |
while (tokenizer.hasMoreTokens()) { |
319 |
} |
| 320 |
set.add(tokenizer.nextToken().trim()); |
320 |
}); |
| 321 |
} |
321 |
|
| 322 |
} |
322 |
SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_nl, 1); |
| 323 |
|
323 |
|
| 324 |
/** |
324 |
fNLCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fNLChoices.toArray(new String[fNLChoices.size()])); |
| 325 |
* Loads combo choices fromt he platform and from PDE core preferences |
325 |
fNLCombo.addModifyListener(new ModifyListener() { |
| 326 |
*/ |
326 |
public void modifyText(ModifyEvent e) { |
| 327 |
private void initializeChoices() { |
327 |
String value = fNLCombo.getText(); |
| 328 |
IEclipsePreferences node = new InstanceScope().getNode(PDECore.PLUGIN_ID); |
328 |
int index = value.indexOf("-"); //$NON-NLS-1$ |
| 329 |
|
329 |
if (index > 0) |
| 330 |
fOSChoices = new TreeSet(); |
330 |
value = value.substring(0, index); |
| 331 |
String[] os = Platform.knownOSValues(); |
331 |
getTargetDefinition().setNL(getModelValue(value)); |
| 332 |
for (int i = 0; i < os.length; i++) { |
332 |
} |
| 333 |
fOSChoices.add(os[i]); |
333 |
}); |
| 334 |
} |
334 |
|
| 335 |
String pref = node.get(ICoreConstants.OS_EXTRA, EMPTY_STRING); |
335 |
} |
| 336 |
if (!EMPTY_STRING.equals(pref)) { |
336 |
|
| 337 |
addExtraChoices(fOSChoices, pref); |
337 |
/** |
| 338 |
} |
338 |
* Returns the given string or <code>null</code> if the string is empty. |
| 339 |
|
339 |
* Used when setting a value in the target definition. |
| 340 |
fWSChoices = new TreeSet(); |
340 |
* |
| 341 |
String[] ws = Platform.knownWSValues(); |
341 |
* @param value |
| 342 |
for (int i = 0; i < ws.length; i++) { |
342 |
* @return trimmed value or <code>null</code> |
| 343 |
fWSChoices.add(ws[i]); |
343 |
*/ |
| 344 |
} |
344 |
private String getModelValue(String value) { |
| 345 |
pref = node.get(ICoreConstants.WS_EXTRA, EMPTY_STRING); |
345 |
if (value != null) { |
| 346 |
if (!EMPTY_STRING.equals(pref)) { |
346 |
value = value.trim(); |
| 347 |
addExtraChoices(fWSChoices, pref); |
347 |
if (value.length() == 0) { |
| 348 |
} |
348 |
return null; |
| 349 |
|
349 |
} |
| 350 |
fArchChoices = new TreeSet(); |
350 |
} |
| 351 |
String[] arch = Platform.knownOSArchValues(); |
351 |
return value; |
| 352 |
for (int i = 0; i < arch.length; i++) { |
352 |
} |
| 353 |
fArchChoices.add(arch[i]); |
353 |
|
| 354 |
} |
354 |
/** |
| 355 |
pref = node.get(ICoreConstants.ARCH_EXTRA, EMPTY_STRING); |
355 |
* Delimits a comma separated preference and add the items to the given set |
| 356 |
if (!EMPTY_STRING.equals(pref)) { |
356 |
* @param set |
| 357 |
addExtraChoices(fArchChoices, pref); |
357 |
* @param preference |
| 358 |
} |
358 |
*/ |
| 359 |
|
359 |
private void addExtraChoices(Set set, String preference) { |
| 360 |
fNLChoices = new TreeSet(); |
360 |
StringTokenizer tokenizer = new StringTokenizer(preference, ","); //$NON-NLS-1$ |
| 361 |
String[] nl = LocaleUtil.getLocales(); |
361 |
while (tokenizer.hasMoreTokens()) { |
| 362 |
for (int i = 0; i < nl.length; i++) { |
362 |
set.add(tokenizer.nextToken().trim()); |
| 363 |
fNLChoices.add(nl[i]); |
363 |
} |
| 364 |
} |
364 |
} |
| 365 |
pref = node.get(ICoreConstants.NL_EXTRA, EMPTY_STRING); |
365 |
|
| 366 |
if (!EMPTY_STRING.equals(pref)) { |
366 |
/** |
| 367 |
addExtraChoices(fNLChoices, pref); |
367 |
* Loads combo choices fromt he platform and from PDE core preferences |
| 368 |
} |
368 |
*/ |
| 369 |
} |
369 |
private void initializeChoices() { |
| 370 |
|
370 |
IEclipsePreferences node = new InstanceScope().getNode(PDECore.PLUGIN_ID); |
| 371 |
private void createJREGroup(Composite container) { |
371 |
|
| 372 |
Group group = SWTFactory.createGroup(container, PDEUIMessages.EnvironmentBlock_jreTitle, 2, 1, GridData.FILL_HORIZONTAL); |
372 |
fOSChoices = new TreeSet(); |
| 373 |
|
373 |
String[] os = Platform.knownOSValues(); |
| 374 |
initializeJREValues(); |
374 |
for (int i = 0; i < os.length; i++) { |
| 375 |
|
375 |
fOSChoices.add(os[i]); |
| 376 |
SWTFactory.createWrapLabel(group, PDEUIMessages.JRESection_description, 2); |
376 |
} |
| 377 |
|
377 |
String pref = node.get(ICoreConstants.OS_EXTRA, EMPTY_STRING); |
| 378 |
fDefaultJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_defaultJRE, 2); |
378 |
if (!EMPTY_STRING.equals(pref)) { |
| 379 |
fDefaultJREButton.addSelectionListener(new SelectionAdapter() { |
379 |
addExtraChoices(fOSChoices, pref); |
| 380 |
public void widgetSelected(SelectionEvent e) { |
380 |
} |
| 381 |
updateJREWidgets(); |
381 |
|
| 382 |
getTargetDefinition().setJREContainer(JavaRuntime.newDefaultJREContainerPath()); |
382 |
fWSChoices = new TreeSet(); |
| 383 |
} |
383 |
String[] ws = Platform.knownWSValues(); |
| 384 |
}); |
384 |
for (int i = 0; i < ws.length; i++) { |
| 385 |
|
385 |
fWSChoices.add(ws[i]); |
| 386 |
fNamedJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_JREName); |
386 |
} |
| 387 |
fNamedJREButton.addSelectionListener(new SelectionAdapter() { |
387 |
pref = node.get(ICoreConstants.WS_EXTRA, EMPTY_STRING); |
| 388 |
public void widgetSelected(SelectionEvent e) { |
388 |
if (!EMPTY_STRING.equals(pref)) { |
| 389 |
updateJREWidgets(); |
389 |
addExtraChoices(fWSChoices, pref); |
| 390 |
getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getText()))); |
390 |
} |
| 391 |
} |
391 |
|
| 392 |
}); |
392 |
fArchChoices = new TreeSet(); |
| 393 |
|
393 |
String[] arch = Platform.knownOSArchValues(); |
| 394 |
fNamedJREsCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, VMUtil.getVMInstallNames()); |
394 |
for (int i = 0; i < arch.length; i++) { |
| 395 |
fNamedJREsCombo.addModifyListener(new ModifyListener() { |
395 |
fArchChoices.add(arch[i]); |
| 396 |
public void modifyText(ModifyEvent e) { |
396 |
} |
| 397 |
getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getText()))); |
397 |
pref = node.get(ICoreConstants.ARCH_EXTRA, EMPTY_STRING); |
| 398 |
} |
398 |
if (!EMPTY_STRING.equals(pref)) { |
| 399 |
}); |
399 |
addExtraChoices(fArchChoices, pref); |
| 400 |
|
400 |
} |
| 401 |
fExecEnvButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_ExecutionEnv); |
401 |
|
| 402 |
fExecEnvButton.addSelectionListener(new SelectionAdapter() { |
402 |
fNLChoices = new TreeSet(); |
| 403 |
public void widgetSelected(SelectionEvent e) { |
403 |
String[] nl = LocaleUtil.getLocales(); |
| 404 |
updateJREWidgets(); |
404 |
for (int i = 0; i < nl.length; i++) { |
| 405 |
getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText()))); |
405 |
fNLChoices.add(nl[i]); |
| 406 |
} |
406 |
} |
| 407 |
}); |
407 |
pref = node.get(ICoreConstants.NL_EXTRA, EMPTY_STRING); |
| 408 |
|
408 |
if (!EMPTY_STRING.equals(pref)) { |
| 409 |
fExecEnvsCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, (String[]) fExecEnvChoices.toArray(new String[fExecEnvChoices.size()])); |
409 |
addExtraChoices(fNLChoices, pref); |
| 410 |
fExecEnvsCombo.addModifyListener(new ModifyListener() { |
410 |
} |
| 411 |
public void modifyText(ModifyEvent e) { |
411 |
} |
| 412 |
getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText()))); |
412 |
|
| 413 |
} |
413 |
private void createJREGroup(Composite container) { |
| 414 |
}); |
414 |
Group group = SWTFactory.createGroup(container, PDEUIMessages.EnvironmentBlock_jreTitle, 2, 1, GridData.FILL_HORIZONTAL); |
| 415 |
|
415 |
|
| 416 |
} |
416 |
initializeJREValues(); |
| 417 |
|
417 |
|
| 418 |
/** |
418 |
SWTFactory.createWrapLabel(group, PDEUIMessages.JRESection_description, 2); |
| 419 |
* Initializes the combo with possible execution environments |
419 |
|
| 420 |
*/ |
420 |
fDefaultJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_defaultJRE, 2); |
| 421 |
protected void initializeJREValues() { |
421 |
fDefaultJREButton.addSelectionListener(new SelectionAdapter() { |
| 422 |
fExecEnvChoices = new TreeSet(); |
422 |
public void widgetSelected(SelectionEvent e) { |
| 423 |
IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); |
423 |
updateJREWidgets(); |
| 424 |
IExecutionEnvironment[] envs = manager.getExecutionEnvironments(); |
424 |
getTargetDefinition().setJREContainer(JavaRuntime.newDefaultJREContainerPath()); |
| 425 |
for (int i = 0; i < envs.length; i++) |
425 |
} |
| 426 |
fExecEnvChoices.add(envs[i].getId()); |
426 |
}); |
| 427 |
} |
427 |
|
| 428 |
|
428 |
fNamedJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_JREName); |
| 429 |
protected void updateJREWidgets() { |
429 |
fNamedJREButton.addSelectionListener(new SelectionAdapter() { |
| 430 |
fNamedJREsCombo.setEnabled(fNamedJREButton.getSelection()); |
430 |
public void widgetSelected(SelectionEvent e) { |
| 431 |
fExecEnvsCombo.setEnabled(fExecEnvButton.getSelection()); |
431 |
updateJREWidgets(); |
| 432 |
} |
432 |
getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getText()))); |
| 433 |
|
433 |
} |
| 434 |
private Control createArgumentsGroup(Composite parent) { |
434 |
}); |
| 435 |
Composite container = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH); |
435 |
|
| 436 |
|
436 |
fNamedJREsCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, VMUtil.getVMInstallNames()); |
| 437 |
SWTFactory.createWrapLabel(container, PDEUIMessages.JavaArgumentsTab_description, 1); |
437 |
fNamedJREsCombo.addModifyListener(new ModifyListener() { |
| 438 |
|
438 |
public void modifyText(ModifyEvent e) { |
| 439 |
Group programGroup = SWTFactory.createGroup(container, PDEUIMessages.JavaArgumentsTab_progamArgsGroup, 1, 1, GridData.FILL_HORIZONTAL); |
439 |
getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getText()))); |
| 440 |
|
440 |
} |
| 441 |
fProgramArgs = SWTFactory.createText(programGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL, 1, 200, 60, GridData.FILL_BOTH); |
441 |
}); |
| 442 |
fProgramArgs.addModifyListener(new ModifyListener() { |
442 |
|
| 443 |
public void modifyText(ModifyEvent e) { |
443 |
fExecEnvButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_ExecutionEnv); |
| 444 |
getTargetDefinition().setProgramArguments(fProgramArgs.getText().trim()); |
444 |
fExecEnvButton.addSelectionListener(new SelectionAdapter() { |
| 445 |
} |
445 |
public void widgetSelected(SelectionEvent e) { |
| 446 |
}); |
446 |
updateJREWidgets(); |
| 447 |
|
447 |
getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText()))); |
| 448 |
Button programVars = new Button(programGroup, SWT.NONE); |
448 |
} |
| 449 |
programVars.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); |
449 |
}); |
| 450 |
programVars.setText(PDEUIMessages.JavaArgumentsTab_programVariables); |
450 |
|
| 451 |
programVars.addSelectionListener(getVariablesListener(fProgramArgs)); |
451 |
fExecEnvsCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, (String[]) fExecEnvChoices.toArray(new String[fExecEnvChoices.size()])); |
| 452 |
|
452 |
fExecEnvsCombo.addModifyListener(new ModifyListener() { |
| 453 |
Group vmGroup = new Group(container, SWT.NONE); |
453 |
public void modifyText(ModifyEvent e) { |
| 454 |
vmGroup.setLayout(new GridLayout(1, false)); |
454 |
getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText()))); |
| 455 |
vmGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
455 |
} |
| 456 |
vmGroup.setText(PDEUIMessages.JavaArgumentsTab_vmArgsGroup); |
456 |
}); |
| 457 |
|
457 |
|
| 458 |
fVMArgs = SWTFactory.createText(vmGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL, 1, 200, 60, GridData.FILL_BOTH); |
458 |
} |
| 459 |
fVMArgs.addModifyListener(new ModifyListener() { |
459 |
|
| 460 |
public void modifyText(ModifyEvent e) { |
460 |
/** |
| 461 |
getTargetDefinition().setVMArguments(fVMArgs.getText().trim()); |
461 |
* Initializes the combo with possible execution environments |
| 462 |
} |
462 |
*/ |
| 463 |
}); |
463 |
protected void initializeJREValues() { |
| 464 |
|
464 |
fExecEnvChoices = new TreeSet(); |
| 465 |
Composite buttons = SWTFactory.createComposite(vmGroup, 2, 1, GridData.HORIZONTAL_ALIGN_END, 0, 0); |
465 |
IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); |
| 466 |
|
466 |
IExecutionEnvironment[] envs = manager.getExecutionEnvironments(); |
| 467 |
Button vmArgs = SWTFactory.createPushButton(buttons, PDEUIMessages.JavaArgumentsTab_addVMArgs, null, GridData.HORIZONTAL_ALIGN_END); |
467 |
for (int i = 0; i < envs.length; i++) |
| 468 |
vmArgs.addSelectionListener(getVMArgsListener(fVMArgs)); |
468 |
fExecEnvChoices.add(envs[i].getId()); |
| 469 |
|
469 |
} |
| 470 |
Button vmVars = SWTFactory.createPushButton(buttons, PDEUIMessages.JavaArgumentsTab_vmVariables, null, GridData.HORIZONTAL_ALIGN_END); |
470 |
|
| 471 |
vmVars.addSelectionListener(getVariablesListener(fVMArgs)); |
471 |
protected void updateJREWidgets() { |
| 472 |
|
472 |
fNamedJREsCombo.setEnabled(fNamedJREButton.getSelection()); |
| 473 |
return container; |
473 |
fExecEnvsCombo.setEnabled(fExecEnvButton.getSelection()); |
| 474 |
} |
474 |
} |
| 475 |
|
475 |
|
| 476 |
/** |
476 |
private Control createArgumentsGroup(Composite parent) { |
| 477 |
* Provide a listener for the Add VM Arguments button. |
477 |
Composite container = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH); |
| 478 |
* The listener invokes the <code>VMArgumentsSelectionDialog</code> and |
478 |
|
| 479 |
* updates the selected VM Arguments back in the VM Arguments Text Box |
479 |
SWTFactory.createWrapLabel(container, PDEUIMessages.JavaArgumentsTab_description, 1); |
| 480 |
* |
480 |
|
| 481 |
* @param textControl |
481 |
Group programGroup = SWTFactory.createGroup(container, PDEUIMessages.JavaArgumentsTab_progamArgsGroup, 1, 1, GridData.FILL_HORIZONTAL); |
| 482 |
* @return <code>SelectionListener</code> for the Add VM Arguments button |
482 |
|
| 483 |
*/ |
483 |
fProgramArgs = SWTFactory.createText(programGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL, 1, 200, 60, GridData.FILL_BOTH); |
| 484 |
private SelectionListener getVMArgsListener(final Text textControl) { |
484 |
fProgramArgs.addModifyListener(new ModifyListener() { |
| 485 |
return new SelectionAdapter() { |
485 |
public void modifyText(ModifyEvent e) { |
| 486 |
public void widgetSelected(SelectionEvent e) { |
486 |
getTargetDefinition().setProgramArguments(fProgramArgs.getText().trim()); |
| 487 |
ArgumentsFromContainerSelectionDialog dialog = new ArgumentsFromContainerSelectionDialog(getShell(), getTargetDefinition()); |
487 |
} |
| 488 |
if (dialog.open() == Window.OK) { |
488 |
}); |
| 489 |
String[] args = dialog.getSelectedArguments(); |
489 |
|
| 490 |
if (args != null && args.length > 0) { |
490 |
Button programVars = new Button(programGroup, SWT.NONE); |
| 491 |
StringBuffer resultBuffer = new StringBuffer(); |
491 |
programVars.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); |
| 492 |
for (int index = 0; index < args.length; ++index) { |
492 |
programVars.setText(PDEUIMessages.JavaArgumentsTab_programVariables); |
| 493 |
resultBuffer.append(args[index] + " "); //$NON-NLS-1$ |
493 |
programVars.addSelectionListener(getVariablesListener(fProgramArgs)); |
| 494 |
} |
494 |
|
| 495 |
fVMArgs.insert(resultBuffer.toString()); |
495 |
Group vmGroup = new Group(container, SWT.NONE); |
| 496 |
} |
496 |
vmGroup.setLayout(new GridLayout(1, false)); |
| 497 |
} |
497 |
vmGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| 498 |
} |
498 |
vmGroup.setText(PDEUIMessages.JavaArgumentsTab_vmArgsGroup); |
| 499 |
}; |
499 |
|
| 500 |
} |
500 |
fVMArgs = SWTFactory.createText(vmGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL, 1, 200, 60, GridData.FILL_BOTH); |
| 501 |
|
501 |
fVMArgs.addModifyListener(new ModifyListener() { |
| 502 |
/** |
502 |
public void modifyText(ModifyEvent e) { |
| 503 |
* Provide a listener for the Variables button. |
503 |
getTargetDefinition().setVMArguments(fVMArgs.getText().trim()); |
| 504 |
* The listener invokes the <code>StringVariableSelectionDialog</code> and |
504 |
} |
| 505 |
* updates the selected Variables back in the VM Arguments Text Box |
505 |
}); |
| 506 |
* |
506 |
|
| 507 |
* @param textControl |
507 |
Composite buttons = SWTFactory.createComposite(vmGroup, 2, 1, GridData.HORIZONTAL_ALIGN_END, 0, 0); |
| 508 |
* @return <code>SelectionListener</code> for the Variables button |
508 |
|
| 509 |
*/ |
509 |
Button vmArgs = SWTFactory.createPushButton(buttons, PDEUIMessages.JavaArgumentsTab_addVMArgs, null, GridData.HORIZONTAL_ALIGN_END); |
| 510 |
private SelectionListener getVariablesListener(final Text textControl) { |
510 |
vmArgs.addSelectionListener(getVMArgsListener(fVMArgs)); |
| 511 |
return new SelectionAdapter() { |
511 |
|
| 512 |
public void widgetSelected(SelectionEvent e) { |
512 |
Button vmVars = SWTFactory.createPushButton(buttons, PDEUIMessages.JavaArgumentsTab_vmVariables, null, GridData.HORIZONTAL_ALIGN_END); |
| 513 |
StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); |
513 |
vmVars.addSelectionListener(getVariablesListener(fVMArgs)); |
| 514 |
dialog.open(); |
514 |
|
| 515 |
String variable = dialog.getVariableExpression(); |
515 |
return container; |
| 516 |
if (variable != null) { |
516 |
} |
| 517 |
textControl.insert(variable); |
517 |
|
| 518 |
} |
518 |
/** |
| 519 |
} |
519 |
* Provide a listener for the Add VM Arguments button. |
| 520 |
}; |
520 |
* The listener invokes the <code>VMArgumentsSelectionDialog</code> and |
| 521 |
} |
521 |
* updates the selected VM Arguments back in the VM Arguments Text Box |
| 522 |
|
522 |
* |
| 523 |
private Control createImplicitTabContents(Composite parent) { |
523 |
* @param textControl |
| 524 |
Composite container = new Composite(parent, SWT.NONE); |
524 |
* @return <code>SelectionListener</code> for the Add VM Arguments button |
| 525 |
GridLayout layout = new GridLayout(2, false); |
525 |
*/ |
| 526 |
container.setLayout(layout); |
526 |
private SelectionListener getVMArgsListener(final Text textControl) { |
| 527 |
container.setLayoutData(new GridData(GridData.FILL_BOTH)); |
527 |
return new SelectionAdapter() { |
| 528 |
|
528 |
public void widgetSelected(SelectionEvent e) { |
| 529 |
createImpLabel(container); |
529 |
ArgumentsFromContainerSelectionDialog dialog = new ArgumentsFromContainerSelectionDialog(getShell(), getTargetDefinition()); |
| 530 |
createImpTable(container); |
530 |
if (dialog.open() == Window.OK) { |
| 531 |
createImpButtons(container); |
531 |
String[] args = dialog.getSelectedArguments(); |
| 532 |
// TODO: PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IHelpContextIds.IMPLICIT_PLUGINS_PREFERENCE_PAGE); |
532 |
if (args != null && args.length > 0) { |
| 533 |
return container; |
533 |
StringBuffer resultBuffer = new StringBuffer(); |
| 534 |
} |
534 |
for (int index = 0; index < args.length; ++index) { |
| 535 |
|
535 |
resultBuffer.append(args[index] + " "); //$NON-NLS-1$ |
| 536 |
private void createImpLabel(Composite container) { |
536 |
} |
| 537 |
Label label = new Label(container, SWT.NONE); |
537 |
fVMArgs.insert(resultBuffer.toString()); |
| 538 |
label.setText(PDEUIMessages.TargetImplicitPluginsTab_desc); |
538 |
} |
| 539 |
GridData gd = new GridData(GridData.FILL_HORIZONTAL); |
539 |
} |
| 540 |
gd.horizontalSpan = 2; |
540 |
} |
| 541 |
label.setLayoutData(gd); |
541 |
}; |
| 542 |
} |
542 |
} |
| 543 |
|
543 |
|
| 544 |
private void createImpTable(Composite container) { |
544 |
/** |
| 545 |
fElementViewer = new TableViewer(container, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); |
545 |
* Provide a listener for the Variables button. |
| 546 |
GridData gd = new GridData(GridData.FILL_BOTH); |
546 |
* The listener invokes the <code>StringVariableSelectionDialog</code> and |
| 547 |
gd.heightHint = 250; |
547 |
* updates the selected Variables back in the VM Arguments Text Box |
| 548 |
fElementViewer.getControl().setLayoutData(gd); |
548 |
* |
| 549 |
fElementViewer.setContentProvider(new DefaultTableProvider() { |
549 |
* @param textControl |
| 550 |
public Object[] getElements(Object inputElement) { |
550 |
* @return <code>SelectionListener</code> for the Variables button |
| 551 |
ITargetDefinition target = getTargetDefinition(); |
551 |
*/ |
| 552 |
if (target != null) { |
552 |
private SelectionListener getVariablesListener(final Text textControl) { |
| 553 |
BundleInfo[] bundles = target.getImplicitDependencies(); |
553 |
return new SelectionAdapter() { |
| 554 |
if (bundles != null) { |
554 |
public void widgetSelected(SelectionEvent e) { |
| 555 |
return bundles; |
555 |
StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); |
| 556 |
} |
556 |
dialog.open(); |
| 557 |
} |
557 |
String variable = dialog.getVariableExpression(); |
| 558 |
return new BundleInfo[0]; |
558 |
if (variable != null) { |
| 559 |
} |
559 |
textControl.insert(variable); |
| 560 |
}); |
560 |
} |
| 561 |
fElementViewer.setLabelProvider(new BundleInfoLabelProvider(false)); |
561 |
} |
| 562 |
fElementViewer.setInput(PDEPlugin.getDefault()); |
562 |
}; |
| 563 |
fElementViewer.setComparator(new ViewerComparator() { |
563 |
} |
| 564 |
public int compare(Viewer viewer, Object e1, Object e2) { |
564 |
|
| 565 |
BundleInfo bundle1 = (BundleInfo) e1; |
565 |
private Control createImplicitTabContents(Composite parent) { |
| 566 |
BundleInfo bundle2 = (BundleInfo) e2; |
566 |
Composite container = new Composite(parent, SWT.NONE); |
| 567 |
return super.compare(viewer, bundle1.getSymbolicName(), bundle2.getSymbolicName()); |
567 |
GridLayout layout = new GridLayout(2, false); |
| 568 |
} |
568 |
container.setLayout(layout); |
| 569 |
}); |
569 |
container.setLayoutData(new GridData(GridData.FILL_BOTH)); |
| 570 |
fElementViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
570 |
|
| 571 |
public void selectionChanged(SelectionChangedEvent event) { |
571 |
createImpLabel(container); |
| 572 |
updateImpButtons(); |
572 |
createImpTable(container); |
| 573 |
} |
573 |
createImpButtons(container); |
| 574 |
}); |
574 |
// TODO: PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IHelpContextIds.IMPLICIT_PLUGINS_PREFERENCE_PAGE); |
| 575 |
fElementViewer.getTable().addKeyListener(new KeyAdapter() { |
575 |
return container; |
| 576 |
public void keyPressed(KeyEvent e) { |
576 |
} |
| 577 |
if (e.character == SWT.DEL && e.stateMask == 0) { |
577 |
|
| 578 |
handleRemove(); |
578 |
private void createImpLabel(Composite container) { |
| 579 |
} |
579 |
Label label = new Label(container, SWT.NONE); |
| 580 |
} |
580 |
label.setText(PDEUIMessages.TargetImplicitPluginsTab_desc); |
| 581 |
}); |
581 |
GridData gd = new GridData(GridData.FILL_HORIZONTAL); |
| 582 |
} |
582 |
gd.horizontalSpan = 2; |
| 583 |
|
583 |
label.setLayoutData(gd); |
| 584 |
private void createImpButtons(Composite container) { |
584 |
} |
| 585 |
Composite buttonContainer = SWTFactory.createComposite(container, 1, 1, GridData.FILL_VERTICAL, 0, 0); |
585 |
|
| 586 |
|
586 |
private void createImpTable(Composite container) { |
| 587 |
fAddButton = new Button(buttonContainer, SWT.PUSH); |
587 |
fElementViewer = new TableViewer(container, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); |
| 588 |
fAddButton.setText(PDEUIMessages.SourceBlock_add); |
588 |
GridData gd = new GridData(GridData.FILL_BOTH); |
| 589 |
fAddButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING)); |
589 |
gd.heightHint = 250; |
| 590 |
SWTUtil.setButtonDimensionHint(fAddButton); |
590 |
fElementViewer.getControl().setLayoutData(gd); |
| 591 |
fAddButton.addSelectionListener(new SelectionAdapter() { |
591 |
fElementViewer.setContentProvider(new DefaultTableProvider() { |
| 592 |
public void widgetSelected(SelectionEvent e) { |
592 |
public Object[] getElements(Object inputElement) { |
| 593 |
handleAdd(); |
593 |
ITargetDefinition target = getTargetDefinition(); |
| 594 |
} |
594 |
if (target != null) { |
| 595 |
}); |
595 |
BundleInfo[] bundles = target.getImplicitDependencies(); |
| 596 |
|
596 |
if (bundles != null) { |
| 597 |
fRemoveButton = new Button(buttonContainer, SWT.PUSH); |
597 |
return bundles; |
| 598 |
fRemoveButton.setText(PDEUIMessages.SourceBlock_remove); |
598 |
} |
| 599 |
fRemoveButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING)); |
599 |
} |
| 600 |
SWTUtil.setButtonDimensionHint(fRemoveButton); |
600 |
return new BundleInfo[0]; |
| 601 |
fRemoveButton.addSelectionListener(new SelectionAdapter() { |
601 |
} |
| 602 |
public void widgetSelected(SelectionEvent e) { |
602 |
}); |
| 603 |
handleRemove(); |
603 |
fElementViewer.setLabelProvider(new BundleInfoLabelProvider(false)); |
| 604 |
} |
604 |
fElementViewer.setInput(PDEPlugin.getDefault()); |
| 605 |
}); |
605 |
fElementViewer.setComparator(new ViewerComparator() { |
| 606 |
|
606 |
public int compare(Viewer viewer, Object e1, Object e2) { |
| 607 |
fRemoveAllButton = new Button(buttonContainer, SWT.PUSH); |
607 |
BundleInfo bundle1 = (BundleInfo) e1; |
| 608 |
fRemoveAllButton.setText(PDEUIMessages.TargetImplicitPluginsTab_removeAll3); |
608 |
BundleInfo bundle2 = (BundleInfo) e2; |
| 609 |
fRemoveAllButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING)); |
609 |
return super.compare(viewer, bundle1.getSymbolicName(), bundle2.getSymbolicName()); |
| 610 |
SWTUtil.setButtonDimensionHint(fRemoveAllButton); |
610 |
} |
| 611 |
fRemoveAllButton.addSelectionListener(new SelectionAdapter() { |
611 |
}); |
| 612 |
public void widgetSelected(SelectionEvent e) { |
612 |
fElementViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
| 613 |
handleRemoveAll(); |
613 |
public void selectionChanged(SelectionChangedEvent event) { |
| 614 |
} |
614 |
updateImpButtons(); |
| 615 |
}); |
615 |
} |
| 616 |
updateImpButtons(); |
616 |
}); |
| 617 |
} |
617 |
fElementViewer.getTable().addKeyListener(new KeyAdapter() { |
| 618 |
|
618 |
public void keyPressed(KeyEvent e) { |
| 619 |
protected void handleAdd() { |
619 |
if (e.character == SWT.DEL && e.stateMask == 0) { |
| 620 |
ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), new BundleInfoLabelProvider(false)); |
620 |
handleRemove(); |
| 621 |
|
621 |
} |
| 622 |
try { |
622 |
} |
| 623 |
dialog.setElements(getValidBundles()); |
623 |
}); |
| 624 |
} catch (CoreException e) { |
624 |
} |
| 625 |
dialog.setMessage(e.getMessage()); |
625 |
|
| 626 |
} |
626 |
private void createImpButtons(Composite container) { |
| 627 |
|
627 |
Composite buttonContainer = SWTFactory.createComposite(container, 1, 1, GridData.FILL_VERTICAL, 0, 0); |
| 628 |
dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title); |
628 |
|
| 629 |
dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message); |
629 |
fAddButton = new Button(buttonContainer, SWT.PUSH); |
| 630 |
dialog.setMultipleSelection(true); |
630 |
fAddButton.setText(PDEUIMessages.SourceBlock_add); |
| 631 |
if (dialog.open() == Window.OK) { |
631 |
fAddButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING)); |
| 632 |
|
632 |
SWTUtil.setButtonDimensionHint(fAddButton); |
| 633 |
Object[] models = dialog.getResult(); |
633 |
fAddButton.addSelectionListener(new SelectionAdapter() { |
| 634 |
ArrayList pluginsToAdd = new ArrayList(); |
634 |
public void widgetSelected(SelectionEvent e) { |
| 635 |
for (int i = 0; i < models.length; i++) { |
635 |
handleAdd(); |
| 636 |
BundleInfo desc = ((BundleInfo) models[i]); |
636 |
} |
| 637 |
pluginsToAdd.add(new BundleInfo(desc.getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false)); |
637 |
}); |
| 638 |
} |
638 |
|
| 639 |
Set allDependencies = new HashSet(); |
639 |
fRemoveButton = new Button(buttonContainer, SWT.PUSH); |
| 640 |
allDependencies.addAll(pluginsToAdd); |
640 |
fRemoveButton.setText(PDEUIMessages.SourceBlock_remove); |
| 641 |
BundleInfo[] currentBundles = getTargetDefinition().getImplicitDependencies(); |
641 |
fRemoveButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING)); |
| 642 |
if (currentBundles != null) { |
642 |
SWTUtil.setButtonDimensionHint(fRemoveButton); |
| 643 |
allDependencies.addAll(Arrays.asList(currentBundles)); |
643 |
fRemoveButton.addSelectionListener(new SelectionAdapter() { |
| 644 |
} |
644 |
public void widgetSelected(SelectionEvent e) { |
| 645 |
getTargetDefinition().setImplicitDependencies((BundleInfo[]) allDependencies.toArray(new BundleInfo[allDependencies.size()])); |
645 |
handleRemove(); |
| 646 |
fElementViewer.refresh(); |
646 |
} |
| 647 |
} |
647 |
}); |
| 648 |
} |
648 |
|
| 649 |
|
649 |
fRemoveAllButton = new Button(buttonContainer, SWT.PUSH); |
| 650 |
/** |
650 |
fRemoveAllButton.setText(PDEUIMessages.TargetImplicitPluginsTab_removeAll3); |
| 651 |
* Gets a list of all the bundles that can be added as implicit dependencies |
651 |
fRemoveAllButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING)); |
| 652 |
* @return list of possible dependencies |
652 |
SWTUtil.setButtonDimensionHint(fRemoveAllButton); |
| 653 |
*/ |
653 |
fRemoveAllButton.addSelectionListener(new SelectionAdapter() { |
| 654 |
protected BundleInfo[] getValidBundles() throws CoreException { |
654 |
public void widgetSelected(SelectionEvent e) { |
| 655 |
BundleInfo[] current = getTargetDefinition().getImplicitDependencies(); |
655 |
handleRemoveAll(); |
| 656 |
Set currentBundles = new HashSet(); |
656 |
} |
| 657 |
if (current != null) { |
657 |
}); |
| 658 |
for (int i = 0; i < current.length; i++) { |
658 |
updateImpButtons(); |
| 659 |
currentBundles.add(current[i].getSymbolicName()); |
659 |
} |
| 660 |
} |
660 |
|
| 661 |
} |
661 |
protected void handleAdd() { |
| 662 |
|
662 |
ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), new BundleInfoLabelProvider(false)); |
| 663 |
List targetBundles = new ArrayList(); |
663 |
|
| 664 |
IResolvedBundle[] allTargetBundles = getTargetDefinition().getBundles(); |
664 |
try { |
| 665 |
if (allTargetBundles == null || allTargetBundles.length == 0) { |
665 |
dialog.setElements(getValidBundles()); |
| 666 |
throw new CoreException(new Status(IStatus.WARNING, PDEPlugin.getPluginId(), PDEUIMessages.ImplicitDependenciesSection_0)); |
666 |
} catch (CoreException e) { |
| 667 |
} |
667 |
dialog.setMessage(e.getMessage()); |
| 668 |
for (int i = 0; i < allTargetBundles.length; i++) { |
668 |
} |
| 669 |
if (!currentBundles.contains(allTargetBundles[i].getBundleInfo().getSymbolicName())) { |
669 |
|
| 670 |
targetBundles.add(allTargetBundles[i].getBundleInfo()); |
670 |
dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title); |
| 671 |
} |
671 |
dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message); |
| 672 |
} |
672 |
dialog.setMultipleSelection(true); |
| 673 |
|
673 |
if (dialog.open() == Window.OK) { |
| 674 |
return (BundleInfo[]) targetBundles.toArray(new BundleInfo[targetBundles.size()]); |
674 |
|
| 675 |
} |
675 |
Object[] models = dialog.getResult(); |
| 676 |
|
676 |
ArrayList pluginsToAdd = new ArrayList(); |
| 677 |
private void handleRemove() { |
677 |
for (int i = 0; i < models.length; i++) { |
| 678 |
LinkedList bundles = new LinkedList(); |
678 |
BundleInfo desc = ((BundleInfo) models[i]); |
| 679 |
bundles.addAll(Arrays.asList(getTargetDefinition().getImplicitDependencies())); |
679 |
pluginsToAdd.add(new BundleInfo(desc.getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false)); |
| 680 |
Object[] removeBundles = ((IStructuredSelection) fElementViewer.getSelection()).toArray(); |
680 |
} |
| 681 |
if (removeBundles.length > 0) { |
681 |
Set allDependencies = new HashSet(); |
| 682 |
for (int i = 0; i < removeBundles.length; i++) { |
682 |
allDependencies.addAll(pluginsToAdd); |
| 683 |
if (removeBundles[i] instanceof BundleInfo) { |
683 |
BundleInfo[] currentBundles = getTargetDefinition().getImplicitDependencies(); |
| 684 |
bundles.remove(removeBundles[i]); |
684 |
if (currentBundles != null) { |
| 685 |
} |
685 |
allDependencies.addAll(Arrays.asList(currentBundles)); |
| 686 |
} |
686 |
} |
| 687 |
getTargetDefinition().setImplicitDependencies((BundleInfo[]) bundles.toArray((new BundleInfo[bundles.size()]))); |
687 |
getTargetDefinition().setImplicitDependencies((BundleInfo[]) allDependencies.toArray(new BundleInfo[allDependencies.size()])); |
| 688 |
fElementViewer.refresh(); |
688 |
fElementViewer.refresh(); |
| 689 |
} |
689 |
} |
| 690 |
} |
690 |
} |
| 691 |
|
691 |
|
| 692 |
private void handleRemoveAll() { |
692 |
/** |
| 693 |
getTargetDefinition().setImplicitDependencies(null); |
693 |
* Gets a list of all the bundles that can be added as implicit dependencies |
| 694 |
fElementViewer.refresh(); |
694 |
* @return list of possible dependencies |
| 695 |
} |
695 |
*/ |
| 696 |
|
696 |
protected BundleInfo[] getValidBundles() throws CoreException { |
| 697 |
private void updateImpButtons() { |
697 |
BundleInfo[] current = getTargetDefinition().getImplicitDependencies(); |
| 698 |
boolean empty = fElementViewer.getSelection().isEmpty(); |
698 |
Set currentBundles = new HashSet(); |
| 699 |
fRemoveButton.setEnabled(!empty); |
699 |
if (current != null) { |
| 700 |
boolean hasElements = fElementViewer.getTable().getItemCount() > 0; |
700 |
for (int i = 0; i < current.length; i++) { |
| 701 |
fRemoveAllButton.setEnabled(hasElements); |
701 |
currentBundles.add(current[i].getSymbolicName()); |
| 702 |
} |
702 |
} |
| 703 |
|
703 |
} |
| 704 |
/* (non-Javadoc) |
704 |
|
| 705 |
* @see org.eclipse.jface.wizard.WizardPage#isPageComplete() |
705 |
List targetBundles = new ArrayList(); |
| 706 |
*/ |
706 |
IResolvedBundle[] allTargetBundles = getTargetDefinition().getBundles(); |
| 707 |
public boolean isPageComplete() { |
707 |
if (allTargetBundles == null || allTargetBundles.length == 0) { |
| 708 |
if (fNameText.getText().trim().length() == 0) |
708 |
throw new CoreException(new Status(IStatus.WARNING, PDEPlugin.getPluginId(), PDEUIMessages.ImplicitDependenciesSection_0)); |
| 709 |
return false; |
709 |
} |
| 710 |
return true; |
710 |
for (int i = 0; i < allTargetBundles.length; i++) { |
| 711 |
} |
711 |
if (!currentBundles.contains(allTargetBundles[i].getBundleInfo().getSymbolicName())) { |
| 712 |
} |
712 |
targetBundles.add(allTargetBundles[i].getBundleInfo()); |
|
|
713 |
} |
| 714 |
} |
| 715 |
|
| 716 |
return (BundleInfo[]) targetBundles.toArray(new BundleInfo[targetBundles.size()]); |
| 717 |
} |
| 718 |
|
| 719 |
private void handleRemove() { |
| 720 |
LinkedList bundles = new LinkedList(); |
| 721 |
bundles.addAll(Arrays.asList(getTargetDefinition().getImplicitDependencies())); |
| 722 |
Object[] removeBundles = ((IStructuredSelection) fElementViewer.getSelection()).toArray(); |
| 723 |
if (removeBundles.length > 0) { |
| 724 |
for (int i = 0; i < removeBundles.length; i++) { |
| 725 |
if (removeBundles[i] instanceof BundleInfo) { |
| 726 |
bundles.remove(removeBundles[i]); |
| 727 |
} |
| 728 |
} |
| 729 |
getTargetDefinition().setImplicitDependencies((BundleInfo[]) bundles.toArray((new BundleInfo[bundles.size()]))); |
| 730 |
fElementViewer.refresh(); |
| 731 |
} |
| 732 |
} |
| 733 |
|
| 734 |
private void handleRemoveAll() { |
| 735 |
getTargetDefinition().setImplicitDependencies(null); |
| 736 |
fElementViewer.refresh(); |
| 737 |
} |
| 738 |
|
| 739 |
private void updateImpButtons() { |
| 740 |
boolean empty = fElementViewer.getSelection().isEmpty(); |
| 741 |
fRemoveButton.setEnabled(!empty); |
| 742 |
boolean hasElements = fElementViewer.getTable().getItemCount() > 0; |
| 743 |
fRemoveAllButton.setEnabled(hasElements); |
| 744 |
} |
| 745 |
|
| 746 |
/* (non-Javadoc) |
| 747 |
* @see org.eclipse.jface.wizard.WizardPage#isPageComplete() |
| 748 |
*/ |
| 749 |
public boolean isPageComplete() { |
| 750 |
if (fNameText.getText().trim().length() == 0) |
| 751 |
return false; |
| 752 |
return true; |
| 753 |
} |
| 754 |
} |