Lines 10-36
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.pde.internal.ui.wizards.exports; |
11 |
package org.eclipse.pde.internal.ui.wizards.exports; |
12 |
|
12 |
|
|
|
13 |
import java.io.File; |
14 |
import java.net.URI; |
13 |
import org.eclipse.jface.dialogs.IDialogSettings; |
15 |
import org.eclipse.jface.dialogs.IDialogSettings; |
14 |
import org.eclipse.pde.internal.core.FeatureModelManager; |
16 |
import org.eclipse.pde.internal.core.FeatureModelManager; |
15 |
import org.eclipse.pde.internal.core.PDECore; |
17 |
import org.eclipse.pde.internal.core.PDECore; |
16 |
import org.eclipse.pde.internal.core.ifeature.IFeatureModel; |
18 |
import org.eclipse.pde.internal.core.ifeature.IFeatureModel; |
17 |
import org.eclipse.pde.internal.ui.PDEUIMessages; |
19 |
import org.eclipse.pde.internal.ui.*; |
18 |
import org.eclipse.pde.internal.ui.SWTFactory; |
20 |
import org.eclipse.pde.internal.ui.util.SWTUtil; |
19 |
import org.eclipse.swt.SWT; |
21 |
import org.eclipse.swt.SWT; |
20 |
import org.eclipse.swt.events.SelectionAdapter; |
22 |
import org.eclipse.swt.events.SelectionAdapter; |
21 |
import org.eclipse.swt.events.SelectionEvent; |
23 |
import org.eclipse.swt.events.SelectionEvent; |
22 |
import org.eclipse.swt.layout.GridData; |
24 |
import org.eclipse.swt.layout.GridData; |
23 |
import org.eclipse.swt.widgets.Button; |
25 |
import org.eclipse.swt.layout.GridLayout; |
24 |
import org.eclipse.swt.widgets.Composite; |
26 |
import org.eclipse.swt.widgets.*; |
25 |
|
27 |
|
26 |
public class FeatureOptionsTab extends ExportOptionsTab { |
28 |
public class FeatureOptionsTab extends ExportOptionsTab { |
27 |
|
29 |
|
28 |
private static final String S_MULTI_PLATFORM = "multiplatform"; //$NON-NLS-1$ |
30 |
private static final String S_MULTI_PLATFORM = "multiplatform"; //$NON-NLS-1$ |
29 |
private static final String S_EXPORT_METADATA = "p2metadata"; //$NON-NLS-1$ |
31 |
private static final String S_EXPORT_METADATA = "p2metadata"; //$NON-NLS-1$ |
|
|
32 |
private static final String S_CATEGORY_FILE = "category_file"; //$NON-NLS-1$ |
33 |
private static final String S_CREATE_CATEGORIES = "create_categories"; //$NON-NLS-1$ |
30 |
|
34 |
|
31 |
private Button fMultiPlatform; |
35 |
private Button fMultiPlatform; |
32 |
private Button fExportMetadata; |
36 |
private Button fExportMetadata; |
33 |
|
37 |
|
|
|
38 |
private Button fCategoryButton; |
39 |
private Combo fCategoryCombo; |
40 |
private Button fCategoryBrowse; |
41 |
|
34 |
public FeatureOptionsTab(FeatureExportWizardPage page) { |
42 |
public FeatureOptionsTab(FeatureExportWizardPage page) { |
35 |
super(page); |
43 |
super(page); |
36 |
} |
44 |
} |
Lines 39-44
Link Here
|
39 |
fJarButton.addSelectionListener(new SelectionAdapter() { |
47 |
fJarButton.addSelectionListener(new SelectionAdapter() { |
40 |
public void widgetSelected(SelectionEvent e) { |
48 |
public void widgetSelected(SelectionEvent e) { |
41 |
fExportMetadata.setEnabled(fJarButton.getSelection()); |
49 |
fExportMetadata.setEnabled(fJarButton.getSelection()); |
|
|
50 |
fCategoryButton.setEnabled(fExportMetadata.getSelection() && fJarButton.getSelection()); |
51 |
updateCategoryGeneration(); |
42 |
} |
52 |
} |
43 |
}); |
53 |
}); |
44 |
fExportMetadata = SWTFactory.createCheckButton(comp, PDEUIMessages.ExportWizard_includesMetadata, null, false, 1); |
54 |
fExportMetadata = SWTFactory.createCheckButton(comp, PDEUIMessages.ExportWizard_includesMetadata, null, false, 1); |
Lines 51-56
Link Here
|
51 |
fMultiPlatform = new Button(comp, SWT.CHECK); |
61 |
fMultiPlatform = new Button(comp, SWT.CHECK); |
52 |
fMultiPlatform.setText(PDEUIMessages.ExportWizard_multi_platform); |
62 |
fMultiPlatform.setText(PDEUIMessages.ExportWizard_multi_platform); |
53 |
} |
63 |
} |
|
|
64 |
Composite categoryComposite = new Composite(comp, SWT.NONE); |
65 |
|
66 |
data = new GridData(SWT.FILL, SWT.FILL, true, false); |
67 |
data.horizontalIndent = 20; |
68 |
categoryComposite.setLayoutData(data); |
69 |
GridLayout layout = new GridLayout(3, false); |
70 |
layout.marginRight = 0; |
71 |
layout.marginLeft = 0; |
72 |
layout.marginWidth = 0; |
73 |
layout.marginHeight = 0; |
74 |
layout.marginBottom = 0; |
75 |
layout.marginTop = 0; |
76 |
categoryComposite.setLayout(layout); |
77 |
|
78 |
fCategoryButton = new Button(categoryComposite, SWT.CHECK); |
79 |
fCategoryButton.setText(PDEUIMessages.ExportWizard_generateCategories + ":"); //$NON-NLS-1$ |
80 |
fCategoryButton.setSelection(true); |
81 |
|
82 |
fCategoryCombo = new Combo(categoryComposite, SWT.NONE); |
83 |
fCategoryCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
84 |
|
85 |
fCategoryBrowse = new Button(categoryComposite, SWT.PUSH); |
86 |
fCategoryBrowse.setText(PDEUIMessages.ExportWizard_browse); |
87 |
fCategoryBrowse.setLayoutData(new GridData()); |
88 |
SWTUtil.setButtonDimensionHint(fCategoryBrowse); |
54 |
|
89 |
|
55 |
} |
90 |
} |
56 |
|
91 |
|
Lines 65-70
Link Here
|
65 |
return fExportMetadata.isEnabled() && fExportMetadata.getSelection(); |
100 |
return fExportMetadata.isEnabled() && fExportMetadata.getSelection(); |
66 |
} |
101 |
} |
67 |
|
102 |
|
|
|
103 |
protected URI getCategoryDefinition() { |
104 |
if (doExportCategories()) { |
105 |
File f = new File(fCategoryCombo.getText().trim()); |
106 |
if (f.exists()) |
107 |
return f.toURI(); |
108 |
} |
109 |
return null; |
110 |
} |
111 |
|
112 |
/** |
113 |
* @return whether to publish categories when exporting |
114 |
*/ |
115 |
private boolean doExportCategories() { |
116 |
return doExportMetadata() && fCategoryButton.getSelection() && fCategoryCombo.getText().trim().length() > 0; |
117 |
} |
118 |
|
68 |
protected void initialize(IDialogSettings settings) { |
119 |
protected void initialize(IDialogSettings settings) { |
69 |
super.initialize(settings); |
120 |
super.initialize(settings); |
70 |
if (fMultiPlatform != null) { |
121 |
if (fMultiPlatform != null) { |
Lines 74-79
Link Here
|
74 |
String selected = settings.get(S_EXPORT_METADATA); |
125 |
String selected = settings.get(S_EXPORT_METADATA); |
75 |
fExportMetadata.setSelection(selected == null ? true : Boolean.TRUE.toString().equals(selected)); |
126 |
fExportMetadata.setSelection(selected == null ? true : Boolean.TRUE.toString().equals(selected)); |
76 |
fExportMetadata.setEnabled(fJarButton.getSelection()); |
127 |
fExportMetadata.setEnabled(fJarButton.getSelection()); |
|
|
128 |
selected = settings.get(S_CREATE_CATEGORIES); |
129 |
|
130 |
fCategoryButton.setEnabled(fExportMetadata.getSelection() && fJarButton.getSelection()); |
131 |
fCategoryButton.setSelection(selected == null ? true : Boolean.TRUE.toString().equals(selected)); |
132 |
if (settings.get(S_CATEGORY_FILE) != null) |
133 |
fCategoryCombo.setText(settings.get(S_CATEGORY_FILE)); |
134 |
updateCategoryGeneration(); |
77 |
} |
135 |
} |
78 |
|
136 |
|
79 |
protected void saveSettings(IDialogSettings settings) { |
137 |
protected void saveSettings(IDialogSettings settings) { |
Lines 82-87
Link Here
|
82 |
settings.put(S_MULTI_PLATFORM, fMultiPlatform.getSelection()); |
140 |
settings.put(S_MULTI_PLATFORM, fMultiPlatform.getSelection()); |
83 |
} |
141 |
} |
84 |
settings.put(S_EXPORT_METADATA, doExportMetadata()); |
142 |
settings.put(S_EXPORT_METADATA, doExportMetadata()); |
|
|
143 |
settings.put(S_CREATE_CATEGORIES, fCategoryButton.getSelection()); |
144 |
settings.put(S_CATEGORY_FILE, fCategoryCombo.getText()); |
85 |
} |
145 |
} |
86 |
|
146 |
|
87 |
protected void hookListeners() { |
147 |
protected void hookListeners() { |
Lines 93-98
Link Here
|
93 |
} |
153 |
} |
94 |
}); |
154 |
}); |
95 |
} |
155 |
} |
|
|
156 |
|
157 |
fExportMetadata.addSelectionListener(new SelectionAdapter() { |
158 |
public void widgetSelected(SelectionEvent e) { |
159 |
fCategoryButton.setEnabled(fExportMetadata.getSelection() && fJarButton.getSelection()); |
160 |
updateCategoryGeneration(); |
161 |
} |
162 |
}); |
163 |
fCategoryButton.addSelectionListener(new SelectionAdapter() { |
164 |
public void widgetSelected(SelectionEvent e) { |
165 |
updateCategoryGeneration(); |
166 |
} |
167 |
}); |
168 |
|
169 |
fCategoryBrowse.addSelectionListener(new SelectionAdapter() { |
170 |
public void widgetSelected(SelectionEvent e) { |
171 |
openFile(fCategoryCombo, new String[] {"*.xml", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$ |
172 |
} |
173 |
}); |
174 |
} |
175 |
|
176 |
protected void updateCategoryGeneration() { |
177 |
fCategoryBrowse.setEnabled(fExportMetadata.getSelection() && fCategoryButton.getSelection() && fJarButton.getSelection()); |
178 |
fCategoryCombo.setEnabled(fExportMetadata.getSelection() && fCategoryButton.getSelection() && fJarButton.getSelection()); |
96 |
} |
179 |
} |
97 |
|
180 |
|
98 |
protected boolean doMultiplePlatform() { |
181 |
protected boolean doMultiplePlatform() { |
Lines 102-107
Link Here
|
102 |
protected void setEnabledForInstall(boolean enabled) { |
185 |
protected void setEnabledForInstall(boolean enabled) { |
103 |
super.setEnabledForInstall(enabled); |
186 |
super.setEnabledForInstall(enabled); |
104 |
fExportMetadata.setEnabled(enabled); |
187 |
fExportMetadata.setEnabled(enabled); |
|
|
188 |
fCategoryButton.setEnabled(enabled); |
189 |
fCategoryCombo.setEnabled(enabled); |
190 |
fCategoryBrowse.setEnabled(enabled); |
191 |
} |
192 |
|
193 |
protected void openFile(Combo combo, String[] filter) { |
194 |
FileDialog dialog = new FileDialog(fPage.getShell(), SWT.OPEN); |
195 |
String path = combo.getText(); |
196 |
if (path.trim().length() == 0) |
197 |
path = PDEPlugin.getWorkspace().getRoot().getLocation().toString(); |
198 |
dialog.setFilterExtensions(filter); |
199 |
dialog.setFileName(path); |
200 |
String res = dialog.open(); |
201 |
if (res != null) { |
202 |
if (combo.indexOf(res) == -1) |
203 |
combo.add(res, 0); |
204 |
combo.setText(res); |
205 |
} |
105 |
} |
206 |
} |
106 |
|
207 |
|
107 |
} |
208 |
} |