Updated ProgressBar set Progress 0

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-unionwizard-widget@98797 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-07-18 13:12:13 +00:00 committed by Giancarlo Panichi
parent 696c7af409
commit 24edd569eb
3 changed files with 110 additions and 40 deletions

View File

@ -68,18 +68,20 @@ public class ColumnMappingCard extends WizardCard {
getWizardWindow().setEnableNextButton(false); getWizardWindow().setEnableNextButton(false);
getWizardWindow().setEnableBackButton(false); getWizardWindow().setEnableBackButton(false);
ArrayList<UnionColumnsMapping> mapMatch=columnMappingPanel.getSelectedMap(); ArrayList<UnionColumnsMapping> columnsMatch=columnMappingPanel.getSelectedMap();
if(mapMatch==null){ if(columnsMatch==null){
Log.debug("No column match created: " Log.debug("No columns match created: "
+mapMatch); +columnsMatch);
UtilsGXT3 UtilsGXT3
.info("Attentions", .info("Attentions",
"Creates a valid map"); "Creates a valid column map");
getWizardWindow().setEnableNextButton(true); getWizardWindow().setEnableNextButton(true);
getWizardWindow().setEnableBackButton(true); getWizardWindow().setEnableBackButton(true);
} else { } else {
Log.debug("ColumnsMatch created: "+columnsMatch);
unionSession.setColumnsMatch(columnsMatch);
goNext();
} }
@ -95,6 +97,7 @@ public class ColumnMappingCard extends WizardCard {
getWizardWindow().nextCard(); getWizardWindow().nextCard();
} catch (Throwable e) { } catch (Throwable e) {
Log.error("goNext: " + e.getLocalizedMessage()); Log.error("goNext: " + e.getLocalizedMessage());
e.printStackTrace();
} }
} }

View File

@ -20,6 +20,8 @@ import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction; import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode; import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
@ -56,10 +58,10 @@ public class ColumnMappingPanel extends ContentPanel {
protected ArrayList<ColumnData> sourceColumns; protected ArrayList<ColumnData> sourceColumns;
protected ArrayList<ColumnData> unionColumns; protected ArrayList<ColumnData> unionColumns;
protected ResizeContainer thisPanel; protected ResizeContainer thisPanel;
protected HashMap<ColumnData,ColumnData> columnMap; protected HashMap<ColumnData, ColumnData> columnMap;
protected ArrayList<UnionColumnsMapping> listUnionColumnsMapping; protected ArrayList<UnionColumnsMapping> listUnionColumnsMapping;
protected String itemIdSourceColumn = "itemIdSourceColumn"; protected String itemIdSourceColumn = "itemIdSourceColumn";
protected String itemIdUnionColumn = "itemIdUnionColumn"; protected String itemIdUnionColumn = "itemIdUnionColumn";
protected String itemIdLabelColumn = "itemIdLabelColumn"; protected String itemIdLabelColumn = "itemIdLabelColumn";
@ -205,16 +207,16 @@ public class ColumnMappingPanel extends ContentPanel {
// Union Combo // Union Combo
ColumnDataProperties propsUnionColumn = GWT ColumnDataProperties propsUnionColumn = GWT
.create(ColumnDataProperties.class); .create(ColumnDataProperties.class);
ListStore<ColumnData> storeComboUnionColumn = new ListStore<ColumnData>( final ListStore<ColumnData> storeComboUnionColumn = new ListStore<ColumnData>(
propsUnionColumn.id()); propsUnionColumn.id());
storeComboUnionColumn.addAll(unionColumns);
final ComboBox<ColumnData> comboUnionColumn = new ComboBox<ColumnData>( final ComboBox<ColumnData> comboUnionColumn = new ComboBox<ColumnData>(
storeComboUnionColumn, propsUnionColumn.label()); storeComboUnionColumn, propsUnionColumn.label());
comboUnionColumn.setItemId(itemIdUnionColumn); comboUnionColumn.setItemId(itemIdUnionColumn);
Log.debug("ComboUnionColumn created"); Log.debug("ComboUnionColumn created");
comboUnionColumn.disable();
comboUnionColumn.setEmptyText("Select a column..."); comboUnionColumn.setEmptyText("Select a column...");
comboUnionColumn.setWidth(COMBOWIDTH); comboUnionColumn.setWidth(COMBOWIDTH);
comboUnionColumn.setEditable(false); comboUnionColumn.setEditable(false);
@ -254,11 +256,35 @@ public class ColumnMappingPanel extends ContentPanel {
} }
}); });
btnDel.setVisible(false); btnDel.setVisible(false);
comboSourceColumn
.addSelectionHandler(new SelectionHandler<ColumnData>() {
@Override
public void onSelection(SelectionEvent<ColumnData> event) {
comboUnionColumn.reset();
storeComboUnionColumn.clear();
ColumnData selectedSourceColumn = event
.getSelectedItem();
storeComboUnionColumn.clear();
for (ColumnData col : unionColumns) {
if (col.getDataTypeName() == selectedSourceColumn
.getDataTypeName()
&& col.getTypeCode() == selectedSourceColumn
.getTypeCode()) {
storeComboUnionColumn.add(col);
}
}
storeComboUnionColumn.commitChanges();
comboUnionColumn.redraw();
comboUnionColumn.enable();
}
});
horiz.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); horiz.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
horiz.setPack(BoxLayoutPack.START); horiz.setPack(BoxLayoutPack.START);
horiz.add(columnLabel, new BoxLayoutData(new Margins(2, 1, 2, 1))); horiz.add(columnLabel, new BoxLayoutData(new Margins(2, 1, 2, 1)));
horiz.add(comboSourceColumn, new BoxLayoutData(new Margins(2, 1, 2, 1))); horiz.add(comboSourceColumn, new BoxLayoutData(new Margins(2, 1, 2, 1)));
horiz.add(comboUnionColumn, new BoxLayoutData(new Margins(2, 1, 2, 1))); horiz.add(comboUnionColumn, new BoxLayoutData(new Margins(2, 1, 2, 1)));
@ -267,7 +293,6 @@ public class ColumnMappingPanel extends ContentPanel {
vert.add(horiz); vert.add(horiz);
} }
protected void addColumnMap() { protected void addColumnMap() {
@ -284,7 +309,7 @@ public class ColumnMappingPanel extends ContentPanel {
.create(ColumnDataProperties.class); .create(ColumnDataProperties.class);
ListStore<ColumnData> storeComboSourceColumn = new ListStore<ColumnData>( ListStore<ColumnData> storeComboSourceColumn = new ListStore<ColumnData>(
propsSourceColumn.id()); propsSourceColumn.id());
storeComboSourceColumn.addAll(unionColumns); storeComboSourceColumn.addAll(sourceColumns);
final ComboBox<ColumnData> comboSourceColumn = new ComboBox<ColumnData>( final ComboBox<ColumnData> comboSourceColumn = new ComboBox<ColumnData>(
storeComboSourceColumn, propsSourceColumn.label()); storeComboSourceColumn, propsSourceColumn.label());
@ -300,9 +325,8 @@ public class ColumnMappingPanel extends ContentPanel {
// Union Combo // Union Combo
ColumnDataProperties propsUnionColumn = GWT ColumnDataProperties propsUnionColumn = GWT
.create(ColumnDataProperties.class); .create(ColumnDataProperties.class);
ListStore<ColumnData> storeComboUnionColumn = new ListStore<ColumnData>( final ListStore<ColumnData> storeComboUnionColumn = new ListStore<ColumnData>(
propsUnionColumn.id()); propsUnionColumn.id());
storeComboUnionColumn.addAll(unionColumns);
final ComboBox<ColumnData> comboUnionColumn = new ComboBox<ColumnData>( final ComboBox<ColumnData> comboUnionColumn = new ComboBox<ColumnData>(
storeComboUnionColumn, propsUnionColumn.label()); storeComboUnionColumn, propsUnionColumn.label());
@ -310,6 +334,7 @@ public class ColumnMappingPanel extends ContentPanel {
Log.debug("ComboUnionColumn created"); Log.debug("ComboUnionColumn created");
comboUnionColumn.disable();
comboUnionColumn.setEmptyText("Select a column..."); comboUnionColumn.setEmptyText("Select a column...");
comboUnionColumn.setWidth(COMBOWIDTH); comboUnionColumn.setWidth(COMBOWIDTH);
comboUnionColumn.setEditable(false); comboUnionColumn.setEditable(false);
@ -350,9 +375,34 @@ public class ColumnMappingPanel extends ContentPanel {
}); });
btnDel.setVisible(false); btnDel.setVisible(false);
comboSourceColumn
.addSelectionHandler(new SelectionHandler<ColumnData>() {
@Override
public void onSelection(SelectionEvent<ColumnData> event) {
comboUnionColumn.reset();
storeComboUnionColumn.clear();
ColumnData selectedSourceColumn = event
.getSelectedItem();
storeComboUnionColumn.clear();
for (ColumnData col : unionColumns) {
if (col.getDataTypeName() == selectedSourceColumn
.getDataTypeName()
&& col.getTypeCode() == selectedSourceColumn
.getTypeCode()) {
storeComboUnionColumn.add(col);
}
}
storeComboUnionColumn.commitChanges();
comboUnionColumn.redraw();
comboUnionColumn.enable();
}
});
horiz.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); horiz.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
horiz.setPack(BoxLayoutPack.START); horiz.setPack(BoxLayoutPack.START);
horiz.add(columnLabel, new BoxLayoutData(new Margins(2, 1, 2, 1))); horiz.add(columnLabel, new BoxLayoutData(new Margins(2, 1, 2, 1)));
horiz.add(comboSourceColumn, new BoxLayoutData(new Margins(2, 1, 2, 1))); horiz.add(comboSourceColumn, new BoxLayoutData(new Margins(2, 1, 2, 1)));
horiz.add(comboUnionColumn, new BoxLayoutData(new Margins(2, 1, 2, 1))); horiz.add(comboUnionColumn, new BoxLayoutData(new Margins(2, 1, 2, 1)));
@ -361,40 +411,58 @@ public class ColumnMappingPanel extends ContentPanel {
vert.add(horiz); vert.add(horiz);
} }
/** /**
* *
* @return * @return
*/ */
protected ArrayList<UnionColumnsMapping> getSelectedMap() { protected ArrayList<UnionColumnsMapping> getSelectedMap() {
listUnionColumnsMapping=new ArrayList<UnionColumnsMapping>(); listUnionColumnsMapping = new ArrayList<UnionColumnsMapping>();
int lenght = vert.getWidgetCount(); int lenght = vert.getWidgetCount();
int i = 0; int i = 0;
for (; i < lenght; i++) { for (; i < lenght; i++) {
HBoxLayoutContainer h = (HBoxLayoutContainer) vert.getWidget(i); HBoxLayoutContainer h = (HBoxLayoutContainer) vert.getWidget(i);
if (h != null) { if (h != null) {
@SuppressWarnings("unchecked") TextField columnLabelField = (TextField) h
ComboBox<ColumnData> comboSourceColumn = (ComboBox<ColumnData>) h .getItemByItemId(itemIdLabelColumn);
.getItemByItemId(itemIdSourceColumn); if (columnLabelField != null) {
ColumnData sourceColumn = comboSourceColumn.getCurrentValue(); String columnLabel = columnLabelField.getCurrentValue();
if (sourceColumn != null) { if (columnLabel != null && !columnLabel.isEmpty()) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ComboBox<ColumnData> comboUnionColumn= (ComboBox<ColumnData>) h ComboBox<ColumnData> comboSourceColumn = (ComboBox<ColumnData>) h
.getItemByItemId(itemIdUnionColumn); .getItemByItemId(itemIdSourceColumn);
ColumnData unionColumn = comboUnionColumn.getCurrentValue(); ColumnData sourceColumn = comboSourceColumn
if (unionColumn != null) { .getCurrentValue();
UnionColumnsMapping colMatch= new UnionColumnsMapping(sourceColumn, unionColumn); if (sourceColumn != null) {
listUnionColumnsMapping.add(colMatch); @SuppressWarnings("unchecked")
ComboBox<ColumnData> comboUnionColumn = (ComboBox<ColumnData>) h
.getItemByItemId(itemIdUnionColumn);
ColumnData unionColumn = comboUnionColumn
.getCurrentValue();
if (unionColumn != null) {
UnionColumnsMapping colMatch = new UnionColumnsMapping(
columnLabel, sourceColumn, unionColumn);
listUnionColumnsMapping.add(colMatch);
} else {
Log.debug("Union Column is null");
}
} else {
Log.debug("Source Column is null");
}
} else {
Log.debug("Column Label is null");
} }
} else {
Log.debug("Column Label Field is null");
} }
} else { } else {
Log.debug("HorizontalContainer is null");
} }
} }
return listUnionColumnsMapping; return listUnionColumnsMapping;
} }
} }

View File

@ -59,8 +59,7 @@ public class UnionProgressBarUpdater implements UnionProgressListener {
@Override @Override
public void operationUpdate(float elaborated) { public void operationUpdate(float elaborated) {
Log.info("Elaborated: "+elaborated); Log.info("Elaborated: "+elaborated);
if (elaborated == 0) progressBar.updateProgress(0, "Initializing..."); if (elaborated>=0 && elaborated<1) {
if (elaborated>0 && elaborated<1) {
Log.trace("progress "+elaborated); Log.trace("progress "+elaborated);
int elab=new Float(elaborated*100).intValue(); int elab=new Float(elaborated*100).intValue();
progressBar.updateProgress(elaborated,elab+"% Progress..."); progressBar.updateProgress(elaborated,elab+"% Progress...");