Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions biz.aQute.bnd.pde/test/test/LaunchToBndrunTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,9 @@ void runChecks(BndEditModel model) {
softly.assertThat(model.getEE())
.as("ee")
.isEqualTo(EE.JavaSE_11);

softly.assertThat(model.getRunEE())
.as("ee")
.isEqualTo(EE.JavaSE_11.getEEName());
}
}
44 changes: 36 additions & 8 deletions biz.aQute.bndlib/src/aQute/bnd/build/model/BndEditModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
import aQute.bnd.build.model.conversions.Converter;
import aQute.bnd.build.model.conversions.DefaultBooleanFormatter;
import aQute.bnd.build.model.conversions.DefaultFormatter;
import aQute.bnd.build.model.conversions.EEConverter;
import aQute.bnd.build.model.conversions.EEFormatter;
import aQute.bnd.build.model.conversions.HeaderClauseFormatter;
import aQute.bnd.build.model.conversions.HeaderClauseListConverter;
import aQute.bnd.build.model.conversions.MapFormatter;
Expand Down Expand Up @@ -224,7 +222,6 @@ public ImportPattern error(
private final static Converter<Map<String, String>, String> propertiesConverter = new PropertiesConverter();

private final static Converter<List<Requirement>, String> requirementListConverter = new RequirementListConverter();
private final static Converter<EE, String> eeConverter = new EEConverter();

// Converter<ResolveMode, String> resolveModeConverter =
// EnumConverter.create(ResolveMode.class, ResolveMode.manual);
Expand Down Expand Up @@ -253,7 +250,6 @@ public ImportPattern error(
private final static Converter<String, Collection<? extends HeaderClause>> standaloneLinkListFormatter = new CollectionFormatter<>(
LIST_SEPARATOR, new HeaderClauseFormatter(), "");

private final static Converter<String, EE> eeFormatter = new EEFormatter();
private final static Converter<String, Collection<? extends String>> runReposFormatter = new CollectionFormatter<>(
LIST_SEPARATOR, Constants.EMPTY_HEADER);

Expand Down Expand Up @@ -307,7 +303,7 @@ public ImportPattern error(
// converters.put(BndConstants.RUNVMARGS, stringConverter);
converters.put(Constants.TESTCASES, listConverter);
converters.put(Constants.RUNREQUIRES, requirementListConverter);
converters.put(Constants.RUNEE, eeConverter);
converters.put(Constants.RUNEE, stringConverter);
converters.put(Constants.RUNREPOS, listConverter);
// converters.put(BndConstants.RESOLVE_MODE, resolveModeConverter);
converters.put(Constants.BUNDLE_BLUEPRINT, headerClauseListConverter);
Expand Down Expand Up @@ -349,7 +345,7 @@ public ImportPattern error(
// formatters.put(BndConstants.TESTSUITES, stringListFormatter);
formatters.put(Constants.TESTCASES, stringListFormatter);
formatters.put(Constants.RUNREQUIRES, requirementListFormatter);
formatters.put(Constants.RUNEE, eeFormatter);
formatters.put(Constants.RUNEE, newlineEscapeFormatter);
formatters.put(Constants.RUNREPOS, runReposFormatter);
// formatters.put(BndConstants.RESOLVE_MODE, resolveModeFormatter);
formatters.put(Constants.BUNDLE_BLUEPRINT, headerClauseListFormatter);
Expand Down Expand Up @@ -1174,13 +1170,45 @@ public String getRunFw() {
return doGetObject(Constants.RUNFW, stringConverter);
}

/**
* @return the an EE from the known enum values. If null, callers should
* call {@link #getRunEE()} too for the String value, which could be
* for newer JDKs which are not (yet) in the enum.
*/
public EE getEE() {
return doGetObject(Constants.RUNEE, eeConverter);
String old = doGetObject(Constants.RUNEE, stringConverter);
if (old == null) {
return null;
}
return EE.parse(old);

}

public void setEE(EE ee) {
EE old = getEE();
doSetObject(Constants.RUNEE, old, ee, eeFormatter);
String oldStr = old == null ? null : old.getEEName();
String newStr = ee == null ? null : ee.getEEName();
doSetObject(Constants.RUNEE, oldStr, newStr, newlineEscapeFormatter);
}

/**
* @return the an EE as a String. This could also return values for e.g.
* newer JDKs which are not (yet) in the {@link EE} enum. Should be
* used by callers preferring more lenient behavior towards unknowwn
* JDKs.
*/
public String getRunEE() {
return doGetObject(Constants.RUNEE, stringConverter);
}

/**
* @param the the EE as a free-text. Value is not validated. Callers are
* responsible for ensuring a valid value (e.g. by using
* {@link EE#parse(String)}
*/
public void setRunEE(String eeString) {
String old = doGetObject(Constants.RUNEE, stringConverter);
doSetObject(Constants.RUNEE, old, eeString, newlineEscapeFormatter);
}

public void setRunFramework(String clause) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Version("4.5.0")
@Version("4.6.0")
package aQute.bnd.build.model;

import org.osgi.annotation.versioning.Version;
17 changes: 9 additions & 8 deletions bndtools.core/src/bndtools/editor/project/RunFrameworkPart.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
Expand Down Expand Up @@ -38,7 +37,7 @@ public class RunFrameworkPart extends BndEditorPart implements PropertyChangeLis
private final OSGiFrameworkContentProvider fwkContentProvider = new OSGiFrameworkContentProvider();

private String selectedFramework = null;
private EE selectedEE = null;
private String selectedEE = null;

private Combo cmbFramework;
private Combo cmbExecEnv;
Expand Down Expand Up @@ -83,7 +82,7 @@ final void createSection(Section section, FormToolkit tk) {
frameworkViewer.setContentProvider(fwkContentProvider);

Label lblExecEnv = tk.createLabel(composite, "Execution Env.:");
cmbExecEnv = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
cmbExecEnv = new Combo(composite, SWT.DROP_DOWN);
ControlDecoration eeDecor = new ControlDecoration(cmbExecEnv, SWT.LEFT | SWT.TOP, composite);
eeDecor.setImage(FieldDecorationRegistry.getDefault()
.getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION)
Expand Down Expand Up @@ -121,9 +120,10 @@ public String getText(Object element) {
else
selectedFramework = element.toString();
}));
eeViewer.addSelectionChangedListener(event -> lock.ifNotModifying(() -> {
cmbExecEnv.addModifyListener(e -> lock.ifNotModifying(() -> {
String text = cmbExecEnv.getText();
markDirty();
selectedEE = (EE) ((IStructuredSelection) event.getSelection()).getFirstElement();
selectedEE = (text != null && !text.isBlank()) ? text : null;
}));

GridLayout layout = new GridLayout(2, false);
Expand Down Expand Up @@ -156,8 +156,9 @@ protected void refreshFromModel() {
if (selectedFramework != null)
cmbFramework.setText(selectedFramework);

selectedEE = model.getEE();
eeViewer.setSelection(selectedEE != null ? new StructuredSelection(selectedEE) : StructuredSelection.EMPTY);
EE ee = model.getEE();
selectedEE = (ee != null) ? ee.getEEName() : model.getRunEE();
cmbExecEnv.setText(selectedEE != null ? selectedEE : "");
});
}

Expand All @@ -168,7 +169,7 @@ public void commitToModel(boolean onSave) {
model.setRunFw(selectedFramework == null ? null
: selectedFramework.trim()
.length() > 0 ? selectedFramework.trim() : null);
model.setEE(selectedEE);
model.setRunEE(selectedEE);
} finally {
committing = false;
}
Expand Down
Loading