Example usage for com.vaadin.ui TabSheet setSelectedTab

List of usage examples for com.vaadin.ui TabSheet setSelectedTab

Introduction

In this page you can find the example usage for com.vaadin.ui TabSheet setSelectedTab.

Prototype

public void setSelectedTab(int index) 

Source Link

Document

Sets the selected tab, identified by its index.

Usage

From source file:br.gov.frameworkdemoiselle.vaadin.util.ViewNavigator.java

License:Open Source License

@SuppressWarnings("serial")
private void navigate(final String caption, final TabSheet tabSheet, final BaseVaadinView view) {
    final Tab saved = tabSheet.addTab(view, caption, null);
    saved.setClosable(true);//www  . j a va  2 s  .c  o m
    saved.setIcon(view.getIcon());
    tabSheet.setSelectedTab(view);
    beanManager.fireEvent(view, new AnnotationLiteral<BeforeNavigateToView>() {
    });
}

From source file:com.hybridbpm.ui.component.bpm.CaseLayout.java

License:Apache License

private void close() {
    if (getParent() instanceof TabSheet) {
        TabSheet parent = (TabSheet) getParent();
        parent.removeTab(parent.getTab(this));
        parent.setSelectedTab(2);
    }/*from w  ww .j  av a 2 s .com*/
}

From source file:com.hybridbpm.ui.component.bpm.TaskLayout.java

License:Apache License

private void close() {
    if (getParent() instanceof TabSheet) {
        TabSheet parent = (TabSheet) getParent();
        parent.removeTab(parent.getTab(this));
        parent.setSelectedTab(0);
    } else if (getParent() != null && getParent() instanceof VerticalLayout
            && getParent().getParent() instanceof AdaptiveTaskPanel) {
        AdaptiveTaskPanel adaptiveTaskPanel = (AdaptiveTaskPanel) getParent().getParent();
        adaptiveTaskPanel.close();//from  www  . ja v a  2s  . c o  m
    } else if (getParent() != null && getParent() instanceof VerticalLayout
            && getParent().getParent() instanceof AdaptiveTaskEditor) {
        AdaptiveTaskEditor adaptiveTaskEditor = (AdaptiveTaskEditor) getParent().getParent();
        adaptiveTaskEditor.close();
    }
}

From source file:com.hybridbpm.ui.view.CalendarView.java

License:Apache License

@Override
public void onTabClose(TabSheet tabsheet, Component tabContent) {
    tabsheet.removeComponent(tabContent);
    tabsheet.setSelectedTab(0);
}

From source file:com.hybridbpm.ui.view.DashboardView.java

License:Apache License

@Override
public void onTabClose(final TabSheet tabsheet, final Component tabContent) {
    if (tabContent instanceof DashboardTab) {
        final DashboardTab dashboardTab = (DashboardTab) tabContent;

        ConfirmDialog.show(UI.getCurrent(), Translate.getMessage("windowTitleConfirm"), "Delete tab?",
                Translate.getMessage("btnOK"), Translate.getMessage("btnCancel"), new ConfirmDialog.Listener() {

                    @Override//from ww  w  .  j  a v a 2s  . com
                    public void onClose(ConfirmDialog dialog) {
                        if (dialog.isConfirmed()) {
                            HybridbpmUI.getDashboardAPI()
                                    .deleteTabDefinition(dashboardTab.getTabDefinition().getId(), true);

                            tabsheet.removeComponent(tabContent);
                            tabsheet.setSelectedTab(0);
                        } else {
                            //                                this.close();
                        }
                    }
                });
    }
}

From source file:com.jiangyifen.ec2.ui.LoginLayout.java

/**
 * ??????RoleType.manager//  w w  w .  j  a v a2s.  c o m
 * @param roleType
 */
public void switchAccountView(RoleType roleType) {
    app.getMainWindow().removeAllComponents();
    app.getMainWindow().addComponent(ec2LoginLayout);
    TabSheet tabSheet = ec2LoginLayout.getLoginTabSheet();
    if (roleType.equals(RoleType.manager)) {
        tabSheet.setSelectedTab(1);
    } else if (roleType.equals(RoleType.csr)) {
        tabSheet.setSelectedTab(0);
    }

    LoginLayout loginLayout = (LoginLayout) tabSheet.getSelectedTab();
    loginLayout.getUsernameTextField().setValue(loginUser.getUsername());
    loginLayout.getPasswordTextField().setValue(loginUser.getPassword());
    if (roleType.equals(RoleType.csr)) {
        loginLayout.getExtenNoField().setValue(exten);
    }
    loginLayout.loginClick();
}

From source file:com.zklogtool.web.components.OpenSnapshotFileDialog.java

License:Apache License

public OpenSnapshotFileDialog(final TabSheet displayTabSheet, final Window windowHandle) {

    buildMainLayout();/*ww w.j  a v a2s. co  m*/
    setCompositionRoot(mainLayout);

    openButton.addClickListener(new ClickListener() {

        DataState dataState;

        @Override
        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {

            File snapshot = new File(snapshotFileLabel.getValue());

            SnapshotFileReader snapReader = new SnapshotFileReader(snapshot, 0);

            SnapshotView snapshotView;

            if (!validateInputs()) {
                return;
            }

            try {

                dataState = snapReader.readFuzzySnapshot();

                snapshotView = new SnapshotView(dataState);

            } catch (CRCValidationException e) {

                snapshotFileLabel
                        .setComponentError(new UserError("CRC validation problem. File is probably corrupted"));
                return;

            } catch (IOException e) {

                snapshotFileLabel.setComponentError(new UserError("IO problem with file"));
                return;

            }

            HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setCaption(tabNameLabel.getValue());
            horizontalLayout.addComponent(snapshotView);
            horizontalLayout.setWidth("100%");
            horizontalLayout.setHeight("100%");
            Tab snapshotTab = displayTabSheet.addTab(horizontalLayout);
            snapshotTab.setClosable(true);
            displayTabSheet.setSelectedTab(snapshotTab);

            windowHandle.close();

        }

    });

}

From source file:com.zklogtool.web.components.OpenTransactionLogFileDialog.java

License:Apache License

public OpenTransactionLogFileDialog(final TabSheet displayTabSheet, final Window windowHandle) {
    buildMainLayout();/*from w w w.j ava  2  s . c  o  m*/
    setCompositionRoot(mainLayout);

    openButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {

            File transactionLogFile = new File(transactionLogFileLabel.getValue());
            File snapshotDir = new File(snapshotDirectoryLabel.getValue());

            if (!transactionLogFile.isFile() && !transactionLogFile.isDirectory()) {

                transactionLogFileLabel.setComponentError(new UserError("IO problem"));
                return;

            }

            if (snapshotDirectoryLabel.getValue() != null && !snapshotDirectoryLabel.getValue().isEmpty()
                    && !snapshotDir.isDirectory()) {

                snapshotDirectoryLabel.setComponentError(new UserError("IO problem"));
                return;

            }

            TransactionLogView transactionLogView = new TransactionLogView(transactionLogFile, snapshotDir,
                    followCheckbox.getValue(), startFromLastCheckbox.getValue(), displayTabSheet,
                    nameLabel.getValue());

            HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setCaption(nameLabel.getValue());
            horizontalLayout.addComponent(transactionLogView);
            horizontalLayout.setWidth("100%");
            horizontalLayout.setHeight("100%");
            Tab transactionLogTab = displayTabSheet.addTab(horizontalLayout);
            transactionLogTab.setClosable(true);
            displayTabSheet.setSelectedTab(transactionLogTab);

            windowHandle.close();

        }

    });

}

From source file:com.zklogtool.web.components.TransactionLogView.java

License:Apache License

public TransactionLogView(final File transactionLogFile, final File snapshotDir, final boolean follow,
        final boolean startFromLast, final TabSheet displayTabSheet, final String name) {
    buildMainLayout();//from  w ww  .j  ava 2  s  .co m
    setCompositionRoot(mainLayout);

    descriptionLabel.setContentMode(ContentMode.PREFORMATTED);

    final Container container = new IndexedContainer();
    container.addContainerProperty("zxid", String.class, 0);
    container.addContainerProperty("cxid", String.class, 0);
    container.addContainerProperty("client id", String.class, 0);
    //container.addContainerProperty("time", Date.class, 0);
    container.addContainerProperty("operation", ZkOperations.class, "");
    container.addContainerProperty("path", String.class, "");

    reconstructDataTreeButton.setVisible(false);
    filterTable.setContainerDataSource(container);
    filterTable.setFilterBarVisible(true);
    filterTable.setFilterDecorator(new TransactionFilterDecoder());
    filterTable.setSelectable(true);
    filterTable.setImmediate(true);

    final TransactionLog transactionLog;
    final Iterator<Transaction> iterator;
    final Map<String, Transaction> transactionMap = new HashMap<String, Transaction>();

    filterTable.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {

            if (filterTable.getValue() == null)
                return;

            StringBuilder description = new StringBuilder();

            TransactionPrinter printer = new TransactionPrinter(description, new UnicodeDecoder());

            printer.print(transactionMap.get("0x" + filterTable.getValue().toString()));

            descriptionLabel.setValue(description.toString());

            if (snapshotDir != null && transactionLogFile.isDirectory()) {

                reconstructDataTreeButton.setVisible(true);

            }

        }
    });

    if (transactionLogFile.isFile()) {

        transactionLog = new TransactionLog(transactionLogFile, new TransactionLogReaderFactory());
    } else {

        transactionLog = new TransactionLog(new DataDirTransactionLogFileList(transactionLogFile),
                new TransactionLogReaderFactory());
    }

    iterator = transactionLog.iterator();

    if (startFromLast) {

        while (iterator.hasNext()) {

            iterator.next();
        }
    }

    final Runnable fillData = new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub

            while (iterator.hasNext()) {

                Transaction t = iterator.next();

                transactionMap.put(Util.longToHexString(t.getTxnHeader().getZxid()), t);

                Item item = container.addItem(Long.toHexString(t.getTxnHeader().getZxid()));
                item.getItemProperty("zxid").setValue(Util.longToHexString(t.getTxnHeader().getZxid()));

                item.getItemProperty("cxid").setValue(Util.longToHexString(t.getTxnHeader().getCxid()));

                item.getItemProperty("client id")
                        .setValue(Util.longToHexString(t.getTxnHeader().getClientId()));

                /*item.getItemProperty("time").setValue(
                 new Date(t.getTxnHeader().getTime()));*/
                switch (t.getTxnHeader().getType()) {

                case OpCode.create:
                    CreateTxn createTxn = (CreateTxn) t.getTxnRecord();
                    item.getItemProperty("operation").setValue(ZkOperations.CREATE);
                    item.getItemProperty("path").setValue(createTxn.getPath());
                    break;

                case OpCode.delete:
                    DeleteTxn deleteTxn = (DeleteTxn) t.getTxnRecord();
                    item.getItemProperty("operation").setValue(ZkOperations.DELTE);
                    item.getItemProperty("path").setValue(deleteTxn.getPath());
                    break;

                case OpCode.setData:
                    SetDataTxn setDataTxn = (SetDataTxn) t.getTxnRecord();
                    item.getItemProperty("operation").setValue(ZkOperations.SET_DATA);
                    item.getItemProperty("path").setValue(setDataTxn.getPath());
                    break;

                case OpCode.setACL:
                    SetACLTxn setACLTxn = (SetACLTxn) t.getTxnRecord();
                    item.getItemProperty("operation").setValue(ZkOperations.SET_ACL);
                    item.getItemProperty("path").setValue(setACLTxn.getPath());
                    break;

                case OpCode.check:
                    CheckVersionTxn checkVersionTxn = (CheckVersionTxn) t.getTxnRecord();
                    item.getItemProperty("operation").setValue(ZkOperations.CHECK);
                    item.getItemProperty("path").setValue(checkVersionTxn.getPath());
                    break;

                case OpCode.multi:
                    item.getItemProperty("operation").setValue(ZkOperations.MULTI);
                    break;

                case OpCode.createSession:
                    item.getItemProperty("operation").setValue(ZkOperations.CREATE_SESSION);
                    break;

                case OpCode.closeSession:
                    item.getItemProperty("operation").setValue(ZkOperations.CLOSE_SESSION);
                    break;

                case OpCode.error:
                    item.getItemProperty("operation").setValue(ZkOperations.ERROR);
                    break;

                }

            }
        }

    };

    fillData.run();

    Thread monitorThread = new Thread(new Runnable() {

        @Override
        public void run() {

            while (true) {
                //push UI
                UI.getCurrent().access(fillData);

                try {
                    Thread.sleep(250);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }

    });

    if (follow) {
        monitorThread.start();

    }

    reconstructDataTreeButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {

            DataDirHelper dataDirHelper = new DataDirHelper(transactionLogFile, snapshotDir);
            List<File> snapshots = dataDirHelper.getSortedSnapshotList();
            DataDirTransactionLogFileList l = new DataDirTransactionLogFileList(transactionLogFile);
            TransactionLog transactionLog = new TransactionLog(l, new TransactionLogReaderFactory());

            File snapFile = null;
            DataState dataState = null;

            long currentZxid = Long.parseLong(filterTable.getValue().toString(), 16);

            int i = snapshots.size() - 1;
            while (i >= 0) {

                long snapZxid = Util.getZxidFromName(snapshots.get(i).getName());

                if (snapZxid <= currentZxid) {

                    if (i == 0) {
                        snapFile = snapshots.get(0);
                    } else {
                        snapFile = snapshots.get(i - 1);
                    }

                    break;

                }

                i--;

            }

            if (snapFile == null) {
                dispalyNotEnoughDataErrorMessage();
                return;
            }

            long TS = Util.getZxidFromName(snapFile.getName());

            //catch this exception and print error
            SnapshotFileReader snapReader = new SnapshotFileReader(snapFile, TS);

            try {
                dataState = snapReader.restoreDataState(transactionLog.iterator());
            } catch (Exception ex) {
                //dispay error dialog
                //not enough information
                dispalyNotEnoughDataErrorMessage();
                return;
            }

            //set iterator to last zxid
            TransactionIterator iterator = transactionLog.iterator();
            Transaction t;

            do {

                t = iterator.next();

            } while (t.getTxnHeader().getZxid() < TS);

            while (iterator.nextTransactionState() == TransactionState.OK
                    && dataState.getLastZxid() < currentZxid) {
                dataState.processTransaction(iterator.next());
            }

            HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setCaption(name + " at zxid 0x" + Long.toString(currentZxid, 16));
            horizontalLayout.addComponent(new SnapshotView(dataState));
            horizontalLayout.setWidth("100%");
            horizontalLayout.setHeight("100%");
            Tab snapshotTab = displayTabSheet.addTab(horizontalLayout);
            snapshotTab.setClosable(true);
            displayTabSheet.setSelectedTab(snapshotTab);

        }

        void dispalyNotEnoughDataErrorMessage() {

            final Window window = new Window("Error");
            window.setModal(true);

            final VerticalLayout verticalLayout = new VerticalLayout();
            verticalLayout.setMargin(true);
            verticalLayout.addComponent(new Label("Not enough data to reconstruct data tree"));

            window.setContent(verticalLayout);
            UI.getCurrent().addWindow(window);

        }

    });

}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientStatusComponent.java

License:Open Source License

public void updateUI(final ProjectBean currentBean) {
    BeanItemContainer<ExperimentStatusBean> experimentstatusBeans = datahandler
            .computeIvacPatientStatus(currentBean);

    int finishedExperiments = 0;
    status.removeAllComponents();//from   w  ww  .j  av a2s . c  o m
    status.setWidth(100.0f, Unit.PERCENTAGE);

    // Generate button caption column
    final GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(experimentstatusBeans);
    gpc.addGeneratedProperty("started", new PropertyValueGenerator<String>() {

        @Override
        public Class<String> getType() {
            return String.class;
        }

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            String status = null;

            if ((double) item.getItemProperty("status").getValue() > 0.0) {
                status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.CHECK.getFontFamily()
                        + ";color:" + "#2dd085" + "\">&#x"
                        + Integer.toHexString(FontAwesome.CHECK.getCodepoint()) + ";</span>";
            } else {
                status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.TIMES.getFontFamily()
                        + ";color:" + "#f54993" + "\">&#x"
                        + Integer.toHexString(FontAwesome.TIMES.getCodepoint()) + ";</span>";
            }

            return status.toString();
        }
    });
    gpc.removeContainerProperty("identifier");

    experiments.setContainerDataSource(gpc);
    // experiments.setHeaderVisible(false);
    // experiments.setHeightMode(HeightMode.ROW);
    experiments.setHeightByRows(gpc.size());
    experiments.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS);

    experiments.getColumn("status").setRenderer(new ProgressBarRenderer());
    // experiments.setColumnOrder("started", "code", "description", "status", "download",
    // "runWorkflow");
    experiments.setColumnOrder("started", "code", "description", "status", "workflow");

    experiments.getColumn("workflow").setRenderer(new ButtonRenderer(new RendererClickListener() {
        @Override
        public void click(RendererClickEvent event) {
            ExperimentStatusBean esb = (ExperimentStatusBean) event.getItemId();
            TabSheet parent = (TabSheet) getParent();
            PatientView pv = (PatientView) parent.getParent().getParent();
            WorkflowComponent wp = pv.getWorkflowComponent();

            // TODO WATCH OUT NUMBER OF WORKFLOW TAB IS HARDCODED AT THE MOMENT, NO BETTER SOLUTION
            // FOUND SO FAR, e.g. get Tab by Name ?

            // TODO idea get description of item to navigate to the correct workflow ?!
            if (esb.getDescription().equals("Barcode Generation")) {
                ArrayList<String> message = new ArrayList<String>();
                message.add("clicked");
                message.add(currentBean.getId());
                //TODO navigate to barcode dragon rawwwr
                //          message.add(BarcodeView.navigateToLabel);
                //          state.notifyObservers(message);
            } else if (esb.getDescription().equals("Variant Annotation")) {
                /*
                 * ArrayList<String> message = new ArrayList<String>(); message.add("clicked");
                 * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType");
                 * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&");
                 * sb.append("experiment="); sb.append("Q_WF_NGS_VARIANT_ANNOTATION");
                 * message.add(sb.toString()); message.add(WorkflowView.navigateToLabel);
                 * state.notifyObservers(message);
                 */

                Map<String, String> args = new HashMap<String, String>();
                args.put("id", currentBean.getId());
                args.put("type", "workflowExperimentType");
                args.put("experiment", "Q_WF_NGS_VARIANT_ANNOTATION");
                parent.setSelectedTab(9);
                wp.update(args);

            } else if (esb.getDescription().equals("Epitope Prediction")) {
                /*
                 * ArrayList<String> message = new ArrayList<String>(); message.add("clicked");
                 * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType");
                 * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&");
                 * sb.append("experiment="); sb.append("Q_WF_NGS_EPITOPE_PREDICTION");
                 * message.add(sb.toString()); message.add(WorkflowView.navigateToLabel);
                 * state.notifyObservers(message);
                 */
                Map<String, String> args = new HashMap<String, String>();
                args.put("id", currentBean.getId());
                args.put("type", "workflowExperimentType");
                args.put("experiment", "Q_WF_NGS_EPITOPE_PREDICTION");
                parent.setSelectedTab(9);
                wp.update(args);
            } else if (esb.getDescription().equals("HLA Typing")) {
                /*
                 * ArrayList<String> message = new ArrayList<String>(); message.add("clicked");
                 * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType");
                 * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&");
                 * sb.append("experiment="); sb.append("Q_WF_NGS_HLATYPING"); message.add(sb.toString());
                 * message.add(WorkflowView.navigateToLabel); state.notifyObservers(message);
                 */
                Map<String, String> args = new HashMap<String, String>();
                args.put("id", currentBean.getId());
                args.put("type", "workflowExperimentType");
                args.put("experiment", "Q_WF_NGS_HLATYPING");
                parent.setSelectedTab(9);
                wp.update(args);
            }

            else {
                Notification notif = new Notification("Workflow not (yet) available.", Type.TRAY_NOTIFICATION);
                // Customize it
                notif.setDelayMsec(60000);
                notif.setPosition(Position.MIDDLE_CENTER);
                // Show it in the page
                notif.show(Page.getCurrent());
            }
        }
    }));

    experiments.getColumn("started").setRenderer(new HtmlRenderer());

    ProgressBar progressBar = new ProgressBar();
    progressBar.setCaption("Overall Progress");
    progressBar.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS);
    progressBar.setStyleName("patientprogress");

    status.addComponent(progressBar);
    status.addComponent(experiments);
    status.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER);
    status.setComponentAlignment(experiments, Alignment.MIDDLE_CENTER);

    /**
     * Defined Experiments for iVac - Barcodes available -> done with project creation (done) -
     * Sequencing done (Status Q_NGS_MEASUREMENT) - Variants annotated (Status
     * Q_NGS_VARIANT_CALLING) - HLA Typing done (STATUS Q_NGS_WF_HLA_TYPING) - Epitope Prediction
     * done (STATUS Q_WF_NGS_EPITOPE_PREDICTION)
     */

    for (Iterator i = experimentstatusBeans.getItemIds().iterator(); i.hasNext();) {
        ExperimentStatusBean statusBean = (ExperimentStatusBean) i.next();

        finishedExperiments += statusBean.getStatus();

        // statusBean.setDownload("Download");
        statusBean.setWorkflow("Run");
    }

    progressBar.setValue((float) finishedExperiments / experimentstatusBeans.size());
}