Skip to content

Commit

Permalink
Fix compiler errors/warnings in o.g.w.d.l.CoverageView*
Browse files Browse the repository at this point in the history
  • Loading branch information
smithkm committed Jan 18, 2016
1 parent 60f4d5a commit 1dc522d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 47 deletions.
Expand Up @@ -17,7 +17,6 @@
import javax.media.jai.ImageLayout; import javax.media.jai.ImageLayout;


import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.markup.html.form.SubmitLink; import org.apache.wicket.markup.html.form.SubmitLink;
import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.link.Link; import org.apache.wicket.markup.html.link.Link;
Expand Down Expand Up @@ -75,7 +74,6 @@ public CoverageViewAbstractPage(PageParameters params) throws IOException {
this(params.get(WORKSPACE).toOptionalString(), params.get(COVERAGESTORE).toString(), null, null); this(params.get(WORKSPACE).toOptionalString(), params.get(COVERAGESTORE).toString(), null, null);
} }


@SuppressWarnings("deprecation")
public CoverageViewAbstractPage(String workspaceName, String storeName, String coverageName, public CoverageViewAbstractPage(String workspaceName, String storeName, String coverageName,
CoverageInfo coverageInfo) throws IOException { CoverageInfo coverageInfo) throws IOException {
storeId = getCatalog().getStoreByName(workspaceName, storeName, CoverageStoreInfo.class) storeId = getCatalog().getStoreByName(workspaceName, storeName, CoverageStoreInfo.class)
Expand Down Expand Up @@ -125,16 +123,18 @@ public CoverageViewAbstractPage(String workspaceName, String storeName, String c
selectedCoverages = new ArrayList<String>(availableCoverages); selectedCoverages = new ArrayList<String>(availableCoverages);


// build the form and the text area // build the form and the text area
Form form = new Form("form", new CompoundPropertyModel(this)); Form<CoverageViewAbstractPage> form = new Form<>("form", new CompoundPropertyModel<>(this));
add(form); add(form);


final TextField nameField = new TextField("name"); final TextField<String> nameField = new TextField<>("name");
nameField.setRequired(true); nameField.setRequired(true);
nameField.add(new CoverageViewNameValidator()); nameField.add(new CoverageViewNameValidator());
form.add(nameField); form.add(nameField);


coverageEditor = new CoverageViewEditor("coverages", new PropertyModel(this, coverageEditor = new CoverageViewEditor("coverages",
"selectedCoverages"), new PropertyModel(this, "outputBands"), availableCoverages); new PropertyModel<>(this,"selectedCoverages"),
new PropertyModel<>(this, "outputBands"),
availableCoverages);
form.add(coverageEditor); form.add(coverageEditor);


// save and cancel at the bottom of the page // save and cancel at the bottom of the page
Expand All @@ -144,7 +144,7 @@ public void onSubmit() {
onSave(); onSave();
} }
}); });
form.add(new Link("cancel") { form.add(new Link<Void>("cancel") {


@Override @Override
public void onClick() { public void onClick() {
Expand Down Expand Up @@ -189,11 +189,11 @@ protected String getFirstErrorMessage(Throwable t) {
/** /**
* Checks the {@link CoverageView} name is unique * Checks the {@link CoverageView} name is unique
*/ */
class CoverageViewNameValidator implements IValidator { class CoverageViewNameValidator implements IValidator<String> {


@Override @Override
public void validate(IValidatable validatable) { public void validate(IValidatable<String> validatable) {
String vcName = (String) validatable.getValue(); String vcName = validatable.getValue();


final CoverageStoreInfo store = getCatalog().getStore(storeId, CoverageStoreInfo.class); final CoverageStoreInfo store = getCatalog().getStore(storeId, CoverageStoreInfo.class);
List<CoverageInfo> coverages = getCatalog().getCoveragesByCoverageStore(store); List<CoverageInfo> coverages = getCatalog().getCoveragesByCoverageStore(store);
Expand Down Expand Up @@ -228,18 +228,4 @@ public void setSelectedCoverages(List<String> selectedCoverages) {
this.selectedCoverages = selectedCoverages; this.selectedCoverages = selectedCoverages;
} }


private class CompositionTypeRenderer extends ChoiceRenderer {

public CompositionTypeRenderer() {
}

public Object getDisplayValue(Object object) {
return object.toString();
}

public String getIdValue(Object object, int index) {
return object.toString();
}
}

} }
Expand Up @@ -20,6 +20,9 @@


public class CoverageViewEditPage extends CoverageViewAbstractPage { public class CoverageViewEditPage extends CoverageViewAbstractPage {


/** serialVersionUID */
private static final long serialVersionUID = -3932025430605245513L;

public CoverageViewEditPage(String workspaceName, String storeName, String coverageName, public CoverageViewEditPage(String workspaceName, String storeName, String coverageName,
CoverageInfo coverageInfo, ResourceConfigurationPage previusPage) throws IOException { CoverageInfo coverageInfo, ResourceConfigurationPage previusPage) throws IOException {
super(workspaceName, storeName, coverageName, coverageInfo); super(workspaceName, storeName, coverageName, coverageInfo);
Expand Down
Expand Up @@ -18,7 +18,6 @@
import org.apache.wicket.markup.html.form.DropDownChoice; import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.FormComponentPanel; import org.apache.wicket.markup.html.form.FormComponentPanel;
import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.markup.html.form.ListMultipleChoice; import org.apache.wicket.markup.html.form.ListMultipleChoice;
import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.IModel; import org.apache.wicket.model.IModel;
Expand All @@ -33,18 +32,18 @@
* *
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class CoverageViewEditor extends FormComponentPanel { public class CoverageViewEditor extends FormComponentPanel<List<String>> {


IModel coverages; IModel<List<String>> coverages;
IModel outputBands; IModel<List<CoverageBand>> outputBands;
List<String> availableCoverages; List<String> availableCoverages;
List<CoverageBand> currentOutputBands; List<CoverageBand> currentOutputBands;
ListMultipleChoice<String> coveragesChoice; ListMultipleChoice<String> coveragesChoice;
CompositionType compositionType; CompositionType compositionType;


ListMultipleChoice<CoverageBand> outputBandsChoice; ListMultipleChoice<CoverageBand> outputBandsChoice;


TextField definition; TextField<String> definition;
DropDownChoice<CompositionType> compositionChoice; DropDownChoice<CompositionType> compositionChoice;


/** /**
Expand All @@ -53,15 +52,15 @@ public class CoverageViewEditor extends FormComponentPanel {
* @param id * @param id
* @param The module should return a non null collection of strings. * @param The module should return a non null collection of strings.
*/ */
public CoverageViewEditor(String id, final IModel inputCoverages, final IModel bands, public CoverageViewEditor(String id, final IModel<List<String>> inputCoverages, final IModel<List<CoverageBand>> bands,
List<String> availableCoverages) { List<String> availableCoverages) {
super(id, inputCoverages); super(id, inputCoverages);
this.coverages = inputCoverages; this.coverages = inputCoverages;
this.outputBands = bands; this.outputBands = bands;


this.availableCoverages = availableCoverages; this.availableCoverages = availableCoverages;


coveragesChoice = new ListMultipleChoice<String>("coveragesChoice", new Model(), coveragesChoice = new ListMultipleChoice<String>("coveragesChoice", new Model<>(),
new ArrayList<String>((List<String>) coverages.getObject()), new ArrayList<String>((List<String>) coverages.getObject()),
new ChoiceRenderer<String>() { new ChoiceRenderer<String>() {
@Override @Override
Expand All @@ -73,8 +72,8 @@ public Object getDisplayValue(String coverage) {
add(coveragesChoice); add(coveragesChoice);


new ArrayList<CoverageBand>(); new ArrayList<CoverageBand>();
outputBandsChoice = new ListMultipleChoice<CoverageBand>("outputBandsChoice", new Model(), outputBandsChoice = new ListMultipleChoice<CoverageBand>("outputBandsChoice", new Model<>(),
new ArrayList<CoverageBand>((List<CoverageBand>) outputBands.getObject()), new ArrayList<CoverageBand>(outputBands.getObject()),
new ChoiceRenderer<CoverageBand>() { new ChoiceRenderer<CoverageBand>() {
@Override @Override
public Object getDisplayValue(CoverageBand vcb) { public Object getDisplayValue(CoverageBand vcb) {
Expand All @@ -87,15 +86,15 @@ public Object getDisplayValue(CoverageBand vcb) {
currentOutputBands = new ArrayList<CoverageBand>(outputBandsChoice.getChoices()); currentOutputBands = new ArrayList<CoverageBand>(outputBandsChoice.getChoices());


add(addBandButton()); add(addBandButton());
definition = new TextField("definition", new Model()); definition = new TextField<>("definition", new Model<>());
definition.setOutputMarkupId(true); definition.setOutputMarkupId(true);


// TODO: make this parametric on the CompositionType choice // TODO: make this parametric on the CompositionType choice
definition.setEnabled(false); definition.setEnabled(false);
// TODO Uncomment this row when it can be used // TODO Uncomment this row when it can be used
//add(definition); //add(definition);
compositionType = CompositionType.getDefault(); compositionType = CompositionType.getDefault();
compositionChoice = new DropDownChoice("compositionType", new PropertyModel(this, compositionChoice = new DropDownChoice<>("compositionType", new PropertyModel<>(this,
"compositionType"), Arrays.asList(CompositionType.BAND_SELECT), new CompositionTypeRenderer()); "compositionType"), Arrays.asList(CompositionType.BAND_SELECT), new CompositionTypeRenderer());


compositionChoice.setOutputMarkupId(true); compositionChoice.setOutputMarkupId(true);
Expand All @@ -121,7 +120,7 @@ private AjaxButton addBandButton() {
AjaxButton button = new AjaxButton("addBand") { AjaxButton button = new AjaxButton("addBand") {


@Override @Override
public void onSubmit(AjaxRequestTarget target, Form form) { public void onSubmit(AjaxRequestTarget target, Form<?> form) {
List<String> selection = (List<String>) coveragesChoice.getModelObject(); List<String> selection = (List<String>) coveragesChoice.getModelObject();
compositionType = compositionChoice.getModelObject(); compositionType = compositionChoice.getModelObject();
List<CoverageBand> bandsList = new ArrayList<CoverageBand>(); List<CoverageBand> bandsList = new ArrayList<CoverageBand>();
Expand Down Expand Up @@ -160,7 +159,7 @@ private AjaxButton addRemoveAllButton() {
AjaxButton button = new AjaxButton("removeAllBands") { AjaxButton button = new AjaxButton("removeAllBands") {


@Override @Override
public void onSubmit(AjaxRequestTarget target, Form form) { public void onSubmit(AjaxRequestTarget target, Form<?> form) {
List<CoverageBand> outputBands = (List<CoverageBand>) outputBandsChoice List<CoverageBand> outputBands = (List<CoverageBand>) outputBandsChoice
.getModelObject(); .getModelObject();
outputBands.clear(); outputBands.clear();
Expand All @@ -179,7 +178,7 @@ private AjaxButton addRemoveButton() {
AjaxButton button = new AjaxButton("removeBands") { AjaxButton button = new AjaxButton("removeBands") {


@Override @Override
public void onSubmit(AjaxRequestTarget target, Form form) { public void onSubmit(AjaxRequestTarget target, Form<?> form) {


List<CoverageBand> removedBands = (List<CoverageBand>) outputBandsChoice List<CoverageBand> removedBands = (List<CoverageBand>) outputBandsChoice
.getModel().getObject(); .getModel().getObject();
Expand All @@ -198,17 +197,14 @@ public void onSubmit(AjaxRequestTarget target, Form form) {
return button; return button;
} }


private class CompositionTypeRenderer extends ChoiceRenderer { private class CompositionTypeRenderer extends ChoiceRenderer<CompositionType> {


public CompositionTypeRenderer() { public Object getDisplayValue(CompositionType object) {
} return object.displayValue();

public Object getDisplayValue(Object object) {
return ((CompositionType) object).displayValue();
} }


public String getIdValue(Object object, int index) { public String getIdValue(CompositionType object, int index) {
return ((CompositionType) object).toValue(); return object.toValue();
} }
} }


Expand Down

0 comments on commit 1dc522d

Please sign in to comment.