Added RuleToolBar
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@113857 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
cd9257ef00
commit
5cb8d6366a
|
@ -761,10 +761,7 @@ public class TabularDataController {
|
||||||
case LOGS:
|
case LOGS:
|
||||||
openLogsWindow();
|
openLogsWindow();
|
||||||
break;
|
break;
|
||||||
case RULE_NEW:
|
|
||||||
break;
|
|
||||||
case RULE_MANAGE:
|
|
||||||
break;
|
|
||||||
case DUPLICATE_DETECTION:
|
case DUPLICATE_DETECTION:
|
||||||
openDuplicatesRowsDetection();
|
openDuplicatesRowsDetection();
|
||||||
break;
|
break;
|
||||||
|
@ -860,6 +857,16 @@ public class TabularDataController {
|
||||||
break;
|
break;
|
||||||
case COLUMN_BATCH_REPLACE:
|
case COLUMN_BATCH_REPLACE:
|
||||||
break;
|
break;
|
||||||
|
case RULE_NEW:
|
||||||
|
break;
|
||||||
|
case RULE_MODIFY:
|
||||||
|
break;
|
||||||
|
case RULE_DELETE:
|
||||||
|
break;
|
||||||
|
case RULE_APPLY:
|
||||||
|
break;
|
||||||
|
case RULE_SHARE:
|
||||||
|
break;
|
||||||
case TEMPLATE_OPEN:
|
case TEMPLATE_OPEN:
|
||||||
openTemplateOpen();
|
openTemplateOpen();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -0,0 +1,228 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.client.ribbon;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.RibbonEvent;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.UIStateEvent;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.RibbonType;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.UIStateType;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.dom.client.Element;
|
||||||
|
import com.google.gwt.dom.client.NodeList;
|
||||||
|
import com.google.gwt.user.client.ui.FlexTable;
|
||||||
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonArrowAlign;
|
||||||
|
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
|
||||||
|
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
||||||
|
import com.sencha.gxt.core.client.dom.XElement;
|
||||||
|
import com.sencha.gxt.widget.core.client.button.ButtonGroup;
|
||||||
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||||
|
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class RuleToolBar {
|
||||||
|
|
||||||
|
private EventBus eventBus;
|
||||||
|
private ToolBar toolBar;
|
||||||
|
|
||||||
|
//Rules
|
||||||
|
private TextButton ruleNewButton;
|
||||||
|
private TextButton ruleModifyButton;
|
||||||
|
private TextButton ruleDeleteButton;
|
||||||
|
private TextButton ruleApplyButton;
|
||||||
|
private TextButton ruleShareButton;
|
||||||
|
|
||||||
|
|
||||||
|
public RuleToolBar(EventBus eventBus) {
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ToolBar getToolBar() {
|
||||||
|
return toolBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void build() {
|
||||||
|
toolBar = new ToolBar();
|
||||||
|
toolBar.setSpacing(1);
|
||||||
|
toolBar.setEnableOverflow(false);
|
||||||
|
|
||||||
|
// Rules
|
||||||
|
ButtonGroup rulesGroup = new ButtonGroup();
|
||||||
|
rulesGroup.setId("Manage");
|
||||||
|
rulesGroup.setStyleName("ribbon");
|
||||||
|
rulesGroup.setHeadingText("Manage");
|
||||||
|
//templateGroup.disable();
|
||||||
|
toolBar.add(rulesGroup);
|
||||||
|
|
||||||
|
FlexTable templateLayout = new FlexTable();
|
||||||
|
rulesGroup.add(templateLayout);
|
||||||
|
|
||||||
|
ruleNewButton = new TextButton("New",
|
||||||
|
TabularDataResources.INSTANCE.templateEdit32());
|
||||||
|
ruleNewButton.enable();
|
||||||
|
ruleNewButton.setToolTip("New");
|
||||||
|
ruleNewButton.setScale(ButtonScale.LARGE);
|
||||||
|
ruleNewButton.setIconAlign(IconAlign.TOP);
|
||||||
|
ruleNewButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||||
|
ruleNewButton.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
eventBus.fireEvent(new RibbonEvent(
|
||||||
|
RibbonType.RULE_NEW));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
templateLayout.setWidget(0, 0, ruleNewButton);
|
||||||
|
templateLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
|
||||||
|
|
||||||
|
ruleModifyButton = new TextButton("Modify",
|
||||||
|
TabularDataResources.INSTANCE.templateAdd32());
|
||||||
|
ruleModifyButton.enable();
|
||||||
|
ruleModifyButton.setToolTip("Modify");
|
||||||
|
ruleModifyButton.setScale(ButtonScale.LARGE);
|
||||||
|
ruleModifyButton.setIconAlign(IconAlign.TOP);
|
||||||
|
ruleModifyButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||||
|
ruleModifyButton.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
eventBus.fireEvent(new RibbonEvent(
|
||||||
|
RibbonType.RULE_MODIFY));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
templateLayout.setWidget(0, 1, ruleModifyButton);
|
||||||
|
templateLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
|
||||||
|
|
||||||
|
|
||||||
|
ruleDeleteButton = new TextButton("Delete",
|
||||||
|
TabularDataResources.INSTANCE.templateDelete32());
|
||||||
|
ruleDeleteButton.enable();
|
||||||
|
ruleDeleteButton.setToolTip("Delete");
|
||||||
|
ruleDeleteButton.setScale(ButtonScale.LARGE);
|
||||||
|
ruleDeleteButton.setIconAlign(IconAlign.TOP);
|
||||||
|
ruleDeleteButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||||
|
ruleDeleteButton.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
eventBus.fireEvent(new RibbonEvent(
|
||||||
|
RibbonType.RULE_DELETE));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
templateLayout.setWidget(0, 2, ruleDeleteButton);
|
||||||
|
templateLayout.getFlexCellFormatter().setRowSpan(0, 2, 2);
|
||||||
|
|
||||||
|
|
||||||
|
ruleApplyButton = new TextButton("Apply",
|
||||||
|
TabularDataResources.INSTANCE.templateApply32());
|
||||||
|
ruleApplyButton.disable();
|
||||||
|
ruleApplyButton.setScale(ButtonScale.LARGE);
|
||||||
|
ruleApplyButton.setIconAlign(IconAlign.TOP);
|
||||||
|
ruleApplyButton.setToolTip("Apply Rule");
|
||||||
|
ruleApplyButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||||
|
ruleApplyButton.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
eventBus.fireEvent(new RibbonEvent(RibbonType.RULE_APPLY));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
templateLayout.setWidget(0, 3, ruleApplyButton);
|
||||||
|
templateLayout.getFlexCellFormatter().setRowSpan(0, 3, 2);
|
||||||
|
|
||||||
|
|
||||||
|
ruleShareButton = new TextButton("Share",
|
||||||
|
TabularDataResources.INSTANCE.templateShare32());
|
||||||
|
ruleShareButton.enable();
|
||||||
|
ruleShareButton.setScale(ButtonScale.LARGE);
|
||||||
|
ruleShareButton.setIconAlign(IconAlign.TOP);
|
||||||
|
ruleShareButton.setToolTip("Share Rule");
|
||||||
|
ruleShareButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||||
|
ruleShareButton.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
eventBus.fireEvent(new RibbonEvent(RibbonType.RULE_SHARE));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
templateLayout.setWidget(0, 4, ruleShareButton);
|
||||||
|
templateLayout.getFlexCellFormatter().setRowSpan(0, 4, 2);
|
||||||
|
|
||||||
|
cleanCells(templateLayout.getElement());
|
||||||
|
|
||||||
|
eventBus.addHandler(UIStateEvent.TYPE,
|
||||||
|
new UIStateEvent.UIStateHandler() {
|
||||||
|
|
||||||
|
public void onUIState(UIStateEvent event) {
|
||||||
|
setUI(event);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cleanCells(Element elem) {
|
||||||
|
NodeList<Element> tds = elem.<XElement> cast().select("td");
|
||||||
|
for (int i = 0; i < tds.getLength(); i++) {
|
||||||
|
Element td = tds.getItem(i);
|
||||||
|
|
||||||
|
if (!td.hasChildNodes() && td.getClassName().equals("")) {
|
||||||
|
td.removeFromParent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUI(UIStateEvent event) {
|
||||||
|
UIStateType uiStateType = event.getUIStateType();
|
||||||
|
try {
|
||||||
|
switch (uiStateType) {
|
||||||
|
case START:
|
||||||
|
ruleModifyButton.enable();
|
||||||
|
ruleNewButton.enable();
|
||||||
|
ruleDeleteButton.enable();
|
||||||
|
ruleApplyButton.disable();
|
||||||
|
ruleShareButton.enable();
|
||||||
|
break;
|
||||||
|
case TR_CLOSE:
|
||||||
|
case TR_READONLY:
|
||||||
|
ruleModifyButton.enable();
|
||||||
|
ruleNewButton.enable();
|
||||||
|
ruleDeleteButton.enable();
|
||||||
|
ruleApplyButton.disable();
|
||||||
|
ruleShareButton.enable();
|
||||||
|
break;
|
||||||
|
case TR_OPEN:
|
||||||
|
case TABLEUPDATE:
|
||||||
|
case TABLECURATION:
|
||||||
|
ruleModifyButton.enable();
|
||||||
|
ruleNewButton.enable();
|
||||||
|
ruleDeleteButton.enable();
|
||||||
|
ruleApplyButton.enable();
|
||||||
|
ruleShareButton.enable();
|
||||||
|
break;
|
||||||
|
case WIZARD_OPEN:
|
||||||
|
ruleModifyButton.disable();
|
||||||
|
ruleNewButton.disable();
|
||||||
|
ruleDeleteButton.disable();
|
||||||
|
ruleApplyButton.disable();
|
||||||
|
ruleShareButton.disable();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("setUI Error : " + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,6 +27,7 @@ public class TabularDataRibbon {
|
||||||
private FileToolBar fileToolBar;
|
private FileToolBar fileToolBar;
|
||||||
private CurationToolBar curationToolBar;
|
private CurationToolBar curationToolBar;
|
||||||
private ModifyToolBar modifyToolBar;
|
private ModifyToolBar modifyToolBar;
|
||||||
|
private RuleToolBar ruleToolBar;
|
||||||
private TemplateToolBar templateToolBar;
|
private TemplateToolBar templateToolBar;
|
||||||
private AnalyseToolBar analyseToolBar;
|
private AnalyseToolBar analyseToolBar;
|
||||||
|
|
||||||
|
@ -54,6 +55,11 @@ public class TabularDataRibbon {
|
||||||
con.add(modifyToolBar.getToolBar(), vldata);
|
con.add(modifyToolBar.getToolBar(), vldata);
|
||||||
ribbon.add(con, "Modify");
|
ribbon.add(con, "Modify");
|
||||||
|
|
||||||
|
ruleToolBar = new RuleToolBar(eventBus);
|
||||||
|
con = new VerticalLayoutContainer();
|
||||||
|
con.add(ruleToolBar.getToolBar(), vldata);
|
||||||
|
ribbon.add(con, "Rule");
|
||||||
|
|
||||||
templateToolBar = new TemplateToolBar(eventBus);
|
templateToolBar = new TemplateToolBar(eventBus);
|
||||||
con = new VerticalLayoutContainer();
|
con = new VerticalLayoutContainer();
|
||||||
con.add(templateToolBar.getToolBar(), vldata);
|
con.add(templateToolBar.getToolBar(), vldata);
|
||||||
|
|
Loading…
Reference in New Issue