Updated Batch Replace

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@94789 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-04-11 16:23:20 +00:00
parent dc7462c918
commit a35d49537c
3 changed files with 93 additions and 60 deletions

View File

@ -94,8 +94,10 @@ public class ReplaceBatchPanel extends FramedPanel implements
protected ColumnData column;
protected boolean hasValidationColumns;
protected ShowOccurrencesType showOccurencesType;
protected ColumnData connection;
protected ReplaceBatchDialog parent;
private ReplaceEntry currentReplaceEntry;
private int currentRowIndex;
@ -103,9 +105,9 @@ public class ReplaceBatchPanel extends FramedPanel implements
private TextButton btnSave;
private TextButton btnClose;
private ToolBar toolBarHead;
private ComboBox<ShowOccurrencesTypeElement> comboShowOccurrencesType = null;
private TextButton btnConnect;
@ -115,7 +117,9 @@ public class ReplaceBatchPanel extends FramedPanel implements
protected Grid<ReplaceEntry> grid;
protected ListStore<ReplaceEntry> store;
protected HTML info;
private TextButton btnDisconnect;
protected TextButton btnDisconnect;
private boolean simpleReplace;
public ReplaceBatchPanel(ReplaceBatchDialog parent, TRId trId,
String columnName, EventBus eventBus) {
@ -123,6 +127,7 @@ public class ReplaceBatchPanel extends FramedPanel implements
this.trId = trId;
this.columnName = columnName;
this.eventBus = eventBus;
connection = null;
hasValidationColumns = false;
Log.debug("Create BatchReplacePanel(): [" + trId.toString()
+ " , columnName:" + columnName + "]");
@ -143,7 +148,7 @@ public class ReplaceBatchPanel extends FramedPanel implements
toolBarHead = new ToolBar();
toolBarHead.add(new LabelToolItem("Show: "));
// Create Combo Show
ShowOccurrencesTypeProperties propsShowOccurrencesType = GWT
.create(ShowOccurrencesTypeProperties.class);
@ -168,45 +173,48 @@ public class ReplaceBatchPanel extends FramedPanel implements
toolBarHead.add(comboShowOccurrencesType);
// Connect Codelist
btnConnect = new TextButton();
btnConnect.setIcon(ResourceBundle.INSTANCE.codelistLink24());
btnConnect.setIconAlign(IconAlign.TOP);
btnConnect.setTitle("Connect");
btnConnect.addSelectHandler(new SelectHandler() {
if (!column.isViewColumn()) {
// Connect Codelist
btnConnect = new TextButton();
btnConnect.setIcon(ResourceBundle.INSTANCE.codelistLink24());
btnConnect.setIconAlign(IconAlign.TOP);
btnConnect.setTitle("Connect");
btnConnect.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
Log.debug("Pressed Connect");
btnConnect.disable();
connectCodelist();
public void onSelect(SelectEvent event) {
Log.debug("Pressed Connect");
btnConnect.disable();
connectCodelist();
}
}
});
});
toolBarHead.add(btnConnect);
// Disconnect Codelist
btnDisconnect = new TextButton();
btnDisconnect.setIcon(ResourceBundle.INSTANCE.codelistLinkBreak24());
btnDisconnect.setIconAlign(IconAlign.TOP);
btnDisconnect.setTitle("Disconnect");
btnDisconnect.addSelectHandler(new SelectHandler() {
toolBarHead.add(btnConnect);
public void onSelect(SelectEvent event) {
Log.debug("Pressed Disconnect");
btnDisconnect.disable();
disconnectCodelist();
// Disconnect Codelist
btnDisconnect = new TextButton();
btnDisconnect
.setIcon(ResourceBundle.INSTANCE.codelistLinkBreak24());
btnDisconnect.setIconAlign(IconAlign.TOP);
btnDisconnect.setTitle("Disconnect");
btnDisconnect.addSelectHandler(new SelectHandler() {
}
public void onSelect(SelectEvent event) {
Log.debug("Pressed Disconnect");
btnDisconnect.disable();
disconnectCodelist();
});
toolBarHead.add(btnDisconnect);
}
});
toolBarHead.add(btnDisconnect);
connectionField = new TextField();
toolBarHead.add(connectionField);
}
connectionField = new TextField();
toolBarHead.add(connectionField);
// Create Grid
IdentityValueProvider<ReplaceEntry> identity = new IdentityValueProvider<ReplaceEntry>();
CheckBoxSelectionModel<ReplaceEntry> sm = new CheckBoxSelectionModel<ReplaceEntry>(
@ -320,7 +328,7 @@ public class ReplaceBatchPanel extends FramedPanel implements
grid.setLoader(loader);
grid.setSelectionModel(sm);
number.initPlugin(grid);
grid.setHeight("388px");
grid.setHeight("376px");
grid.getView().setStripeRows(true);
grid.getView().setColumnLines(true);
grid.getView().setAutoFill(true);
@ -378,9 +386,10 @@ public class ReplaceBatchPanel extends FramedPanel implements
new Margins(5, 2, 5, 2)));
add(v);
connectionField.setVisible(false);
btnDisconnect.setVisible(false);
if (!column.isViewColumn()) {
connectionField.setVisible(false);
btnDisconnect.setVisible(false);
}
}
protected void retrieveColumn() {
@ -592,14 +601,28 @@ public class ReplaceBatchPanel extends FramedPanel implements
protected void callSingleValueReplaceDialog() {
Log.debug("callSingleValueReplaceDialog");
SingleValueReplaceDialog dialogSingleValueReplace = new SingleValueReplaceDialog(
currentReplaceEntry.getValue(),
currentReplaceEntry.getReplacementValue(), column, eventBus);
dialogSingleValueReplace.addListener(this);
dialogSingleValueReplace.show();
simpleReplace = true;
if (connection == null) {
SingleValueReplaceDialog dialogSingleValueReplace = new SingleValueReplaceDialog(
currentReplaceEntry.getValue(),
currentReplaceEntry.getReplacementValue(), column, eventBus);
dialogSingleValueReplace.addListener(this);
dialogSingleValueReplace.show();
} else {
Log.debug("callDimensionRowSelectionDialog");
CellData cellData = new CellData(currentReplaceEntry.getValue(),
connection.getName(), connection.getColumnId(),
connection.getLabel(), currentReplaceEntry.getRowId(), 0, 0);
DimensionRowSelectionDialog dialogDimensionRowSelection = new DimensionRowSelectionDialog(
connection, cellData, eventBus);
dialogDimensionRowSelection.addListener(this);
dialogDimensionRowSelection.show();
}
}
protected void callDimensionRowSelectionDialog() {
simpleReplace = false;
Log.debug("callDimensionRowSelectionDialog");
CellData cellData = new CellData(currentReplaceEntry.getValue(),
column.getName(), column.getColumnId(), column.getLabel(),
@ -614,10 +637,16 @@ public class ReplaceBatchPanel extends FramedPanel implements
@Override
public void selectedDimensionRow(DimensionRow dimensionRow) {
Log.debug("Change Value: " + dimensionRow);
currentReplaceEntry.setReplacementValue(dimensionRow.getValue());
currentReplaceEntry.setReplacementDimensionRow(dimensionRow);
store.update(currentReplaceEntry);
updateInfo();
if (simpleReplace) {
currentReplaceEntry.setReplacementValue(dimensionRow.getValue());
store.update(currentReplaceEntry);
updateInfo();
} else {
currentReplaceEntry.setReplacementValue(dimensionRow.getValue());
currentReplaceEntry.setReplacementDimensionRow(dimensionRow);
store.update(currentReplaceEntry);
updateInfo();
}
}
@Override
@ -663,6 +692,7 @@ public class ReplaceBatchPanel extends FramedPanel implements
protected void disconnectCodelist() {
Log.debug("Disconnect codelist");
this.connection = null;
connectionField.setValue("");
connectionField.setVisible(false);
btnDisconnect.setVisible(false);
@ -674,6 +704,7 @@ public class ReplaceBatchPanel extends FramedPanel implements
@Override
public void selectedConnectCodelist(ColumnData connection) {
Log.debug("Selected connection: " + connection);
this.connection = connection;
connectionField.setValue(connection.getLabel());
connectionField.setVisible(true);
btnDisconnect.setVisible(true);

View File

@ -12,9 +12,9 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class SingleValueReplaceDialog extends Window {
protected String WIDTH = "500px";
@ -25,13 +25,13 @@ public class SingleValueReplaceDialog extends Window {
protected String replaceValue;
protected ColumnData column;
protected ArrayList<SingleValueReplaceListener> listeners;
public SingleValueReplaceDialog(String value, String replaceValue, ColumnData column, EventBus eventBus) {
listeners=new ArrayList<SingleValueReplaceListener>();
this.value=value;
this.replaceValue=replaceValue;
this.column=column;
public SingleValueReplaceDialog(String value, String replaceValue,
ColumnData column, EventBus eventBus) {
listeners = new ArrayList<SingleValueReplaceListener>();
this.value = value;
this.replaceValue = replaceValue;
this.column = column;
this.eventBus = eventBus;
initWindow();
create();
@ -66,8 +66,8 @@ public class SingleValueReplaceDialog extends Window {
}
protected void create() {
SingleValueReplacePanel replacePanel = new SingleValueReplacePanel(this, value, replaceValue,column,
eventBus);
SingleValueReplacePanel replacePanel = new SingleValueReplacePanel(
this, value, replaceValue, column, eventBus);
add(replacePanel);
}

View File

@ -61,6 +61,8 @@ public class SingleValueReplacePanel extends FramedPanel {
create();
}
protected void initPanel() {
setWidth(WIDTH);