Skip to content

Commit fd0809d

Browse files
committed
Added support to add sources in the Feature Editor
1 parent 5247598 commit fd0809d

7 files changed

Lines changed: 50 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", "add-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: 19 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 fSources;
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+
fSources = getBooleanAttribute(node, "add-sources"); //$NON-NLS-1$
216218
NodeList children = node.getChildNodes();
217219
fValid = true;
218220

@@ -570,6 +572,9 @@ public void restoreProperty(String name, Object oldValue, Object newValue) throw
570572
case P_IMAGE:
571573
setImageName((String) newValue);
572574
break;
575+
case P_SOURCES:
576+
setfSources(newValue != null ? ((Boolean) newValue).booleanValue() : false);
577+
break;
573578
default:
574579
super.restoreProperty(name, oldValue, newValue);
575580
break;
@@ -581,6 +586,7 @@ public void reset() {
581586
super.reset();
582587
fData.clear();
583588
fPlugins.clear();
589+
fSources = false;
584590
fImports.clear();
585591
fChildren.clear();
586592
fUrl = null;
@@ -654,6 +660,7 @@ public void write(String indent, PrintWriter writer) {
654660
writeIfDefined(indenta, writer, "id", getId()); //$NON-NLS-1$
655661
writeIfDefined(indenta, writer, "label", getWritableString(getLabel())); //$NON-NLS-1$
656662
writeIfDefined(indenta, writer, "version", getVersion()); //$NON-NLS-1$
663+
writeIfDefined(indenta, writer, "add-sources", String.valueOf(isfSources())); //$NON-NLS-1$ )
657664
writeIfDefined(indenta, writer, "provider-name", //$NON-NLS-1$
658665
getWritableString(fProviderName));
659666
writeIfDefined(indenta, writer, "plugin", //$NON-NLS-1$
@@ -772,4 +779,16 @@ public String toString() {
772779
return getId() + " (" + getVersion() + ")"; //$NON-NLS-1$//$NON-NLS-2$
773780
}
774781

782+
@Override
783+
public boolean isfSources() {
784+
return fSources;
785+
}
786+
787+
@Override
788+
public void setfSources(boolean b) {
789+
Object oldValue = fSources;
790+
this.fSources = b;
791+
firePropertyChanged(this, "add-sources", oldValue, b); //$NON-NLS-1$
792+
}
793+
775794
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public interface IFeature extends IFeatureObject, IVersionable, IEnvironment {
6363
public static final int INFO_DESCRIPTION = 0;
6464
public static final int INFO_COPYRIGHT = 1;
6565
public static final int INFO_LICENSE = 2;
66+
67+
public static final String P_SOURCES = "false"; //$NON-NLS-1$
6668

6769
static final String[] INFO_TAGS = {"description", "copyright", "license"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
6870

@@ -257,6 +259,10 @@ public interface IFeature extends IFeatureObject, IVersionable, IEnvironment {
257259
void setApplication(String value) throws CoreException;
258260

259261
boolean isValid();
262+
263+
public boolean isfSources();
264+
265+
void setfSources(boolean b);
260266

261267
public void swap(IFeatureChild feature1, IFeatureChild feature2);
262268
}

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
@@ -2229,6 +2229,8 @@ public class PDEUIMessages extends NLS {
22292229
public static String FeatureSection_addRequired;
22302230
public static String FeatureSection_toggleRoot;
22312231

2232+
public static String FeatureSpecSection_addSources0;
2233+
22322234
public static String ImportPackageSection_desc;
22332235
public static String ImportPackageSection_descFragment;
22342236
public static String ExportPackageSection_desc;

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,16 @@
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.SelectionAdapter;
52+
import org.eclipse.swt.events.SelectionEvent;
5053
import org.eclipse.swt.layout.GridData;
54+
import org.eclipse.swt.widgets.Button;
5155
import org.eclipse.swt.widgets.Composite;
5256
import org.eclipse.ui.forms.events.HyperlinkEvent;
5357
import org.eclipse.ui.forms.widgets.FormToolkit;
@@ -75,6 +79,8 @@ public class FeatureSpecSection extends PDESection {
7579

7680
private boolean fPatch = false;
7781

82+
private Button fSourcesCheckbox;
83+
7884
public FeatureSpecSection(FeatureFormPage page, Composite parent) {
7985
super(page, parent, Section.DESCRIPTION);
8086
getSection().setText(PDEUIMessages.FeatureEditor_SpecSection_title);
@@ -380,6 +386,18 @@ public void textValueChanged(FormEntry text) {
380386
}
381387
});
382388

389+
fSourcesCheckbox = toolkit.createButton(container, PDEUIMessages.FeatureSpecSection_addSources0, SWT.CHECK);
390+
fSourcesCheckbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
391+
fSourcesCheckbox.addSelectionListener(new SelectionAdapter() {
392+
@Override
393+
public void widgetSelected(SelectionEvent e) {
394+
boolean isSelected = fSourcesCheckbox.getSelection();
395+
IFeatureModel model = (IFeatureModel) getPage().getModel();
396+
IFeature feature = model.getFeature();
397+
feature.setfSources(isSelected);
398+
}
399+
});
400+
383401
GridData gd = (GridData) fIdText.getText().getLayoutData();
384402
gd.widthHint = 150;
385403

@@ -495,6 +513,7 @@ private void setIfDefined(FormEntry formText, String value) {
495513
}
496514
}
497515

516+
498517
@Override
499518
public void refresh() {
500519
IFeatureModel model = (IFeatureModel) getPage().getModel();
@@ -503,6 +522,7 @@ public void refresh() {
503522
setIfDefined(fTitleText, feature.getLabel());
504523
getPage().getManagedForm().getForm().setText(model.getResourceString(feature.getLabel()));
505524
setIfDefined(fVersionText, feature.getVersion());
525+
fSourcesCheckbox.setSelection(feature.isfSources());
506526
setIfDefined(fProviderText, feature.getProviderName());
507527
setIfDefined(fPluginText, feature.getPlugin());
508528
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
@@ -1255,6 +1255,7 @@ FeatureImportWizard_messages_updating = Updating...
12551255
FeatureImportWizard_title = Import Features
12561256
FeatureSection_addRequired=Add Required
12571257
FeatureSection_toggleRoot=Toggle Install Mode
1258+
FeatureSpecSection_addSources0=Add sources automatically
12581259
FeatureImportWizard_noToAll = No to A&ll
12591260
FeatureImportWizard_messages_noFeatures = No features found. Ensure that the chosen directory contains 'features' folder.
12601261
FeatureImportWizard_messages_title = Feature Import

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/feature/AbstractCreateFeatureOperation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ protected IFile createFeature() throws CoreException {
171171
feature.setLabel(fFeatureData.name);
172172
feature.setId(fFeatureData.id);
173173
feature.setVersion(fFeatureData.version);
174+
feature.setfSources(false);
174175
feature.setProviderName(fFeatureData.provider);
175176
if (fFeatureData.hasCustomHandler()) {
176177
feature.setInstallHandler(model.getFactory().createInstallHandler());

0 commit comments

Comments
 (0)