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.cleanlogic.cesiumjs4gwt.showcase.examples.Interpolation.java

License:Apache License

@Override
public void buildPanel() {
    csVPanel = new ViewerPanel();

    csVPanel.getViewer().scene().globe.enableLighting = false;
    CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
    cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
    cesiumTerrainProviderOptions.requestWaterMask = true;
    cesiumTerrainProviderOptions.requestVertexNormals = true;
    csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(cesiumTerrainProviderOptions);

    csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;

    Math.setRandomNumberSeed(3);/*from w  ww .  ja  v a2 s  .com*/

    _start = JulianDate.fromDate(new JsDate(2015, 2, 25, 16));
    _stop = JulianDate.addSeconds(_start, 360, new JulianDate());

    csVPanel.getViewer().clock().startTime = _start.clone();
    csVPanel.getViewer().clock().stopTime = _stop.clone();
    csVPanel.getViewer().clock().currentTime = _start.clone();
    csVPanel.getViewer().clock().clockRange = ClockRange.LOOP_STOP();
    csVPanel.getViewer().clock().multiplier = 10;

    csVPanel.getViewer().timeline().zoomTo(_start, _stop);

    PositionProperty position = computeCirclularFlight(-112.110693, 36.0994841, 0.03);
    TimeIntervalOptions timeIntervalOptions = new TimeIntervalOptions();
    timeIntervalOptions.start = _start;
    timeIntervalOptions.stop = _stop;

    ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
    modelGraphicsOptions.uri = new ConstantProperty<>(
            GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.gltf");
    modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(64);

    PolylineGlowMaterialPropertyOptions polylineGlowMaterialPropertyOptions = new PolylineGlowMaterialPropertyOptions();
    polylineGlowMaterialPropertyOptions.glowPower = new ConstantProperty<>(0.1);
    polylineGlowMaterialPropertyOptions.color = new ConstantProperty<>(Color.YELLOW());
    PathGraphicsOptions pathGraphicsOptions = new PathGraphicsOptions();
    pathGraphicsOptions.resolution = new ConstantProperty<>(1);
    pathGraphicsOptions.material = new PolylineGlowMaterialProperty(polylineGlowMaterialPropertyOptions);
    pathGraphicsOptions.width = new ConstantProperty<>(10);

    EntityOptions entityOptions = new EntityOptions();
    entityOptions.availability = new TimeIntervalCollection(
            new TimeInterval[] { new TimeInterval(timeIntervalOptions) });
    entityOptions.position = position;
    entityOptions.orientation = new VelocityOrientationProperty(position);
    entityOptions.model = new ModelGraphics(modelGraphicsOptions);
    entityOptions.path = new PathGraphics(pathGraphicsOptions);
    _entity = csVPanel.getViewer().entities().add(entityOptions);

    ListBox interpolationsLBox = new ListBox();
    interpolationsLBox.addItem("Interpolation: Linear Approximation", "0");
    interpolationsLBox.addItem("Interpolation: Lagrange Polynomial Approximation", "1");
    interpolationsLBox.addItem("Interpolation: Hermite Polynomial Approximation", "2");
    interpolationsLBox.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent changeEvent) {
            ListBox source = (ListBox) changeEvent.getSource();
            SampledPropertyInterpolationOptions sampledPropertyInterpolationOptions = new SampledPropertyInterpolationOptions();
            switch (source.getSelectedValue()) {
            case "0":
                sampledPropertyInterpolationOptions.interpolationDegree = 1;
                sampledPropertyInterpolationOptions.interpolationAlgorithm = LinearApproximation.instance();
                ((SampledPositionProperty) _entity.position)
                        .setInterpolationOptions(sampledPropertyInterpolationOptions);
                break;
            case "1":
                sampledPropertyInterpolationOptions.interpolationDegree = 5;
                sampledPropertyInterpolationOptions.interpolationAlgorithm = LagrangePolynomialApproximation
                        .instance();
                ((SampledPositionProperty) _entity.position)
                        .setInterpolationOptions(sampledPropertyInterpolationOptions);
                break;
            case "2":
                sampledPropertyInterpolationOptions.interpolationDegree = 2;
                sampledPropertyInterpolationOptions.interpolationAlgorithm = HermitePolynomialApproximation
                        .instance();
                ((SampledPositionProperty) _entity.position)
                        .setInterpolationOptions(sampledPropertyInterpolationOptions);
                break;
            default:
                break;
            }
        }
    });

    Button viewTopDownBtn = new Button("View Top Down");
    viewTopDownBtn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            Viewer viewer = csVPanel.getViewer();
            viewer.trackedEntity = (Entity) JsObject.undefined();
            viewer.zoomTo(viewer.entities(), new HeadingPitchRange(0, Math.toRadians(-90), 0));

        }
    });
    Button viewSideBtn = new Button("View Side");
    viewSideBtn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            Viewer viewer = csVPanel.getViewer();
            viewer.trackedEntity = (Entity) JsObject.undefined();
            viewer.zoomTo(viewer.entities(),
                    new HeadingPitchRange(Math.toRadians(-90), Math.toRadians(-15), 7500.0));
        }
    });
    Button viewAircraftBtn = new Button("View Aircraft");
    viewAircraftBtn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            Viewer viewer = csVPanel.getViewer();
            viewer.trackedEntity = _entity;
        }
    });

    HorizontalPanel btnHPanel = new HorizontalPanel();
    btnHPanel.setSpacing(5);
    btnHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    btnHPanel.add(interpolationsLBox);
    btnHPanel.add(viewTopDownBtn);
    btnHPanel.add(viewSideBtn);
    btnHPanel.add(viewAircraftBtn);

    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(btnHPanel, 20, 20);

    contentPanel.add(new HTML("<p>This example shows simple Cesium application</p>"));
    contentPanel.add(aPanel);

    initWidget(contentPanel);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.SkyAtmosphere.java

License:Apache License

@Override
public void buildPanel() {
    _csVPanel = new ViewerPanel();
    Camera camera = _csVPanel.getViewer().camera;
    ViewOptions viewOptions = new ViewOptions();
    viewOptions.destinationPos = Cartesian3.fromDegrees(-75.5847, 40.0397, 1000.0);
    viewOptions.orientation = new HeadingPitchRoll(-Math.PI_OVER_TWO(), 0.2, 0.0);
    camera.setView(viewOptions);/*from ww w.jav a 2s  .  c om*/

    HorizontalPanel hueShiftHPanel = new HorizontalPanel();
    hueShiftHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    hueShiftHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hueShiftHPanel.setSpacing(10);
    _hueShiftSlider = new Slider("hueShift", -100, 100, 0);
    _hueShiftSlider.setStep(1);
    _hueShiftSlider.setWidth("150px");
    _hueShiftSlider.addListener(new MSliderListener());
    _hueShiftTBox = new TextBox();
    _hueShiftTBox.addChangeHandler(new MChangeHandler());
    _hueShiftTBox.setText("0");
    _hueShiftTBox.setSize("30px", "12px");
    hueShiftHPanel.add(_hueShiftSlider);
    hueShiftHPanel.add(_hueShiftTBox);

    HorizontalPanel saturationShiftHPanel = new HorizontalPanel();
    saturationShiftHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    saturationShiftHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    saturationShiftHPanel.setSpacing(10);
    _saturationShiftSlider = new Slider("saturationShift", -100, 100, 0);
    _saturationShiftSlider.setStep(1);
    _saturationShiftSlider.setWidth("150px");
    _saturationShiftSlider.addListener(new MSliderListener());
    _saturationShiftTBox = new TextBox();
    _saturationShiftTBox.addChangeHandler(new MChangeHandler());
    _saturationShiftTBox.setText("0");
    _saturationShiftTBox.setSize("30px", "12px");
    saturationShiftHPanel.add(_saturationShiftSlider);
    saturationShiftHPanel.add(_saturationShiftTBox);

    HorizontalPanel brightnessShiftHPanel = new HorizontalPanel();
    brightnessShiftHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    brightnessShiftHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    brightnessShiftHPanel.setSpacing(10);
    _brightnessShiftSlider = new Slider("brightnessShift", -100, 100, 0);
    _brightnessShiftSlider.setStep(1);
    _brightnessShiftSlider.setWidth("150px");
    _brightnessShiftSlider.addListener(new MSliderListener());
    _brightnessShiftTBox = new TextBox();
    _brightnessShiftTBox.addChangeHandler(new MChangeHandler());
    _brightnessShiftTBox.setText("0");
    _brightnessShiftTBox.setSize("30px", "12px");
    brightnessShiftHPanel.add(_brightnessShiftSlider);
    brightnessShiftHPanel.add(_brightnessShiftTBox);

    CheckBox lightingCBox = new CheckBox();
    lightingCBox.setWidth("100px");
    lightingCBox.setValue(true);
    lightingCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            _csVPanel.getViewer()
                    .scene().globe.enableLighting = !_csVPanel.getViewer().scene().globe.enableLighting;
        }
    });

    CheckBox fogCBox = new CheckBox();
    fogCBox.setWidth("100px");
    fogCBox.setValue(true);
    fogCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            _csVPanel.getViewer().scene().fog.enabled = !_csVPanel.getViewer().scene().fog.enabled;
        }
    });

    FlexTable flexTable = new FlexTable();
    flexTable.setHTML(1, 0, "<font color=\"white\">hueShift</font>");
    flexTable.setWidget(1, 1, hueShiftHPanel);
    flexTable.setHTML(2, 0, "<font color=\"white\">saturationShift</font>");
    flexTable.setWidget(2, 1, saturationShiftHPanel);
    flexTable.setHTML(3, 0, "<font color=\"white\">brightnessShift</font>");
    flexTable.setWidget(3, 1, brightnessShiftHPanel);
    flexTable.setHTML(4, 0, "<font color=\"white\">Toggle Lighting</font>");
    flexTable.setWidget(4, 1, lightingCBox);
    flexTable.setHTML(5, 0, "<font color=\"white\">Toggle Fog</font>");
    flexTable.setWidget(5, 1, fogCBox);

    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(_csVPanel);
    aPanel.add(flexTable, 20, 20);

    contentPanel.add(new HTML("<p>Adjust hue, saturation, and brightness of the sky/atmosphere.</p>"));
    contentPanel.add(aPanel);

    initWidget(contentPanel);
}

From source file:org.cruxframework.crux.widgets.client.colorpicker.ColorPickerDialog.java

License:Apache License

protected HorizontalPanel createDialogArea() {
    setText(messages.colorPickerDialogSelectColor());

    HorizontalPanel panel = new HorizontalPanel();
    panel.setSpacing(5);
    // the pickers
    slPicker = new SaturationLightnessPicker();

    slPicker.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override/*w  w w  .j  a v  a  2  s . c o m*/
        public void onValueChange(ValueChangeEvent<String> event) {
            previewPanel.getElement().getStyle().setBackgroundColor("#" + event.getValue());
            manualPicker.setText("#" + event.getValue());
        }
    });
    panel.add(slPicker);
    huePicker = new HuePicker();
    panel.add(huePicker);

    // bind saturation/lightness picker and hue picker together
    huePicker.addValueChangeHandler(new ValueChangeHandler<Integer>() {
        @Override
        public void onValueChange(ValueChangeEvent<Integer> event) {
            slPicker.setHue(event.getValue());
        }
    });

    return panel;
}

From source file:org.cruxframework.crux.widgets.client.dialog.ConfirmDialog.java

License:Apache License

/**
 * Constructor /*from  ww w .  j  a  v a2s .co  m*/
 */
public ConfirmDialog() {
    dialogBox = new DialogBox(false, true);

    confirmPanel = new DockPanel();
    messageLabel = createMessageLabel();
    confirmPanel.add(messageLabel, DockPanel.CENTER);

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setSpacing(10);
    okButton = createOkButton();
    horizontalPanel.add(okButton);
    cancelButton = createCancelButton();
    horizontalPanel.add(cancelButton);

    if (defaultCloseHandlers != null) {
        for (CloseHandler<ConfirmDialog> closeHandler : defaultCloseHandlers) {
            this.addCloseHandler(closeHandler);
        }
    }

    if (defaultOpenHandlers != null) {
        for (OpenHandler<ConfirmDialog> openHandler : defaultOpenHandlers) {
            this.addOpenHandler(openHandler);
        }
    }

    confirmPanel.add(horizontalPanel, DockPanel.SOUTH);
    confirmPanel.setCellHorizontalAlignment(horizontalPanel, HasHorizontalAlignment.ALIGN_CENTER);

    dialogBox.add(confirmPanel);
    confirmPanel.getElement().getParentElement().setAttribute("align", "center");

    setStyleName(DEFAULT_STYLE_NAME);
}

From source file:org.cruxframework.crux.widgets.client.dialog.MessageDialog.java

License:Apache License

/**
 * Constructor /*ww w.  ja va  2  s.  c  o m*/
 */
public MessageDialog() {
    dialogBox = new DialogBox(false, true);

    messagePanel = new DockPanel();
    messageLabel = createMessageLabel();
    messagePanel.add(messageLabel, DockPanel.CENTER);

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setSpacing(10);
    okButton = createOkButton();
    horizontalPanel.add(okButton);

    if (defaultCloseHandlers != null) {
        for (CloseHandler<MessageDialog> closeHandler : defaultCloseHandlers) {
            this.addCloseHandler(closeHandler);
        }
    }

    if (defaultOpenHandlers != null) {
        for (OpenHandler<MessageDialog> openHandler : defaultOpenHandlers) {
            this.addOpenHandler(openHandler);
        }
    }

    messagePanel.add(horizontalPanel, DockPanel.SOUTH);
    messagePanel.setCellHorizontalAlignment(horizontalPanel, HasHorizontalAlignment.ALIGN_CENTER);

    dialogBox.add(messagePanel);
    messagePanel.getElement().getParentElement().setAttribute("align", "center");

    setStyleName(DEFAULT_STYLE_NAME);
    handleOrientationChangeHandlers();
}

From source file:org.cruxframework.crux.widgets.client.dialog.Progress.java

License:Apache License

public Progress() {
    dialog = new DialogBox(false, true);
    dialog.setStyleName(DEFAULT_STYLE_NAME);

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setSpacing(0);

    FocusPanel iconPanel = createIconPanel();
    horizontalPanel.add(iconPanel);/*from  ww  w . j a  v  a2  s . com*/
    this.messageLabel = createMessageLabel();
    horizontalPanel.add(this.messageLabel);

    dialog.add(horizontalPanel);
}

From source file:org.cruxframework.crux.widgets.client.tabcontainer.FlapController.java

License:Apache License

/**
 * @param tabs//www  .  ja  va 2  s . c o  m
 * @param tabId
 * @param tabLabel
 * @param closeable
 */
public FlapController(final TabContainer tabs, final String tabId, String tabLabel, boolean asHTML,
        boolean closeable) {
    this.closeable = closeable;
    HorizontalPanel flap = new HorizontalPanel();

    initWidget(flap);

    flap.setSpacing(0);

    if (asHTML) {
        title = new HTML(tabLabel);
    } else {
        title = new Label(tabLabel);
    }
    title.setStyleName("flapLabel");
    flap.add(title);

    if (closeable) {
        closeButton = new FocusWidget(new Label(" ").getElement()) {
        };

        closeButton.setStyleName("flapCloseButton");
        closeButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                event.stopPropagation();
                tabs.closeView(tabId, false);
            }
        });

        closeButton.addKeyDownHandler(new KeyDownHandler() {
            public void onKeyDown(KeyDownEvent event) {
                if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                    event.stopPropagation();
                    tabs.closeView(tabId, false);
                }
            }
        });

        closeButton.setVisible(closeable);

        Screen.ensureDebugId(closeButton, tabs.getElement().getId() + "_" + tabId + "_close_btn");

        flap.add(closeButton);
    }
}

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

License:Apache License

public Widget display(final String entityId, final CellTree tree) {
    //final Grid grid = //new Grid(7,2);
    final FlexTable grid = Util.createTable("Title:", "", "Contact:", "Subjects:", "Type:", "Rights:");
    grid.setWidth("90%");
    grid.getCellFormatter().setStyleName(1, 1, "PaddedCell");

    final HorizontalPanel hp = new HorizontalPanel();

    hp.setSpacing(5);

    final Image image = new Image("images/wait.gif");
    final Label delete = Util.label("Delete [X]", "SimplerButton");
    final Label title = Util.label(getTitle(), "HeadingField");

    final Label expand = new Label("[+]");
    expand.setStyleName("Expand");

    final Label collapse = new Label("[-]");
    collapse.setStyleName("Collapse");
    final ScrollPanel treePanel = getTree(tree);

    delete.addClickHandler(new ClickHandler() {

        @Override//w ww. j  a  v  a  2 s  .  c  o  m
        public void onClick(ClickEvent event) {
            depositService.deleteCollection(entityId, SeadApp.accessurl, new AsyncCallback<Boolean>() {

                @Override
                public void onSuccess(Boolean result) {
                    Window.alert("The collection was deleted.");
                    History.newItem(SeadState.HOME.toToken());
                }

                @Override
                public void onFailure(Throwable caught) {
                    Window.alert("Sorry, the collection could not be deleted.");
                    History.newItem(SeadState.HOME.toToken());
                }
            });

        }
    });

    expand.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            hp.remove(expand);
            hp.remove(title);
            int del = 0;
            if (delete.isAttached()) {
                hp.remove(delete);
                del = 1;
            }
            hp.add(collapse);
            hp.add(title);
            if (del == 1)
                hp.add(delete);
            if (tree != null) {
                //grid.setWidget(1, 0, new Label("Contains"));
                grid.setWidget(1, 1, treePanel);
            } else {
                History.newItem("related;" + entityId);
            }
        }
    });

    collapse.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            grid.remove(treePanel);
            hp.remove(collapse);
            hp.remove(title);
            int del = 0;
            if (delete.isAttached()) {
                hp.remove(delete);
                del = 1;
            }
            hp.add(expand);
            hp.add(title);
            if (del == 1)
                hp.add(delete);
        }
    });
    //TODO:Loading of related files takes too much time
    if (tree == null) {

        hp.add(expand);
    } else {

        hp.add(collapse);
        //hp.add(collapse);
    }
    hp.add(title);

    hp.add(image);
    final AsyncCallback<UserSession> cb = new AsyncCallback<UserSession>() {

        public void onSuccess(final UserSession result) {
            if (image.isAttached())
                hp.remove(image);
            if (getSubmitter().getSubmitterId().equals(result.getEmail())) {
                hp.add(delete);
            }
        }

        public void onFailure(Throwable error) {
            Window.alert("Failed to login: " + error.getMessage());

        }
    };

    SeadApp.userService.checkSession(null, cb);

    grid.setWidget(0, 1, hp);
    grid.setWidget(2, 1, new Label(getContact()));
    grid.setWidget(3, 1, new Label(toString(getSubjects())));
    grid.setWidget(4, 1, new Label(getType()));
    grid.setWidget(5, 1, new Label(getRights()));

    if (tree != null)
        grid.setWidget(1, 1, treePanel);

    return grid;
}

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

License:Apache License

public EditPopupPanel(final JsEntity entity, final EditDcpTreeModel.JsEntityCell jsEntityCell, final JsDcp dcp,
        final String sipPath, final String type) {
    super(true);/*w  w  w  .  java 2 s.  co  m*/
    this.setGlassEnabled(true);
    this.addCloseHandler(new CloseHandler<PopupPanel>() {

        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
        }
    });
    this.show();
    this.setStyleName("loginPopupContainer");
    this.setPopupPosition(Window.WINDOW_WIDTH / 3, Window.WINDOW_HEIGHT / 4);

    outerPanel = new VerticalPanel();
    outerPanel.setSpacing(10);
    outerPanel.setWidth("95%");
    outerPanel.setStyleName("loginPopupContainer");
    setWidget(outerPanel);

    outerPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);

    Label loginLabel = new Label("Edit Entity");
    loginLabel.setStyleName("loginLabelStyle");

    outerPanel.add(loginLabel);

    final HorizontalPanel innerPanel = new HorizontalPanel();
    innerPanel.setSpacing(10);
    saveButton = new Button("Save changes");
    saveButton.setStyleName("popupLoginButton");
    saveButton.setWidth("150px");
    saveButton.setHeight("40px");

    final PopupPanel thisPanel = this;

    String titleStr = null;
    String abstractStr = null;

    List<String> authors = new ArrayList<String>();
    final FlexTable propertiesGrid = new FlexTable();
    propertiesGrid.setWidth("85%");
    propertiesGrid.setCellPadding(8);
    if (type.equalsIgnoreCase("file")) {

        String fileName = ((JsFile) entity).getName();
        int dotIndex = fileName.lastIndexOf(".");
        if (dotIndex != -1) {
            titleStr = fileName.substring(0, dotIndex);
            extension = fileName.substring(dotIndex);
        } else
            titleStr = fileName;
        final JsArray<JsMetadata> metadataList = ((JsFile) entity).getMetadata();
        int j = 0;
        for (int i = 0; i < metadataList.length(); i++) {
            final int index = i;
            final JsMetadata metadata = metadataList.get(i);
            transformerServiceAsync.parseEntityMetadata(metadata.getMetadata(),
                    new AsyncCallback<Map<String, String>>() {
                        @Override
                        public void onSuccess(Map<String, String> map) {
                            Iterator iterator = map.entrySet().iterator();
                            Entry<String, String> result = null;
                            while (iterator.hasNext()) {
                                result = (Entry<String, String>) iterator.next();
                                break;
                            }

                            if (Constants.predicateViewMap.containsKey(result.getKey().trim())) {
                                int k = propertiesGrid.getRowCount();
                                propertiesGrid.setWidget(k, 0,
                                        new Label(Constants.predicateViewMap.get(result.getKey().trim())));
                                TextBox metadataValue = new TextBox();
                                metadataValue.setText(result.getValue());
                                propertiesGrid.setWidget(k, 1, metadataValue);
                            }
                            if (index == metadataList.length() - 1) {

                                outerPanel.add(propertiesGrid);
                                innerPanel.add(saveButton);
                                outerPanel.add(innerPanel);
                            }
                        }

                        @Override
                        public void onFailure(Throwable caught) {
                            ;
                        }
                    });
        }
    } else if (type.equalsIgnoreCase("deliverableUnit")) {

        titleStr = ((JsDeliverableUnit) entity).getCoreMd().getTitle();
        abstractStr = ((JsDeliverableUnit) entity).getAbstract();
        JsArray<JsCreator> creators = ((JsDeliverableUnit) entity).getCreators();
        for (int i = 0; i < creators.length(); i++)
            authors.add(creators.get(i).getCreatorName());

        final JsArray<JsMetadata> metadataList = ((JsFile) entity).getMetadata();

        for (int i = 0; i < metadataList.length(); i++) {
            final int index = i;
            final JsMetadata metadata = metadataList.get(i);
            transformerServiceAsync.parseEntityMetadata(metadata.getMetadata(),
                    new AsyncCallback<Map<String, String>>() {
                        @Override
                        public void onSuccess(Map<String, String> map) {
                            Iterator iterator = map.entrySet().iterator();
                            Entry<String, String> result = null;
                            while (iterator.hasNext()) {
                                result = (Entry<String, String>) iterator.next();
                                break;
                            }

                            if (Constants.predicateViewMap.containsKey(result.getKey().trim())) {
                                int k = propertiesGrid.getRowCount();
                                propertiesGrid.setWidget(k, 0,
                                        new Label(Constants.predicateViewMap.get(result.getKey().trim())));
                                TextBox metadataValue = new TextBox();
                                metadataValue.setText(result.getValue());
                                propertiesGrid.setWidget(k, 1, metadataValue);
                            }

                            if (index == metadataList.length() - 1) {

                                outerPanel.add(propertiesGrid);
                                innerPanel.add(saveButton);
                                outerPanel.add(innerPanel);
                            }
                        }

                        @Override
                        public void onFailure(Throwable caught) {
                            ;
                        }
                    });
        }
    }

    saveButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {

            entityName = title.getText();

            if (type.equalsIgnoreCase("file")) {
                if (extension != null)
                    entityName += extension;
                ((JsFile) entity).setName(entityName);
            } else if (type.equalsIgnoreCase("deliverableUnit")) {
                ((JsDeliverableUnit) entity).setTitle(entityName);
                ((JsDeliverableUnit) entity).setAbstract(abstractBox.getText());
            }

            Map<String, List<String>> changes = new HashMap<String, List<String>>();
            List<String> nameList = new ArrayList<String>();
            nameList.add(entityName);
            changes.put("title", nameList);
            if (abstractBox != null) {
                List<String> abstractList = new ArrayList<String>();
                abstractList.add(abstractBox.getText());
                changes.put("abstract", abstractList);
            }

            if (propertiesGrid != null) {
                int count = propertiesGrid.getRowCount();
                for (int i = 0; i < count; i++) {
                    if (propertiesGrid.getWidget(i, 0) != null && propertiesGrid.getWidget(i, 1) != null) {
                        String newValue = ((TextBox) propertiesGrid.getWidget(i, 1)).getText().trim();
                        String predicate = Constants.viewPredicateMap
                                .get(((Label) propertiesGrid.getWidget(i, 0)).getText().trim());
                        List<String> customMd = new ArrayList<String>();
                        if (changes.containsKey(predicate))
                            customMd = changes.get(predicate);
                        customMd.add(newValue);
                        changes.put(predicate, customMd);
                    }
                }
            }

            //Update the SIP that gets sent to the registry/ro system
            registryService.updateSip(sipPath, entity.getId(), changes, Constants.predicateViewMap,
                    new AsyncCallback<Void>() {

                        @Override
                        public void onSuccess(Void result) {
                            EditPresenter.EVENT_BUS.fireEvent(new ROEditEvent(true, sipPath));
                            thisPanel.hide();
                        }

                        @Override
                        public void onFailure(Throwable caught) {
                            new ErrorPopupPanel("Error:" + caught.getMessage()).show();
                        }
                    });
        }
    });

    createCoreMd(titleStr, extension, abstractStr, authors);

}

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

License:Apache License

public LoginPopupPanel() {
    super(true);//  w  w w .  j  a  v  a  2 s  . c  o  m
    this.setGlassEnabled(true);
    this.addCloseHandler(new CloseHandler<PopupPanel>() {

        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            History.newItem(SeadState.HOME.toToken());
        }
    });
    this.show();
    this.setStyleName("loginPopupContainer");

    this.setPopupPosition(Window.WINDOW_WIDTH / 3, Window.WINDOW_HEIGHT / 4);

    VerticalPanel outerPanel = new VerticalPanel();
    //outerPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    outerPanel.setSpacing(10);
    outerPanel.setWidth("95%");

    outerPanel.setStyleName("loginPopupContainer");

    setWidget(outerPanel);

    outerPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);

    userLoginDetails = new UserLoginDetails();
    userRegisterDetails = new UserRegisterDetails();
    Label loginLabel = new Label("Login");
    loginLabel.setStyleName("loginLabelStyle");

    loginForm = new Grid(2, 2);
    loginForm.setCellPadding(8);
    outerPanel.add(loginLabel);
    errorMessage = new Label();
    errorMessage.setStyleName("greenFont");
    outerPanel.add(errorMessage);
    outerPanel.add(loginForm);

    HorizontalPanel innerPanel = new HorizontalPanel();
    innerPanel.setSpacing(10);
    googleLogin = new Button(" Google Sign On");
    googleLogin.setStyleName("popupLoginButton");
    googleLogin.setWidth("150px");
    googleLogin.setHeight("40px");
    loginButton = new Button("Login");
    loginButton.setStyleName("popupLoginButton");
    loginButton.setWidth("100px");
    loginButton.setHeight("40px");

    innerPanel.add(loginButton);

    innerPanel.add(googleLogin);

    outerPanel.add(innerPanel);

    registerForm = new Grid(8, 2);
    registerForm.setCellPadding(6);
    createRegisterForm();
    registerClosure = new DisclosurePanel("SignUp");
    registerClosure.setAnimationEnabled(true);
    registerClosure.setContent(registerForm);
    outerPanel.add(registerClosure);
    createLoginForm();
}