Example usage for com.google.gwt.user.client.ui HorizontalPanel setSpacing

List of usage examples for com.google.gwt.user.client.ui HorizontalPanel setSpacing

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui HorizontalPanel setSpacing.

Prototype

public void setSpacing(int spacing) 

Source Link

Document

Sets the amount of spacing between this panel's cells.

Usage

From source file:org.dataconservancy.dcs.access.client.ui.SeadAdvancedSearchWidget.java

License:Apache License

public SeadAdvancedSearchWidget(Search.UserField[] userfields, String[] userqueries) {

    advancedPanel = new FlowPanel();
    advancedPanel.setStyleName("advancedSearchPanel");
    initWidget(advancedPanel);//from ww  w .j  a  v a 2  s  . com
    Button search = new Button("Search");

    final FlexTable table = new FlexTable();

    advancedPanel.add(table);

    // Called to search filled in query

    final ClickHandler searchlistener = new ClickHandler() {

        public void onClick(ClickEvent event) {
            doSearch(table);
        }
    };

    final Button add = createNewAddButton(table);

    if (userfields != null) {
        for (int i = 0; i < userfields.length; i++) {
            if (userfields[i] == null) {
                continue;
            }

            int row = table.getRowCount();
            addRow(table, row);

            ListBox lb = (ListBox) table.getWidget(row, 2);
            TextBox tb = (TextBox) table.getWidget(row, 0);
            tb.setText(userqueries[i]);
        }
    } else {
        addRow(table, 0);
    }

    HorizontalPanel hp = new HorizontalPanel();
    hp.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
    hp.setSpacing(5);
    // hp.add(add);
    hp.add(search);

    advancedPanel.add(hp);
    hp.setWidth("80%"); // 80% to align hp to the right of AdvancedPanel
    search.addClickHandler(searchlistener);

}

From source file:org.dataconservancy.dcs.access.client.ui.UploadBagDialog.java

License:Apache License

public UploadBagDialog(String bagUrl
//, final CaptionPanel researchObjectPanel, final Button ingestButton
) {//from  www .  j  av  a2 s.  co m
    dBox = new DialogBox(false, true);

    Panel panel = new FlowPanel();

    dBox.setAnimationEnabled(true);
    dBox.setText("Upload Bag as a .zip file");
    dBox.setWidget(panel);
    dBox.center();

    final HorizontalPanel buttons = new HorizontalPanel();
    buttons.setSpacing(5);

    Button upload = new Button("Upload");
    Button cancel = new Button("Cancel");

    buttons.add(upload);
    buttons.add(cancel);

    final FormPanel form = new FormPanel();
    FlowPanel formcontents = new FlowPanel();
    form.add(formcontents);

    Hidden depositurl = new Hidden("bagUrl");
    depositurl.setValue(bagUrl);

    final FileUpload upfile = new FileUpload();
    upfile.setName("file");

    formcontents.add(upfile);
    formcontents.add(depositurl);
    form.setMethod(FormPanel.METHOD_POST);
    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setAction(SeadApp.BAG_UPLOAD_URL);

    panel.add(new Label("Uploaded files will be included in the SIP."));
    panel.add(form);
    panel.add(buttons);

    upload.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            form.submit();
        }
    });

    cancel.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            dBox.hide();
        }
    });

    form.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        public void onSubmitComplete(SubmitCompleteEvent event) {
            if (event.getResults() == null) {
                Window.alert("File upload failed");
                dBox.hide();
                return;
            }

            String[] tempString = event.getResults().split(";");
            final String sipPath = tempString[tempString.length - 1].split("<")[0];
            String jsonString = event.getResults();
            jsonString = jsonString.substring(jsonString.indexOf('{'), jsonString.lastIndexOf('}') + 1);

            dBox.hide();

            JsDcp dcp = JsDcp.create();
            JsSearchResult result = JsSearchResult.create(jsonString);
            for (int i = 0; i < result.matches().length(); i++) {
                Util.add(dcp, result.matches().get(i));
            }

            PublishDataView.EVENT_BUS.fireEvent(new EntityEditEvent(dcp, true, sipPath));
        }
    });
}

From source file:org.dataconservancy.dcs.access.client.ui.UploadFgdcDialog.java

License:Apache License

public UploadFgdcDialog(String fileUploadUrl) {
    dBox = new DialogBox(false, true);

    Panel panel = new FlowPanel();

    dBox.setAnimationEnabled(true);//from  ww w .j  av  a2s . c o m
    //  dBox.setText("Upload local file");
    dBox.setStyleName("dialogBox");
    dBox.setWidget(panel);
    dBox.center();

    final HorizontalPanel buttons = new HorizontalPanel();
    buttons.setSpacing(5);

    Button upload = new Button("Upload");
    Button cancel = new Button("Cancel");

    buttons.add(upload);
    buttons.add(cancel);

    final FormPanel form = new FormPanel();
    FlowPanel formcontents = new FlowPanel();
    form.add(formcontents);

    final FileUpload upfile = new FileUpload();
    upfile.setName("file");

    Hidden depositurl = new Hidden("depositurl");
    depositurl.setValue(fileUploadUrl);
    //depositConfig.fileUploadUrl());

    formcontents.add(upfile);
    formcontents.add(depositurl);

    form.setMethod(FormPanel.METHOD_POST);
    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setAction(SeadApp.FILE_UPLOAD_URL);

    panel.add(Util.label("Upload Metadata file to be included in the SIP.", "greenFont"));
    panel.add(form);
    panel.add(buttons);

    upload.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {

            form.submit();
        }
    });

    cancel.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            dBox.hide();
        }
    });

    form.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        public void onSubmitComplete(SubmitCompleteEvent event) {
            if (event.getResults() == null) {
                Window.alert("File upload failed");
                dBox.hide();
                return;
            }

            String[] parts = event.getResults().split("\\^");

            if (parts.length != 4) {
                Window.alert("File upload failed: " + event.getResults());
                dBox.hide();
                return;
            }

            String filesrc = parts[1].trim();

            MediciIngestPresenter.metadataSrc = filesrc;
            dBox.hide();
            MediciIngestPresenter.mdCb.setText("Uploaded Metadata!");
            MediciIngestPresenter.mdCb.setEnabled(false);

            //Fire an event to update FGDC's successful update
        }
    });
}

From source file:org.dataconservancy.dcs.access.client.upload.MetadataSetEditor.java

License:Apache License

public MetadataSetEditor() {
    this.stack = new DecoratedStackPanel();

    VerticalPanel panel = new VerticalPanel();

    panel.add(stack);//ww  w .j a  v  a  2s  .  c  o m

    final TextBox schema = new TextBox();

    Button add = new Button("Add");
    Button remove = new Button("Remove");

    HorizontalPanel hp = new HorizontalPanel();
    hp.add(new Label("Schema:"));
    hp.add(schema);
    hp.add(add);
    hp.add(remove);
    hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
    hp.setSpacing(5);

    panel.add(hp);

    add.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            String s = schema.getText().trim();

            if (s.length() > 0) {
                stack.add(new MetadataEditor(s), s);
                stack.showStack(stack.getWidgetCount() - 1);
            }
        }
    });

    remove.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            int i = stack.getSelectedIndex();

            if (i != -1) {
                stack.remove(i);

                if (stack.getWidgetCount() > 0) {
                    stack.showStack(0);
                }
            }
        }
    });

    initWidget(panel);
}

From source file:org.dataconservancy.dcs.access.client.upload.Util.java

License:Apache License

public static void popupChooser(final TextBox result, String description, final List<String> list,
        boolean multiple) {
    final DialogBox db = new DialogBox(false, true);

    Panel panel = new FlowPanel();

    db.setAnimationEnabled(true);//from www.j av  a  2  s .c o m
    db.setText(description);
    db.setWidget(panel);
    db.center();

    final HorizontalPanel buttons = new HorizontalPanel();
    buttons.setSpacing(5);

    Button ok = new Button("Ok");
    Button cancel = new Button("Cancel");

    buttons.add(ok);
    buttons.add(cancel);

    final ListBox lb = new ListBox(multiple);
    lb.setVisibleItemCount(5);

    panel.add(lb);
    panel.add(buttons);

    for (String s : list) {
        lb.addItem(s);
    }

    ok.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < list.size(); i++) {
                if (lb.isItemSelected(i)) {
                    if (sb.length() > 0) {
                        sb.append(", ");
                    }

                    sb.append(list.get(i));
                }
            }

            result.setText(sb.toString());
            db.hide();
        }
    });

    cancel.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            db.hide();
        }
    });
}

From source file:org.dataconservancy.dcs.access.client.upload.Util.java

License:Apache License

public static Widget createListChooser(final TextBox result, final String description, final List<String> list,
        boolean multiple) {
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(5);
    hp.add(result);/*  w w w.java2  s .  co  m*/

    Button choose = new Button("Choose");

    choose.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (list.size() > 0) {
                Util.popupChooser(result, description, list, true);
            }
        }
    });

    hp.add(choose);

    return hp;
}

From source file:org.dataconservancy.dcs.access.ui.client.Application.java

License:Apache License

private HorizontalPanel createSearchResultsNav(int page, int numpages, String tokenqueryprefix) {
    HorizontalPanel nav = new HorizontalPanel();
    nav.setStylePrimaryName("ResultsNav");
    nav.setSpacing(2);

    if (numpages > 1) {
        if (page > 0) {
            nav.add(new Hyperlink("<<", tokenqueryprefix + ';' + 0));

            int offset = (page - 1) * MAX_SEARCH_RESULTS;
            Hyperlink h = new Hyperlink("Previous", tokenqueryprefix + ';' + offset);
            nav.add(h);//from   w  ww  . java 2 s . c  o  m
        }

        int max_pages_shown = 10;

        int startpage = page - (max_pages_shown / 2);

        if (startpage < 0) {
            startpage = 0;
        }

        int endpage = startpage + max_pages_shown;

        if (endpage > numpages) {
            endpage = numpages;
        }

        for (int i = startpage; i < endpage; i++) {
            if (i == page) {
                nav.add(Util.label("" + (i + 1), "CurrentNavigationPage"));
            } else {
                int offset = i * MAX_SEARCH_RESULTS;
                Hyperlink h = new Hyperlink("" + (i + 1), tokenqueryprefix + ';' + offset);
                nav.add(h);
            }
        }

        if (page < numpages - 1) {
            int offset = (page + 1) * MAX_SEARCH_RESULTS;
            Hyperlink h = new Hyperlink("Next", tokenqueryprefix + ';' + offset);
            nav.add(h);

            nav.add(new Hyperlink(">>", tokenqueryprefix + ';' + (numpages - 1) * MAX_SEARCH_RESULTS));
        }
    }

    return nav;
}

From source file:org.dataconservancy.dcs.access.ui.client.Application.java

License:Apache License

private Widget createAdvancedSearchWidget(Search.UserField[] userfields, String[] userqueries) {
    FlowPanel panel = new FlowPanel();

    Button search = new Button("Search");

    final FlexTable table = new FlexTable();

    Button add = new Button("Add field");

    panel.add(table);//from  ww  w. j a  v a 2s .  co m

    // Called to search filled in query

    final ClickHandler searchlistener = new ClickHandler() {

        public void onClick(ClickEvent event) {
            // Build up search history token

            String[] data = new String[(table.getRowCount() * 2) + 1];
            int dataindex = 0;
            boolean emptyquery = true;

            for (int i = 0; i < table.getRowCount(); i++) {
                ListBox lb = (ListBox) table.getWidget(i, 0);
                TextBox tb = (TextBox) table.getWidget(i, 1);

                int sel = lb.getSelectedIndex();

                if (sel != -1) {
                    String userquery = tb.getText().trim();
                    String userfield = Search.UserField.values()[sel].name();

                    if (userquery.isEmpty()) {
                        userfield = null;
                        userquery = null;
                    } else {
                        emptyquery = false;
                    }

                    data[dataindex++] = userfield;
                    data[dataindex++] = userquery;
                }
            }

            data[dataindex] = "0";

            if (!emptyquery) {
                History.newItem(State.SEARCH.toToken(data));
            }
        }
    };

    ClickHandler addlistener = new ClickHandler() {

        public void onClick(ClickEvent event) {
            int row = table.getRowCount();

            table.setWidget(row, 0, createAdvancedSearchFieldSelector());

            TextBox tb = new TextBox();
            table.setWidget(row, 1, tb);

            tb.addKeyDownHandler(new KeyDownHandler() {

                public void onKeyDown(KeyDownEvent event) {
                    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                        searchlistener.onClick(null);
                    }
                }
            });

            final Button remove = new Button("Remove");

            table.setWidget(row, 2, remove);

            remove.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    for (int row = 0; row < table.getRowCount(); row++) {
                        if (table.getWidget(row, 2) == remove) {
                            table.removeRow(row);
                        }
                    }
                }
            });
        }
    };

    add.addClickHandler(addlistener);

    if (userfields != null) {
        for (int i = 0; i < userfields.length; i++) {
            if (userfields[i] == null) {
                continue;
            }

            int row = table.getRowCount();
            addlistener.onClick(null);

            ListBox lb = (ListBox) table.getWidget(row, 0);
            lb.setItemSelected(userfields[i].ordinal(), true);
            TextBox tb = (TextBox) table.getWidget(row, 1);
            tb.setText(userqueries[i]);
        }
    } else {
        addlistener.onClick(null);
    }

    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(5);
    hp.add(add);
    hp.add(search);

    panel.add(hp);

    search.addClickHandler(searchlistener);

    return panel;
}

From source file:org.dataconservancy.dcs.access.ui.client.model.JsDeliverableUnit.java

License:Apache License

public Widget display() {
    FlowPanel panel = new FlowPanel();

    panel.setStylePrimaryName("Entity");

    FlexTable table = Util.createTable("Identifier:", "Entity type:", "Parents:", "Collections:", "Former refs",
            "Metadata refs:", "Surrogate");
    panel.add(table);/*  w w w .  j a  v a  2 s.c o  m*/

    HorizontalPanel hp = new HorizontalPanel();

    table.setWidget(0, 1, hp);

    hp.add(Util.entityLink(getId()));
    hp.setSpacing(5);
    hp.add(new Hyperlink("(related)", State.RELATED.toToken(getId())));

    table.setText(1, 1, "Deliverable Unit");

    if (getParents() != null) {
        table.setWidget(2, 1, Util.entityLinks(getParents()));
    }

    if (getCollections() != null) {
        table.setWidget(3, 1, Util.entityLinks(getCollections()));
    }

    table.setText(4, 1, toString(getFormerExternalRefs()));
    table.setWidget(5, 1, Util.entityLinks(getMetadataRefs()));
    table.setText(6, 1, isDigitalSurrogate() == null ? "Unknown" : "" + isDigitalSurrogate());

    panel.add(Util.label("Core metadata", "SubSectionHeader"));
    panel.add(getCoreMd().display());

    if (getMetadata() != null && getMetadata().length() > 0) {
        panel.add(Util.label("Additional metadata", "SubSectionHeader"));
        JsMetadata.display(panel, getMetadata());
    }

    if (getRelations() != null && getRelations().length() > 0) {
        panel.add(Util.label("Relations", "SubSectionHeader"));
        JsRelation.display(panel, getRelations());
    }

    return panel;
}

From source file:org.dataconservancy.dcs.ingest.ui.client.Application.java

License:Apache License

private void viewFiles() {
    content.clear();/* w w w  .  j  a  va 2  s.  com*/

    Label explain = new Label(
            "Upload local files for inclusion to the SIP. Remote files accessible by a URL may also be added. Files with the same technical enviroment in the same Deliverable Unit will be put in the same Manifestation.");
    explain.setStylePrimaryName("Explanation");

    content.add(explain);

    if (files.getWidgetCount() > 0) {
        files.selectTab(0);
    } else {
        files.setVisible(false);
    }

    Button upload = new Button("Upload local file");
    Button uploadremote = new Button("Add remote file");
    Button remove = new Button("Remove");

    final HorizontalPanel buttons = new HorizontalPanel();
    buttons.setSpacing(5);
    buttons.add(upload);
    buttons.add(uploadremote);

    buttons.add(remove);

    content.add(files);
    content.add(buttons);

    remove.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            int tab = files.getTabBar().getSelectedTab();

            if (tab != -1) {
                files.remove(tab);
                fileids.remove(tab);

                if (files.getWidgetCount() > 0) {
                    files.selectTab(0);
                } else {
                    files.setVisible(false);
                }
            }
        }
    });

    uploadremote.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            files.setVisible(true);
            String id = nextFileId();
            fileids.add(id);
            files.add(new FileEditor(id, "name", "http://"), id);
            files.selectTab(files.getWidgetCount() - 1);
        }
    });

    upload.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            displayUploadFileDialog();
        }
    });
}