View | Details | Raw Unified | Return to bug 269417 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/ui/editor/contentassist/display/BrowserInformationControl.java (-564 / +564 lines)
Lines 1-564 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006 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
11
12
package org.eclipse.pde.internal.ui.editor.contentassist.display;
12
package org.eclipse.pde.internal.ui.editor.contentassist.display;
13
13
14
import java.io.IOException;
14
import java.io.IOException;
15
import java.io.StringReader;
15
import java.io.StringReader;
16
import java.util.Iterator;
16
import java.util.Iterator;
17
import org.eclipse.core.runtime.ListenerList;
17
import org.eclipse.core.runtime.ListenerList;
18
import org.eclipse.jface.text.*;
18
import org.eclipse.jface.text.*;
19
import org.eclipse.pde.internal.ui.PDEPlugin;
19
import org.eclipse.pde.internal.ui.PDEPlugin;
20
import org.eclipse.pde.internal.ui.editor.text.HTMLPrinter;
20
import org.eclipse.pde.internal.ui.editor.text.HTMLPrinter;
21
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.SWTError;
22
import org.eclipse.swt.SWTError;
23
import org.eclipse.swt.browser.*;
23
import org.eclipse.swt.browser.*;
24
import org.eclipse.swt.custom.StyleRange;
24
import org.eclipse.swt.custom.StyleRange;
25
import org.eclipse.swt.events.*;
25
import org.eclipse.swt.events.*;
26
import org.eclipse.swt.graphics.*;
26
import org.eclipse.swt.graphics.*;
27
import org.eclipse.swt.layout.GridData;
27
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridLayout;
28
import org.eclipse.swt.layout.GridLayout;
29
import org.eclipse.swt.widgets.*;
29
import org.eclipse.swt.widgets.*;
30
30
31
/**
31
/**
32
 * Displays textual information in a {@link org.eclipse.swt.browser.Browser}
32
 * Displays textual information in a {@link org.eclipse.swt.browser.Browser}
33
 * widget.
33
 * widget.
34
 *
34
 *
35
 * <p>
35
 * <p>
36
 * This class may be instantiated; it is not intended to be subclassed.
36
 * This class may be instantiated; it is not intended to be subclassed.
37
 * </p>
37
 * </p>
38
 * <p>
38
 * <p>
39
 * Current problems:
39
 * Current problems:
40
 * - the size computation is too small
40
 * - the size computation is too small
41
 * - focusLost event is not sent (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=84532)
41
 * - focusLost event is not sent (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=84532)
42
 * </p>
42
 * </p>
43
 *
43
 *
44
 * @since 3.1
44
 * @since 3.1
45
 */
45
 */
46
public class BrowserInformationControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension3, DisposeListener {
46
public class BrowserInformationControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension3, DisposeListener {
47
47
48
	/**
48
	/**
49
	 * Tells whether the SWT Browser widget and hence this information
49
	 * Tells whether the SWT Browser widget and hence this information
50
	 * control is available.
50
	 * control is available.
51
	 *
51
	 *
52
	 * @param parent the parent component used for checking or <code>null</code> if none
52
	 * @param parent the parent component used for checking or <code>null</code> if none
53
	 * @return <code>true</code> if this control is available
53
	 * @return <code>true</code> if this control is available
54
	 */
54
	 */
55
	public static boolean isAvailable(Composite parent) {
55
	public static boolean isAvailable(Composite parent) {
56
		if (!fgAvailabilityChecked) {
56
		if (!fgAvailabilityChecked) {
57
			try {
57
			try {
58
				if (parent == null)
58
				if (parent == null)
59
					parent = PDEPlugin.getActiveWorkbenchShell();
59
					parent = PDEPlugin.getActiveWorkbenchShell();
60
				if (parent == null)
60
				if (parent == null)
61
					return false; // don't store this value - try again later
61
					return false; // don't store this value - try again later
62
62
63
				Browser browser = new Browser(parent, SWT.NONE);
63
				Browser browser = new Browser(parent, SWT.NONE);
64
				browser.dispose();
64
				browser.dispose();
65
				fgIsAvailable = true;
65
				fgIsAvailable = true;
66
			} catch (SWTError er) {
66
			} catch (SWTError er) {
67
				fgIsAvailable = false;
67
				fgIsAvailable = false;
68
			} finally {
68
			} finally {
69
				fgAvailabilityChecked = true;
69
				fgAvailabilityChecked = true;
70
			}
70
			}
71
		}
71
		}
72
72
73
		return fgIsAvailable;
73
		return fgIsAvailable;
74
	}
74
	}
75
75
76
	/** Border thickness in pixels. */
76
	/** Border thickness in pixels. */
77
	private static final int BORDER = 1;
77
	private static final int BORDER = 1;
78
78
79
	/**
79
	/**
80
	 * Minimal size constraints.
80
	 * Minimal size constraints.
81
	 * @since 3.2
81
	 * @since 3.2
82
	 */
82
	 */
83
	private static final int MIN_WIDTH = 80;
83
	private static final int MIN_WIDTH = 80;
84
	private static final int MIN_HEIGHT = 80;
84
	private static final int MIN_HEIGHT = 80;
85
85
86
	/**
86
	/**
87
	 * Availability checking cache.
87
	 * Availability checking cache.
88
	 */
88
	 */
89
	private static boolean fgIsAvailable = false;
89
	private static boolean fgIsAvailable = false;
90
	private static boolean fgAvailabilityChecked = false;
90
	private static boolean fgAvailabilityChecked = false;
91
91
92
	/** The control's shell */
92
	/** The control's shell */
93
	private Shell fShell;
93
	private Shell fShell;
94
	/** The control's browser widget */
94
	/** The control's browser widget */
95
	private Browser fBrowser;
95
	private Browser fBrowser;
96
	/** Tells whether the browser has content */
96
	/** Tells whether the browser has content */
97
	private boolean fBrowserHasContent;
97
	private boolean fBrowserHasContent;
98
	/** The control width constraint */
98
	/** The control width constraint */
99
	private int fMaxWidth = -1;
99
	private int fMaxWidth = -1;
100
	/** The control height constraint */
100
	/** The control height constraint */
101
	private int fMaxHeight = -1;
101
	private int fMaxHeight = -1;
102
	private Font fStatusTextFont;
102
	private Font fStatusTextFont;
103
	private Label fStatusTextField;
103
	private Label fStatusTextField;
104
	private String fStatusFieldText;
104
	private String fStatusFieldText;
105
	private boolean fHideScrollBars;
105
	private boolean fHideScrollBars;
106
	private Listener fDeactivateListener;
106
	private Listener fDeactivateListener;
107
	private ListenerList fFocusListeners = new ListenerList();
107
	private ListenerList fFocusListeners = new ListenerList();
108
	private Label fSeparator;
108
	private Label fSeparator;
109
	private String fInputText;
109
	private String fInputText;
110
	private TextLayout fTextLayout;
110
	private TextLayout fTextLayout;
111
111
112
	private TextStyle fBoldStyle;
112
	private TextStyle fBoldStyle;
113
113
114
	/**
114
	/**
115
	 * Creates a default information control with the given shell as parent. The given
115
	 * Creates a default information control with the given shell as parent. The given
116
	 * information presenter is used to process the information to be displayed. The given
116
	 * information presenter is used to process the information to be displayed. The given
117
	 * styles are applied to the created styled text widget.
117
	 * styles are applied to the created styled text widget.
118
	 *
118
	 *
119
	 * @param parent the parent shell
119
	 * @param parent the parent shell
120
	 * @param shellStyle the additional styles for the shell
120
	 * @param shellStyle the additional styles for the shell
121
	 * @param style the additional styles for the styled text widget
121
	 * @param style the additional styles for the styled text widget
122
	 */
122
	 */
123
	public BrowserInformationControl(Shell parent, int shellStyle, int style) {
123
	public BrowserInformationControl(Shell parent, int shellStyle, int style) {
124
		this(parent, shellStyle, style, null);
124
		this(parent, shellStyle, style, null);
125
	}
125
	}
126
126
127
	/**
127
	/**
128
	 * Creates a default information control with the given shell as parent. The given
128
	 * Creates a default information control with the given shell as parent. The given
129
	 * information presenter is used to process the information to be displayed. The given
129
	 * information presenter is used to process the information to be displayed. The given
130
	 * styles are applied to the created styled text widget.
130
	 * styles are applied to the created styled text widget.
131
	 *
131
	 *
132
	 * @param parent the parent shell
132
	 * @param parent the parent shell
133
	 * @param shellStyle the additional styles for the shell
133
	 * @param shellStyle the additional styles for the shell
134
	 * @param style the additional styles for the styled text widget
134
	 * @param style the additional styles for the styled text widget
135
	 * @param statusFieldText the text to be used in the optional status field
135
	 * @param statusFieldText the text to be used in the optional status field
136
	 *                         or <code>null</code> if the status field should be hidden
136
	 *                         or <code>null</code> if the status field should be hidden
137
	 */
137
	 */
138
	public BrowserInformationControl(Shell parent, int shellStyle, int style, String statusFieldText) {
138
	public BrowserInformationControl(Shell parent, int shellStyle, int style, String statusFieldText) {
139
		fStatusFieldText = statusFieldText;
139
		fStatusFieldText = statusFieldText;
140
140
141
		fShell = new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle);
141
		fShell = new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle);
142
		Display display = fShell.getDisplay();
142
		Display display = fShell.getDisplay();
143
		fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
143
		fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
144
		fTextLayout = new TextLayout(display);
144
		fTextLayout = new TextLayout(display);
145
145
146
		Composite composite = fShell;
146
		Composite composite = fShell;
147
		GridLayout layout = new GridLayout(1, false);
147
		GridLayout layout = new GridLayout(1, false);
148
		int border = ((shellStyle & SWT.NO_TRIM) == 0) ? 0 : BORDER;
148
		int border = ((shellStyle & SWT.NO_TRIM) == 0) ? 0 : BORDER;
149
		layout.marginHeight = border;
149
		layout.marginHeight = border;
150
		layout.marginWidth = border;
150
		layout.marginWidth = border;
151
		composite.setLayout(layout);
151
		composite.setLayout(layout);
152
152
153
		if (statusFieldText != null) {
153
		if (statusFieldText != null) {
154
			composite = new Composite(composite, SWT.NONE);
154
			composite = new Composite(composite, SWT.NONE);
155
			layout = new GridLayout(1, false);
155
			layout = new GridLayout(1, false);
156
			layout.marginHeight = 0;
156
			layout.marginHeight = 0;
157
			layout.marginWidth = 0;
157
			layout.marginWidth = 0;
158
			layout.verticalSpacing = 1;
158
			layout.verticalSpacing = 1;
159
			layout.horizontalSpacing = 1;
159
			layout.horizontalSpacing = 1;
160
			composite.setLayout(layout);
160
			composite.setLayout(layout);
161
161
162
			GridData gd = new GridData(GridData.FILL_BOTH);
162
			GridData gd = new GridData(GridData.FILL_BOTH);
163
			composite.setLayoutData(gd);
163
			composite.setLayoutData(gd);
164
164
165
			composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
165
			composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
166
			composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
166
			composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
167
		}
167
		}
168
168
169
		// Browser field
169
		// Browser field
170
		fBrowser = new Browser(composite, SWT.NONE);
170
		fBrowser = new Browser(composite, SWT.NONE);
171
171
172
		// Disable javascript for security reasons, see bug 265808
172
		// Disable javascript for security reasons, see bug 265808
173
		fBrowser.setJavascriptEnabled(false);
173
		fBrowser.setJavascriptEnabled(false);
174
174
175
		fHideScrollBars = (style & SWT.V_SCROLL) == 0 && (style & SWT.H_SCROLL) == 0;
175
		fHideScrollBars = (style & SWT.V_SCROLL) == 0 && (style & SWT.H_SCROLL) == 0;
176
176
177
		GridData gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
177
		GridData gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
178
		fBrowser.setLayoutData(gd);
178
		fBrowser.setLayoutData(gd);
179
179
180
		fBrowser.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
180
		fBrowser.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
181
		fBrowser.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
181
		fBrowser.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
182
		fBrowser.addKeyListener(new KeyListener() {
182
		fBrowser.addKeyListener(new KeyListener() {
183
183
184
			public void keyPressed(KeyEvent e) {
184
			public void keyPressed(KeyEvent e) {
185
				if (e.character == 0x1B) // ESC
185
				if (e.character == 0x1B) // ESC
186
					fShell.dispose();
186
					fShell.dispose();
187
			}
187
			}
188
188
189
			public void keyReleased(KeyEvent e) {
189
			public void keyReleased(KeyEvent e) {
190
			}
190
			}
191
		});
191
		});
192
		/*
192
		/*
193
		 * XXX revisit when the Browser support is better 
193
		 * XXX revisit when the Browser support is better 
194
		 * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=107629. Choosing a link to a
194
		 * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=107629. Choosing a link to a
195
		 * non-available target will show an error dialog behind the ON_TOP shell that seemingly
195
		 * non-available target will show an error dialog behind the ON_TOP shell that seemingly
196
		 * blocks the workbench. Disable links completely for now.
196
		 * blocks the workbench. Disable links completely for now.
197
		 */
197
		 */
198
		fBrowser.addLocationListener(new LocationAdapter() {
198
		fBrowser.addLocationListener(new LocationAdapter() {
199
			/*
199
			/*
200
			 * @see org.eclipse.swt.browser.LocationAdapter#changing(org.eclipse.swt.browser.LocationEvent)
200
			 * @see org.eclipse.swt.browser.LocationAdapter#changing(org.eclipse.swt.browser.LocationEvent)
201
			 */
201
			 */
202
			public void changing(LocationEvent event) {
202
			public void changing(LocationEvent event) {
203
				String location = event.location;
203
				String location = event.location;
204
				if (!"about:blank".equals(location)) //$NON-NLS-1$
204
				if (!"about:blank".equals(location)) //$NON-NLS-1$
205
					event.doit = false;
205
					event.doit = false;
206
			}
206
			}
207
		});
207
		});
208
208
209
		// Replace browser's built-in context menu with none
209
		// Replace browser's built-in context menu with none
210
		fBrowser.setMenu(new Menu(fShell, SWT.NONE));
210
		fBrowser.setMenu(new Menu(fShell, SWT.NONE));
211
211
212
		// Status field
212
		// Status field
213
		if (statusFieldText != null) {
213
		if (statusFieldText != null) {
214
214
215
			fSeparator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
215
			fSeparator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
216
			fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
216
			fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
217
217
218
			// Status field label
218
			// Status field label
219
			fStatusTextField = new Label(composite, SWT.RIGHT);
219
			fStatusTextField = new Label(composite, SWT.RIGHT);
220
			fStatusTextField.setText(statusFieldText);
220
			fStatusTextField.setText(statusFieldText);
221
			Font font = fStatusTextField.getFont();
221
			Font font = fStatusTextField.getFont();
222
			FontData[] fontDatas = font.getFontData();
222
			FontData[] fontDatas = font.getFontData();
223
			for (int i = 0; i < fontDatas.length; i++)
223
			for (int i = 0; i < fontDatas.length; i++)
224
				fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
224
				fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
225
			fStatusTextFont = new Font(fStatusTextField.getDisplay(), fontDatas);
225
			fStatusTextFont = new Font(fStatusTextField.getDisplay(), fontDatas);
226
			fStatusTextField.setFont(fStatusTextFont);
226
			fStatusTextField.setFont(fStatusTextFont);
227
			gd = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
227
			gd = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
228
			fStatusTextField.setLayoutData(gd);
228
			fStatusTextField.setLayoutData(gd);
229
229
230
			fStatusTextField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
230
			fStatusTextField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
231
231
232
			fStatusTextField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
232
			fStatusTextField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
233
		}
233
		}
234
234
235
		addDisposeListener(this);
235
		addDisposeListener(this);
236
		createTextLayout();
236
		createTextLayout();
237
	}
237
	}
238
238
239
	/**
239
	/**
240
	 * Creates a default information control with the given shell as parent. The given
240
	 * Creates a default information control with the given shell as parent. The given
241
	 * information presenter is used to process the information to be displayed. The given
241
	 * information presenter is used to process the information to be displayed. The given
242
	 * styles are applied to the created styled text widget.
242
	 * styles are applied to the created styled text widget.
243
	 *
243
	 *
244
	 * @param parent the parent shell
244
	 * @param parent the parent shell
245
	 * @param style the additional styles for the browser widget
245
	 * @param style the additional styles for the browser widget
246
	 */
246
	 */
247
	public BrowserInformationControl(Shell parent, int style) {
247
	public BrowserInformationControl(Shell parent, int style) {
248
		this(parent, SWT.TOOL | SWT.NO_TRIM, style);
248
		this(parent, SWT.TOOL | SWT.NO_TRIM, style);
249
	}
249
	}
250
250
251
	/**
251
	/**
252
	 * Creates a default information control with the given shell as parent.
252
	 * Creates a default information control with the given shell as parent.
253
	 * No information presenter is used to process the information
253
	 * No information presenter is used to process the information
254
	 * to be displayed. No additional styles are applied to the styled text widget.
254
	 * to be displayed. No additional styles are applied to the styled text widget.
255
	 *
255
	 *
256
	 * @param parent the parent shell
256
	 * @param parent the parent shell
257
	 */
257
	 */
258
	public BrowserInformationControl(Shell parent) {
258
	public BrowserInformationControl(Shell parent) {
259
		this(parent, SWT.NONE);
259
		this(parent, SWT.NONE);
260
	}
260
	}
261
261
262
	/*
262
	/*
263
	 * @see IInformationControl#setInformation(String)
263
	 * @see IInformationControl#setInformation(String)
264
	 */
264
	 */
265
	public void setInformation(String content) {
265
	public void setInformation(String content) {
266
		fBrowserHasContent = content != null && content.length() > 0;
266
		fBrowserHasContent = content != null && content.length() > 0;
267
267
268
		if (!fBrowserHasContent)
268
		if (!fBrowserHasContent)
269
			content = "<html><body ></html>"; //$NON-NLS-1$
269
			content = "<html><body ></html>"; //$NON-NLS-1$
270
270
271
		fInputText = content;
271
		fInputText = content;
272
272
273
		int shellStyle = fShell.getStyle();
273
		int shellStyle = fShell.getStyle();
274
		boolean RTL = (shellStyle & SWT.RIGHT_TO_LEFT) != 0;
274
		boolean RTL = (shellStyle & SWT.RIGHT_TO_LEFT) != 0;
275
275
276
		String[] styles = null;
276
		String[] styles = null;
277
		if (RTL && !fHideScrollBars)
277
		if (RTL && !fHideScrollBars)
278
			styles = new String[] {"direction:rtl;", "word-wrap:break-word;"}; //$NON-NLS-1$ //$NON-NLS-2$
278
			styles = new String[] {"direction:rtl;", "word-wrap:break-word;"}; //$NON-NLS-1$ //$NON-NLS-2$
279
		else if (RTL && fHideScrollBars)
279
		else if (RTL && fHideScrollBars)
280
			styles = new String[] {"direction:rtl;", "overflow:hidden;", "word-wrap:break-word;"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
280
			styles = new String[] {"direction:rtl;", "overflow:hidden;", "word-wrap:break-word;"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
281
		else if (fHideScrollBars && true)
281
		else if (fHideScrollBars && true)
282
			styles = new String[] {"overflow:hidden;", "word-wrap: break-word;"}; //$NON-NLS-1$ //$NON-NLS-2$
282
			styles = new String[] {"overflow:hidden;", "word-wrap: break-word;"}; //$NON-NLS-1$ //$NON-NLS-2$
283
283
284
		if (styles != null) {
284
		if (styles != null) {
285
			StringBuffer buffer = new StringBuffer(content);
285
			StringBuffer buffer = new StringBuffer(content);
286
			HTMLPrinter.insertStyles(buffer, styles);
286
			HTMLPrinter.insertStyles(buffer, styles);
287
			content = buffer.toString();
287
			content = buffer.toString();
288
		}
288
		}
289
289
290
		fBrowser.setText(content);
290
		fBrowser.setText(content);
291
291
292
	}
292
	}
293
293
294
	/*
294
	/*
295
	 * @see org.eclipse.jdt.internal.ui.text.IInformationControlExtension4#setStatusText(java.lang.String)
295
	 * @see org.eclipse.jdt.internal.ui.text.IInformationControlExtension4#setStatusText(java.lang.String)
296
	 * @since 3.2
296
	 * @since 3.2
297
	 */
297
	 */
298
	public void setStatusText(String statusFieldText) {
298
	public void setStatusText(String statusFieldText) {
299
		fStatusFieldText = statusFieldText;
299
		fStatusFieldText = statusFieldText;
300
	}
300
	}
301
301
302
	/*
302
	/*
303
	 * @see IInformationControl#setVisible(boolean)
303
	 * @see IInformationControl#setVisible(boolean)
304
	 */
304
	 */
305
	public void setVisible(boolean visible) {
305
	public void setVisible(boolean visible) {
306
		if (fShell.isVisible() == visible)
306
		if (fShell.isVisible() == visible)
307
			return;
307
			return;
308
308
309
		if (visible) {
309
		if (visible) {
310
			if (fStatusTextField != null) {
310
			if (fStatusTextField != null) {
311
				boolean state = fStatusFieldText != null;
311
				boolean state = fStatusFieldText != null;
312
				if (state)
312
				if (state)
313
					fStatusTextField.setText(fStatusFieldText);
313
					fStatusTextField.setText(fStatusFieldText);
314
				fStatusTextField.setVisible(state);
314
				fStatusTextField.setVisible(state);
315
				fSeparator.setVisible(state);
315
				fSeparator.setVisible(state);
316
			}
316
			}
317
		}
317
		}
318
318
319
		fShell.setVisible(visible);
319
		fShell.setVisible(visible);
320
		if (!visible)
320
		if (!visible)
321
			setInformation(""); //$NON-NLS-1$
321
			setInformation(""); //$NON-NLS-1$
322
	}
322
	}
323
323
324
	/**
324
	/**
325
	 * Creates and initializes the text layout used
325
	 * Creates and initializes the text layout used
326
	 * to compute the size hint.
326
	 * to compute the size hint.
327
	 * 
327
	 * 
328
	 * @since 3.2
328
	 * @since 3.2
329
	 */
329
	 */
330
	private void createTextLayout() {
330
	private void createTextLayout() {
331
		fTextLayout = new TextLayout(fBrowser.getDisplay());
331
		fTextLayout = new TextLayout(fBrowser.getDisplay());
332
332
333
		// Initialize fonts
333
		// Initialize fonts
334
		Font font = fBrowser.getFont();
334
		Font font = fBrowser.getFont();
335
		fTextLayout.setFont(font);
335
		fTextLayout.setFont(font);
336
		fTextLayout.setWidth(-1);
336
		fTextLayout.setWidth(-1);
337
		FontData[] fontData = font.getFontData();
337
		FontData[] fontData = font.getFontData();
338
		for (int i = 0; i < fontData.length; i++)
338
		for (int i = 0; i < fontData.length; i++)
339
			fontData[i].setStyle(SWT.BOLD);
339
			fontData[i].setStyle(SWT.BOLD);
340
		font = new Font(fShell.getDisplay(), fontData);
340
		font = new Font(fShell.getDisplay(), fontData);
341
		fBoldStyle = new TextStyle(font, null, null);
341
		fBoldStyle = new TextStyle(font, null, null);
342
342
343
		// Compute and set tab width
343
		// Compute and set tab width
344
		fTextLayout.setText("    "); //$NON-NLS-1$
344
		fTextLayout.setText("    "); //$NON-NLS-1$
345
		int tabWidth = fTextLayout.getBounds().width;
345
		int tabWidth = fTextLayout.getBounds().width;
346
		fTextLayout.setTabs(new int[] {tabWidth});
346
		fTextLayout.setTabs(new int[] {tabWidth});
347
347
348
		fTextLayout.setText(""); //$NON-NLS-1$
348
		fTextLayout.setText(""); //$NON-NLS-1$
349
	}
349
	}
350
350
351
	/*
351
	/*
352
	 * @see IInformationControl#dispose()
352
	 * @see IInformationControl#dispose()
353
	 */
353
	 */
354
	public void dispose() {
354
	public void dispose() {
355
		fTextLayout.dispose();
355
		fTextLayout.dispose();
356
		fTextLayout = null;
356
		fTextLayout = null;
357
		fBoldStyle.font.dispose();
357
		fBoldStyle.font.dispose();
358
		fBoldStyle = null;
358
		fBoldStyle = null;
359
		if (fShell != null && !fShell.isDisposed())
359
		if (fShell != null && !fShell.isDisposed())
360
			fShell.dispose();
360
			fShell.dispose();
361
		else
361
		else
362
			widgetDisposed(null);
362
			widgetDisposed(null);
363
	}
363
	}
364
364
365
	/*
365
	/*
366
	 * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
366
	 * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
367
	 */
367
	 */
368
	public void widgetDisposed(DisposeEvent event) {
368
	public void widgetDisposed(DisposeEvent event) {
369
		if (fStatusTextFont != null && !fStatusTextFont.isDisposed())
369
		if (fStatusTextFont != null && !fStatusTextFont.isDisposed())
370
			fStatusTextFont.dispose();
370
			fStatusTextFont.dispose();
371
371
372
		fShell = null;
372
		fShell = null;
373
		fBrowser = null;
373
		fBrowser = null;
374
		fStatusTextFont = null;
374
		fStatusTextFont = null;
375
	}
375
	}
376
376
377
	/*
377
	/*
378
	 * @see IInformationControl#setSize(int, int)
378
	 * @see IInformationControl#setSize(int, int)
379
	 */
379
	 */
380
	public void setSize(int width, int height) {
380
	public void setSize(int width, int height) {
381
		fShell.setSize(Math.min(width, fMaxWidth), Math.min(height, fMaxHeight));
381
		fShell.setSize(Math.min(width, fMaxWidth), Math.min(height, fMaxHeight));
382
	}
382
	}
383
383
384
	/*
384
	/*
385
	 * @see IInformationControl#setLocation(Point)
385
	 * @see IInformationControl#setLocation(Point)
386
	 */
386
	 */
387
	public void setLocation(Point location) {
387
	public void setLocation(Point location) {
388
		fShell.setLocation(location);
388
		fShell.setLocation(location);
389
	}
389
	}
390
390
391
	/*
391
	/*
392
	 * @see IInformationControl#setSizeConstraints(int, int)
392
	 * @see IInformationControl#setSizeConstraints(int, int)
393
	 */
393
	 */
394
	public void setSizeConstraints(int maxWidth, int maxHeight) {
394
	public void setSizeConstraints(int maxWidth, int maxHeight) {
395
		fMaxWidth = maxWidth;
395
		fMaxWidth = maxWidth;
396
		fMaxHeight = maxHeight;
396
		fMaxHeight = maxHeight;
397
	}
397
	}
398
398
399
	/*
399
	/*
400
	 * @see IInformationControl#computeSizeHint()
400
	 * @see IInformationControl#computeSizeHint()
401
	 */
401
	 */
402
	public Point computeSizeHint() {
402
	public Point computeSizeHint() {
403
		TextPresentation presentation = new TextPresentation();
403
		TextPresentation presentation = new TextPresentation();
404
		HTML2TextReader reader = new HTML2TextReader(new StringReader(fInputText), presentation);
404
		HTML2TextReader reader = new HTML2TextReader(new StringReader(fInputText), presentation);
405
		String text;
405
		String text;
406
		try {
406
		try {
407
			text = reader.getString();
407
			text = reader.getString();
408
		} catch (IOException e) {
408
		} catch (IOException e) {
409
			text = ""; //$NON-NLS-1$
409
			text = ""; //$NON-NLS-1$
410
		}
410
		}
411
411
412
		fTextLayout.setText(text);
412
		fTextLayout.setText(text);
413
		Iterator iter = presentation.getAllStyleRangeIterator();
413
		Iterator iter = presentation.getAllStyleRangeIterator();
414
		while (iter.hasNext()) {
414
		while (iter.hasNext()) {
415
			StyleRange sr = (StyleRange) iter.next();
415
			StyleRange sr = (StyleRange) iter.next();
416
			if (sr.fontStyle == SWT.BOLD)
416
			if (sr.fontStyle == SWT.BOLD)
417
				fTextLayout.setStyle(fBoldStyle, sr.start, sr.start + sr.length - 1);
417
				fTextLayout.setStyle(fBoldStyle, sr.start, sr.start + sr.length - 1);
418
		}
418
		}
419
		Rectangle bounds = fTextLayout.getBounds();
419
		Rectangle bounds = fTextLayout.getBounds();
420
		int width = bounds.width;
420
		int width = bounds.width;
421
		int height = bounds.height;
421
		int height = bounds.height;
422
422
423
		width += 15;
423
		width += 15;
424
		height += 25;
424
		height += 25;
425
425
426
		if (fStatusFieldText != null && fSeparator != null) {
426
		if (fStatusFieldText != null && fSeparator != null) {
427
			fTextLayout.setText(fStatusFieldText);
427
			fTextLayout.setText(fStatusFieldText);
428
			Rectangle statusBounds = fTextLayout.getBounds();
428
			Rectangle statusBounds = fTextLayout.getBounds();
429
			Rectangle separatorBounds = fSeparator.getBounds();
429
			Rectangle separatorBounds = fSeparator.getBounds();
430
			width = Math.max(width, statusBounds.width);
430
			width = Math.max(width, statusBounds.width);
431
			height = height + statusBounds.height + separatorBounds.height;
431
			height = height + statusBounds.height + separatorBounds.height;
432
		}
432
		}
433
433
434
		// Apply size constraints
434
		// Apply size constraints
435
		if (fMaxWidth != SWT.DEFAULT)
435
		if (fMaxWidth != SWT.DEFAULT)
436
			width = Math.min(fMaxWidth, width);
436
			width = Math.min(fMaxWidth, width);
437
		if (fMaxHeight != SWT.DEFAULT)
437
		if (fMaxHeight != SWT.DEFAULT)
438
			height = Math.min(fMaxHeight, height);
438
			height = Math.min(fMaxHeight, height);
439
439
440
		// Ensure minimal size
440
		// Ensure minimal size
441
		width = Math.max(MIN_WIDTH, width);
441
		width = Math.max(MIN_WIDTH, width);
442
		height = Math.max(MIN_HEIGHT, height);
442
		height = Math.max(MIN_HEIGHT, height);
443
443
444
		return new Point(width, height);
444
		return new Point(width, height);
445
	}
445
	}
446
446
447
	/*
447
	/*
448
	 * @see org.eclipse.jface.text.IInformationControlExtension3#computeTrim()
448
	 * @see org.eclipse.jface.text.IInformationControlExtension3#computeTrim()
449
	 */
449
	 */
450
	public Rectangle computeTrim() {
450
	public Rectangle computeTrim() {
451
		return fShell.computeTrim(0, 0, 0, 0);
451
		return fShell.computeTrim(0, 0, 0, 0);
452
	}
452
	}
453
453
454
	/*
454
	/*
455
	 * @see org.eclipse.jface.text.IInformationControlExtension3#getBounds()
455
	 * @see org.eclipse.jface.text.IInformationControlExtension3#getBounds()
456
	 */
456
	 */
457
	public Rectangle getBounds() {
457
	public Rectangle getBounds() {
458
		return fShell.getBounds();
458
		return fShell.getBounds();
459
	}
459
	}
460
460
461
	/*
461
	/*
462
	 * @see org.eclipse.jface.text.IInformationControlExtension3#restoresLocation()
462
	 * @see org.eclipse.jface.text.IInformationControlExtension3#restoresLocation()
463
	 */
463
	 */
464
	public boolean restoresLocation() {
464
	public boolean restoresLocation() {
465
		return false;
465
		return false;
466
	}
466
	}
467
467
468
	/*
468
	/*
469
	 * @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize()
469
	 * @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize()
470
	 */
470
	 */
471
	public boolean restoresSize() {
471
	public boolean restoresSize() {
472
		return false;
472
		return false;
473
	}
473
	}
474
474
475
	/*
475
	/*
476
	 * @see IInformationControl#addDisposeListener(DisposeListener)
476
	 * @see IInformationControl#addDisposeListener(DisposeListener)
477
	 */
477
	 */
478
	public void addDisposeListener(DisposeListener listener) {
478
	public void addDisposeListener(DisposeListener listener) {
479
		fShell.addDisposeListener(listener);
479
		fShell.addDisposeListener(listener);
480
	}
480
	}
481
481
482
	/*
482
	/*
483
	 * @see IInformationControl#removeDisposeListener(DisposeListener)
483
	 * @see IInformationControl#removeDisposeListener(DisposeListener)
484
	 */
484
	 */
485
	public void removeDisposeListener(DisposeListener listener) {
485
	public void removeDisposeListener(DisposeListener listener) {
486
		fShell.removeDisposeListener(listener);
486
		fShell.removeDisposeListener(listener);
487
	}
487
	}
488
488
489
	/*
489
	/*
490
	 * @see IInformationControl#setForegroundColor(Color)
490
	 * @see IInformationControl#setForegroundColor(Color)
491
	 */
491
	 */
492
	public void setForegroundColor(Color foreground) {
492
	public void setForegroundColor(Color foreground) {
493
		fBrowser.setForeground(foreground);
493
		fBrowser.setForeground(foreground);
494
	}
494
	}
495
495
496
	/*
496
	/*
497
	 * @see IInformationControl#setBackgroundColor(Color)
497
	 * @see IInformationControl#setBackgroundColor(Color)
498
	 */
498
	 */
499
	public void setBackgroundColor(Color background) {
499
	public void setBackgroundColor(Color background) {
500
		fBrowser.setBackground(background);
500
		fBrowser.setBackground(background);
501
	}
501
	}
502
502
503
	/*
503
	/*
504
	 * @see IInformationControl#isFocusControl()
504
	 * @see IInformationControl#isFocusControl()
505
	 */
505
	 */
506
	public boolean isFocusControl() {
506
	public boolean isFocusControl() {
507
		return fBrowser.isFocusControl();
507
		return fBrowser.isFocusControl();
508
	}
508
	}
509
509
510
	/*
510
	/*
511
	 * @see IInformationControl#setFocus()
511
	 * @see IInformationControl#setFocus()
512
	 */
512
	 */
513
	public void setFocus() {
513
	public void setFocus() {
514
		fShell.forceFocus();
514
		fShell.forceFocus();
515
		fBrowser.setFocus();
515
		fBrowser.setFocus();
516
	}
516
	}
517
517
518
	/*
518
	/*
519
	 * @see IInformationControl#addFocusListener(FocusListener)
519
	 * @see IInformationControl#addFocusListener(FocusListener)
520
	 */
520
	 */
521
	public void addFocusListener(final FocusListener listener) {
521
	public void addFocusListener(final FocusListener listener) {
522
		fBrowser.addFocusListener(listener);
522
		fBrowser.addFocusListener(listener);
523
523
524
		/*
524
		/*
525
		 * FIXME:	This is a workaround for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=84532
525
		 * FIXME:	This is a workaround for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=84532
526
		 * 			(Browser widget does not send focusLost event)
526
		 * 			(Browser widget does not send focusLost event)
527
		 */
527
		 */
528
		if (fFocusListeners.isEmpty()) {
528
		if (fFocusListeners.isEmpty()) {
529
			fDeactivateListener = new Listener() {
529
			fDeactivateListener = new Listener() {
530
				public void handleEvent(Event event) {
530
				public void handleEvent(Event event) {
531
					Object[] listeners = fFocusListeners.getListeners();
531
					Object[] listeners = fFocusListeners.getListeners();
532
					for (int i = 0; i < listeners.length; i++)
532
					for (int i = 0; i < listeners.length; i++)
533
						((FocusListener) listeners[i]).focusLost(new FocusEvent(event));
533
						((FocusListener) listeners[i]).focusLost(new FocusEvent(event));
534
				}
534
				}
535
			};
535
			};
536
			fBrowser.getShell().addListener(SWT.Deactivate, fDeactivateListener);
536
			fBrowser.getShell().addListener(SWT.Deactivate, fDeactivateListener);
537
		}
537
		}
538
		fFocusListeners.add(listener);
538
		fFocusListeners.add(listener);
539
	}
539
	}
540
540
541
	/*
541
	/*
542
	 * @see IInformationControl#removeFocusListener(FocusListener)
542
	 * @see IInformationControl#removeFocusListener(FocusListener)
543
	 */
543
	 */
544
	public void removeFocusListener(FocusListener listener) {
544
	public void removeFocusListener(FocusListener listener) {
545
		fBrowser.removeFocusListener(listener);
545
		fBrowser.removeFocusListener(listener);
546
546
547
		/*
547
		/*
548
		 * FIXME:	This is a workaround for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=84532
548
		 * FIXME:	This is a workaround for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=84532
549
		 * 			(Browser widget does not send focusLost event)
549
		 * 			(Browser widget does not send focusLost event)
550
		 */
550
		 */
551
		fFocusListeners.remove(listener);
551
		fFocusListeners.remove(listener);
552
		if (fFocusListeners.isEmpty()) {
552
		if (fFocusListeners.isEmpty()) {
553
			fBrowser.getShell().removeListener(SWT.Deactivate, fDeactivateListener);
553
			fBrowser.getShell().removeListener(SWT.Deactivate, fDeactivateListener);
554
			fDeactivateListener = null;
554
			fDeactivateListener = null;
555
		}
555
		}
556
	}
556
	}
557
557
558
	/*
558
	/*
559
	 * @see IInformationControlExtension#hasContents()
559
	 * @see IInformationControlExtension#hasContents()
560
	 */
560
	 */
561
	public boolean hasContents() {
561
	public boolean hasContents() {
562
		return fBrowserHasContent;
562
		return fBrowserHasContent;
563
	}
563
	}
564
}
564
}
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/ArgumentsSection.java (-210 / +417 lines)
Lines 1-210 Link Here
1
/*******************************************************************************
1
<<<<<<< ArgumentsSection.java
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
2
/*******************************************************************************
3
 * All rights reserved. This program and the accompanying materials
3
 * Copyright (c) 2005, 2009 IBM Corporation and others.
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * All rights reserved. This program and the accompanying materials
5
 * which accompanies this distribution, and is available at
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * which accompanies this distribution, and is available at
7
 *
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * Contributors:
8
 *
9
 *     IBM Corporation - initial API and implementation
9
 * Contributors:
10
 *******************************************************************************/
10
 *     IBM Corporation - initial API and implementation
11
package org.eclipse.pde.internal.ui.editor.targetdefinition;
11
 *******************************************************************************/
12
12
package org.eclipse.pde.internal.ui.editor.targetdefinition;
13
import org.eclipse.debug.ui.StringVariableSelectionDialog;
13
14
import org.eclipse.jface.window.Window;
14
import org.eclipse.debug.ui.StringVariableSelectionDialog;
15
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
15
import org.eclipse.jface.dialogs.Dialog;
16
import org.eclipse.pde.internal.ui.PDEPluginImages;
16
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
17
import org.eclipse.pde.internal.ui.PDEUIMessages;
17
import org.eclipse.pde.internal.ui.PDEPluginImages;
18
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
18
import org.eclipse.pde.internal.ui.PDEUIMessages;
19
import org.eclipse.pde.internal.ui.parts.FormEntry;
19
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
20
import org.eclipse.pde.internal.ui.shared.target.ArgumentsFromContainerSelectionDialog;
20
import org.eclipse.pde.internal.ui.parts.FormEntry;
21
import org.eclipse.swt.SWT;
21
import org.eclipse.pde.internal.ui.shared.target.ArgumentsFromContainerSelectionDialog;
22
import org.eclipse.swt.custom.CTabFolder;
22
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.custom.CTabItem;
23
import org.eclipse.swt.custom.CTabFolder;
24
import org.eclipse.swt.events.SelectionAdapter;
24
import org.eclipse.swt.custom.CTabItem;
25
import org.eclipse.swt.events.SelectionEvent;
25
import org.eclipse.swt.events.SelectionAdapter;
26
import org.eclipse.swt.graphics.Color;
26
import org.eclipse.swt.events.SelectionEvent;
27
import org.eclipse.swt.graphics.Image;
27
import org.eclipse.swt.graphics.Color;
28
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.graphics.Image;
29
import org.eclipse.swt.layout.GridLayout;
29
import org.eclipse.swt.layout.GridData;
30
import org.eclipse.swt.widgets.Button;
30
import org.eclipse.swt.widgets.Button;
31
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.ui.forms.IFormColors;
32
import org.eclipse.ui.forms.IFormColors;
33
import org.eclipse.ui.forms.SectionPart;
33
import org.eclipse.ui.forms.SectionPart;
34
import org.eclipse.ui.forms.editor.FormPage;
34
import org.eclipse.ui.forms.editor.FormPage;
35
import org.eclipse.ui.forms.widgets.*;
35
import org.eclipse.ui.forms.widgets.*;
36
36
37
/**
37
/**
38
 * Section for editing VM and program arguments in the target definition editor
38
 * Section for editing VM and program arguments in the target definition editor
39
 * @see EnvironmentPage
39
 * @see EnvironmentPage
40
 * @see TargetEditor
40
 * @see TargetEditor
41
 */
41
 */
42
public class ArgumentsSection extends SectionPart {
42
public class ArgumentsSection extends SectionPart {
43
43
44
	private CTabFolder fTabFolder;
44
	private CTabFolder fTabFolder;
45
	private FormEntry fProgramArguments;
45
	private FormEntry fProgramArguments;
46
	private FormEntry fVMArguments;
46
	private FormEntry fVMArguments;
47
	private Image fImage;
47
	private Image fImage;
48
	private TargetEditor fEditor;
48
	private TargetEditor fEditor;
49
49
50
	public ArgumentsSection(FormPage page, Composite parent) {
50
	public ArgumentsSection(FormPage page, Composite parent) {
51
		super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
51
		super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
52
		fEditor = (TargetEditor) page.getEditor();
52
		fEditor = (TargetEditor) page.getEditor();
53
		fImage = PDEPluginImages.DESC_ARGUMENT_TAB.createImage();
53
		fImage = PDEPluginImages.DESC_ARGUMENT_TAB.createImage();
54
		createClient(getSection(), page.getEditor().getToolkit());
54
		createClient(getSection(), page.getEditor().getToolkit());
55
	}
55
	}
56
56
57
	/**
57
	/**
58
	 * @return The target model backing this editor
58
	 * @return The target model backing this editor
59
	 */
59
	 */
60
	private ITargetDefinition getTarget() {
60
	private ITargetDefinition getTarget() {
61
		return fEditor.getTarget();
61
		return fEditor.getTarget();
62
	}
62
	}
63
63
64
	/**
64
	/**
65
	 * Creates the UI for this section.
65
	 * Creates the UI for this section.
66
	 * 
66
	 * 
67
	 * @param section section the UI is being added to
67
	 * @param section section the UI is being added to
68
	 * @param toolkit form toolkit used to create the widgets
68
	 * @param toolkit form toolkit used to create the widgets
69
	 */
69
	 */
70
	protected void createClient(Section section, FormToolkit toolkit) {
70
	protected void createClient(Section section, FormToolkit toolkit) {
71
		section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
71
		section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
72
		section.setText(PDEUIMessages.ArgumentsSection_editorTitle);
72
		section.setText(PDEUIMessages.ArgumentsSection_editorTitle);
73
		section.setDescription(PDEUIMessages.ArgumentsSection_description);
73
		section.setDescription(PDEUIMessages.ArgumentsSection_description);
74
		GridData data = new GridData(GridData.FILL_BOTH);
74
		GridData data = new GridData(GridData.FILL_BOTH);
75
		data.horizontalSpan = 1;
75
		data.horizontalSpan = 1;
76
		section.setLayoutData(data);
76
		section.setLayoutData(data);
77
77
78
		Composite client = toolkit.createComposite(section);
78
		Composite client = toolkit.createComposite(section);
79
		client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
79
		client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
80
		GridData gd = new GridData(GridData.FILL_BOTH);
80
		GridData gd = new GridData(GridData.FILL_BOTH);
81
		gd.widthHint = 100;
81
		gd.widthHint = 100;
82
		client.setLayoutData(gd);
82
		client.setLayoutData(gd);
83
83
84
		fTabFolder = new CTabFolder(client, SWT.FLAT | SWT.TOP);
84
		fTabFolder = new CTabFolder(client, SWT.FLAT | SWT.TOP);
85
		toolkit.adapt(fTabFolder, true, true);
85
		toolkit.adapt(fTabFolder, true, true);
86
		gd = new GridData(GridData.FILL_BOTH);
86
		gd = new GridData(GridData.FILL_BOTH);
87
		fTabFolder.setLayoutData(gd);
87
		fTabFolder.setLayoutData(gd);
88
		toolkit.getColors().initializeSectionToolBarColors();
88
		toolkit.getColors().initializeSectionToolBarColors();
89
		Color selectedColor = toolkit.getColors().getColor(IFormColors.TB_BG);
89
		Color selectedColor = toolkit.getColors().getColor(IFormColors.TB_BG);
90
		fTabFolder.setSelectionBackground(new Color[] {selectedColor, toolkit.getColors().getBackground()}, new int[] {100}, true);
90
		fTabFolder.setSelectionBackground(new Color[] {selectedColor, toolkit.getColors().getBackground()}, new int[] {100}, true);
91
91
92
		Composite programComp = toolkit.createComposite(fTabFolder);
92
		Composite programComp = toolkit.createComposite(fTabFolder);
93
		programComp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
93
		programComp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
94
		programComp.setLayoutData(new GridData(GridData.FILL_BOTH));
94
		programComp.setLayoutData(new GridData(GridData.FILL_BOTH));
95
		fProgramArguments = new FormEntry(programComp, toolkit, PDEUIMessages.ArgumentsSection_0, SWT.MULTI | SWT.WRAP);
95
		fProgramArguments = new FormEntry(programComp, toolkit, PDEUIMessages.ArgumentsSection_0, SWT.MULTI | SWT.WRAP);
96
		fProgramArguments.getText().setLayoutData(new GridData(GridData.FILL_BOTH));
96
		fProgramArguments.getText().setLayoutData(new GridData(GridData.FILL_BOTH));
97
		fProgramArguments.setFormEntryListener(new SimpleFormEntryAdapter(this) {
97
		fProgramArguments.setFormEntryListener(new SimpleFormEntryAdapter(this) {
98
			public void textValueChanged(FormEntry entry) {
98
			public void textValueChanged(FormEntry entry) {
99
				String value = entry.getValue().trim();
99
				String value = entry.getValue().trim();
100
				getTarget().setProgramArguments(value.length() > 0 ? value : null);
100
				getTarget().setProgramArguments(value.length() > 0 ? value : null);
101
			}
101
			}
102
		});
102
		});
103
		Button variables = toolkit.createButton(programComp, PDEUIMessages.ArgumentsSection_variableButtonTitle, SWT.NONE);
103
		Button variables = toolkit.createButton(programComp, PDEUIMessages.ArgumentsSection_variableButtonTitle, SWT.NONE);
104
		variables.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
104
		variables.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
105
		variables.addSelectionListener(new SelectionAdapter() {
105
		variables.addSelectionListener(new SelectionAdapter() {
106
			public void widgetSelected(SelectionEvent e) {
106
			public void widgetSelected(SelectionEvent e) {
107
				StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getSection().getShell());
107
				StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getSection().getShell());
108
				dialog.open();
108
				dialog.open();
109
				String variable = dialog.getVariableExpression();
109
				String variable = dialog.getVariableExpression();
110
				if (variable != null) {
110
				if (variable != null) {
111
					fProgramArguments.getText().insert(variable);
111
					fProgramArguments.getText().insert(variable);
112
				}
112
				}
113
			}
113
			}
114
		});
114
		});
115
		CTabItem programTab = new CTabItem(fTabFolder, SWT.NULL);
115
		CTabItem programTab = new CTabItem(fTabFolder, SWT.NULL);
116
		programTab.setText(PDEUIMessages.ArgumentsSection_programTabLabel);
116
		programTab.setText(PDEUIMessages.ArgumentsSection_programTabLabel);
117
		programTab.setImage(fImage);
117
		programTab.setImage(fImage);
118
		programTab.setControl(programComp);
118
		programTab.setControl(programComp);
119
		toolkit.paintBordersFor(programComp);
119
		toolkit.paintBordersFor(programComp);
120
120
121
		Composite vmComp = toolkit.createComposite(fTabFolder);
121
		Composite vmComp = toolkit.createComposite(fTabFolder);
122
		vmComp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
122
		vmComp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
123
		vmComp.setLayoutData(new GridData(GridData.FILL_BOTH));
123
		vmComp.setLayoutData(new GridData(GridData.FILL_BOTH));
124
		fVMArguments = new FormEntry(vmComp, toolkit, PDEUIMessages.ArgumentsSection_1, SWT.MULTI | SWT.WRAP);
124
		fVMArguments = new FormEntry(vmComp, toolkit, PDEUIMessages.ArgumentsSection_1, SWT.MULTI | SWT.WRAP);
125
		fVMArguments.getText().setLayoutData(new GridData(GridData.FILL_BOTH));
125
		fVMArguments.getText().setLayoutData(new GridData(GridData.FILL_BOTH));
126
		fVMArguments.setFormEntryListener(new SimpleFormEntryAdapter(this) {
126
		fVMArguments.setFormEntryListener(new SimpleFormEntryAdapter(this) {
127
			public void textValueChanged(FormEntry entry) {
127
			public void textValueChanged(FormEntry entry) {
128
				String value = entry.getValue().trim();
128
				String value = entry.getValue().trim();
129
				getTarget().setVMArguments(value.length() > 0 ? value : null);
129
				getTarget().setVMArguments(value.length() > 0 ? value : null);
130
			}
130
			}
131
		});
131
		});
132
132
133
		Composite buttons = new Composite(vmComp, SWT.NONE);
133
		Composite buttons = new Composite(vmComp, SWT.NONE);
134
		GridLayout layout = FormLayoutFactory.createSectionClientGridLayout(false, 2);
134
		buttons.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
135
		layout.marginTop = 0;
135
		buttons.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
136
		layout.marginBottom = 0;
136
		Button vmArgs = toolkit.createButton(buttons, PDEUIMessages.ArgumentsSection_argumentsButtonTitle, SWT.NONE);
137
		layout.marginRight = 0;
137
		vmArgs.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
138
		layout.marginLeft = 0;
138
		vmArgs.addSelectionListener(new SelectionAdapter() {
139
		buttons.setLayout(layout);
139
			public void widgetSelected(SelectionEvent e) {
140
		buttons.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
140
				ArgumentsFromContainerSelectionDialog dialog = new ArgumentsFromContainerSelectionDialog(getSection().getShell(), getTarget());
141
		Button vmArgs = toolkit.createButton(buttons, PDEUIMessages.ArgumentsSection_argumentsButtonTitle, SWT.NONE);
141
				if (dialog.open() == Dialog.OK) {
142
		vmArgs.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
142
					String[] args = dialog.getSelectedArguments();
143
		vmArgs.addSelectionListener(new SelectionAdapter() {
143
					if (args != null && args.length > 0) {
144
			public void widgetSelected(SelectionEvent e) {
144
						StringBuffer resultBuffer = new StringBuffer();
145
				ArgumentsFromContainerSelectionDialog dialog = new ArgumentsFromContainerSelectionDialog(getSection().getShell(), getTarget());
145
						for (int index = 0; index < args.length; ++index) {
146
				if (dialog.open() == Window.OK) {
146
							resultBuffer.append(args[index] + " "); //$NON-NLS-1$
147
					String[] args = dialog.getSelectedArguments();
147
						}
148
					if (args != null && args.length > 0) {
148
						fVMArguments.getText().insert(resultBuffer.toString());
149
						StringBuffer resultBuffer = new StringBuffer();
149
					}
150
						for (int index = 0; index < args.length; ++index) {
150
				}
151
							resultBuffer.append(args[index] + " "); //$NON-NLS-1$
151
			}
152
						}
152
		});
153
						fVMArguments.getText().insert(resultBuffer.toString());
153
154
					}
154
		variables = toolkit.createButton(buttons, PDEUIMessages.ArgumentsSection_variableButtonTitle, SWT.NONE);
155
				}
155
		variables.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
156
			}
156
		variables.addSelectionListener(new SelectionAdapter() {
157
		});
157
			public void widgetSelected(SelectionEvent e) {
158
158
				StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getSection().getShell());
159
		variables = toolkit.createButton(buttons, PDEUIMessages.ArgumentsSection_variableButtonTitle, SWT.NONE);
159
				dialog.open();
160
		variables.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
160
				String variable = dialog.getVariableExpression();
161
		variables.addSelectionListener(new SelectionAdapter() {
161
				if (variable != null) {
162
			public void widgetSelected(SelectionEvent e) {
162
					fVMArguments.getText().insert(variable);
163
				StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getSection().getShell());
163
				}
164
				dialog.open();
164
			}
165
				String variable = dialog.getVariableExpression();
165
		});
166
				if (variable != null) {
166
		CTabItem vmTab = new CTabItem(fTabFolder, SWT.NULL);
167
					fVMArguments.getText().insert(variable);
167
		vmTab.setText(PDEUIMessages.ArgumentsSection_vmTabLabel);
168
				}
168
		vmTab.setImage(fImage);
169
			}
169
		vmTab.setControl(vmComp);
170
		});
170
		toolkit.paintBordersFor(vmComp);
171
		CTabItem vmTab = new CTabItem(fTabFolder, SWT.NULL);
171
172
		vmTab.setText(PDEUIMessages.ArgumentsSection_vmTabLabel);
172
		fTabFolder.setSelection(programTab);
173
		vmTab.setImage(fImage);
173
174
		vmTab.setControl(vmComp);
174
		toolkit.paintBordersFor(client);
175
		toolkit.paintBordersFor(vmComp);
175
		section.setClient(client);
176
176
	}
177
		fTabFolder.setSelection(programTab);
177
178
178
	/* (non-Javadoc)
179
		toolkit.paintBordersFor(client);
179
	 * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
180
		section.setClient(client);
180
	 */
181
	}
181
	public void refresh() {
182
182
		fProgramArguments.setValue(getTarget().getProgramArguments(), true);
183
	/* (non-Javadoc)
183
		fVMArguments.setValue(getTarget().getVMArguments(), true);
184
	 * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
184
		super.refresh();
185
	 */
185
	}
186
	public void refresh() {
186
187
		fProgramArguments.setValue(getTarget().getProgramArguments(), true);
187
	/* (non-Javadoc)
188
		fVMArguments.setValue(getTarget().getVMArguments(), true);
188
	 * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean)
189
		super.refresh();
189
	 */
190
	}
190
	public void commit(boolean onSave) {
191
191
		fProgramArguments.commit();
192
	/* (non-Javadoc)
192
		fVMArguments.commit();
193
	 * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean)
193
		super.commit(onSave);
194
	 */
194
	}
195
	public void commit(boolean onSave) {
195
196
		fProgramArguments.commit();
196
	/* (non-Javadoc)
197
		fVMArguments.commit();
197
	 * @see org.eclipse.ui.forms.AbstractFormPart#dispose()
198
		super.commit(onSave);
198
	 */
199
	}
199
	public void dispose() {
200
200
		if (fImage != null)
201
	/* (non-Javadoc)
201
			fImage.dispose();
202
	 * @see org.eclipse.ui.forms.AbstractFormPart#dispose()
202
		super.dispose();
203
	 */
203
	}
204
	public void dispose() {
204
205
		if (fImage != null)
205
}
206
			fImage.dispose();
206
=======
207
		super.dispose();
207
/*******************************************************************************
208
	}
208
 * Copyright (c) 2005, 2009 IBM Corporation and others.
209
209
 * All rights reserved. This program and the accompanying materials
210
}
210
 * are made available under the terms of the Eclipse Public License v1.0
211
 * which accompanies this distribution, and is available at
212
 * http://www.eclipse.org/legal/epl-v10.html
213
 *
214
 * Contributors:
215
 *     IBM Corporation - initial API and implementation
216
 *******************************************************************************/
217
package org.eclipse.pde.internal.ui.editor.targetdefinition;
218
219
import org.eclipse.debug.ui.StringVariableSelectionDialog;
220
import org.eclipse.jface.window.Window;
221
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
222
import org.eclipse.pde.internal.ui.PDEPluginImages;
223
import org.eclipse.pde.internal.ui.PDEUIMessages;
224
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
225
import org.eclipse.pde.internal.ui.parts.FormEntry;
226
import org.eclipse.pde.internal.ui.shared.target.ArgumentsFromContainerSelectionDialog;
227
import org.eclipse.swt.SWT;
228
import org.eclipse.swt.custom.CTabFolder;
229
import org.eclipse.swt.custom.CTabItem;
230
import org.eclipse.swt.events.SelectionAdapter;
231
import org.eclipse.swt.events.SelectionEvent;
232
import org.eclipse.swt.graphics.Color;
233
import org.eclipse.swt.graphics.Image;
234
import org.eclipse.swt.layout.GridData;
235
import org.eclipse.swt.layout.GridLayout;
236
import org.eclipse.swt.widgets.Button;
237
import org.eclipse.swt.widgets.Composite;
238
import org.eclipse.ui.forms.IFormColors;
239
import org.eclipse.ui.forms.SectionPart;
240
import org.eclipse.ui.forms.editor.FormPage;
241
import org.eclipse.ui.forms.widgets.*;
242
243
/**
244
 * Section for editing VM and program arguments in the target definition editor
245
 * @see EnvironmentPage
246
 * @see TargetEditor
247
 */
248
public class ArgumentsSection extends SectionPart {
249
250
	private CTabFolder fTabFolder;
251
	private FormEntry fProgramArguments;
252
	private FormEntry fVMArguments;
253
	private Image fImage;
254
	private TargetEditor fEditor;
255
256
	public ArgumentsSection(FormPage page, Composite parent) {
257
		super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
258
		fEditor = (TargetEditor) page.getEditor();
259
		fImage = PDEPluginImages.DESC_ARGUMENT_TAB.createImage();
260
		createClient(getSection(), page.getEditor().getToolkit());
261
	}
262
263
	/**
264
	 * @return The target model backing this editor
265
	 */
266
	private ITargetDefinition getTarget() {
267
		return fEditor.getTarget();
268
	}
269
270
	/**
271
	 * Creates the UI for this section.
272
	 * 
273
	 * @param section section the UI is being added to
274
	 * @param toolkit form toolkit used to create the widgets
275
	 */
276
	protected void createClient(Section section, FormToolkit toolkit) {
277
		section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
278
		section.setText(PDEUIMessages.ArgumentsSection_editorTitle);
279
		section.setDescription(PDEUIMessages.ArgumentsSection_description);
280
		GridData data = new GridData(GridData.FILL_BOTH);
281
		data.horizontalSpan = 1;
282
		section.setLayoutData(data);
283
284
		Composite client = toolkit.createComposite(section);
285
		client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
286
		GridData gd = new GridData(GridData.FILL_BOTH);
287
		gd.widthHint = 100;
288
		client.setLayoutData(gd);
289
290
		fTabFolder = new CTabFolder(client, SWT.FLAT | SWT.TOP);
291
		toolkit.adapt(fTabFolder, true, true);
292
		gd = new GridData(GridData.FILL_BOTH);
293
		fTabFolder.setLayoutData(gd);
294
		toolkit.getColors().initializeSectionToolBarColors();
295
		Color selectedColor = toolkit.getColors().getColor(IFormColors.TB_BG);
296
		fTabFolder.setSelectionBackground(new Color[] {selectedColor, toolkit.getColors().getBackground()}, new int[] {100}, true);
297
298
		Composite programComp = toolkit.createComposite(fTabFolder);
299
		programComp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
300
		programComp.setLayoutData(new GridData(GridData.FILL_BOTH));
301
		fProgramArguments = new FormEntry(programComp, toolkit, PDEUIMessages.ArgumentsSection_0, SWT.MULTI | SWT.WRAP);
302
		fProgramArguments.getText().setLayoutData(new GridData(GridData.FILL_BOTH));
303
		fProgramArguments.setFormEntryListener(new SimpleFormEntryAdapter(this) {
304
			public void textValueChanged(FormEntry entry) {
305
				String value = entry.getValue().trim();
306
				getTarget().setProgramArguments(value.length() > 0 ? value : null);
307
			}
308
		});
309
		Button variables = toolkit.createButton(programComp, PDEUIMessages.ArgumentsSection_variableButtonTitle, SWT.NONE);
310
		variables.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
311
		variables.addSelectionListener(new SelectionAdapter() {
312
			public void widgetSelected(SelectionEvent e) {
313
				StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getSection().getShell());
314
				dialog.open();
315
				String variable = dialog.getVariableExpression();
316
				if (variable != null) {
317
					fProgramArguments.getText().insert(variable);
318
				}
319
			}
320
		});
321
		CTabItem programTab = new CTabItem(fTabFolder, SWT.NULL);
322
		programTab.setText(PDEUIMessages.ArgumentsSection_programTabLabel);
323
		programTab.setImage(fImage);
324
		programTab.setControl(programComp);
325
		toolkit.paintBordersFor(programComp);
326
327
		Composite vmComp = toolkit.createComposite(fTabFolder);
328
		vmComp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
329
		vmComp.setLayoutData(new GridData(GridData.FILL_BOTH));
330
		fVMArguments = new FormEntry(vmComp, toolkit, PDEUIMessages.ArgumentsSection_1, SWT.MULTI | SWT.WRAP);
331
		fVMArguments.getText().setLayoutData(new GridData(GridData.FILL_BOTH));
332
		fVMArguments.setFormEntryListener(new SimpleFormEntryAdapter(this) {
333
			public void textValueChanged(FormEntry entry) {
334
				String value = entry.getValue().trim();
335
				getTarget().setVMArguments(value.length() > 0 ? value : null);
336
			}
337
		});
338
339
		Composite buttons = new Composite(vmComp, SWT.NONE);
340
		GridLayout layout = FormLayoutFactory.createSectionClientGridLayout(false, 2);
341
		layout.marginTop = 0;
342
		layout.marginBottom = 0;
343
		layout.marginRight = 0;
344
		layout.marginLeft = 0;
345
		buttons.setLayout(layout);
346
		buttons.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
347
		Button vmArgs = toolkit.createButton(buttons, PDEUIMessages.ArgumentsSection_argumentsButtonTitle, SWT.NONE);
348
		vmArgs.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
349
		vmArgs.addSelectionListener(new SelectionAdapter() {
350
			public void widgetSelected(SelectionEvent e) {
351
				ArgumentsFromContainerSelectionDialog dialog = new ArgumentsFromContainerSelectionDialog(getSection().getShell(), getTarget());
352
				if (dialog.open() == Window.OK) {
353
					String[] args = dialog.getSelectedArguments();
354
					if (args != null && args.length > 0) {
355
						StringBuffer resultBuffer = new StringBuffer();
356
						for (int index = 0; index < args.length; ++index) {
357
							resultBuffer.append(args[index] + " "); //$NON-NLS-1$
358
						}
359
						fVMArguments.getText().insert(resultBuffer.toString());
360
					}
361
				}
362
			}
363
		});
364
365
		variables = toolkit.createButton(buttons, PDEUIMessages.ArgumentsSection_variableButtonTitle, SWT.NONE);
366
		variables.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
367
		variables.addSelectionListener(new SelectionAdapter() {
368
			public void widgetSelected(SelectionEvent e) {
369
				StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getSection().getShell());
370
				dialog.open();
371
				String variable = dialog.getVariableExpression();
372
				if (variable != null) {
373
					fVMArguments.getText().insert(variable);
374
				}
375
			}
376
		});
377
		CTabItem vmTab = new CTabItem(fTabFolder, SWT.NULL);
378
		vmTab.setText(PDEUIMessages.ArgumentsSection_vmTabLabel);
379
		vmTab.setImage(fImage);
380
		vmTab.setControl(vmComp);
381
		toolkit.paintBordersFor(vmComp);
382
383
		fTabFolder.setSelection(programTab);
384
385
		toolkit.paintBordersFor(client);
386
		section.setClient(client);
387
	}
388
389
	/* (non-Javadoc)
390
	 * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
391
	 */
392
	public void refresh() {
393
		fProgramArguments.setValue(getTarget().getProgramArguments(), true);
394
		fVMArguments.setValue(getTarget().getVMArguments(), true);
395
		super.refresh();
396
	}
397
398
	/* (non-Javadoc)
399
	 * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean)
400
	 */
401
	public void commit(boolean onSave) {
402
		fProgramArguments.commit();
403
		fVMArguments.commit();
404
		super.commit(onSave);
405
	}
406
407
	/* (non-Javadoc)
408
	 * @see org.eclipse.ui.forms.AbstractFormPart#dispose()
409
	 */
410
	public void dispose() {
411
		if (fImage != null)
412
			fImage.dispose();
413
		super.dispose();
414
	}
415
416
}
417
>>>>>>> 1.7
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/ImplicitDependenciesSection.java (+285 lines)
Lines 1-3 Link Here
1
<<<<<<< ImplicitDependenciesSection.java
2
/*******************************************************************************
3
 * Copyright (c) 2005, 2009 IBM Corporation and others.
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.editor.targetdefinition;
13
14
import java.util.*;
15
import java.util.List;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
18
import org.eclipse.jface.viewers.*;
19
import org.eclipse.jface.window.Window;
20
import org.eclipse.osgi.util.NLS;
21
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
22
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
23
import org.eclipse.pde.internal.ui.*;
24
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
25
import org.eclipse.pde.internal.ui.editor.plugin.ManifestEditor;
26
import org.eclipse.pde.internal.ui.elements.DefaultTableProvider;
27
import org.eclipse.pde.internal.ui.shared.target.BundleInfoLabelProvider;
28
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.events.SelectionAdapter;
30
import org.eclipse.swt.events.SelectionEvent;
31
import org.eclipse.swt.layout.GridData;
32
import org.eclipse.swt.layout.GridLayout;
33
import org.eclipse.swt.widgets.*;
34
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
35
import org.eclipse.ui.forms.IFormColors;
36
import org.eclipse.ui.forms.SectionPart;
37
import org.eclipse.ui.forms.editor.FormPage;
38
import org.eclipse.ui.forms.widgets.*;
39
40
/**
41
 * Section for editing implicit dependencies in the target definition editor
42
 * @see EnvironmentPage
43
 * @see TargetEditor
44
 */
45
public class ImplicitDependenciesSection extends SectionPart {
46
47
	private TableViewer fViewer;
48
	private TargetEditor fEditor;
49
	private Button fAdd;
50
	private Button fRemove;
51
	private Button fRemoveAll;
52
	private Label fCount;
53
54
	public ImplicitDependenciesSection(FormPage page, Composite parent) {
55
		super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
56
		fEditor = (TargetEditor) page.getEditor();
57
		createClient(getSection(), page.getEditor().getToolkit());
58
	}
59
60
	/**
61
	 * @return The target model backing this editor
62
	 */
63
	private ITargetDefinition getTarget() {
64
		return fEditor.getTarget();
65
	}
66
67
	/**
68
	 * Creates the UI for this section.
69
	 * 
70
	 * @param section section the UI is being added to
71
	 * @param toolkit form toolkit used to create the widgets
72
	 */
73
	protected void createClient(Section section, FormToolkit toolkit) {
74
		section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
75
		section.setText(PDEUIMessages.ImplicitDependenicesSection_Title);
76
		section.setDescription(PDEUIMessages.TargetImplicitPluginsTab_desc);
77
		Composite container = toolkit.createComposite(section);
78
		container.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
79
		container.setLayoutData(new GridData(GridData.FILL_BOTH));
80
81
		createTableViewer(toolkit, container);
82
83
		Composite buttonComp = toolkit.createComposite(container);
84
		GridLayout layout = new GridLayout();
85
		layout.marginWidth = layout.marginHeight = 0;
86
		buttonComp.setLayout(layout);
87
		buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
88
89
		createButtons(toolkit, buttonComp);
90
91
		toolkit.paintBordersFor(container);
92
		section.setClient(container);
93
		GridData gd = new GridData(GridData.FILL_BOTH);
94
		section.setLayoutData(gd);
95
		updateButtons();
96
	}
97
98
	/**
99
	 * Creates the table viewer in this section
100
	 * @param toolkit toolkit used to create the widgets
101
	 * @param parent parent composite
102
	 */
103
	private void createTableViewer(FormToolkit toolkit, Composite parent) {
104
		// TODO Support global delete action, maybe copy/paste as well
105
		Table table = toolkit.createTable(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
106
		table.setLayoutData(new GridData(GridData.FILL_BOTH));
107
		fViewer = new TableViewer(table);
108
		fViewer.setContentProvider(new DefaultTableProvider() {
109
			public Object[] getElements(Object inputElement) {
110
				BundleInfo[] bundles = getTarget().getImplicitDependencies();
111
				if (bundles == null) {
112
					return new BundleInfo[0];
113
				}
114
				return bundles;
115
			}
116
		});
117
		fViewer.setLabelProvider(new BundleInfoLabelProvider(true));
118
		fViewer.setComparator(new ViewerComparator() {
119
			public int compare(Viewer viewer, Object e1, Object e2) {
120
				BundleInfo bundle1 = (BundleInfo) e1;
121
				BundleInfo bundle2 = (BundleInfo) e2;
122
				return super.compare(viewer, bundle1.getSymbolicName(), bundle2.getSymbolicName());
123
			}
124
		});
125
		fViewer.setInput(getTarget());
126
		fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
127
			public void selectionChanged(SelectionChangedEvent event) {
128
				updateButtons();
129
			}
130
		});
131
		fViewer.addDoubleClickListener(new IDoubleClickListener() {
132
			public void doubleClick(DoubleClickEvent event) {
133
				Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
134
				ManifestEditor.openPluginEditor(((BundleInfo) object).getSymbolicName());
135
			}
136
		});
137
	}
138
139
	/**
140
	 * Creates the buttons that sit beside the table
141
	 * @param toolkit toolkit used to create widgets
142
	 * @param parent parent composite
143
	 */
144
	private void createButtons(FormToolkit toolkit, Composite parent) {
145
		fAdd = toolkit.createButton(parent, PDEUIMessages.ImplicitDependenicesSection_Add, SWT.PUSH);
146
		fAdd.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
147
		fAdd.addSelectionListener(new SelectionAdapter() {
148
			public void widgetSelected(SelectionEvent e) {
149
				handleAdd();
150
			}
151
		});
152
		SWTFactory.setButtonDimensionHint(fAdd);
153
		fRemove = toolkit.createButton(parent, PDEUIMessages.ImplicitDependenicesSection_Remove, SWT.PUSH);
154
		fRemove.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
155
		fRemove.addSelectionListener(new SelectionAdapter() {
156
			public void widgetSelected(SelectionEvent e) {
157
				handleRemove();
158
			}
159
		});
160
		SWTFactory.setButtonDimensionHint(fRemove);
161
		fRemoveAll = toolkit.createButton(parent, PDEUIMessages.ImplicitDependenicesSection_RemoveAll, SWT.PUSH);
162
		fRemoveAll.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
163
		fRemoveAll.addSelectionListener(new SelectionAdapter() {
164
			public void widgetSelected(SelectionEvent e) {
165
				handleRemoveAll();
166
			}
167
		});
168
		SWTFactory.setButtonDimensionHint(fRemoveAll);
169
		Composite countComp = toolkit.createComposite(parent);
170
		GridLayout layout = new GridLayout();
171
		layout.marginWidth = layout.marginHeight = 0;
172
		countComp.setLayout(layout);
173
		countComp.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_END | GridData.FILL_BOTH));
174
		fCount = toolkit.createLabel(parent, ""); //$NON-NLS-1$
175
		fCount.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
176
		fCount.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
177
	}
178
179
	private void updateButtons() {
180
		fRemove.setEnabled(!fViewer.getSelection().isEmpty());
181
		fRemoveAll.setEnabled(fViewer.getTable().getItemCount() > 0);
182
	}
183
184
	/**
185
	 * Updates the label in the bottom right with the current count of implicit plug-ins
186
	 */
187
	private void updateCount() {
188
		if (fCount != null && !fCount.isDisposed())
189
			fCount.setText(NLS.bind(PDEUIMessages.TableSection_itemCount, Integer.toString(fViewer.getTable().getItemCount())));
190
	}
191
192
	protected void handleAdd() {
193
		ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), new BundleInfoLabelProvider(false));
194
		dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title);
195
		dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message);
196
		dialog.setMultipleSelection(true);
197
		try {
198
			dialog.setElements(getValidBundles());
199
		} catch (CoreException e) {
200
			dialog.setMessage(e.getMessage());
201
		}
202
203
		if (dialog.open() == Window.OK) {
204
			Object[] models = dialog.getResult();
205
			ArrayList pluginsToAdd = new ArrayList();
206
			for (int i = 0; i < models.length; i++) {
207
				BundleInfo selected = ((BundleInfo) models[i]);
208
				pluginsToAdd.add(new BundleInfo(selected.getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false));
209
			}
210
			Set allDependencies = new HashSet();
211
			allDependencies.addAll(pluginsToAdd);
212
			BundleInfo[] currentBundles = getTarget().getImplicitDependencies();
213
			if (currentBundles != null) {
214
				allDependencies.addAll(Arrays.asList(currentBundles));
215
			}
216
			getTarget().setImplicitDependencies((BundleInfo[]) allDependencies.toArray(new BundleInfo[allDependencies.size()]));
217
			markDirty();
218
			refresh();
219
		}
220
	}
221
222
	/**
223
	 * Gets a list of all the bundles that can be added as implicit dependencies
224
	 * @return list of possible dependencies
225
	 */
226
	protected BundleInfo[] getValidBundles() throws CoreException {
227
		BundleInfo[] current = getTarget().getImplicitDependencies();
228
		Set currentBundles = new HashSet();
229
		if (current != null) {
230
			for (int i = 0; i < current.length; i++) {
231
				currentBundles.add(current[i].getSymbolicName());
232
			}
233
		}
234
235
		List targetBundles = new ArrayList();
236
		IResolvedBundle[] allTargetBundles = getTarget().getBundles();
237
		if (allTargetBundles == null || allTargetBundles.length == 0) {
238
			throw new CoreException(new Status(IStatus.WARNING, PDEPlugin.getPluginId(), PDEUIMessages.ImplicitDependenciesSection_0));
239
		}
240
		for (int i = 0; i < allTargetBundles.length; i++) {
241
			if (!currentBundles.contains(allTargetBundles[i].getBundleInfo().getSymbolicName())) {
242
				targetBundles.add(allTargetBundles[i].getBundleInfo());
243
			}
244
		}
245
246
		return (BundleInfo[]) targetBundles.toArray(new BundleInfo[targetBundles.size()]);
247
	}
248
249
	private void handleRemove() {
250
		LinkedList bundles = new LinkedList();
251
		bundles.addAll(Arrays.asList(getTarget().getImplicitDependencies()));
252
		Object[] removeBundles = ((IStructuredSelection) fViewer.getSelection()).toArray();
253
		if (removeBundles.length > 0) {
254
			for (int i = 0; i < removeBundles.length; i++) {
255
				if (removeBundles[i] instanceof BundleInfo) {
256
					bundles.remove(removeBundles[i]);
257
				}
258
			}
259
			getTarget().setImplicitDependencies((BundleInfo[]) bundles.toArray((new BundleInfo[bundles.size()])));
260
			markDirty();
261
			refresh();
262
		}
263
	}
264
265
	private void handleRemoveAll() {
266
		getTarget().setImplicitDependencies(null);
267
		markDirty();
268
		refresh();
269
	}
270
271
	/* (non-Javadoc)
272
	 * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
273
	 */
274
	public void refresh() {
275
		// TODO Try to retain selection during refresh, add and remove operations
276
		fViewer.setInput(getTarget());
277
		fViewer.refresh();
278
		updateButtons();
279
		updateCount();
280
		super.refresh();
281
	}
282
283
}
284
=======
1
/*******************************************************************************
285
/*******************************************************************************
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
286
 * Copyright (c) 2005, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
287
 * All rights reserved. This program and the accompanying materials
Lines 281-283 Link Here
281
	}
565
	}
282
566
283
}
567
}
568
>>>>>>> 1.10
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/InformationSection.java (-111 / +111 lines)
Lines 1-111 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.editor.targetdefinition;
11
package org.eclipse.pde.internal.ui.editor.targetdefinition;
12
12
13
import org.eclipse.jface.dialogs.IMessageProvider;
13
import org.eclipse.jface.dialogs.IMessageProvider;
14
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
14
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
15
import org.eclipse.pde.internal.ui.PDEUIMessages;
15
import org.eclipse.pde.internal.ui.PDEUIMessages;
16
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
16
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
17
import org.eclipse.pde.internal.ui.editor.validation.ControlValidationUtility;
17
import org.eclipse.pde.internal.ui.editor.validation.ControlValidationUtility;
18
import org.eclipse.pde.internal.ui.editor.validation.TextValidator;
18
import org.eclipse.pde.internal.ui.editor.validation.TextValidator;
19
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.events.ModifyEvent;
20
import org.eclipse.swt.events.ModifyEvent;
21
import org.eclipse.swt.events.ModifyListener;
21
import org.eclipse.swt.events.ModifyListener;
22
import org.eclipse.swt.layout.GridData;
22
import org.eclipse.swt.layout.GridData;
23
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.swt.widgets.Text;
24
import org.eclipse.swt.widgets.Text;
25
import org.eclipse.ui.forms.SectionPart;
25
import org.eclipse.ui.forms.SectionPart;
26
import org.eclipse.ui.forms.editor.FormPage;
26
import org.eclipse.ui.forms.editor.FormPage;
27
import org.eclipse.ui.forms.widgets.*;
27
import org.eclipse.ui.forms.widgets.*;
28
28
29
/**
29
/**
30
 * Section for editing target name and description in the target definition editor
30
 * Section for editing target name and description in the target definition editor
31
 * @see DefinitionPage
31
 * @see DefinitionPage
32
 * @see TargetEditor
32
 * @see TargetEditor
33
 */
33
 */
34
public class InformationSection extends SectionPart {
34
public class InformationSection extends SectionPart {
35
35
36
	private Text fNameText;
36
	private Text fNameText;
37
	private TargetEditor fEditor;
37
	private TargetEditor fEditor;
38
38
39
	private TextValidator fNameTextValidator;
39
	private TextValidator fNameTextValidator;
40
	private FormPage fPage;
40
	private FormPage fPage;
41
41
42
	public InformationSection(FormPage page, Composite parent) {
42
	public InformationSection(FormPage page, Composite parent) {
43
		super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
43
		super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
44
		fPage = page;
44
		fPage = page;
45
		fEditor = (TargetEditor) page.getEditor();
45
		fEditor = (TargetEditor) page.getEditor();
46
		createClient(getSection(), page.getEditor().getToolkit());
46
		createClient(getSection(), page.getEditor().getToolkit());
47
	}
47
	}
48
48
49
	/**
49
	/**
50
	 * @return The target model backing this editor
50
	 * @return The target model backing this editor
51
	 */
51
	 */
52
	private ITargetDefinition getTarget() {
52
	private ITargetDefinition getTarget() {
53
		return fEditor.getTarget();
53
		return fEditor.getTarget();
54
	}
54
	}
55
55
56
	/**
56
	/**
57
	 * Creates the UI for this section.
57
	 * Creates the UI for this section.
58
	 * 
58
	 * 
59
	 * @param section section the UI is being added to
59
	 * @param section section the UI is being added to
60
	 * @param toolkit form toolkit used to create the widgets
60
	 * @param toolkit form toolkit used to create the widgets
61
	 */
61
	 */
62
	protected void createClient(Section section, FormToolkit toolkit) {
62
	protected void createClient(Section section, FormToolkit toolkit) {
63
		section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
63
		section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
64
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
64
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
65
		data.verticalAlignment = SWT.TOP;
65
		data.verticalAlignment = SWT.TOP;
66
		data.horizontalSpan = 2;
66
		data.horizontalSpan = 2;
67
		section.setLayoutData(data);
67
		section.setLayoutData(data);
68
68
69
		section.setText(PDEUIMessages.InformationSection_0);
69
		section.setText(PDEUIMessages.InformationSection_0);
70
		section.setDescription(PDEUIMessages.InformationSection_1);
70
		section.setDescription(PDEUIMessages.InformationSection_1);
71
71
72
		Composite client = toolkit.createComposite(section);
72
		Composite client = toolkit.createComposite(section);
73
		client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
73
		client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
74
		client.setLayoutData(new GridData(GridData.FILL_BOTH));
74
		client.setLayoutData(new GridData(GridData.FILL_BOTH));
75
75
76
		fNameText = toolkit.createText(client, getTarget().getName());
76
		fNameText = toolkit.createText(client, getTarget().getName());
77
		fNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
77
		fNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
78
		fNameText.addModifyListener(new ModifyListener() {
78
		fNameText.addModifyListener(new ModifyListener() {
79
			public void modifyText(ModifyEvent e) {
79
			public void modifyText(ModifyEvent e) {
80
				String value = fNameText.getText().trim();
80
				String value = fNameText.getText().trim();
81
				getTarget().setName(value.length() > 0 ? value : null);
81
				getTarget().setName(value.length() > 0 ? value : null);
82
				markDirty();
82
				markDirty();
83
			}
83
			}
84
		});
84
		});
85
85
86
		fNameTextValidator = new TextValidator(fPage.getManagedForm(), fNameText, null, true) {
86
		fNameTextValidator = new TextValidator(fPage.getManagedForm(), fNameText, null, true) {
87
87
88
			protected boolean autoEnable() {
88
			protected boolean autoEnable() {
89
				if (getText().getEditable() == false) {
89
				if (getText().getEditable() == false) {
90
					return false;
90
					return false;
91
				}
91
				}
92
				return true;
92
				return true;
93
			}
93
			}
94
94
95
			protected boolean validateControl() {
95
			protected boolean validateControl() {
96
				return ControlValidationUtility.validateRequiredField(fNameText.getText(), fNameTextValidator, IMessageProvider.ERROR);
96
				return ControlValidationUtility.validateRequiredField(fNameText.getText(), fNameTextValidator, IMessageProvider.ERROR);
97
			}
97
			}
98
		};
98
		};
99
		toolkit.paintBordersFor(client);
99
		toolkit.paintBordersFor(client);
100
		section.setClient(client);
100
		section.setClient(client);
101
	}
101
	}
102
102
103
	/* (non-Javadoc)
103
	/* (non-Javadoc)
104
	 * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
104
	 * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
105
	 */
105
	 */
106
	public void refresh() {
106
	public void refresh() {
107
		fNameText.setText(getTarget().getName() != null ? getTarget().getName() : ""); //$NON-NLS-1$
107
		fNameText.setText(getTarget().getName() != null ? getTarget().getName() : ""); //$NON-NLS-1$
108
		super.refresh();
108
		super.refresh();
109
	}
109
	}
110
110
111
}
111
}
(-)src/org/eclipse/pde/internal/ui/wizards/BundleProviderUtil.java (+80 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 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.pde.internal.ui.wizards;
12
13
import org.eclipse.jface.dialogs.IDialogSettings;
14
import org.eclipse.swt.widgets.Combo;
15
16
/**
17
 * Provides helper methods to load and save provider names from and to combo boxes.
18
 * 
19
 * @author <a href="mailto:phil.kursawe@gmail.com">Philipp Kursawe</a>
20
 *
21
 */
22
public class BundleProviderUtil {
23
	/**
24
	 * Dialog settings constants
25
	 */
26
	private final static String S_PROVIDERS = "providers"; //$NON-NLS-1$
27
28
	/**
29
	 * Loads the history of providers from the given settings.
30
	 * <h2>Note</h2>
31
	 * <p>
32
	 * This method also selects the first entry of the history into
33
	 * the given combo. This might trigger a <code>SWT.Modify</code> event.
34
	 * </p> 
35
	 */
36
	public static void loadHistory(Combo combo, IDialogSettings settings) {
37
		if (null == combo || null == settings) {
38
			return;
39
		}
40
		String providers[] = settings.getArray(S_PROVIDERS);
41
		if (null != providers) {
42
			for (int i = 0; i < providers.length; ++i) {
43
				combo.add(providers[i]);
44
			}
45
		}
46
	}
47
48
	/**
49
	 * Saves the items of the given combo to the given settings.
50
	 * 
51
	 * <p>
52
	 * If the combo text is not in the list of history items yet, it will be
53
	 * added. The combo text will be the most recent history value (saved first).
54
	 * </p>
55
	 * @param combo
56
	 * @param settings
57
	 */
58
	public static void saveHistory(Combo combo, IDialogSettings settings) {
59
		if (null == combo) {
60
			return;
61
		}
62
		// Save all providers from the combo list + the newly entered
63
		String text = combo.getText();
64
		if (0 == text.length()) {
65
			return;
66
		}
67
		int indexOfText = combo.indexOf(text);
68
		// If the item was already in the list, remove it now 
69
		if (indexOfText != -1) {
70
			combo.remove(indexOfText);
71
		}
72
		// And always add the entered text as the most recent one to the top of 
73
		// the list
74
		combo.add(text, 0);
75
		String[] items = combo.getItems();
76
		if (items != null && items.length > 0) {
77
			settings.put(S_PROVIDERS, items);
78
		}
79
	}
80
}
(-)src/org/eclipse/pde/internal/ui/wizards/feature/AbstractFeatureSpecPage.java (+3 lines)
Lines 13-18 Link Here
13
13
14
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.jface.dialogs.Dialog;
15
import org.eclipse.jface.dialogs.Dialog;
16
import org.eclipse.jface.dialogs.IDialogSettings;
16
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
17
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
17
import org.eclipse.pde.internal.core.util.IdUtil;
18
import org.eclipse.pde.internal.core.util.IdUtil;
18
import org.eclipse.pde.internal.core.util.VersionUtil;
19
import org.eclipse.pde.internal.core.util.VersionUtil;
Lines 61-66 Link Here
61
62
62
	protected abstract String getHelpId();
63
	protected abstract String getHelpId();
63
64
65
	protected abstract void saveSettings(IDialogSettings settings);
66
64
	protected void createCommonInput(Composite common) {
67
	protected void createCommonInput(Composite common) {
65
		Label label = new Label(common, SWT.NULL);
68
		Label label = new Label(common, SWT.NULL);
66
		label.setText(PDEUIMessages.NewFeatureWizard_SpecPage_name);
69
		label.setText(PDEUIMessages.NewFeatureWizard_SpecPage_name);
(-)src/org/eclipse/pde/internal/ui/wizards/feature/AbstractNewFeatureWizard.java (+1 lines)
Lines 105-110 Link Here
105
	public boolean performFinish() {
105
	public boolean performFinish() {
106
		try {
106
		try {
107
			IDialogSettings settings = getDialogSettings();
107
			IDialogSettings settings = getDialogSettings();
108
			fSpecPage.saveSettings(settings);
108
			if (settings != null && fSecondPage != null)
109
			if (settings != null && fSecondPage != null)
109
				fSecondPage.saveSettings(settings);
110
				fSecondPage.saveSettings(settings);
110
111
(-)src/org/eclipse/pde/internal/ui/wizards/feature/FeatureSpecPage.java (-6 / +15 lines)
Lines 11-19 Link Here
11
11
12
package org.eclipse.pde.internal.ui.wizards.feature;
12
package org.eclipse.pde.internal.ui.wizards.feature;
13
13
14
import org.eclipse.jface.dialogs.IDialogSettings;
14
import org.eclipse.pde.internal.core.util.IdUtil;
15
import org.eclipse.pde.internal.core.util.IdUtil;
15
import org.eclipse.pde.internal.ui.IHelpContextIds;
16
import org.eclipse.pde.internal.ui.IHelpContextIds;
16
import org.eclipse.pde.internal.ui.PDEUIMessages;
17
import org.eclipse.pde.internal.ui.PDEUIMessages;
18
import org.eclipse.pde.internal.ui.wizards.BundleProviderUtil;
17
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.events.ModifyListener;
20
import org.eclipse.swt.events.ModifyListener;
19
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.layout.GridData;
Lines 22-28 Link Here
22
24
23
public class FeatureSpecPage extends AbstractFeatureSpecPage {
25
public class FeatureSpecPage extends AbstractFeatureSpecPage {
24
26
25
	private Text fFeatureProviderText;
27
	private Combo fFeatureProviderCombo;
26
	private Text fFeatureIdText;
28
	private Text fFeatureIdText;
27
29
28
	public FeatureSpecPage() {
30
	public FeatureSpecPage() {
Lines 45-51 Link Here
45
		FeatureData data = new FeatureData();
47
		FeatureData data = new FeatureData();
46
		data.id = fFeatureIdText.getText();
48
		data.id = fFeatureIdText.getText();
47
		data.version = fFeatureVersionText.getText();
49
		data.version = fFeatureVersionText.getText();
48
		data.provider = fFeatureProviderText.getText();
50
		data.provider = fFeatureProviderCombo.getText();
49
		data.name = fFeatureNameText.getText();
51
		data.name = fFeatureNameText.getText();
50
		data.library = getInstallHandlerLibrary();
52
		data.library = getInstallHandlerLibrary();
51
		return data;
53
		return data;
Lines 77-90 Link Here
77
79
78
		label = new Label(group, SWT.NULL);
80
		label = new Label(group, SWT.NULL);
79
		label.setText(PDEUIMessages.NewFeatureWizard_SpecPage_provider);
81
		label.setText(PDEUIMessages.NewFeatureWizard_SpecPage_provider);
80
		fFeatureProviderText = new Text(group, SWT.BORDER);
82
		fFeatureProviderCombo = new Combo(group, SWT.BORDER | SWT.DROP_DOWN);
81
		fFeatureProviderText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
83
		fFeatureProviderCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
84
		BundleProviderUtil.loadHistory(fFeatureProviderCombo, getDialogSettings());
82
85
83
		createInstallHandlerText(group);
86
		createInstallHandlerText(group);
84
	}
87
	}
85
88
86
	protected void attachListeners(ModifyListener listener) {
89
	protected void attachListeners(ModifyListener listener) {
87
		fFeatureProviderText.addModifyListener(listener);
90
		fFeatureProviderCombo.addModifyListener(listener);
88
		fFeatureIdText.addModifyListener(listener);
91
		fFeatureIdText.addModifyListener(listener);
89
	}
92
	}
90
93
Lines 99-105 Link Here
99
		String id = IdUtil.getValidId(getProjectName());
102
		String id = IdUtil.getValidId(getProjectName());
100
		fFeatureIdText.setText(id);
103
		fFeatureIdText.setText(id);
101
		fFeatureNameText.setText(IdUtil.getValidName(id));
104
		fFeatureNameText.setText(IdUtil.getValidName(id));
102
		fFeatureProviderText.setText(IdUtil.getValidProvider(id));
105
		if (0 == fFeatureProviderCombo.getText().length()) {
106
			fFeatureProviderCombo.setText(IdUtil.getValidProvider(id));
107
		}
103
		fSelfModification = false;
108
		fSelfModification = false;
104
	}
109
	}
110
111
	protected void saveSettings(IDialogSettings settings) {
112
		BundleProviderUtil.saveHistory(fFeatureProviderCombo, settings);
113
	}
105
}
114
}
(-)src/org/eclipse/pde/internal/ui/wizards/feature/PatchSpecPage.java (-7 / +16 lines)
Lines 11-16 Link Here
11
11
12
package org.eclipse.pde.internal.ui.wizards.feature;
12
package org.eclipse.pde.internal.ui.wizards.feature;
13
13
14
import org.eclipse.jface.dialogs.IDialogSettings;
14
import org.eclipse.jface.dialogs.IMessageProvider;
15
import org.eclipse.jface.dialogs.IMessageProvider;
15
import org.eclipse.jface.window.Window;
16
import org.eclipse.jface.window.Window;
16
import org.eclipse.jface.wizard.IWizardPage;
17
import org.eclipse.jface.wizard.IWizardPage;
Lines 22-27 Link Here
22
import org.eclipse.pde.internal.ui.PDEUIMessages;
23
import org.eclipse.pde.internal.ui.PDEUIMessages;
23
import org.eclipse.pde.internal.ui.dialogs.FeatureSelectionDialog;
24
import org.eclipse.pde.internal.ui.dialogs.FeatureSelectionDialog;
24
import org.eclipse.pde.internal.ui.util.SWTUtil;
25
import org.eclipse.pde.internal.ui.util.SWTUtil;
26
import org.eclipse.pde.internal.ui.wizards.BundleProviderUtil;
25
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.events.*;
28
import org.eclipse.swt.events.*;
27
import org.eclipse.swt.layout.GridData;
29
import org.eclipse.swt.layout.GridData;
Lines 30-36 Link Here
30
32
31
public class PatchSpecPage extends AbstractFeatureSpecPage {
33
public class PatchSpecPage extends AbstractFeatureSpecPage {
32
34
33
	private Text fPatchProviderText;
35
	private Combo fPatchProviderCombo;
34
	private Button fBrowseButton;
36
	private Button fBrowseButton;
35
	private Text fPatchIdText;
37
	private Text fPatchIdText;
36
	private Text fPatchNameText;
38
	private Text fPatchNameText;
Lines 85-93 Link Here
85
	}
87
	}
86
88
87
	private String getPatchProvider() {
89
	private String getPatchProvider() {
88
		if (fPatchProviderText == null)
90
		if (fPatchProviderCombo == null)
89
			return ""; //$NON-NLS-1$
91
			return ""; //$NON-NLS-1$
90
		return fPatchProviderText.getText();
92
		return fPatchProviderCombo.getText();
91
	}
93
	}
92
94
93
	public FeatureData getFeatureData() {
95
	public FeatureData getFeatureData() {
Lines 136-143 Link Here
136
138
137
		label = new Label(patchGroup, SWT.NULL);
139
		label = new Label(patchGroup, SWT.NULL);
138
		label.setText(PDEUIMessages.NewFeaturePatch_SpecPage_provider);
140
		label.setText(PDEUIMessages.NewFeaturePatch_SpecPage_provider);
139
		fPatchProviderText = new Text(patchGroup, SWT.BORDER);
141
		fPatchProviderCombo = new Combo(patchGroup, SWT.BORDER | SWT.DROP_DOWN);
140
		fPatchProviderText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
142
		fPatchProviderCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
143
		BundleProviderUtil.loadHistory(fPatchProviderCombo, getDialogSettings());
141
144
142
		createInstallHandlerText(patchGroup);
145
		createInstallHandlerText(patchGroup);
143
	}
146
	}
Lines 197-203 Link Here
197
	protected void attachListeners(ModifyListener listener) {
200
	protected void attachListeners(ModifyListener listener) {
198
		fPatchIdText.addModifyListener(listener);
201
		fPatchIdText.addModifyListener(listener);
199
		fPatchNameText.addModifyListener(listener);
202
		fPatchNameText.addModifyListener(listener);
200
		fPatchProviderText.addModifyListener(listener);
203
		fPatchProviderCombo.addModifyListener(listener);
201
		fFeatureIdText.addModifyListener(listener);
204
		fFeatureIdText.addModifyListener(listener);
202
	}
205
	}
203
206
Lines 212-218 Link Here
212
		String id = IdUtil.getValidId(getProjectName());
215
		String id = IdUtil.getValidId(getProjectName());
213
		fPatchIdText.setText(id);
216
		fPatchIdText.setText(id);
214
		fPatchNameText.setText(IdUtil.getValidName(id));
217
		fPatchNameText.setText(IdUtil.getValidName(id));
215
		fPatchProviderText.setText(IdUtil.getValidProvider(id));
218
		if (0 == fPatchProviderCombo.getText().length()) {
219
			fPatchProviderCombo.setText(IdUtil.getValidProvider(id));
220
		}
216
		fSelfModification = false;
221
		fSelfModification = false;
217
	}
222
	}
223
224
	protected void saveSettings(IDialogSettings settings) {
225
		BundleProviderUtil.saveHistory(fPatchProviderCombo, settings);
226
	}
218
}
227
}
(-)src/org/eclipse/pde/internal/ui/wizards/plugin/ContentPage.java (-5 / +24 lines)
Lines 12-17 Link Here
12
package org.eclipse.pde.internal.ui.wizards.plugin;
12
package org.eclipse.pde.internal.ui.wizards.plugin;
13
13
14
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.jface.dialogs.IDialogSettings;
15
import org.eclipse.jface.wizard.IWizardPage;
16
import org.eclipse.jface.wizard.IWizardPage;
16
import org.eclipse.jface.wizard.WizardPage;
17
import org.eclipse.jface.wizard.WizardPage;
17
import org.eclipse.pde.internal.core.PDECoreMessages;
18
import org.eclipse.pde.internal.core.PDECoreMessages;
Lines 19-32 Link Here
19
import org.eclipse.pde.internal.core.util.VersionUtil;
20
import org.eclipse.pde.internal.core.util.VersionUtil;
20
import org.eclipse.pde.internal.ui.PDEUIMessages;
21
import org.eclipse.pde.internal.ui.PDEUIMessages;
21
import org.eclipse.pde.internal.ui.util.PDELabelUtility;
22
import org.eclipse.pde.internal.ui.util.PDELabelUtility;
23
import org.eclipse.pde.internal.ui.wizards.BundleProviderUtil;
22
import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
24
import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
23
import org.eclipse.pde.ui.IFieldData;
25
import org.eclipse.pde.ui.IFieldData;
24
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.events.ModifyEvent;
27
import org.eclipse.swt.events.ModifyEvent;
26
import org.eclipse.swt.events.ModifyListener;
28
import org.eclipse.swt.events.ModifyListener;
27
import org.eclipse.swt.layout.GridData;
29
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.*;
29
import org.eclipse.swt.widgets.Text;
30
31
31
public abstract class ContentPage extends WizardPage {
32
public abstract class ContentPage extends WizardPage {
32
33
Lines 34-40 Link Here
34
	protected Text fIdText;
35
	protected Text fIdText;
35
	protected Text fVersionText;
36
	protected Text fVersionText;
36
	protected Text fNameText;
37
	protected Text fNameText;
37
	protected Text fProviderText;
38
	protected Combo fProviderCombo;
38
39
39
	protected NewProjectCreationPage fMainPage;
40
	protected NewProjectCreationPage fMainPage;
40
	protected AbstractFieldData fData;
41
	protected AbstractFieldData fData;
Lines 75-80 Link Here
75
		return text;
76
		return text;
76
	}
77
	}
77
78
79
	protected Combo createProviderCombo(Composite parent, ModifyListener listener, int horizSpan) {
80
		Combo combo = new Combo(parent, SWT.BORDER | SWT.DROP_DOWN);
81
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
82
		data.horizontalSpan = horizSpan;
83
		combo.setLayoutData(data);
84
		BundleProviderUtil.loadHistory(combo, getDialogSettings());
85
		// Add listener only now, otherwise combo.select(0) would trigger it
86
		// and cause a NPE during validation.
87
		combo.addModifyListener(listener);
88
		return combo;
89
	}
90
78
	protected abstract void validatePage();
91
	protected abstract void validatePage();
79
92
80
	protected String validateProperties() {
93
	protected String validateProperties() {
Lines 152-158 Link Here
152
				fIdText.setText(id);
165
				fIdText.setText(id);
153
				fVersionText.setText("1.0.0.qualifier"); //$NON-NLS-1$
166
				fVersionText.setText("1.0.0.qualifier"); //$NON-NLS-1$
154
				fNameText.setText(IdUtil.getValidName(id));
167
				fNameText.setText(IdUtil.getValidName(id));
155
				fProviderText.setText(IdUtil.getValidProvider(id));
168
				if (0 == fProviderCombo.getText().length()) {
169
					fProviderCombo.setText(IdUtil.getValidProvider(id));
170
				}
156
				fChangedGroups = oldfChanged;
171
				fChangedGroups = oldfChanged;
157
			}
172
			}
158
			if (fInitialized)
173
			if (fInitialized)
Lines 167-177 Link Here
167
		return IdUtil.getValidId(fProjectProvider.getProjectName());
182
		return IdUtil.getValidId(fProjectProvider.getProjectName());
168
	}
183
	}
169
184
185
	public void saveSettings(IDialogSettings settings) {
186
		BundleProviderUtil.saveHistory(fProviderCombo, settings);
187
	}
188
170
	public void updateData() {
189
	public void updateData() {
171
		fData.setId(fIdText.getText().trim());
190
		fData.setId(fIdText.getText().trim());
172
		fData.setVersion(fVersionText.getText().trim());
191
		fData.setVersion(fVersionText.getText().trim());
173
		fData.setName(fNameText.getText().trim());
192
		fData.setName(fNameText.getText().trim());
174
		fData.setProvider(fProviderText.getText().trim());
193
		fData.setProvider(fProviderCombo.getText().trim());
175
	}
194
	}
176
195
177
	public IFieldData getData() {
196
	public IFieldData getData() {
(-)src/org/eclipse/pde/internal/ui/wizards/plugin/FragmentContentPage.java (-1 / +1 lines)
Lines 107-113 Link Here
107
107
108
		label = new Label(propertiesGroup, SWT.NONE);
108
		label = new Label(propertiesGroup, SWT.NONE);
109
		label.setText(PDEUIMessages.ContentPage_fprovider);
109
		label.setText(PDEUIMessages.ContentPage_fprovider);
110
		fProviderText = createText(propertiesGroup, propertiesListener, 2);
110
		fProviderCombo = createProviderCombo(propertiesGroup, propertiesListener, 2);
111
111
112
		createExecutionEnvironmentControls(propertiesGroup);
112
		createExecutionEnvironmentControls(propertiesGroup);
113
	}
113
	}
(-)src/org/eclipse/pde/internal/ui/wizards/plugin/NewFragmentProjectWizard.java (+8 lines)
Lines 13-18 Link Here
13
import java.lang.reflect.InvocationTargetException;
13
import java.lang.reflect.InvocationTargetException;
14
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.runtime.*;
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.jface.dialogs.IDialogSettings;
16
import org.eclipse.jface.wizard.IWizardPage;
17
import org.eclipse.jface.wizard.IWizardPage;
17
import org.eclipse.pde.internal.ui.*;
18
import org.eclipse.pde.internal.ui.*;
18
import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
19
import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
Lines 30-35 Link Here
30
31
31
	public NewFragmentProjectWizard() {
32
	public NewFragmentProjectWizard() {
32
		setDefaultPageImageDescriptor(PDEPluginImages.DESC_NEWFRAGPRJ_WIZ);
33
		setDefaultPageImageDescriptor(PDEPluginImages.DESC_NEWFRAGPRJ_WIZ);
34
		setDialogSettings(PDEPlugin.getDefault().getDialogSettings());
33
		setWindowTitle(PDEUIMessages.NewFragmentProjectWizard_title);
35
		setWindowTitle(PDEUIMessages.NewFragmentProjectWizard_title);
34
		setNeedsProgressMonitor(true);
36
		setNeedsProgressMonitor(true);
35
		PDEPlugin.getDefault().getLabelProvider().connect(this);
37
		PDEPlugin.getDefault().getLabelProvider().connect(this);
Lines 79-84 Link Here
79
		try {
81
		try {
80
			fMainPage.updateData();
82
			fMainPage.updateData();
81
			fContentPage.updateData();
83
			fContentPage.updateData();
84
			IDialogSettings settings = getDialogSettings();
85
			if (settings != null) {
86
				fMainPage.saveSettings(settings);
87
				fContentPage.saveSettings(settings);
88
			}
89
82
			BasicNewProjectResourceWizard.updatePerspective(fConfig);
90
			BasicNewProjectResourceWizard.updatePerspective(fConfig);
83
			getContainer().run(false, true, new NewProjectCreationOperation(fFragmentData, fProjectProvider, null));
91
			getContainer().run(false, true, new NewProjectCreationOperation(fFragmentData, fProjectProvider, null));
84
92
(-)src/org/eclipse/pde/internal/ui/wizards/plugin/PluginContentPage.java (-1 / +2 lines)
Lines 125-131 Link Here
125
125
126
		label = new Label(propertiesGroup, SWT.NONE);
126
		label = new Label(propertiesGroup, SWT.NONE);
127
		label.setText(PDEUIMessages.ContentPage_pprovider);
127
		label.setText(PDEUIMessages.ContentPage_pprovider);
128
		fProviderText = createText(propertiesGroup, propertiesListener, 2);
128
		fProviderCombo = createProviderCombo(propertiesGroup, propertiesListener, 2);
129
129
130
		createExecutionEnvironmentControls(propertiesGroup);
130
		createExecutionEnvironmentControls(propertiesGroup);
131
	}
131
	}
Lines 367-372 Link Here
367
	 * @param settings
367
	 * @param settings
368
	 */
368
	 */
369
	public void saveSettings(IDialogSettings settings) {
369
	public void saveSettings(IDialogSettings settings) {
370
		super.saveSettings(settings);
370
		settings.put(S_GENERATE_ACTIVATOR, !fGenerateActivator.getSelection());
371
		settings.put(S_GENERATE_ACTIVATOR, !fGenerateActivator.getSelection());
371
		if (fUIPlugin.isEnabled()) {
372
		if (fUIPlugin.isEnabled()) {
372
			settings.put(S_UI_PLUGIN, !fUIPlugin.getSelection());
373
			settings.put(S_UI_PLUGIN, !fUIPlugin.getSelection());
(-)src/org/eclipse/pde/internal/ui/wizards/provisioner/p2/ProvisionerMessages.java (-45 / +45 lines)
Lines 1-45 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
2
 * Copyright (c) 2008 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.provisioner.p2;
11
package org.eclipse.pde.internal.ui.wizards.provisioner.p2;
12
12
13
import org.eclipse.osgi.util.NLS;
13
import org.eclipse.osgi.util.NLS;
14
14
15
public class ProvisionerMessages extends NLS {
15
public class ProvisionerMessages extends NLS {
16
	private static final String BUNDLE_NAME = "org.eclipse.pde.internal.ui.wizards.provisioner.p2.ProvisionerMessages"; //$NON-NLS-1$
16
	private static final String BUNDLE_NAME = "org.eclipse.pde.internal.ui.wizards.provisioner.p2.ProvisionerMessages"; //$NON-NLS-1$
17
	public static String P2TargetProvisionerWizard_1;
17
	public static String P2TargetProvisionerWizard_1;
18
	public static String P2TargetProvisionerWizard_10;
18
	public static String P2TargetProvisionerWizard_10;
19
	public static String P2TargetProvisionerWizard_2;
19
	public static String P2TargetProvisionerWizard_2;
20
	public static String P2TargetProvisionerWizard_3;
20
	public static String P2TargetProvisionerWizard_3;
21
	public static String P2TargetProvisionerWizard_7;
21
	public static String P2TargetProvisionerWizard_7;
22
	public static String P2TargetProvisionerWizard_9;
22
	public static String P2TargetProvisionerWizard_9;
23
	public static String P2TargetProvisionerWizardPage_0;
23
	public static String P2TargetProvisionerWizardPage_0;
24
	public static String P2TargetProvisionerWizardPage_11;
24
	public static String P2TargetProvisionerWizardPage_11;
25
	public static String P2TargetProvisionerWizardPage_14;
25
	public static String P2TargetProvisionerWizardPage_14;
26
	public static String P2TargetProvisionerWizardPage_16;
26
	public static String P2TargetProvisionerWizardPage_16;
27
	public static String P2TargetProvisionerWizardPage_17;
27
	public static String P2TargetProvisionerWizardPage_17;
28
	public static String P2TargetProvisionerWizardPage_1;
28
	public static String P2TargetProvisionerWizardPage_1;
29
	public static String P2TargetProvisionerWizardPage_2;
29
	public static String P2TargetProvisionerWizardPage_2;
30
	public static String P2TargetProvisionerWizardPage_3;
30
	public static String P2TargetProvisionerWizardPage_3;
31
	public static String P2TargetProvisionerWizardPage_4;
31
	public static String P2TargetProvisionerWizardPage_4;
32
	public static String P2TargetProvisionerWizardPage_5;
32
	public static String P2TargetProvisionerWizardPage_5;
33
	public static String P2TargetProvisionerWizardPage_6;
33
	public static String P2TargetProvisionerWizardPage_6;
34
	public static String P2TargetProvisionerWizardPage_7;
34
	public static String P2TargetProvisionerWizardPage_7;
35
	public static String P2TargetProvisionerWizardPage_8;
35
	public static String P2TargetProvisionerWizardPage_8;
36
	public static String P2TargetProvisionerWizardPage_9;
36
	public static String P2TargetProvisionerWizardPage_9;
37
	public static String P2TargetProvisionerWizardPage_10;
37
	public static String P2TargetProvisionerWizardPage_10;
38
	static {
38
	static {
39
		// initialize resource bundle
39
		// initialize resource bundle
40
		NLS.initializeMessages(BUNDLE_NAME, ProvisionerMessages.class);
40
		NLS.initializeMessages(BUNDLE_NAME, ProvisionerMessages.class);
41
	}
41
	}
42
42
43
	private ProvisionerMessages() {
43
	private ProvisionerMessages() {
44
	}
44
	}
45
}
45
}
(-)src/org/eclipse/pde/internal/ui/wizards/target/EditTargetDefinitionWizard.java (-102 / +102 lines)
Lines 1-102 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.core.runtime.CoreException;
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.jface.wizard.IWizardPage;
14
import org.eclipse.jface.wizard.IWizardPage;
15
import org.eclipse.jface.wizard.Wizard;
15
import org.eclipse.jface.wizard.Wizard;
16
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
16
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
17
import org.eclipse.pde.internal.core.target.provisional.ITargetPlatformService;
17
import org.eclipse.pde.internal.core.target.provisional.ITargetPlatformService;
18
import org.eclipse.pde.internal.ui.PDEPlugin;
18
import org.eclipse.pde.internal.ui.PDEPlugin;
19
19
20
/**
20
/**
21
 * Wizard to edit a target definition, creates a working copy to edit.  Any changes are
21
 * Wizard to edit a target definition, creates a working copy to edit.  Any changes are
22
 * not saved by this wizard and must be done by the client.  The edited target 
22
 * not saved by this wizard and must be done by the client.  The edited target 
23
 * can be accessed using {@link #getTargetDefinition()}
23
 * can be accessed using {@link #getTargetDefinition()}
24
 */
24
 */
25
public class EditTargetDefinitionWizard extends Wizard {
25
public class EditTargetDefinitionWizard extends Wizard {
26
26
27
	/**
27
	/**
28
	 * The target definition being edited - a copy of the original
28
	 * The target definition being edited - a copy of the original
29
	 */
29
	 */
30
	private ITargetDefinition fDefinition;
30
	private ITargetDefinition fDefinition;
31
31
32
	/**
32
	/**
33
	 * Constructs a wizard to edit the given definition.
33
	 * Constructs a wizard to edit the given definition.
34
	 * 
34
	 * 
35
	 * @param definition target definition being edited
35
	 * @param definition target definition being edited
36
	 * @param createWorkingCopy if true, a copy of the definition will be created to edit, if false the definition will be edited directly 
36
	 * @param createWorkingCopy if true, a copy of the definition will be created to edit, if false the definition will be edited directly 
37
	 */
37
	 */
38
	public EditTargetDefinitionWizard(ITargetDefinition definition, boolean createWorkingCopy) {
38
	public EditTargetDefinitionWizard(ITargetDefinition definition, boolean createWorkingCopy) {
39
		setTargetDefinition(definition, createWorkingCopy);
39
		setTargetDefinition(definition, createWorkingCopy);
40
		setNeedsProgressMonitor(true);
40
		setNeedsProgressMonitor(true);
41
	}
41
	}
42
42
43
	/* (non-Javadoc)
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
44
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
45
	 */
45
	 */
46
	public boolean performFinish() {
46
	public boolean performFinish() {
47
		// Do nothing, edited target is available 
47
		// Do nothing, edited target is available 
48
		return true;
48
		return true;
49
49
50
	}
50
	}
51
51
52
	/* (non-Javadoc)
52
	/* (non-Javadoc)
53
	 * @see org.eclipse.jface.wizard.Wizard#addPages()
53
	 * @see org.eclipse.jface.wizard.Wizard#addPages()
54
	 */
54
	 */
55
	public void addPages() {
55
	public void addPages() {
56
		addPage(new TargetDefinitionContentPage(fDefinition));
56
		addPage(new TargetDefinitionContentPage(fDefinition));
57
	}
57
	}
58
58
59
	/**
59
	/**
60
	 * Sets the target definition to be edited. Will delegate to pages to
60
	 * Sets the target definition to be edited. Will delegate to pages to
61
	 * refresh controls if already created.
61
	 * refresh controls if already created.
62
	 * 
62
	 * 
63
	 * @param definition target definition
63
	 * @param definition target definition
64
	 * @param createWorkingCopy if true, a copy of the definition will be created to edit, if false the definition will be edited directly
64
	 * @param createWorkingCopy if true, a copy of the definition will be created to edit, if false the definition will be edited directly
65
	 */
65
	 */
66
	public void setTargetDefinition(ITargetDefinition definition, boolean createWorkingCopy) {
66
	public void setTargetDefinition(ITargetDefinition definition, boolean createWorkingCopy) {
67
		ITargetDefinition workingCopy = null;
67
		ITargetDefinition workingCopy = null;
68
		if (createWorkingCopy) {
68
		if (createWorkingCopy) {
69
			try {
69
			try {
70
				ITargetPlatformService service = TargetDefinitionPage.getTargetService();
70
				ITargetPlatformService service = TargetDefinitionPage.getTargetService();
71
				if (service != null) {
71
				if (service != null) {
72
					if (definition.getHandle().exists()) {
72
					if (definition.getHandle().exists()) {
73
						// Make a copy from the handle
73
						// Make a copy from the handle
74
						workingCopy = definition.getHandle().getTargetDefinition();
74
						workingCopy = definition.getHandle().getTargetDefinition();
75
					} else {
75
					} else {
76
						// If no handle use the service to create a new one
76
						// If no handle use the service to create a new one
77
						workingCopy = service.newTarget();
77
						workingCopy = service.newTarget();
78
					}
78
					}
79
					service.copyTargetDefinition(definition, workingCopy);
79
					service.copyTargetDefinition(definition, workingCopy);
80
				}
80
				}
81
			} catch (CoreException e) {
81
			} catch (CoreException e) {
82
				PDEPlugin.log(e);
82
				PDEPlugin.log(e);
83
			}
83
			}
84
		} else {
84
		} else {
85
			workingCopy = definition;
85
			workingCopy = definition;
86
		}
86
		}
87
		fDefinition = workingCopy;
87
		fDefinition = workingCopy;
88
		IWizardPage[] pages = getPages();
88
		IWizardPage[] pages = getPages();
89
		for (int i = 0; i < pages.length; i++) {
89
		for (int i = 0; i < pages.length; i++) {
90
			((TargetDefinitionPage) pages[i]).targetChanged(workingCopy);
90
			((TargetDefinitionPage) pages[i]).targetChanged(workingCopy);
91
		}
91
		}
92
	}
92
	}
93
93
94
	/**
94
	/**
95
	 * Returns the target definition being edited
95
	 * Returns the target definition being edited
96
	 * 
96
	 * 
97
	 * @return target definition
97
	 * @return target definition
98
	 */
98
	 */
99
	public ITargetDefinition getTargetDefinition() {
99
	public ITargetDefinition getTargetDefinition() {
100
		return fDefinition;
100
		return fDefinition;
101
	}
101
	}
102
}
102
}
(-)src/org/eclipse/pde/internal/ui/wizards/target/EditTargetNode.java (-75 / +75 lines)
Lines 1-75 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.jface.wizard.IWizard;
13
import org.eclipse.jface.wizard.IWizard;
14
import org.eclipse.jface.wizard.IWizardNode;
14
import org.eclipse.jface.wizard.IWizardNode;
15
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
15
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
16
import org.eclipse.pde.internal.ui.PDEUIMessages;
16
import org.eclipse.pde.internal.ui.PDEUIMessages;
17
import org.eclipse.swt.graphics.Point;
17
import org.eclipse.swt.graphics.Point;
18
18
19
/**
19
/**
20
 * Embedded wizard to edit a target
20
 * Embedded wizard to edit a target
21
 */
21
 */
22
public class EditTargetNode implements IWizardNode {
22
public class EditTargetNode implements IWizardNode {
23
23
24
	private EditTargetDefinitionWizard fWizard;
24
	private EditTargetDefinitionWizard fWizard;
25
	private ITargetDefinition fDefinition;
25
	private ITargetDefinition fDefinition;
26
26
27
	/* (non-Javadoc)
27
	/* (non-Javadoc)
28
	 * @see org.eclipse.jface.wizard.IWizardNode#dispose()
28
	 * @see org.eclipse.jface.wizard.IWizardNode#dispose()
29
	 */
29
	 */
30
	public void dispose() {
30
	public void dispose() {
31
		if (fWizard != null) {
31
		if (fWizard != null) {
32
			fWizard.dispose();
32
			fWizard.dispose();
33
			fWizard = null;
33
			fWizard = null;
34
			fDefinition = null;
34
			fDefinition = null;
35
		}
35
		}
36
	}
36
	}
37
37
38
	/* (non-Javadoc)
38
	/* (non-Javadoc)
39
	 * @see org.eclipse.jface.wizard.IWizardNode#getExtent()
39
	 * @see org.eclipse.jface.wizard.IWizardNode#getExtent()
40
	 */
40
	 */
41
	public Point getExtent() {
41
	public Point getExtent() {
42
		return new Point(-1, -1);
42
		return new Point(-1, -1);
43
	}
43
	}
44
44
45
	/* (non-Javadoc)
45
	/* (non-Javadoc)
46
	 * @see org.eclipse.jface.wizard.IWizardNode#getWizard()
46
	 * @see org.eclipse.jface.wizard.IWizardNode#getWizard()
47
	 */
47
	 */
48
	public IWizard getWizard() {
48
	public IWizard getWizard() {
49
		if (fWizard == null) {
49
		if (fWizard == null) {
50
			fWizard = new EditTargetDefinitionWizard(fDefinition, false);
50
			fWizard = new EditTargetDefinitionWizard(fDefinition, false);
51
			fWizard.setWindowTitle(PDEUIMessages.EditTargetNode_0);
51
			fWizard.setWindowTitle(PDEUIMessages.EditTargetNode_0);
52
		}
52
		}
53
		return fWizard;
53
		return fWizard;
54
	}
54
	}
55
55
56
	/* (non-Javadoc)
56
	/* (non-Javadoc)
57
	 * @see org.eclipse.jface.wizard.IWizardNode#isContentCreated()
57
	 * @see org.eclipse.jface.wizard.IWizardNode#isContentCreated()
58
	 */
58
	 */
59
	public boolean isContentCreated() {
59
	public boolean isContentCreated() {
60
		return fWizard != null;
60
		return fWizard != null;
61
	}
61
	}
62
62
63
	/**
63
	/**
64
	 * Sets the target being edited.
64
	 * Sets the target being edited.
65
	 * 
65
	 * 
66
	 * @param definition
66
	 * @param definition
67
	 */
67
	 */
68
	public void setTargetDefinition(ITargetDefinition definition) {
68
	public void setTargetDefinition(ITargetDefinition definition) {
69
		fDefinition = definition;
69
		fDefinition = definition;
70
		if (fWizard != null) {
70
		if (fWizard != null) {
71
			fWizard.setTargetDefinition(definition, false);
71
			fWizard.setTargetDefinition(definition, false);
72
		}
72
		}
73
	}
73
	}
74
74
75
}
75
}

Return to bug 269417