178 lines
4.3 KiB
Java
178 lines
4.3 KiB
Java
package org.gcube.portlets.user.databasesmanager.client.form;
|
|
|
|
|
|
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryData;
|
|
|
|
//import org.gcube.portlets.user.dbmanager.client.datamodel.SubmitQueryData;
|
|
|
|
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
|
import com.extjs.gxt.ui.client.widget.VerticalPanel;
|
|
import com.extjs.gxt.ui.client.widget.form.CheckBox;
|
|
import com.extjs.gxt.ui.client.widget.form.FormPanel;
|
|
import com.extjs.gxt.ui.client.widget.form.TextField;
|
|
import com.extjs.gxt.ui.client.widget.layout.FormData;
|
|
|
|
public class GxtFormSubmitQuery extends LayoutContainer {
|
|
|
|
private VerticalPanel vp;
|
|
FormPanel form;
|
|
private FormData formData;
|
|
|
|
// private SubmitQueryData data;
|
|
|
|
// private boolean ReadOnlyQuery;
|
|
// private boolean SmartCorrection;
|
|
|
|
private static Logger rootLogger = Logger.getLogger("GxtFormSubmitQuery");
|
|
|
|
|
|
|
|
public GxtFormSubmitQuery() {
|
|
|
|
formData = new FormData("-20");
|
|
vp = new VerticalPanel();
|
|
|
|
vp.setSpacing(10);
|
|
|
|
createLayout();
|
|
|
|
add(vp);
|
|
|
|
}
|
|
|
|
private void createLayout() {
|
|
|
|
// FormPanel form = new FormPanel();
|
|
|
|
form = new FormPanel();
|
|
|
|
// form.setHeading("Submit Query");
|
|
form.setHeaderVisible(false);
|
|
form.setFrame(true);
|
|
form.setWidth(250);
|
|
// form.setWidth(350);
|
|
// form.setHeight(250);
|
|
|
|
// Query field
|
|
TextField<String> query = new TextField<String>();
|
|
query.setFieldLabel("Query");
|
|
|
|
// query.setHeight(50);
|
|
// query.setWidth(50);
|
|
// query.setAllowBlank(false);
|
|
query.getFocusSupport().setPreviousId(form.getButtonBar().getId());
|
|
form.add(query, formData);
|
|
|
|
// Read-Only button
|
|
// CheckBoxGroup readOnlyQuery = new CheckBoxGroup();
|
|
// readOnlyQuery.setFieldLabel("Read Only Query");
|
|
|
|
// CheckBox checkRO = new CheckBox();
|
|
// checkRO.setFieldLabel("Read Only Query");
|
|
// checkRO.setValue(true);
|
|
// // readOnlyQuery.add(checkRO);
|
|
// // form.add(readOnlyQuery, formData);
|
|
// form.add(checkRO, formData);
|
|
|
|
// Smart Correction button
|
|
// CheckBoxGroup smartCorrection = new CheckBoxGroup();
|
|
// smartCorrection.setFieldLabel("Apply Smart Correction");
|
|
|
|
CheckBox checkSC = new CheckBox();
|
|
checkSC.setFieldLabel("Apply Smart Corrections");
|
|
checkSC.setValue(true);
|
|
// smartCorrection.add(checkSC);
|
|
// form.add(smartCorrection, formData);
|
|
form.add(checkSC, formData);
|
|
|
|
// // SQL Dialect ComboBox
|
|
//
|
|
// ListStore<SQLDialect> store = new ListStore<SQLDialect>();
|
|
// List<SQLDialect> elements = new ArrayList<SQLDialect>();
|
|
//
|
|
// // load data to display in comboBox
|
|
// elements = SQLDialect.loadData();
|
|
// store.add(elements);
|
|
//
|
|
// ComboBox<SQLDialect> combo = new ComboBox<SQLDialect>();
|
|
// combo.setFieldLabel("Language");
|
|
// combo.setDisplayField("name");
|
|
// combo.setTriggerAction(TriggerAction.ALL);
|
|
// combo.setValue(store.getAt(0));
|
|
// combo.setStore(store);
|
|
// form.add(combo, formData);
|
|
|
|
vp.add(form);
|
|
|
|
}
|
|
|
|
private String getQuery() {
|
|
|
|
String query = ((TextField<String>) form.getWidget(0)).getValue();
|
|
|
|
// System.out.println("GxtFormSubmitQuery->query: " + query);
|
|
|
|
rootLogger.log(Level.SEVERE, "query: " + query);
|
|
|
|
return query;
|
|
}
|
|
|
|
// private boolean getReadOnlyQueryValue() {
|
|
//
|
|
// CheckBox checkRO = ((CheckBox) form.getWidget(1));
|
|
//
|
|
// System.out.println("GxtFormSubmitQuery->readonlyquery: "
|
|
// + checkRO.getValue());
|
|
// return (checkRO.getValue());
|
|
//
|
|
// }
|
|
|
|
private boolean getSmartCorrectionValue() {
|
|
|
|
// CheckBox checkSC = ((CheckBox) form.getWidget(2));
|
|
CheckBox checkSC = ((CheckBox) form.getWidget(1));
|
|
|
|
// System.out.println("GxtFormSubmitQuery->smartcorrection: "
|
|
// + checkSC.getValue());
|
|
|
|
rootLogger.log(Level.SEVERE, "smartcorrection: " + checkSC.getValue());
|
|
|
|
return (checkSC.getValue());
|
|
|
|
}
|
|
|
|
// private String getLanguage() {
|
|
//
|
|
// ComboBox<SQLDialect> combo = ((ComboBox<SQLDialect>) form.getWidget(3));
|
|
// SQLDialect item = combo.getValue();
|
|
//
|
|
// System.out.println("GxtFormSubmitQuery->language: " + item.getName());
|
|
//
|
|
// return item.getName();
|
|
// }
|
|
|
|
public SubmitQueryData getSubmitQueryData() {
|
|
|
|
layout(true);
|
|
|
|
SubmitQueryData data = new SubmitQueryData();
|
|
|
|
data.setQuery(this.getQuery());
|
|
|
|
//TO REMOVE
|
|
// data.setReadOnlyQuery(this.getReadOnlyQueryValue());
|
|
|
|
data.setSmartCorrection(this.getSmartCorrectionValue());
|
|
|
|
//TO REMOVE
|
|
// data.setLanguage(this.getLanguage());
|
|
|
|
return data;
|
|
}
|
|
|
|
}
|