Example usage for com.vaadin.ui Window setPositionX

List of usage examples for com.vaadin.ui Window setPositionX

Introduction

In this page you can find the example usage for com.vaadin.ui Window setPositionX.

Prototype

public void setPositionX(int positionX) 

Source Link

Document

Sets the distance of Window left border in pixels from left border of the containing (main window).

Usage

From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java

License:Open Source License

private void _postGameEvent(String title, final GameEvent.EventType typ, String buttName, boolean doWarning,
        MenuBar mbar) {// w  w  w .  j  a v  a  2s . com
    // Create the window...
    final Window bcastWindow = new Window(title);
    bcastWindow.setModal(true);

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("99%");
    bcastWindow.setContent(layout);
    layout.addComponent(new Label("Compose message (255 char limit):"));
    final TextArea ta = new TextArea();
    ta.setRows(5);
    ta.setWidth("99%");
    layout.addComponent(ta);

    HorizontalLayout buttHl = new HorizontalLayout();
    final Button bcancelButt = new Button("Cancel");
    buttHl.addComponent(bcancelButt);
    Button bokButt = new Button(buttName);
    bokButt.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    buttHl.addComponent(bokButt);
    layout.addComponent(buttHl);
    layout.setComponentAlignment(buttHl, Alignment.TOP_RIGHT);

    if (doWarning)
        layout.addComponent(new Label("Use with great deliberation!"));

    bcastWindow.setWidth("320px");
    UI.getCurrent().addWindow(bcastWindow);
    bcastWindow.setPositionX(0);
    bcastWindow.setPositionY(0);

    ta.focus();

    @SuppressWarnings("serial")
    ClickListener lis = new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            if (event.getButton() == bcancelButt)
                ; // nothin
            else {
                // This check is now done in GameEvent.java, but should ideally prompt the user.
                String msg = ta.getValue().toString().trim();
                if (msg.length() > 0) {
                    HSess.init();
                    if (msg.length() > 255) // clamp to 255 to avoid db exception
                        msg = msg.substring(0, 254);
                    User u = Mmowgli2UI.getGlobals().getUserTL();
                    if (typ == GameEvent.EventType.GAMEMASTERNOTE)
                        GameEventLogger.logGameMasterCommentTL(msg, u);
                    else
                        GameEventLogger.logGameMasterBroadcastTL(typ, msg, u);
                    HSess.close();
                }
            }

            bcastWindow.close();
        }
    };
    bcancelButt.addClickListener(lis);
    bokButt.addClickListener(lis);
}

From source file:edu.nps.moves.mmowgli.MmowgliMessageBroadcaster.java

License:Open Source License

private static void _postGameEvent(String title, final GameEvent.EventType typ, String buttName,
        boolean doWarning) {
    // Create the window...
    final Window bcastWindow = new Window(title);
    bcastWindow.setModal(true);//from   w w  w  .ja  v a2s  .c o  m

    VerticalLayout layout = new VerticalLayout();
    bcastWindow.setContent(layout);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("99%");

    layout.addComponent(new Label("Compose message (255 char limit):"));
    final TextArea ta = new TextArea();
    ta.setRows(5);
    ta.setWidth("99%");
    layout.addComponent(ta);

    HorizontalLayout buttHl = new HorizontalLayout();
    final Button bcancelButt = new Button("Cancel");
    buttHl.addComponent(bcancelButt);
    Button bokButt = new Button(buttName);
    buttHl.addComponent(bokButt);
    layout.addComponent(buttHl);
    layout.setComponentAlignment(buttHl, Alignment.TOP_RIGHT);

    if (doWarning)
        layout.addComponent(new Label("Use with great deliberation!"));

    bcastWindow.setWidth("320px");
    UI.getCurrent().addWindow(bcastWindow);
    bcastWindow.setPositionX(0);
    bcastWindow.setPositionY(0);

    ta.focus();

    @SuppressWarnings("serial")
    ClickListener lis = new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        @HibernateUserRead
        public void buttonClick(ClickEvent event) {
            if (event.getButton() == bcancelButt)
                ; // nothin
            else {
                // This check is now done in GameEvent.java, but should ideally prompt the user.
                HSess.init();
                String msg = ta.getValue().toString().trim();
                if (msg.length() > 0) {
                    if (msg.length() > 255) // clamp to 255 to avoid db exception
                        msg = msg.substring(0, 254);
                    Serializable uid = Mmowgli2UI.getGlobals().getUserID();
                    User u = User.getTL(uid);
                    if (typ == GameEvent.EventType.GAMEMASTERNOTE)
                        GameEventLogger.logGameMasterCommentTL(msg, u);
                    else
                        GameEventLogger.logGameMasterBroadcastTL(typ, msg, u); // GameEvent.save(new GameEvent(typ,msg));
                    HSess.close();
                }
            }
            bcastWindow.close();
        }
    };
    bcancelButt.addClickListener(lis);
    bokButt.addClickListener(lis);
}

From source file:fi.vtt.RVaadin.RContainer.java

License:Apache License

/**
 * Get a Vaadin Window element that contains the corresponding R plot
 * generated by submitting and evaluating the RPlotCall String. The
 * imageName corresponds to the downloadable .png image name. The full name
 * of the images shown in the browser are of the format
 * {@code imageName_ISODate_runningId_[sessionId].png}, e.g.
 * 'Image_2012-08-29_001_[bmgolmfgvk].png' to keep them chronologically
 * ordered./*  ww  w  .  j  a  v  a2  s.  c  o m*/
 * 
 * @param RPlotCall
 *            the String to be evaluated by R
 * @param width
 *            the width of the graphical image
 * @param height
 *            the height of the graphical image
 * @param imageName
 *            the image name attached to the right-click downloadable file
 * @param windowName
 *            the title name of the Vaadin window element
 * @return Vaadin Window object
 */
public Window getGraph(final String RPlotCall, final int width, final int height, final String imageName,
        String windowName) {

    /* Construct a Window to show the graphics */
    Window RGraphics = new Window(windowName);
    HorizontalLayout root = new HorizontalLayout();
    root.setMargin(true);

    RGraphics.setContent(root);
    RGraphics.setSizeUndefined();

    /* Control the image position */
    final int imageXoffset = 180;
    final int imageYoffset = 60;

    int imageYpos = rand.nextInt(50);
    int imageXpos = rand.nextInt(90);

    RGraphics.setPositionX(imageXoffset + imageXpos);
    RGraphics.setPositionY(imageYoffset + imageYpos);

    /* Call R for the graphics */
    Embedded rPlot = getEmbeddedGraph(RPlotCall, width, height, imageName);
    root.addComponent(rPlot);

    /*
     * Button bar to generate PDF (and for other options in the future)
     */
    if (showButtonsInGraph) {
        final HorizontalLayout buttonLayout = new HorizontalLayout();
        Button open = new Button("PDF");
        open.setStyleName(Reindeer.BUTTON_SMALL);
        buttonLayout.addComponent(open);

        Button.ClickListener openClicked = new Button.ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                StreamResource s = getImageResource(RPlotCall, width / screen_dpi, height / screen_dpi,
                        imageName, "pdf");

                Link pdfLink = new Link("Open pdf", s);
                pdfLink.setTargetName("_blank");

                buttonLayout.removeAllComponents();
                buttonLayout.addComponent(pdfLink);
            }
        };
        open.addClickListener(openClicked);
        root.addComponent(buttonLayout);
    }

    return RGraphics;
}

From source file:kn.uni.gis.ui.GameApplication.java

License:Apache License

private Window createGameWindow() {

    tabsheet = new TabSheet();
    tabsheet.setImmediate(true);//www  .ja  va 2s . co m
    tabsheet.setCloseHandler(new CloseHandler() {
        @Override
        public void onTabClose(TabSheet tabsheet, Component tabContent) {

            Game game = ((GameComposite) tabContent).getGame();

            GameComposite remove = gameMap.remove(game);

            // closes the game and the running thread!
            remove.getLayer().handleApplicationClosedEvent(new ApplicationClosedEvent());

            eventBus.unregister(remove);
            eventBus.unregister(remove.getLayer());

            map.removeLayer(remove.getLayer());

            tabsheet.removeComponent(tabContent);

            if (gameMap.isEmpty()) {
                pi.setVisible(false);
            }
        }
    });

    final Window mywindow = new Window("Games");
    mywindow.setPositionX(0);
    mywindow.setPositionY(0);
    mywindow.setHeight("50%");
    mywindow.setWidth("25%");
    VerticalLayout layout = new VerticalLayout();
    HorizontalLayout lay = new HorizontalLayout();

    final Button button_1 = new Button();
    button_1.setCaption("Open Game");
    button_1.setWidth("-1px");
    button_1.setHeight("-1px");

    button_1.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            final String id = textField_1.getValue().toString();

            if (id.length() < 5) {
                window.showNotification("id must have at least 5 characters", Notification.TYPE_ERROR_MESSAGE);
            } else {
                String sql = String.format("select player_id,player_name,min(timestamp),max(timestamp) from %s"
                        + " where id LIKE ? group by player_id, player_name", GisResource.FOX_HUNTER);

                final Game game = new Game(id);
                final PreparedStatement statement = geoUtil.getConn()
                        .prepareStatement("select poly_geom,timestamp from " + GisResource.FOX_HUNTER
                                + " where id LIKE ? and player_id=? and timestamp > ? order by timestamp LIMIT "
                                + MAX_STATES_IN_MEM);

                try {
                    geoUtil.getConn().executeSafeQuery(sql, new DoWithin() {

                        @Override
                        public void doIt(ResultSet executeQuery) throws SQLException {

                            while (executeQuery.next()) {
                                if (statement == null) {

                                }
                                String playerId = executeQuery.getString(1);
                                Timestamp min = executeQuery.getTimestamp(3);
                                Timestamp max = executeQuery.getTimestamp(4);
                                game.addPlayer(playerId, executeQuery.getString(2), min, max,
                                        new TimingIterator(geoUtil, id, playerId, min.getTime(), statement));
                            }
                        }
                    }, id + "%");
                } catch (SQLException e) {
                    LOGGER.info("error on sql!", e);

                }

                game.finish(statement);

                if (!!!gameMap.containsKey(game)) {
                    if (game.getStates().size() == 0) {
                        window.showNotification("game not found!");
                    } else {
                        LOGGER.info("received game info: {},{} ", game.getId(), game.getStates().size());

                        GameVectorLayer gameVectorLayer = new GameVectorLayer(GameApplication.this, eventBus,
                                game, createColorMap(game));

                        final GameComposite gameComposite = new GameComposite(GameApplication.this, game,
                                gameVectorLayer, eventBus);

                        eventBus.register(gameComposite);
                        eventBus.register(gameVectorLayer);

                        map.addLayer(gameVectorLayer);
                        gameMap.put(game, gameComposite);

                        // Add the component to the tab sheet as a new tab.
                        Tab addTab = tabsheet.addTab(gameComposite);
                        addTab.setCaption(game.getId().substring(0, 5));
                        addTab.setClosable(true);

                        pi.setVisible(true);
                        // pl.get
                        PlayerState playerState = game.getStates().get(game.getFox()).peek();
                        map.zoomToExtent(new Bounds(CPOINT_TO_POINT.apply(playerState.getPoint())));
                    }
                }
            }
        }

        private Map<Player, Integer> createColorMap(Game game) {
            Function<Double, Double> scale = HardTasks.scale(0, game.getStates().size());

            ImmutableMap.Builder<Player, Integer> builder = ImmutableMap.builder();

            int i = 0;

            for (Player play : game.getStates().keySet()) {
                builder.put(play, getColor(scale.apply((double) i++)));
            }

            return builder.build();
        }

        private Integer getColor(double dob) {

            int toReturn = 0;
            toReturn = toReturn | 255 - (int) Math.round(255 * dob);
            toReturn = toReturn | (int) ((Math.round(255 * dob)) << 16);
            return toReturn;
            // return (int) (10000 + 35000 * dob + 5000 * dob + 1000 * dob +
            // 5 * dob);
        }

    });

    Button button_2 = new Button();
    button_2.setCaption("All seeing Hunter");
    button_2.setImmediate(false);
    button_2.setWidth("-1px");
    button_2.setHeight("-1px");
    button_2.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (adminWindow == null) {
                adminWindow = new AdminWindow(password, geoUtil, new ItemClickListener() {
                    @Override
                    public void itemClick(ItemClickEvent event) {

                        textField_1.setValue(event.getItemId().toString());
                        mywindow.bringToFront();
                        button_1.focus();
                    }
                });
                window.addWindow(adminWindow);
                adminWindow.setWidth("30%");
                adminWindow.setHeight("40%");
                adminWindow.addListener(new CloseListener() {
                    @Override
                    public void windowClose(CloseEvent e) {
                        adminWindow = null;
                    }
                });
            }
        }
    });

    lay.addComponent(button_1);
    textField_1 = new TextField();
    textField_1.setImmediate(false);
    textField_1.setWidth("-1px");
    textField_1.setHeight("-1px");
    lay.addComponent(textField_1);
    lay.addComponent(button_2);
    lay.addComponent(pi);

    lay.setComponentAlignment(pi, Alignment.TOP_RIGHT);

    layout.addComponent(lay);
    layout.addComponent(tabsheet);

    mywindow.addComponent(layout);
    mywindow.setClosable(false);

    /* Add the window inside the main window. */
    return mywindow;
}

From source file:org.aksw.autosparql.tbsl.gui.vaadin.TBSLApplication.java

License:Apache License

private void onShowLearnedQuery() {
    String learnedSPARQLQuery = UserSession.getManager().getLearnedSPARQLQuery();
    VerticalLayout layout = new VerticalLayout();
    final Window w = new Window("Learned SPARQL Query", layout);
    w.setWidth("300px");
    w.setSizeUndefined();//from w  w  w  .  j  a  v a  2 s.  c  o m
    w.setPositionX(200);
    w.setPositionY(100);
    getMainWindow().addWindow(w);
    w.addListener(new Window.CloseListener() {

        @Override
        public void windowClose(CloseEvent e) {
            getMainWindow().removeWindow(w);
        }
    });
    Label queryLabel = new Label(learnedSPARQLQuery, Label.CONTENT_PREFORMATTED);
    queryLabel.setWidth(null);
    layout.addComponent(queryLabel);

    Label nlLabel = new Label(UserSession.getManager().getNLRepresentation(learnedSPARQLQuery));
    layout.addComponent(nlLabel);

}

From source file:org.casbah.ui.IssuedCertificateList.java

License:Open Source License

private void collectKeyCertificateInfo() throws CAProviderException {
    final Window principalWindow = new Window("Specify Certificate Details");
    principalWindow.setPositionX(200);
    principalWindow.setPositionY(100);/*from  ww w. j  a  v  a 2  s  .c  om*/
    principalWindow.setWidth("600px");
    principalWindow.setHeight("500px");
    principalWindow.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1L;

        public void windowClose(CloseEvent e) {
            parentApplication.getMainWindow().removeWindow(principalWindow);

        }
    });

    VerticalLayout vl = new VerticalLayout();
    final PrincipalComponent pc = new PrincipalComponent();
    Principal parentPrincipal = new Principal(provider.getCACertificate().getSubjectX500Principal());
    pc.init(new Principal(parentPrincipal, provider.getRuleMap()));
    vl.addComponent(pc);
    HorizontalLayout passLayout = new HorizontalLayout();
    vl.addComponent(passLayout);
    final TextField pass1 = new TextField("Private key/keystore passphrase");
    pass1.setSecret(true);
    final TextField pass2 = new TextField();
    pass2.setSecret(true);
    passLayout.addComponent(pass1);
    passLayout.addComponent(pass2);
    passLayout.setComponentAlignment(pass1, Alignment.BOTTOM_CENTER);
    passLayout.setComponentAlignment(pass2, Alignment.BOTTOM_CENTER);

    final OptionGroup type = new OptionGroup("Bundle Type");
    type.addItem(BundleType.OPENSSL);
    type.addItem(BundleType.PKCS12);
    type.addItem(BundleType.JKS);
    type.setValue(BundleType.OPENSSL);
    vl.addComponent(type);

    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.addComponent(new Button("Create", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (pass1.getValue().equals(pass2.getValue())) {
                try {
                    createKeyCertificatePair(pc.toPrincipal(), (String) pass1.getValue(),
                            (BundleType) type.getValue());
                    parentApplication.getMainWindow().removeWindow(principalWindow);
                } catch (Exception e) {
                    logger.severe(e.getMessage());
                    parentApplication.getMainWindow().showNotification(
                            "An error prevented the correct creation of the key/certificate pair",
                            Notification.TYPE_ERROR_MESSAGE);
                }
            } else {
                parentApplication.getMainWindow().showNotification("Passphrases do not match",
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    }));
    buttonsLayout.addComponent(new Button("Cancel", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            parentApplication.getMainWindow().removeWindow(principalWindow);
        }
    }));

    vl.addComponent(buttonsLayout);
    principalWindow.setContent(vl);
    parentApplication.getMainWindow().addWindow(principalWindow);
}

From source file:org.casbah.ui.MainCAView.java

License:Open Source License

private void uploadAndSignCsr() throws CAProviderException {
    final Window csrWindow = new Window("Upload CSR");
    csrWindow.setPositionX(200);
    csrWindow.setPositionY(100);//w w  w . j a  v a 2  s.c  o  m
    csrWindow.setWidth("800px");
    csrWindow.setHeight("300px");
    csrWindow.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1L;

        public void windowClose(CloseEvent e) {
            application.getMainWindow().removeWindow(csrWindow);

        }
    });

    final TextField csrData = new TextField("DER Encoded CSR");
    csrData.setColumns(80);
    csrData.setRows(20);
    csrData.setWordwrap(false);
    csrWindow.addComponent(csrData);
    HorizontalLayout hl = new HorizontalLayout();
    csrWindow.addComponent(hl);
    hl.addComponent(new Button("Cancel", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            application.getMainWindow().removeWindow(csrWindow);

        }
    }));
    hl.addComponent(new Button("Upload", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            String csr = (String) csrData.getValue();
            try {
                X509Certificate result = provider.sign(csr);
                showEncodedCertificate(result, result.getSerialNumber().toString(16));

            } catch (CAProviderException cpe) {
                cpe.printStackTrace();
            }
        }
    }));
    csrWindow.setModal(true);
    application.getMainWindow().addWindow(csrWindow);
}

From source file:org.casbah.ui.MainCAView.java

License:Open Source License

private void showEncodedCertificate(X509Certificate cert, String serialNumber) throws CAProviderException {
    final Window certWindow = new Window(serialNumber);
    certWindow.setPositionX(200);
    certWindow.setPositionY(100);/*from   ww w .j a va  2  s.c o  m*/
    certWindow.setWidth("800px");
    certWindow.setHeight("300px");
    certWindow.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1L;

        public void windowClose(CloseEvent e) {
            application.getMainWindow().removeWindow(certWindow);

        }
    });
    String certData = CertificateHelper.encodeCertificate(cert, true);
    TextField encodedCert = new TextField("Encoded Certificate", certData);
    encodedCert.setReadOnly(true);
    encodedCert.setColumns(80);
    encodedCert.setRows(certData.split("\n").length);
    encodedCert.setWordwrap(false);
    certWindow.addComponent(encodedCert);
    certWindow.addComponent(new Button("Close", new Button.ClickListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            application.getMainWindow().removeWindow(certWindow);
        }
    }));
    certWindow.setModal(true);
    application.getMainWindow().addWindow(certWindow);

}

From source file:ro.zg.netcell.vaadin.action.OpenGroupsActionHandler.java

License:Apache License

protected void centerWindow(Window w, OpenGroupsApplication app) {
    WebBrowser wb = app.getAppContext().getBrowser();
    float width = (float) (wb.getScreenWidth() * 0.9);
    float height = (float) (wb.getScreenHeight() * 0.6);

    w.setHeight(height, Sizeable.UNITS_PIXELS);
    w.setWidth(width, Sizeable.UNITS_PIXELS);
    w.setPositionX((int) ((wb.getScreenWidth() - width) / 2));
    w.setPositionY((int) ((wb.getScreenHeight() - height) / 6));
}

From source file:ru.codeinside.gses.webui.utils.Components.java

License:Mozilla Public License

public static Window createWindow(Window mainwindow, String caption) {
    Window subwindow = new Window(caption);
    subwindow.setSizeUndefined();/*from  w w w.  ja v a  2 s. c  o m*/
    subwindow.getContent().setSizeUndefined();
    subwindow.setScrollable(false);
    subwindow.setResizable(false);
    subwindow.setPositionX(50);
    subwindow.setPositionY(50);
    mainwindow.addWindow(subwindow);
    return subwindow;
}