Example usage for com.vaadin.ui TabSheet removeComponent

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

Introduction

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

Prototype


@Override
public void removeComponent(Component component) 

Source Link

Document

Removes a component and its corresponding tab.

Usage

From source file:annis.gui.SearchView.java

License:Apache License

@Override
public void onTabClose(TabSheet tabsheet, Component tabContent) {
    // select the tab that was selected before
    if (tabsheet == mainTab) {
        selectedTabHistory.remove(tabContent);

        if (!selectedTabHistory.isEmpty()) {
            // get the last selected tab
            Component[] asArray = selectedTabHistory.toArray(new Component[selectedTabHistory.size()]);
            mainTab.setSelectedTab(asArray[asArray.length - 1]);
        }/*w w  w .ja  v a  2s  . co m*/
    }

    tabsheet.removeComponent(tabContent);
    if (tabContent instanceof FrequencyQueryPanel) {
        controlPanel.getQueryPanel().notifyFrequencyTabClose();
    }

}

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  w  w  w . j a v  a 2 s.c om*/
                    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.mgr.tabsheet.MgrTabSheet.java

public MgrTabSheet() {
    loginUser = SpringContextHolder.getLoginUser();
    ShareData.mgrToTabSheet.put(loginUser.getId(), this);
    this.addListener(this);
    this.setImmediate(true);
    this.setCloseHandler(new CloseHandler() {

        // lc tab,tab,tab?tab.tab,,???
        @Override/*w  w w.  jav  a  2s .co  m*/
        public void onTabClose(TabSheet tabsheet, Component tabContent) {
            if (tabContent == callCheck) {

                callCheck.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(callCheck);

            } else if (tabContent == callCheckByCallTimeLength) {

                callCheckByCallTimeLength.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(callCheckByCallTimeLength);

            } else if (tabContent == employeeCheck) {

                employeeCheck.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(employeeCheck);

            } else if (tabContent == loginLogoutDetail) {

                loginLogoutDetail.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(loginLogoutDetail);

            } else if (tabContent == concurrentStatics) {

                concurrentStatics.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(concurrentStatics);

            } else if (tabContent == projectFinishedStatus) {

                projectFinishedStatus.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(projectFinishedStatus);

            } else if (tabContent == serviceRecordStatus) {

                serviceRecordStatus.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(serviceRecordStatus);

            }

            else if (tabContent == queueDetail) {

                queueDetail.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(queueDetail);

            }

            else if (tabContent == autodialDetail) {
                autodialDetail.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(autodialDetail);
            }

            else if (tabContent == satisfactionInvestigate) {
                satisfactionInvestigate.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(satisfactionInvestigate);
            }

            else if (tabContent == kpi) {
                kpi.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(kpi);

            }

            else if (tabContent == projectPool) {
                projectPool.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(projectPool);
            }
            // jrh ?? [] ??
            // else if (tabContent == transferLog) {
            // transferLog.getTabSheet().removeAllComponents();
            // tabsheet.removeComponent(transferLog);
            // }

            else if (tabContent == questionnaire) {
                questionnaire.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(questionnaire);
            }

            else if (tabContent == customerDetail) {
                customerDetail.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(customerDetail);
            }

            else if (tabContent == businessDetail) {
                businessDetail.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(businessDetail);
            }

            else if (tabContent == csrWorkDetail) {
                csrWorkDetail.getTabSheet().removeAllComponents();
                tabsheet.removeComponent(csrWorkDetail);
            }

            // jrh ??
            else if (tabContent == projectControl) {
                tabsheet.removeComponent(projectControl);
                projectControl = null;
            }

            else {
                tabsheet.removeComponent(tabContent);
                // ?
                stopSupperviceThread(tabContent, "onTabClose");
            }

        }
    });
}

From source file:com.peergreen.webconsole.scope.system.internal.bundle.BundleView.java

License:Open Source License

@PostConstruct
public void createView() {
    setMargin(true);//  w w  w  .  j ava 2s  . c o m
    setSpacing(true);

    /*
    Page.Styles styles = Page.getCurrent().getStyles();
    styles.add(".no-padding {padding: 0em 0em 0em 0em !important; }");
    */

    HorizontalLayout header = new HorizontalLayout();
    //        header.setWidth("100%");
    header.setSpacing(true);
    header.setMargin(true);

    Label title = new Label("OSGi Bundles");
    title.addStyleName("h1");
    //        title.setSizeUndefined();
    header.addComponent(title);
    header.setComponentAlignment(title, Alignment.MIDDLE_LEFT);

    final TextField filter = new TextField();
    filter.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(final FieldEvents.TextChangeEvent event) {
            data.removeAllContainerFilters();
            String trimmed = event.getText().trim();
            Container.Filter or = new Or(new SimpleStringFilter(BUNDLE_ID_COLUMN, trimmed, true, false),
                    new SimpleStringFilter(BUNDLE_NAME_COLUMN, trimmed, true, false),
                    new SimpleStringFilter(BUNDLE_SYMBOLICNAME_COLUMN, trimmed, true, false),
                    new SimpleStringFilter(VERSION_COLUMN, trimmed, true, false),
                    new SimpleStringFilter(PRETTY_STATE_COLUMN, trimmed, true, false));

            data.addContainerFilter(or);
        }
    });

    filter.setInputPrompt("Filter");
    filter.addShortcutListener(new ShortcutListener("Clear", ShortcutAction.KeyCode.ESCAPE, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            filter.setValue("");
            data.removeAllContainerFilters();
        }
    });
    header.addComponent(filter);
    header.setExpandRatio(filter, 1);
    header.setComponentAlignment(filter, Alignment.MIDDLE_LEFT);

    // Store the header in the vertical layout (this)
    addComponent(header);

    addComponent(tabSheet);

    table = new Table();
    table.setContainerDataSource(data);
    table.setSizeFull();
    table.setSortContainerPropertyId(BUNDLE_ID_COLUMN);
    table.setSortAscending(true);
    table.setImmediate(true);
    table.setColumnHeader(BUNDLE_ID_COLUMN, "Bundle ID");
    table.setColumnHeader(PRETTY_NAME_COLUMN, "Bundle Name");
    table.setColumnHeader(VERSION_COLUMN, "Version");
    table.setColumnHeader(PRETTY_STATE_COLUMN, "State");
    table.setColumnHeader("actions", "Actions");

    table.setColumnWidth(BUNDLE_ID_COLUMN, 100);

    table.setColumnAlignment(BUNDLE_ID_COLUMN, Table.Align.CENTER);
    table.setColumnAlignment(PRETTY_STATE_COLUMN, Table.Align.CENTER);
    table.setColumnAlignment(VERSION_COLUMN, Table.Align.CENTER);

    table.addGeneratedColumn("actions", new Table.ColumnGenerator() {
        @Override
        public Object generateCell(final Table source, final Object itemId, final Object columnId) {
            HorizontalLayout layout = new HorizontalLayout();
            BeanItem<BundleItem> item = (BeanItem<BundleItem>) source.getContainerDataSource().getItem(itemId);
            Bundle bundle = item.getBean().getBundle();
            if (BundleHelper.isState(bundle, Bundle.INSTALLED)
                    || BundleHelper.isState(bundle, Bundle.RESOLVED)) {
                Button changeState = new Button();
                changeState.addClickListener(new StartBundleClickListener(bundle, notifierService));
                //changeState.addStyleName("no-padding");
                changeState.setCaption("Start");
                //changeState.setIcon(new ClassResource(BundleViewer.class, "/images/go-next.png"));
                if (!securityManager.isUserInRole("admin")) {
                    changeState.setDisableOnClick(true);
                }
                layout.addComponent(changeState);
            }
            if (BundleHelper.isState(bundle, Bundle.ACTIVE)) {
                Button changeState = new Button();
                changeState.addClickListener(new StopBundleClickListener(bundle, notifierService));
                //changeState.addStyleName("no-padding");
                changeState.setCaption("Stop");
                if (!securityManager.isUserInRole("admin")) {
                    changeState.setDisableOnClick(true);
                }
                //changeState.setIcon(new ClassResource(BundleViewer.class, "/images/media-record.png"));
                layout.addComponent(changeState);
            }

            // Update
            Button update = new Button();
            update.addClickListener(new UpdateBundleClickListener(bundle, notifierService));
            //update.addStyleName("no-padding");
            update.setCaption("Update");
            if (!securityManager.isUserInRole("admin")) {
                update.setDisableOnClick(true);
            }
            //update.setIcon(new ClassResource(BundleViewer.class, "/images/view-refresh.png"));
            layout.addComponent(update);

            // Trash
            Button trash = new Button();
            trash.addClickListener(new UninstallBundleClickListener(bundle, notifierService));
            //trash.addStyleName("no-padding");
            trash.setCaption("Delete");
            if (!securityManager.isUserInRole("admin")) {
                trash.setDisableOnClick(true);
            }
            //trash.setIcon(new ClassResource(BundleViewer.class, "/images/user-trash-full.png"));
            layout.addComponent(trash);

            return layout;
        }
    });

    table.setVisibleColumns(BUNDLE_ID_COLUMN, PRETTY_NAME_COLUMN, VERSION_COLUMN, PRETTY_STATE_COLUMN,
            "actions");

    table.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(final ItemClickEvent event) {
            if (event.isDoubleClick()) {
                BeanItem<BundleItem> item = (BeanItem<BundleItem>) table.getContainerDataSource()
                        .getItem(event.getItemId());
                Bundle bundle = item.getBean().getBundle();
                showBundle(bundle);
            }
        }
    });

    createBundleTracker();

    tabSheet.setSizeFull();
    selectedTabListener = new SelectedTabListener(uiContext.getViewNavigator());
    selectedTabListener.addLocation(table, uiContext.getViewNavigator().getLocation(this.getClass().getName()));
    tabSheet.addSelectedTabChangeListener(selectedTabListener);
    tabSheet.addTab(table, "Bundles", new ClassResource(BundleView.class, "/images/22x22/user-home.png"));
    setExpandRatio(tabSheet, 1.5f);

    tabSheet.setCloseHandler(new TabSheet.CloseHandler() {
        @Override
        public void onTabClose(TabSheet tabsheet, Component tabContent) {
            for (Map.Entry<Long, Component> tab : openTabs.entrySet()) {
                if (tabContent.equals(tab.getValue())) {
                    openTabs.remove(tab.getKey());
                }
            }
            tabsheet.removeComponent(tabContent);
            selectedTabListener.removeLocation(tabContent);
        }
    });
}

From source file:com.peergreen.webconsole.vaadin.tabs.CloseTabListener.java

License:Open Source License

@Override
public void onTabClose(TabSheet tabsheet, Component tabContent) {
    notifierService//from w  ww .ja  v  a 2 s.c o  m
            .addNotification("Warning ! You have closed " + tabsheet.getTab(tabContent).getCaption() + " tab");
    tabsheet.removeComponent(tabContent);
}

From source file:de.catma.ui.tabbedview.TabbedView.java

License:Open Source License

public void onTabClose(TabSheet tabsheet, Component tabContent) {
    tabsheet.removeComponent(tabContent);
    ((ClosableTab) tabContent).close();/*from   w  w  w .jav a 2  s  .  c  om*/

    if (tabsheet.getComponentCount() == 0) {
        //setVisible(false) doesn't work here because of out of sync errors
        tabSheet.hideTabs(true);
        tabSheet.setHeight("0px");
        addComponent(noOpenTabsLabel, 0);
        noOpenTabsLabel.setVisible(true);
        setMargin(true);
    }

}

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

License:Apache License

private Window createGameWindow() {

    tabsheet = new TabSheet();
    tabsheet.setImmediate(true);/*  ww  w .j  av a  2s .  c  o  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.jumpmind.vaadin.ui.common.TabbedApplicationPanel.java

License:Open Source License

public TabbedApplicationPanel() {
    setSizeFull();/*  ww  w. j ava2  s. c o m*/
    addStyleName(ValoTheme.TABSHEET_FRAMED);
    addStyleName(ValoTheme.TABSHEET_COMPACT_TABBAR);

    addSelectedTabChangeListener(new SelectedTabChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            Component selected = event.getTabSheet().getSelectedTab();
            if (selected instanceof IUiPanel) {
                ((IUiPanel) selected).selected();
            }
        }
    });

    setCloseHandler(new CloseHandler() {
        private static final long serialVersionUID = 1L;

        @Override
        public void onTabClose(TabSheet tabsheet, Component tabContent) {
            if (tabContent instanceof IUiPanel) {
                if (((IUiPanel) tabContent).closing()) {
                    tabsheet.removeComponent(tabContent);
                }
            } else {
                tabsheet.removeComponent(tabContent);
            }
        }
    });
}

From source file:org.openeos.services.ui.vaadin.internal.DefaultVaadinERPWindowFactory.java

License:Apache License

@Override
public Component createWindowComponent(IWindowDefinition window,
        final UIApplication<IUnoVaadinApplication> application) {

    final VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();/*from  ww  w  . ja va 2  s  .  c  o m*/

    verticalLayout.setMargin(false);

    final VaadinWindow vaadinWindow = createWindowImpl(window, application);
    Component toolbar = createToolBar(vaadinWindow);
    Component entityActionPanel = createEntityActionPanel(vaadinWindow, application);
    if (entityActionPanel != null) {
        verticalLayout.addComponent(toolbar);
        HorizontalLayout horizontal = new HorizontalLayout();
        horizontal.addComponent(vaadinWindow.getComponent());
        horizontal.addComponent(entityActionPanel);
        horizontal.setSizeFull();
        horizontal.setExpandRatio(vaadinWindow.getComponent(), 1.0f);
        verticalLayout.addComponent(horizontal);
        verticalLayout.setExpandRatio(toolbar, 0);
        verticalLayout.setExpandRatio(horizontal, 1);
    } else {
        verticalLayout.addComponent(toolbar);
        verticalLayout.addComponent(vaadinWindow.getComponent());
        verticalLayout.setExpandRatio(toolbar, 0);
        verticalLayout.setExpandRatio(vaadinWindow.getComponent(), 1);
    }

    application.getConcreteApplication().addCloseTabListener(new CloseTabListener() {
        @Override
        public boolean closeTab(final TabSheet tabSheet, final Component c) {
            if (c == verticalLayout && vaadinWindow.getActiveTab().isModified()) {
                application.showConfirmation("The changes will be lost, are you sure?",
                        new ConfirmationCallback() {

                            @Override
                            public void onCloseConfirmation(boolean accepted) {
                                if (accepted) {
                                    tabSheet.removeComponent(c);
                                    removeListener();
                                }
                            }
                        });
                return true;
            }
            return false;
        }

        private void removeListener() {
            application.getConcreteApplication().removeCloseTabListener(this);
        }

    });

    return verticalLayout;

}