Skip to content

Commit 7a6a70c

Browse files
nburnwal09HannesWell
authored andcommitted
Added support to add sources in the Feature Editor
1 parent 630d0d7 commit 7a6a70c

6 files changed

Lines changed: 43 additions & 1 deletion

File tree

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/FeatureErrorReporter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class FeatureErrorReporter extends ManifestErrorReporter {
4040

4141
static HashSet<String> attrs = new HashSet<>();
4242

43-
static String[] attrNames = {"id", "version", "label", "provider-name", "image", "os", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
43+
static String[] attrNames = { "id", "version", "include-sources", "label", "provider-name", "image", "os", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
4444
"ws", "arch", "nl", "colocation-affinity", "primary", "exclusive", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
4545
"plugin", "application", "license-feature", "license-feature-version"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
4646

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/feature/Feature.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class Feature extends VersionableObject implements IFeature {
5858
private String fCopyright;
5959
private String fLicenseFeatureID;
6060
private String fLicenseFeatureVersion;
61+
private boolean fIncludeSources;
6162

6263
@Override
6364
public void addPlugins(IFeaturePlugin[] newPlugins) throws CoreException {
@@ -213,6 +214,7 @@ protected void parse(Node node) {
213214
fApplication = getNodeAttribute(node, "application"); //$NON-NLS-1$
214215
fPrimary = getBooleanAttribute(node, "primary"); //$NON-NLS-1$
215216
fExclusive = getBooleanAttribute(node, "exclusive"); //$NON-NLS-1$
217+
fIncludeSources = getBooleanAttribute(node, "include-sources"); //$NON-NLS-1$
216218
NodeList children = node.getChildNodes();
217219
fValid = true;
218220

@@ -372,6 +374,11 @@ public String getApplication() {
372374
return fApplication;
373375
}
374376

377+
@Override
378+
public boolean isIncludingSources() {
379+
return fIncludeSources;
380+
}
381+
375382
@Override
376383
public void setOS(String os) throws CoreException {
377384
ensureModelEditable();
@@ -442,6 +449,13 @@ public void setApplication(String newValue) throws CoreException {
442449
firePropertyChanged(P_APPLICATION, oldValue, newValue);
443450
}
444451

452+
@Override
453+
public void setIncludingSources(boolean includesSources) {
454+
Object oldValue = fIncludeSources;
455+
this.fIncludeSources = includesSources;
456+
firePropertyChanged(this, P_SOURCES, oldValue, includesSources);
457+
}
458+
445459
@Override
446460
public void setProviderName(String providerName) throws CoreException {
447461
ensureModelEditable();
@@ -570,6 +584,9 @@ public void restoreProperty(String name, Object oldValue, Object newValue) throw
570584
case P_IMAGE:
571585
setImageName((String) newValue);
572586
break;
587+
case P_SOURCES:
588+
setIncludingSources(newValue != null ? ((Boolean) newValue).booleanValue() : false);
589+
break;
573590
default:
574591
super.restoreProperty(name, oldValue, newValue);
575592
break;
@@ -581,6 +598,7 @@ public void reset() {
581598
super.reset();
582599
fData.clear();
583600
fPlugins.clear();
601+
fIncludeSources = false;
584602
fImports.clear();
585603
fChildren.clear();
586604
fUrl = null;
@@ -654,6 +672,8 @@ public void write(String indent, PrintWriter writer) {
654672
writeIfDefined(indenta, writer, "id", getId()); //$NON-NLS-1$
655673
writeIfDefined(indenta, writer, "label", getWritableString(getLabel())); //$NON-NLS-1$
656674
writeIfDefined(indenta, writer, "version", getVersion()); //$NON-NLS-1$
675+
writeIfDefined(indenta, writer, "include-sources", //$NON-NLS-1$
676+
isIncludingSources() ? String.valueOf(isIncludingSources()) : null);
657677
writeIfDefined(indenta, writer, "provider-name", //$NON-NLS-1$
658678
getWritableString(fProviderName));
659679
writeIfDefined(indenta, writer, "plugin", //$NON-NLS-1$

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ifeature/IFeature.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public interface IFeature extends IFeatureObject, IVersionable, IEnvironment {
5959

6060
public static final String P_COLLOCATION_AFFINITY = "colocation-affinity"; //$NON-NLS-1$
6161
public static final String P_APPLICATION = "application"; //$NON-NLS-1$
62+
public static final String P_SOURCES = "include-sources"; //$NON-NLS-1$
6263

6364
public static final int INFO_DESCRIPTION = 0;
6465
public static final int INFO_COPYRIGHT = 1;
@@ -257,6 +258,10 @@ public interface IFeature extends IFeatureObject, IVersionable, IEnvironment {
257258
void setApplication(String value) throws CoreException;
258259

259260
boolean isValid();
261+
262+
public boolean isIncludingSources();
263+
264+
void setIncludingSources(boolean b);
260265

261266
public void swap(IFeatureChild feature1, IFeatureChild feature2);
262267
}

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,6 +2233,8 @@ public class PDEUIMessages extends NLS {
22332233
public static String FeatureSection_addRequired;
22342234
public static String FeatureSection_toggleRoot;
22352235

2236+
public static String FeatureSpecSection_addSources0;
2237+
22362238
public static String ImportPackageSection_desc;
22372239
public static String ImportPackageSection_descFragment;
22382240
public static String ExportPackageSection_desc;

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/feature/FeatureSpecSection.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@
4242
import org.eclipse.pde.internal.ui.parts.FormEntry;
4343
import org.eclipse.pde.internal.ui.util.SWTUtil;
4444
import org.eclipse.pde.internal.ui.wizards.plugin.NewPluginProjectWizard;
45+
import org.eclipse.swt.SWT;
4546
import org.eclipse.swt.dnd.Clipboard;
4647
import org.eclipse.swt.dnd.RTFTransfer;
4748
import org.eclipse.swt.dnd.TextTransfer;
4849
import org.eclipse.swt.dnd.Transfer;
4950
import org.eclipse.swt.dnd.TransferData;
51+
import org.eclipse.swt.events.SelectionListener;
5052
import org.eclipse.swt.layout.GridData;
53+
import org.eclipse.swt.widgets.Button;
5154
import org.eclipse.swt.widgets.Composite;
5255
import org.eclipse.ui.forms.events.HyperlinkEvent;
5356
import org.eclipse.ui.forms.widgets.FormToolkit;
@@ -75,6 +78,8 @@ public class FeatureSpecSection extends PDESection {
7578

7679
private boolean fPatch = false;
7780

81+
private Button fIncludesSourcesCheckbox;
82+
7883
public FeatureSpecSection(FeatureFormPage page, Composite parent) {
7984
super(page, parent, Section.DESCRIPTION);
8085
getSection().setText(PDEUIMessages.FeatureEditor_SpecSection_title);
@@ -380,6 +385,14 @@ public void textValueChanged(FormEntry text) {
380385
}
381386
});
382387

388+
fIncludesSourcesCheckbox = toolkit.createButton(container, PDEUIMessages.FeatureSpecSection_addSources0, SWT.CHECK);
389+
fIncludesSourcesCheckbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
390+
391+
fIncludesSourcesCheckbox.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
392+
boolean isSelected = fIncludesSourcesCheckbox.getSelection();
393+
feature.setIncludingSources(isSelected);
394+
}));
395+
383396
GridData gd = (GridData) fIdText.getText().getLayoutData();
384397
gd.widthHint = 150;
385398

@@ -503,6 +516,7 @@ public void refresh() {
503516
setIfDefined(fTitleText, feature.getLabel());
504517
getPage().getManagedForm().getForm().setText(model.getResourceString(feature.getLabel()));
505518
setIfDefined(fVersionText, feature.getVersion());
519+
fIncludesSourcesCheckbox.setSelection(feature.isIncludingSources());
506520
setIfDefined(fProviderText, feature.getProviderName());
507521
setIfDefined(fPluginText, feature.getPlugin());
508522
if (isPatch()) {

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,7 @@ FeatureImportWizard_messages_updating = Updating...
12561256
FeatureImportWizard_title = Import Features
12571257
FeatureSection_addRequired=Add Required
12581258
FeatureSection_toggleRoot=Toggle Install Mode
1259+
FeatureSpecSection_addSources0=Include sources automatically
12591260
FeatureImportWizard_noToAll = No to A&ll
12601261
FeatureImportWizard_messages_noFeatures = No features found. Ensure that the chosen directory contains 'features' folder.
12611262
FeatureImportWizard_messages_title = Feature Import

0 commit comments

Comments
 (0)