Skip to content

Commit

Permalink
openlangrid-0.2: Add domain selecting box to service search page
Browse files Browse the repository at this point in the history
  • Loading branch information
thichai committed Mar 11, 2015
1 parent 5d284ce commit fcb18de
Showing 1 changed file with 110 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import jp.go.nict.langrid.management.web.model.ServiceMetaAttributeModel;
import jp.go.nict.langrid.management.web.model.enumeration.LanguagePathType;
import jp.go.nict.langrid.management.web.model.exception.ServiceManagerException;
import jp.go.nict.langrid.management.web.view.component.choice.DomainDropDownChoice;
import jp.go.nict.langrid.management.web.view.model.LangridSearchCondition;
import jp.go.nict.langrid.management.web.view.page.language.component.form.panel.LanguageFormPanel;
import jp.go.nict.langrid.management.web.view.page.language.component.form.panel.LanguagePairFormPanel;
Expand All @@ -41,6 +42,7 @@
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.ajax.form.AjaxFormValidatingBehavior;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.Form;
Expand Down Expand Up @@ -79,6 +81,7 @@ public LangridSearchCondition getSearchCondition(){
if(accessRightCheck.getModelObject() != null){
condition.setScope(accessRightCheck.getModelObject() ? Scope.ACCESSIBLE : Scope.ALL);
}

// add service type condition
if(serviceTypeField.getModelObject() != null) {
String typeId = serviceTypeField.getModelObject().getTypeId();
Expand Down Expand Up @@ -146,9 +149,32 @@ protected Component getRewriteComponent(){
}

@Override
protected void initialize(final Form form, String gridId) throws ServiceManagerException{
protected void initialize(final Form form, final String gridId) throws ServiceManagerException{
languagePathId = "languagePath";


form.add(serviceNameField = new SearchTextField("serviceNameField"));
form.add(domainChoice = new DomainDropDownChoice(gridId, "domain") {
@Override
public CharSequence getDefaultChoice(Object selected){
String option = getLocalizer()
.getString(getId() + ".nullValid", this, "");
if(Strings.isEmpty(option)){
option = getLocalizer().getString("nullValid", this, "");
}
// The <option> tag buffer
AppendingStringBuffer buffer = new AppendingStringBuffer(32 + option
.length());
// Add option tag
buffer.append("\n<option");
// Add body of option tag
buffer.append(" value=\"\">").append(option).append("</option>");
return buffer;
}

private static final long serialVersionUID = 1L;
});

form.add(serviceTypeField = new ServiceTypeDropDownChoice(gridId , "serviceTypeField"){
@Override
public CharSequence getDefaultChoice(Object selected){
Expand All @@ -169,6 +195,87 @@ public CharSequence getDefaultChoice(Object selected){

private static final long serialVersionUID = 1L;
});

domainChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {

@Override
protected void onUpdate(AjaxRequestTarget target) {
if (domainChoice.getInput() !=null && !domainChoice.getInput().equals("")) {
try {
form.addOrReplace(serviceTypeField = new ServiceTypeDropDownChoice(gridId, domainChoice.getModelObject().getDomainId(), "serviceTypeField") {
@Override
public CharSequence getDefaultChoice(Object selected){
String option = getLocalizer()
.getString(getId() + ".nullValid", this, "");
if(Strings.isEmpty(option)){
option = getLocalizer().getString("nullValid", this, "");
}
// The <option> tag buffer
AppendingStringBuffer buffer = new AppendingStringBuffer(32 + option
.length());
// Add option tag
buffer.append("\n<option");
// Add body of option tag
buffer.append(" value=\"\">").append(option).append("</option>");
return buffer;
}

private static final long serialVersionUID = 1L;
});
} catch (ServiceManagerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
try {
form.addOrReplace(serviceTypeField = new ServiceTypeDropDownChoice(gridId, "serviceTypeField") {
@Override
public CharSequence getDefaultChoice(Object selected){
String option = getLocalizer()
.getString(getId() + ".nullValid", this, "");
if(Strings.isEmpty(option)){
option = getLocalizer().getString("nullValid", this, "");
}
// The <option> tag buffer
AppendingStringBuffer buffer = new AppendingStringBuffer(32 + option
.length());
// Add option tag
buffer.append("\n<option");
// Add body of option tag
buffer.append(" value=\"\">").append(option).append("</option>");
return buffer;
}

private static final long serialVersionUID = 1L;
});
} catch (ServiceManagerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

target.addComponent(getRewriteComponent());

serviceTypeField.add(new AjaxFormComponentUpdatingBehavior("onchange"){
@Override
protected void onUpdate(AjaxRequestTarget target){
if(serviceTypeField.getInput() != null && !serviceTypeField.getInput().equals("")){
form.addOrReplace(
languagePath = getLanguagePathPanel(
serviceTypeField.getModelObject().getTypeSet()));
}else{
form.addOrReplace(languagePath = new LanguageFormPanel(
languagePathId));
}
languagePath.add(new WebMarkupContainer("removePathLink")
.setVisible(false));
target.addComponent(getRewriteComponent());
}

private static final long serialVersionUID = 1L;
});
}
});

serviceTypeField.add(new AjaxFormComponentUpdatingBehavior("onchange"){
@Override
Expand Down Expand Up @@ -238,6 +345,8 @@ private boolean isAllWildcard(LanguagePath[] paths){
private ServiceTypeDropDownChoice serviceTypeField;
private ProvisionControlDropDownChoice provision;
private UsingServiceDropDownChoice usingService;

private DomainDropDownChoice domainChoice;

private static final long serialVersionUID = 1L;
}

0 comments on commit fcb18de

Please sign in to comment.