diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsPortlet.java b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsPortlet.java index 8b70e5f..c8eecb4 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsPortlet.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsPortlet.java @@ -60,6 +60,6 @@ public class ConstantsPortlet { public static final long MILLISECS_PER_DAY = 1000L * 60L * 60L * 24L; - public static final int NORTH_HEIGHT = 70; + public static final int NORTH_HEIGHT = 77; } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtBasicTabPanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtBasicTabPanel.java index a8b898c..ec96536 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtBasicTabPanel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtBasicTabPanel.java @@ -46,7 +46,7 @@ public class GxtBasicTabPanel extends LayoutContainer { private TabItem tabView = null; private TabItem tabSearch = null; private TabPanel tabPanel = null; - private Text txtPath = new Text("PATH:"); + private Text txtPath = new Text("PATH:"); private Label labelPath = new Label(""); private GxtComboBox comboBoxGxt = null; private ComboBox cbViewScope = null; @@ -54,7 +54,7 @@ public class GxtBasicTabPanel extends LayoutContainer { private Text txtViewScope = new Text("View Scope:"); public enum viewSwitchType {TREE,SHORTCUT}; private final String EMPTY = "EMPTY"; - + //Tab Search private final TextField textSearch = new TextField(); private Button bSearch = new Button("Search"); @@ -65,15 +65,15 @@ public class GxtBasicTabPanel extends LayoutContainer { private final String FIELDVALIDATEERROR = "The field must be alphanumeric"; private SimpleComboBox cbNameFilter = null; // TableData tdContentView = null; - + public GxtBasicTabPanel() { // Log.trace("Initializing GxtBasicTabPanel"); - + setLayout(new FitLayout()); setBorders(true); setId("ContentPanelTab"); - + this.tabPanel = new TabPanel(); this.tabView = new TabItem("View"); this.tabSearch = new TabItem("Search"); @@ -101,28 +101,15 @@ public class GxtBasicTabPanel extends LayoutContainer { tabPanel.setBorderStyle(false); tabPanel.setPlain(true); - VBoxLayout vBoxLayout = new VBoxLayout(); - vBoxLayout.setPadding(new Padding(5)); - vBoxLayout.setVBoxLayoutAlign(VBoxLayoutAlign.LEFT); - VBoxLayoutData flex = new VBoxLayoutData(new Margins(30, 10, 10, 10)); - - txtPath.addStyleName("pad-text"); - txtPath.setStyleAttribute("backgroundColor", "white"); + VBoxLayout vBoxLayout = new VBoxLayout(); + vBoxLayout.setPadding(new Padding(5)); + vBoxLayout.setVBoxLayoutAlign(VBoxLayoutAlign.LEFT); + VBoxLayoutData flex = new VBoxLayoutData(new Margins(30, 10, 10, 10)); + + txtPath.addStyleName("pad-text"); + txtPath.setStyleAttribute("backgroundColor", "white"); txtPath.setAutoWidth(true); - -// Radio radioTree = new Radio(); -// radioTree.setBoxLabel("Tree"); -// radioTree.setValue(true); -// radioTree.setValueAttribute(viewSwitchType.TREE.toString()); -// Radio radioShortcut = new Radio(); -// radioShortcut.setBoxLabel("Shortcut"); -// radioShortcut.setValueAttribute(viewSwitchType.SHORTCUT.toString()); -// RadioGroup radioGroup = new RadioGroup(); -// radioGroup.setFieldLabel("Afecto"); -// radioGroup.add(radioTree); -// radioGroup.add(radioShortcut); -// radioGroup.setStyleAttribute("margin-left", "20px"); - + HorizontalPanel hpPath = new HorizontalPanel(); hpPath.setLayout(new FitLayout()); hpPath.setBorders(true); @@ -131,49 +118,40 @@ public class GxtBasicTabPanel extends LayoutContainer { this.setLabelPath(""); this.labelPath.setStyleAttribute("margin-left", "20px"); hpPath.add(this.labelPath); - + HorizontalPanel hpScope = new HorizontalPanel(); hpScope.setLayout(new FitLayout()); hpScope.add(txtViewScope); - - //Select in combo the first element of store + + //Select in combo the first element of store this.cbViewScope.addListener(Events.Attach, new Listener(){ public void handleEvent(BaseEvent be) { - cbViewScope.setValue(cbViewScope.getStore().getAt(0)); + cbViewScope.setValue(cbViewScope.getStore().getAt(0)); } }); - + this.cbViewScope.addSelectionChangedListener(new SelectionChangedListener() { - + @Override public void selectionChanged(SelectionChangedEvent se) { - -// Window.alert("selected scope" + se.getSelectedItem().get("name")); - - //TODO - + } }); - + this.cbViewScope.setStyleAttribute("margin-left", "20px"); hpScope.add(this.cbViewScope); - -// HorizontalPanel hpRadio = new HorizontalPanel(); -// hpRadio.setLayout(new FitLayout()); -// hpRadio.add(txtSwitch); -// hpRadio.add(radioGroup); - + cp.add(hpPath,flex); cp.add(hpScope,flex); // cp.add(hpRadio, flex); this.tabView.add(cp); - + tabPanel.add(tabView); add(tabPanel); } - - + + private void initTabSearch() { ContentPanel cp = new ContentPanel(); @@ -181,28 +159,24 @@ public class GxtBasicTabPanel extends LayoutContainer { cp.setLayout(new RowLayout()); cp.setBorders(false); cp.setBodyBorder(false); - - + FormPanel formPanel = new FormPanel(); formPanel.setHeaderVisible(false); formPanel.setBodyBorder(false); - // formPanel.setFrame(true); formPanel.setWidth(350); - FormData formData = new FormData("-20"); - - - cbNameFilter.setFieldLabel("Name Filter"); -// combo.setDisplayField("name"); + FormData formData = new FormData("-20"); + cbNameFilter.setFieldLabel("Name Filter"); +// combo.setDisplayField("name"); formPanel.add(cbNameFilter, formData); - + textSearch.setFieldLabel("Item Name"); textSearch.setAllowBlank(false); textSearch.setRegex("^[ a-zA-Z0-9_-]*$"); // textSearch.getMessages().setRegexText(FIELDVALIDATEERROR); formPanel.add(textSearch, formData); - + fromDate.setName("date"); fromDate.setFieldLabel("From"); formPanel.add(fromDate); @@ -210,13 +184,13 @@ public class GxtBasicTabPanel extends LayoutContainer { toDate.setName("date"); toDate.setFieldLabel("To"); formPanel.add(toDate); - + textFull.setFieldLabel("Full Text"); textFull.setAllowBlank(true); formPanel.add(textFull, formData); - + this.tabSearch.add(formPanel); - + bSearch.addSelectionListener(new SelectionListener() { public void componentSelected(ButtonEvent ce) { if (textSearch.getValue() == null || textSearch.getValue() == "" || !textSearch.isValid()) { @@ -231,32 +205,31 @@ public class GxtBasicTabPanel extends LayoutContainer { } } }); - - + + this.bCancel.addSelectionListener(new SelectionListener() { @Override public void componentSelected(ButtonEvent ce) { resetFieldsInTabSearch(); - } }); - - formPanel.setButtonAlign(HorizontalAlignment.LEFT); - - formPanel.addButton(this.bSearch); + + formPanel.setButtonAlign(HorizontalAlignment.LEFT); + + formPanel.addButton(this.bSearch); formPanel.addButton(this.bCancel); - - - FormButtonBinding binding = new FormButtonBinding(formPanel); + + + FormButtonBinding binding = new FormButtonBinding(formPanel); binding.addButton(this.bSearch); - + tabPanel.add(tabSearch); add(tabPanel); } - + public void resetFieldsInTabSearch(){ this.textSearch.reset(); this.textFull.reset(); @@ -265,26 +238,26 @@ public class GxtBasicTabPanel extends LayoutContainer { this.cbNameFilter.reset(); } - + public LayoutContainer getTabs() { return this; } - + public String getValueComboNameFilter(){ - + return this.cbViewScope.getRawValue(); - + } - + public void setLabelPath(String path){ - - if(path != null && (!path.isEmpty())) + + if(path != null && !path.isEmpty()) this.labelPath.setText(path); else this.labelPath.setText(EMPTY); - - + + } - + } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtSeachAndFilterPanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtSeachAndFilterPanel.java index c007cf2..b8475f8 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtSeachAndFilterPanel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtSeachAndFilterPanel.java @@ -24,20 +24,21 @@ import com.extjs.gxt.ui.client.widget.form.DateField; import com.extjs.gxt.ui.client.widget.form.SimpleComboBox; import com.extjs.gxt.ui.client.widget.form.TextField; import com.extjs.gxt.ui.client.widget.layout.FitLayout; +import com.github.gwtbootstrap.client.ui.Button; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.RootPanel; + /** + * The Class GxtSeachAndFilterPanel. + * * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * @author Massimiliano Assante ISTI-CNR - * - * @version 1.0 May 14th 2012 + * Jun 1, 2016 */ public class GxtSeachAndFilterPanel extends LayoutContainer { @@ -45,49 +46,42 @@ public class GxtSeachAndFilterPanel extends LayoutContainer { private ComboBox cbViewScope = null; private final TextField textSearch = new TextField(); private Button bSearch = new Button(ConstantsPortlet.SEARCH); -// private Image bSearchIn = Resources.getIconSearchWs().createImage(); -// private HorizontalPanel hpSearchIn = new HorizontalPanel(); -// private String searchInFolderId = ""; //is the root private Button bCancel = new Button(ConstantsPortlet.CANCEL); private Button bSave = new Button(ConstantsPortlet.SAVE); -// private Label labelSearchIn = new Label(); private TextField textFull = new TextField(); private DateField fromDate = new DateField(); private DateField toDate = new DateField(); private SimpleComboBox cbNameFilter = null; -// private HorizontalPanel hpToolbarPathPanel = null; private boolean isSearchActive = false; private VerticalPanel verticalPanel = new VerticalPanel(); - private HorizontalPanel hp = new HorizontalPanel(); -// private HorizontalPanel hp2 = new HorizontalPanel(); - + private HorizontalPanel hpMain = new HorizontalPanel(); private GxtBreadcrumbPathPanel toolbarPahtPanel; + /** + * Instantiates a new gxt seach and filter panel. + * + * @param toolBarPathPanel the tool bar path panel + */ public GxtSeachAndFilterPanel(GxtBreadcrumbPathPanel toolBarPathPanel) { setLayout(new FitLayout()); setBorders(true); this.setId("SearchAndFilter"); this.setBorders(false); -// this.setStyleAttribute("background-color", "#d0def0"); this.comboBoxGxt = new GxtComboBox(); this.cbViewScope = this.comboBoxGxt.getComboViewScope(); this.cbNameFilter = this.comboBoxGxt.getComboStringFilter(); this.textSearch.setId("text-search"); -// this.textSearch.setStyleAttribute("margin-bottom", "0px"); this.cbViewScope.setWidth(360); -// this.cbViewScope.setAutoWidth(true); this.toolbarPahtPanel = toolBarPathPanel; - + hp.setStyleAttribute("margin-left", "2px"); seVisibleButtonsCancelSave(false); textSearch.setAllowBlank(true); textSearch.setEmptyText(ConstantsPortlet.SEARCHBYNAME); -// textSearch.setWidth(325); -// textSearch.setHeight(12); /* COMMENTED TO FIX https://support.social.isti.cnr.it/ticket/87 textSearch.setRegex("^[a-zA-Z0-9]+[ a-zA-Z0-9_().-]*"); //alphanumeric @@ -95,75 +89,52 @@ public class GxtSeachAndFilterPanel extends LayoutContainer { textSearch.setAutoValidate(true); */ hp.add(textSearch); - - bSearch.setStyleName("wizardButton"); + +// bSearch.setStyleName("wizardButton"); // bSearch.getElement().getStyle().setMarginLeft(3, Unit.PX); - bCancel.setStyleName("wizardButton"); +// bCancel.setStyleName("wizardButton"); bCancel.getElement().getStyle().setMarginLeft(3, Unit.PX); - bSave.setStyleName("wizardButton"); +// bSave.setStyleName("wizardButton"); bSave.getElement().getStyle().setMarginLeft(3, Unit.PX); - + hp.add(bSearch); hp.add(bSave); hp.setVerticalAlign(VerticalAlignment.MIDDLE); - -// hp.setHeight(20); -// hpMain.setHeight(20); - bSearch.setWidth("70px"); - bSave.setWidth("70px"); - + bSearch.addStyleName("button_toolbar"); + bSave.addStyleName("button_toolbar"); cbViewScope.setStyleAttribute("margin-left", "132px"); cbViewScope.setStyleAttribute("margin-top", "2px"); - - hpMain.setId("hpMain"); - hpMain.setStyleAttribute("background", "#D0DEF0"); + + hpMain.setId("hpSearchAndFilter"); +// hpMain.setStyleAttribute("background", "#D0DEF0"); verticalPanel.setId("VerticalPanelSearchAndFilter"); verticalPanel.setStyleAttribute("background", "#D0DEF0"); hpMain.add(hp); hpMain.setVerticalAlign(VerticalAlignment.MIDDLE); - + //SOLUTION FOR SCOPE INVISIBLE cbViewScope.setVisible(false); - verticalPanel.add(this.toolbarPahtPanel.getToolBarPathPanel()); verticalPanel.add(hpMain); verticalPanel.setVerticalAlign(VerticalAlignment.MIDDLE); - + this.addListeners(); add(verticalPanel); - + updateSize(); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { updateSize(); } - }); - + }); + layout(); } - /* - private void initSearchIn(){ - - hpSearchIn.removeAll(); - searchInFolderId = ""; - labelSearchIn.setText(""); -// labelSearchIn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); - hpSearchIn.add(labelSearchIn); - hpSearchIn.setStyleAttribute("margin-left", "3px"); - hpSearchIn.add(bSearchIn); - hpSearchIn.layout(true); - } - - private void selectedFolderToSearch(Item item){ - searchInFolderId = item.getId(); - labelSearchIn.setText("in "+item.getName()); - labelSearchIn.setTitle("search in "+item.getName()); - }*/ /** - * Update window size + * Update window size. */ public void updateSize() { RootPanel workspace = RootPanel.get(ConstantsPortlet.WORKSPACEDIV); @@ -172,11 +143,16 @@ public class GxtSeachAndFilterPanel extends LayoutContainer { //SOLUTION FOR SCOPE INVISIBLE hp.setWidth(rootWidth); - + // ORIGINAL CODE // hp.setWidth(rootWidth - 500); } - + + /** + * Search text. + * + * @param value the value + */ public void searchText(String value){ textSearch.setValue(value); seVisibleButtonsCancelSave(true); @@ -184,14 +160,17 @@ public class GxtSeachAndFilterPanel extends LayoutContainer { AppController.getEventBus().fireEvent(new SearchTextEvent(value, parentId)); } + /** + * Adds the listeners. + */ private void addListeners(){ - bSearch.addClickHandler(new ClickHandler() { + bSearch.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if(isValidSearch()){ // seVisibleButtonsCancelSave(true); -// AppController.getEventBus().fireEvent(new SearchTextEvent(textSearch.getValue())); +// AppController.getEventBus().fireEvent(new SearchTextEvent(textSearch.getValue())); searchText(textSearch.getValue()); }else if(textSearch.getValue()==null || textSearch.getValue().isEmpty()){ searchCancel(); @@ -202,7 +181,7 @@ public class GxtSeachAndFilterPanel extends LayoutContainer { KeyListener keyListener = new KeyListener() { public void componentKeyUp(ComponentEvent event) { if (event.getKeyCode() == 13) { // KEY_ENTER - if(isValidSearch()){ + if(isValidSearch()){ searchText(textSearch.getValue()); }else if(textSearch.getValue()==null || textSearch.getValue().isEmpty()){ searchCancel(); @@ -213,17 +192,8 @@ public class GxtSeachAndFilterPanel extends LayoutContainer { textSearch.addKeyListener(keyListener); // -// bCancel.addClickHandler(new ClickHandler() { -// @Override -// public void onClick(ClickEvent event) { -// if(textSearch.getValue()!=null && !textSearch.getValue().isEmpty() && textSearch.isValid()){ -// searchCancel(); -// AppController.getEventBus().fireEvent(new SearchTextEvent(null)); -// } -// } -// }); - - bSave.addClickHandler(new ClickHandler() { + + bSave.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if(textSearch.getValue()!=null && !textSearch.getValue().isEmpty() && textSearch.isValid()){ @@ -234,7 +204,7 @@ public class GxtSeachAndFilterPanel extends LayoutContainer { } } }); - + this.cbViewScope.addSelectionChangedListener(new SelectionChangedListener() { @Override @@ -249,6 +219,9 @@ public class GxtSeachAndFilterPanel extends LayoutContainer { } + /** + * Reset fields. + */ public void resetFields(){ this.textSearch.reset(); this.textFull.reset(); @@ -257,49 +230,96 @@ public class GxtSeachAndFilterPanel extends LayoutContainer { this.cbNameFilter.reset(); } - + + /** + * Checks if is valid search. + * + * @return true, if is valid search + */ private boolean isValidSearch(){ return textSearch.getValue()!=null && !textSearch.getValue().isEmpty() && textSearch.isValid(); } + /** + * Se visible buttons cancel save. + * + * @param flag the flag + */ public void seVisibleButtonsCancelSave(boolean flag){ this.bCancel.setVisible(flag); this.bSave.setVisible(flag); } + /** + * Search cancel. + */ public void searchCancel(){ resetFields(); -// initSearchIn(); seVisibleButtonsCancelSave(false); } + /** + * Checks if is search active. + * + * @return true, if is search active + */ public boolean isSearchActive(){ return this.isSearchActive; } + /** + * Sets the list scope. + * + * @param listScope the new list scope + */ public void setListScope(List listScope){ this.comboBoxGxt.setListScope(listScope); } + /** + * Select scope by index. + * + * @param index the index + */ public void selectScopeByIndex(int index){ - this.cbViewScope.setValue(cbViewScope.getStore().getAt(index)); + this.cbViewScope.setValue(cbViewScope.getStore().getAt(index)); } + /** + * Sets the search active. + * + * @param isSearchActive the new search active + */ public void setSearchActive(boolean isSearchActive) { this.isSearchActive = isSearchActive; } + /** + * Sets the visible button save. + * + * @param bool the new visible button save + */ public void setVisibleButtonSave(boolean bool){ this.bSave.setVisible(bool); } + /** + * Sets the empty text. + * + * @param emptyText the new empty text + */ public void setEmptyText(String emptyText){ textSearch.setEmptyText(emptyText); } + /** + * Gets the toolbar path panel. + * + * @return the toolbar path panel + */ public GxtBreadcrumbPathPanel getToolbarPathPanel() { return toolbarPahtPanel; } diff --git a/src/main/webapp/workspaceportlet.css b/src/main/webapp/workspaceportlet.css index 21c341c..cbaa989 100644 --- a/src/main/webapp/workspaceportlet.css +++ b/src/main/webapp/workspaceportlet.css @@ -420,13 +420,27 @@ vertical-align: middle; } +#hpSearchAndFilter { + background-color: #D0DEF0; +} + +#hpSearchAndFilter td { + vertical-align: top; + ! + important; +} + #text-search { margin-right: 3px; width: 325px !important; } -#text-search>input:first-child { - height: 18px !important; - width: 319px !important; - padding: 1px 2px; +#text-search-input { + height: 20px !important; + width: 312px !important; + /* padding: 1px 2px; */ +} + +.button_toolbar { + width: 60px; } \ No newline at end of file