Example usage for com.google.gwt.user.client Window open

List of usage examples for com.google.gwt.user.client Window open

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window open.

Prototype

public static void open(String url, String name, String features) 

Source Link

Usage

From source file:org.iplantc.phyloviewer.viewer.client.Phyloviewer.java

License:Creative Commons License

/**
 * This is the entry point method.//from  w w  w . j  a  v a  2  s  .com
 */
public void onModuleLoad() {

    widget = new TreeWidget(searchService, eventBus);

    Style highlight = new Style("highlight");
    highlight.setNodeStyle(new NodeStyle("#C2C2F5", Double.NaN, null));
    highlight.setLabelStyle(new LabelStyle(null));
    highlight.setGlyphStyle(new GlyphStyle(null, "#C2C2F5", Double.NaN));
    highlight.setBranchStyle(new BranchStyle("#C2C2F5", Double.NaN));

    RenderPreferences rp = new RenderPreferences();
    rp.setHighlightStyle(highlight);
    widget.setRenderPreferences(rp);

    MenuBar fileMenu = new MenuBar(true);
    fileMenu.addItem("Open...", new Command() {

        @Override
        public void execute() {
            Phyloviewer.this.displayTrees();
        }

    });

    Command openURL = new Command() {
        @Override
        public void execute() {
            Window.open(widget.exportImageURL(), "_blank", "");
        }
    };

    fileMenu.addItem("Get image (opens in a popup window)", openURL);

    Command showSVG = new Command() {
        @Override
        public void execute() {
            String svg = getSVG();
            String url = "data:image/svg+xml;charset=utf-8," + svg;
            Window.open(url, "_blank", "");
        }
    };
    fileMenu.addItem("Export to SVG", showSVG);

    MenuBar layoutMenu = new MenuBar(true);
    layoutMenu.addItem("Rectangular Cladogram", new Command() {
        @Override
        public void execute() {
            ITree tree = widget.getDocument().getTree();
            byte[] treeID = ((RemoteTree) tree).getHash();
            widget.setDocument(null);
            widget.setViewType(TreeWidget.ViewType.VIEW_TYPE_CLADOGRAM);
            layoutType = "LAYOUT_TYPE_CLADOGRAM";

            loadTree(null, treeID, layoutType);
        }
    });
    layoutMenu.addItem("Rectangular Phylogram", new Command() {
        @Override
        public void execute() {
            ITree tree = widget.getDocument().getTree();
            byte[] treeID = ((RemoteTree) tree).getHash();
            widget.setDocument(null);
            widget.setViewType(TreeWidget.ViewType.VIEW_TYPE_CLADOGRAM);
            layoutType = "LAYOUT_TYPE_PHYLOGRAM";

            loadTree(null, treeID, layoutType);
        }
    });
    layoutMenu.addItem("Circular", new Command() {
        @Override
        public void execute() {
            ITree tree = widget.getDocument().getTree();
            byte[] treeID = ((RemoteTree) tree).getHash();
            widget.setDocument(null);
            widget.setViewType(TreeWidget.ViewType.VIEW_TYPE_RADIAL);
            layoutType = "LAYOUT_TYPE_CLADOGRAM";

            loadTree(null, treeID, layoutType);
        }
    });

    MenuBar styleMenu = new MenuBar(true);
    final TextInputPopup styleTextPopup = new TextInputPopup();
    styleTextPopup.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String style = event.getValue();

            try {
                IStyleMap styleMap = StyleServiceClient.parseJSON(style);
                widget.getDocument().setStyleMap(styleMap);
                widget.render();
            } catch (StyleServiceException e) {
                Window.alert(
                        "Unable to parse style document. See https://pods.iplantcollaborative.org/wiki/display/iptol/Using+Phyloviewer+GWT+client+library#UsingPhyloviewerGWTclientlibrary-Addingstylingmarkuptoviewer for help.");
            }
        }
    });

    styleTextPopup.setModal(true);

    styleMenu.addItem("Import Tree Styling", new Command() {
        @Override
        public void execute() {
            styleTextPopup.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
                @Override
                public void setPosition(int offsetWidth, int offsetHeight) {
                    int left = (Window.getClientWidth() - offsetWidth) / 3;
                    int top = (Window.getClientHeight() - offsetHeight) / 3;
                    styleTextPopup.setPopupPosition(left, top);
                }
            });
        }
    });

    // Make a search box
    final SuggestBox searchBox = new SuggestBox(searchService);
    searchBox.setLimit(10); // TODO make scrollable?
    searchBox.addSelectionHandler(new SelectionHandler<Suggestion>() {
        @Override
        public void onSelection(SelectionEvent<Suggestion> event) {
            Box2D box = ((RemoteNodeSuggestion) event.getSelectedItem()).getResult().layout.boundingBox;
            widget.show(box);
        }
    });

    // create some styling widgets for the context menu
    NodeStyleWidget nodeStyleWidget = new NodeStyleWidget(widget.getDocument());
    BranchStyleWidget branchStyleWidget = new BranchStyleWidget(widget.getDocument());
    GlyphStyleWidget glyphStyleWidget = new GlyphStyleWidget(widget.getDocument());
    LabelStyleWidget labelStyleWidget = new LabelStyleWidget(widget.getDocument());

    // replace their default TextBoxes with ColorBoxes, which jscolor.js will add a color picker to
    nodeStyleWidget.setColorWidget(createColorBox());
    branchStyleWidget.setStrokeColorWidget(createColorBox());
    glyphStyleWidget.setStrokeColorWidget(createColorBox());
    glyphStyleWidget.setFillColorWidget(createColorBox());
    labelStyleWidget.setColorWidget(createColorBox());

    // add the widgets to separate panels on the context menu
    final ContextMenu contextMenuPanel = new ContextMenu(widget);
    contextMenuPanel.add(new NodeTable(), "Node details", 3);
    contextMenuPanel.add(nodeStyleWidget, "Node", 3);
    contextMenuPanel.add(branchStyleWidget, "Branch", 3);
    contextMenuPanel.add(glyphStyleWidget, "Glyph", 3);
    contextMenuPanel.add(labelStyleWidget, "Label", 3);

    HorizontalPanel searchPanel = new HorizontalPanel();
    searchPanel.add(new Label("Search:"));
    searchPanel.add(searchBox);

    // Make the UI.
    MenuBar menu = new MenuBar();
    final DockLayoutPanel mainPanel = new DockLayoutPanel(Unit.EM);
    mainPanel.addNorth(menu, 2);
    mainPanel.addSouth(searchPanel, 2);
    mainPanel.addWest(contextMenuPanel, 0);
    mainPanel.add(widget);
    RootLayoutPanel.get().add(mainPanel);

    MenuBar viewMenu = new MenuBar(true);
    viewMenu.addItem("Layout", layoutMenu);
    viewMenu.addItem("Style", styleMenu);

    contextMenuPanel.setVisible(false);
    viewMenu.addItem("Toggle Context Panel", new Command() {
        @Override
        public void execute() {
            if (contextMenuPanel.isVisible()) {
                contextMenuPanel.setVisible(false);
                mainPanel.setWidgetSize(contextMenuPanel, 0);
                mainPanel.forceLayout();
            } else {
                contextMenuPanel.setVisible(true);
                mainPanel.setWidgetSize(contextMenuPanel, 20);
                mainPanel.forceLayout();
            }
        }
    });

    menu.addItem("File", fileMenu);
    menu.addItem("View", viewMenu);

    // Draw for the first time.
    RootLayoutPanel.get().forceLayout();
    mainPanel.forceLayout();
    widget.setViewType(ViewType.VIEW_TYPE_CLADOGRAM);
    widget.render();

    initColorPicker();

    String[] splitPath = Window.Location.getPath().split("/");
    String treeIdString = null;
    for (int i = 0; i < splitPath.length; i++) {
        if (splitPath[i].equalsIgnoreCase("tree")) {
            treeIdString = splitPath[i + 1];
        }
    }

    if (treeIdString != null && !treeIdString.equals("")) {
        try {
            final byte[] treeId = Hex.decodeHex(treeIdString.toCharArray());
            this.loadTree(null, treeId, layoutType);
        } catch (Exception e) {
            Window.alert("Unable to parse tree ID string from URL");
        }
    } else {
        // Present the user the dialog to load a tree.
        this.displayTrees();
    }

    updateStyle();
    History.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            updateStyle();
        }
    });
}

From source file:org.jahia.ajax.gwt.client.widget.form.FormDeployPortletDefinition.java

License:Open Source License

protected void createUI() {
    setAction(getPortletDeploymentParam("formActionUrl"));
    setEncoding(Encoding.MULTIPART);
    setMethod(Method.POST);/*from   ww w.j  a va  2 s  . co  m*/
    setBodyBorder(false);
    setFrame(false);
    setAutoHeight(true);
    setHeaderVisible(false);
    setButtonAlign(Style.HorizontalAlignment.CENTER);
    setStyleAttribute("padding", "4");
    setLabelWidth(200);
    setFieldWidth(300);

    final com.extjs.gxt.ui.client.widget.form.FileUploadField portletDefinitionField = new com.extjs.gxt.ui.client.widget.form.FileUploadField();
    portletDefinitionField.setAllowBlank(false);
    portletDefinitionField.setName("portletDefinition");
    portletDefinitionField.setWidth(290);
    portletDefinitionField.setFieldLabel(
            Messages.get("org.jahia.engines.PortletsManager.wizard.upload.label", "Portlets WAR file"));
    add(portletDefinitionField);

    final HiddenField<Boolean> preparePortlet = new HiddenField<Boolean>();
    preparePortlet.setName("doPrepare");
    preparePortlet.setValue(false);
    add(preparePortlet);

    final HiddenField<Boolean> deployPortlet = new HiddenField<Boolean>();
    deployPortlet.setName("doDeploy");
    deployPortlet.setValue(false);
    add(deployPortlet);

    final HiddenField<String> jcrReturnContentType = new HiddenField<String>();
    jcrReturnContentType.setName("jcrReturnContentType");
    jcrReturnContentType.setValue("json");
    add(jcrReturnContentType);

    Button prepareButton = new Button(Messages.get("label.portletPrepareWar", "Prepare"));
    prepareButton.addSelectionListener(new SelectionListener<ButtonEvent>() {
        @Override
        public void componentSelected(ButtonEvent ce) {
            preparePortlet.setValue(true);
            doCloseParent = true;
            submitAfterValidation(portletDefinitionField);
        }
    });
    addButton(prepareButton);

    final boolean autoDeploySupported = autoDeploySupported();
    Button deployButton = new Button(Messages.get("label.deployNewPortlet", "Deploy"));
    deployButton.addSelectionListener(new SelectionListener<ButtonEvent>() {
        @Override
        public void componentSelected(ButtonEvent ce) {
            if (autoDeploySupported) {
                deployPortlet.setValue(true);
                doCloseParent = true;
                submitAfterValidation(portletDefinitionField);
            } else {
                doCloseParent = false;
                Window.open(getAppserverDeployerUrl(), "_blank", "");
            }
        }
    });
    addButton(deployButton);

    if (autoDeploySupported) {
        Button prepareAndDeployButton = new Button(
                Messages.get("label.prepareAndDeployWar", "Prepare and deploy"));
        prepareAndDeployButton.addSelectionListener(new SelectionListener<ButtonEvent>() {
            @Override
            public void componentSelected(ButtonEvent ce) {
                deployPortlet.setValue(true);
                preparePortlet.setValue(true);
                doCloseParent = true;
                submitAfterValidation(portletDefinitionField);

            }
        });
        addButton(prepareAndDeployButton);

    }

    Button helpButton = new Button("?");
    helpButton.setWidth(30);
    helpButton.addSelectionListener(new SelectionListener<ButtonEvent>() {
        public void componentSelected(ButtonEvent buttonEvent) {
            deployPortlet.setValue(false);
            preparePortlet.setValue(false);
            doCloseParent = false;
            submit();
        }
    });
    addButton(helpButton);

    final FormPanel form = this;

    addListener(Events.BeforeSubmit, new Listener<FormEvent>() {
        public void handleEvent(FormEvent formEvent) {
            form.mask(Messages.get("label.loading", "Loading..."));
        }
    });
    addListener(Events.Submit, new Listener<FormEvent>() {
        public void handleEvent(FormEvent formEvent) {
            if (doCloseParent) {
                closeParent();
            }
            HTML responseHTML = new HTML(formEvent.getResultHtml());
            String response = responseHTML.getText();

            if (!response.trim().isEmpty()) {
                JSONValue rspValue = JSONParser.parseStrict(response);
                if (rspValue != null && rspValue.isObject() != null
                        && rspValue.isObject().containsKey("dspMsg")) {
                    String dspMsg = rspValue.isObject().get("dspMsg").isString().stringValue();
                    MessageBox.info(Messages.get("label.deployNewPortlet", "Deploy new portlets"), dspMsg,
                            new Listener<MessageBoxEvent>() {
                                public void handleEvent(MessageBoxEvent be) {
                                    refreshParent();
                                }
                            });
                }
            }
            form.unmask();
        }
    });

    layout();
}

From source file:org.jahia.ajax.gwt.client.widget.toolbar.action.OpenWindowActionItem.java

License:Open Source License

@Override
public void onComponentSelection() {
    Map preferences = getGwtToolbarItem().getProperties();
    final GWTJahiaProperty windowUrl = (GWTJahiaProperty) preferences.get(Constants.URL);
    if (Log.isDebugEnabled()) {
        Iterator it = preferences.keySet().iterator();
        while (it.hasNext()) {
            Log.debug("Found property: " + it.next());
        }//w ww  . j ava2s . co m
    }

    String wOptions = "";

    final GWTJahiaProperty noOptions = (GWTJahiaProperty) preferences.get(Constants.NO_OPTIONS);

    if (noOptions == null) {
        final GWTJahiaProperty windowWidth = (GWTJahiaProperty) preferences.get(Constants.WIDTH);
        String wWidth = "";
        if (windowWidth == null) {
            Log.debug("Warning: width not found - nb. preferences:" + preferences.size());
            wWidth = ",width=900";
        } else {
            wWidth = ",width=" + windowWidth.getValue();
        }

        final GWTJahiaProperty windowHeight = (GWTJahiaProperty) preferences.get(Constants.HEIGHT);
        String wHeight = "";
        if (windowHeight == null) {
            wHeight = ",height=600";
        } else {
            wHeight = ",height=" + windowHeight.getValue();
        }
        wOptions = "scrollbars=yes,resizable=yes,status=no,location=no" + wWidth + wHeight;
    }

    String name = getPropertyValue(getGwtToolbarItem(), "target");
    name = name != null ? name : getGwtToolbarItem().getTitle().replaceAll(" ", "_").replaceAll("-", "_");
    final String jsUrl = getPropertyValue(getGwtToolbarItem(), "js.url");
    if (jsUrl != null) {
        Window.open(JahiaGWTParameters.getParam(jsUrl), name, wOptions);
    } else if (windowUrl != null && windowUrl.getValue() != null) {
        String value = URL.replacePlaceholders(windowUrl.getValue(),
                linker.getSelectionContext().getSingleSelection());
        Window.open(value, name, wOptions);
    }
}

From source file:org.jahia.ajax.gwt.client.widget.toolbar.action.SwitchModeActionItem.java

License:Open Source License

private void onComponentSelection(final boolean openWindow) {
    final String workspace = getPropertyValue(getGwtToolbarItem(), "workspace");
    final String urlParams = getPropertyValue(getGwtToolbarItem(), "urlParams");
    final String servlet = getPropertyValue(getGwtToolbarItem(), "servlet");
    final GWTJahiaNode node = linker.getSelectionContext().getMainNode();
    if (node != null) {
        String path = node.getPath();
        String locale = JahiaGWTParameters.getLanguage();
        JahiaContentManagementService.App.getInstance().getNodeURL(servlet, path, null, null, workspace, locale,
                false, new BaseAsyncCallback<String>() {
                    public void onSuccess(String url) {
                        String url1 = url + ((urlParams != null) ? "?" + urlParams : "");
                        if (openWindow) {
                            Window.open(url1, "_blank", "");
                        } else {
                            Window.Location.assign(url1);
                        }//from  www. j ava2s.  co  m
                    }
                });
    }
}

From source file:org.jboss.as.console.client.shared.runtime.logging.store.LogStore.java

License:Open Source License

@Process(actionType = DownloadLogFile.class)
public void downloadLogFile(final DownloadLogFile action, final Dispatcher.Channel channel) {
    if (bootstrap.isSsoEnabled())
        DownloadUtil.downloadHttpGet(streamUrl(action.getName()), action.getName(),
                DMRHandler.getBearerToken());
    else/*from  www.j  a va 2s.  c  o m*/
        Window.open(streamUrl(action.getName()), "", "");

    channel.ack();
}

From source file:org.jboss.as.console.client.v3.deployment.DeploymentBrowseContentPresenter.java

License:Open Source License

public void downloadFile(String filepath) {
    String filename = filepath.substring(filepath.lastIndexOf("/") + 1);
    if (bootstrap.isSsoEnabled()) {
        DownloadUtil.downloadHttpGet(streamUrl(deploymentName, filepath), filename,
                DMRHandler.getBearerToken());

    } else/*from   w w  w.ja v a  2 s. co m*/
        Window.open(streamUrl(deploymentName, filepath), "", "");
}

From source file:org.jbpm.console.ng.bh.client.editors.home.HomeViewImpl.java

License:Apache License

@Override
public void init(final HomePresenter presenter) {
    this.presenter = presenter;
    String url = GWT.getHostPageBaseURL();
    // avatar.setUrl(url + "images/avatars/" + identity.getName() + ".png");
    // avatar.setSize("64px", "64px");
    List<Role> roles = identity.getRoles();

    carouselImg5.setUrl(url + "images/mountain.jpg");
    carouselImg4.setUrl(url + "images/mountain.jpg");
    carouselImg3.setUrl(url + "images/mountain.jpg");
    carouselImg2.setUrl(url + "images/mountain.jpg");
    carouselImg1.setUrl(url + "images/mountain.jpg");
    carouselImg0.setUrl(url + "images/mountain.jpg");

    authoringLabel.setText(constants.Authoring());
    modelProcessAnchor.setText(constants.Business_Processes());
    workLabel.setText(constants.Work());
    workTaskListAnchor.setText(constants.Tasks_List());
    workProcessDefinitionsAnchor.setText(constants.Process_Definitions());
    workProcessInstancesAnchor.setText(constants.Process_Instances());
    monitorLabel.setText(constants.Monitor());
    monitorBAMAnchor.setText(constants.Business_Activity_Monitoring());
    thejBPMCycle.setText(constants.The_jBPM_Cycle());
    thejBPMCycle.setStyleName("");

    discoverLabel.setText(constants.Discover());
    discoverLabel.setStyleName("");
    discoverTextLabel.setText(constants.Discover_Text());
    discoverTextLabel.setStyleName("");
    designLabel.setText(constants.Design());
    designLabel.setStyleName("");
    designTextLabel.setText(constants.Design_Text());
    designTextLabel.setStyleName("");
    deployLabel.setText(constants.Deploy());
    deployLabel.setStyleName("");
    deployTextLabel.setText(constants.Deploy_Text());
    deployTextLabel.setStyleName("");
    workTasksLabel.setText(constants.Work());
    workTasksLabel.setStyleName("");
    workTasksTextLabel.setText(constants.Work_Text());
    workTasksTextLabel.setStyleName("");
    bamLabel.setText(constants.Business_Activity_Monitoring());
    bamLabel.setStyleName("");
    bamTextLabel.setText(constants.BAM_Text());
    bamTextLabel.setStyleName("");
    improveLabel.setText(constants.Improve());
    improveLabel.setStyleName("");
    improveTextLabel.setText(constants.Improve_Text());
    improveTextLabel.setStyleName("");

    modelProcessAnchor.addClickHandler(new ClickHandler() {
        @Override//from   ww  w  .j a  v  a  2 s .  c  o m
        public void onClick(ClickEvent event) {
            PlaceRequest placeRequestImpl = new DefaultPlaceRequest("Authoring");
            placeManager.goTo(placeRequestImpl);
        }
    });

    workTaskListAnchor.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            PlaceRequest placeRequestImpl = new DefaultPlaceRequest("Tasks List");
            placeManager.goTo(placeRequestImpl);
        }
    });

    workProcessDefinitionsAnchor.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            PlaceRequest placeRequestImpl = new DefaultPlaceRequest("Process Definition List");
            placeManager.goTo(placeRequestImpl);
        }
    });

    workProcessInstancesAnchor.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            PlaceRequest placeRequestImpl = new DefaultPlaceRequest("Process Instances");
            placeManager.goTo(placeRequestImpl);
        }
    });

    monitorBAMAnchor.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            Window.open("http://localhost:8080/dashbuilder/workspace/jbpm-dashboard", "_blank", "");
        }
    });

}

From source file:org.jbpm.console.ng.client.ShowcaseEntryPoint.java

License:Apache License

private List<? extends MenuItem> getBAMViews() {
    final List<MenuItem> result = new ArrayList<MenuItem>(1);
    result.add(MenuFactory.newSimpleItem(constants.Process_Dashboard()).respondsWith(new Command() {
        @Override/*w  ww .  j a v a 2s  . c o  m*/
        public void execute() {
            Window.open("http://localhost:8080/dashbuilder/workspace/jbpm-dashboard", "_blank", "");
        }
    }).endMenu().build().getItems().get(0));

    return result;
}

From source file:org.jbpm.console.ng.dm.client.document.details.DocumentDetailsPresenter.java

License:Apache License

public void downloadDocument() {
    if (document != null) {
        Window.open(linkURL + "?documentId=" + document.getId() + "&documentName=" + document.getName(),
                "_blank", "");
    }/* w  ww .  j  a v a2s.c  o m*/
}

From source file:org.jbpm.console.ng.pm.client.editors.newprocess.NewProcessDefinitionPresenter.java

License:Apache License

public void createNewProcess(final String path) {

    domainService.call(new RemoteCallback<String>() {
        @Override/* w  w w.j a v  a2  s. c  om*/
        public void callback(String path) {
            view.displayNotification("File Created " + path.toString());
            Window.open("http://localhost:8080/designer/editor?profile=jbpm&pp=&uuid=git://jbpm-playground"
                    + path.toString(), "_blank", "");
        }
    }).createProcessDefinitionFile(path);

}