Java 类com.vaadin.ui.MenuBar.Command 实例源码

项目:sqlexplorer-vaadin    文件:SqlExplorer.java   
protected void addShowButton(MenuBar contentMenuBar) {
    boolean visible = showButton != null ? showButton.isVisible() : false;
    showButton = contentMenuBar.addItem("", new Command() {
        private static final long serialVersionUID = 1L;

        @Override
        public void menuSelected(MenuItem selectedItem) {
            setSplitPosition(savedSplitPosition, Unit.PIXELS);
            setLocked(false);
            showButton.setVisible(false);
        }
    });
    showButton.setIcon(FontAwesome.BARS);
    showButton.setDescription("Show the database explorer");
    showButton.setVisible(visible);
}
项目:sqlexplorer-vaadin    文件:TabularResultLayout.java   
protected void buildFollowToMenu() {
    ForeignKey[] foreignKeys = resultTable.getForeignKeys();
    for (final ForeignKey foreignKey : foreignKeys) {
        String optionTitle = foreignKey.getForeignTableName() + " (";
        for (Reference ref : foreignKey.getReferences()) {
            optionTitle += ref.getLocalColumnName() + ", ";
        }
        optionTitle = optionTitle.substring(0, optionTitle.length() - 2) + ")";
        followToMenu.addItem(optionTitle, new ContextMenu.Command() {

            private static final long serialVersionUID = 1L;

            @Override
            public void menuSelected(MenuItem selectedItem) {
                followTo(foreignKey);
            }
        });
    }
}
项目:opennmszh    文件:MenuBarBuilder.java   
@SuppressWarnings("unchecked")
public MenuBar get() {
       MenuBar menuBar = new MenuBar();

       Set<Entry<String, Object>> sortedEntrySet = getSortedMenuItems();
       for(Entry<String, Object> entry : sortedEntrySet) {
           if(entry.getValue() instanceof Map) {
               MenuBar.MenuItem menuItem = menuBar.addItem(entry.getKey(), null);
               addMenuItems(menuItem, (Map<String, Object>) entry.getValue());
           }else {
               menuBar.addItem(entry.getKey(), (Command) entry.getValue());
           }

       }
       return menuBar;
   }
项目:opennmszh    文件:MenuBarBuilder.java   
@SuppressWarnings("unchecked")
protected void addMenuItems(MenuItem subMenu, Map<String, Object> value) {

    Set<Entry<String, Object>> sortedEntrySet = getSortedSubmenuGroup(subMenu.getText(), value);
    for(Entry<String, Object> entry : sortedEntrySet) {
        String commandKey = entry.getKey();
        if(entry.getValue() instanceof Map) {
            MenuBar.MenuItem subMenuItem = subMenu.addItem(commandKey, null);
            addMenuItems(subMenuItem, (Map<String, Object>) entry.getValue());
        }else {
            if(commandKey.startsWith("separator")) {
                subMenu.addSeparator();
            }else {
                subMenu.addItem(removeLabelProperties(commandKey), (Command) entry.getValue());
            }
        }

    }
}
项目:GlycanBuilderVaadin7Version    文件:VaadinGlycanCanvas.java   
public void appendStructureMenu(MenuItem parent){
    MenuItem structureMenu=parent.addItem("Add structure", null);

    for(String superclass:CoreDictionary.getSuperclasses()){
        MenuItem superClassMenu=structureMenu.addItem(superclass,null);
        for(final CoreType t:CoreDictionary.getCores(superclass)){
            superClassMenu.addItem(t.getName(), new Command(){
                private static final long serialVersionUID=-148395291969656325L;

                @Override
                public void menuSelected(MenuItem selectedItem) {
                    theCanvas.addSequenceByName(t.getName());
                }
            });
        }
    }

    createAddResidueMenu(parent);
    createInsertResidueMenu(parent);
    createChangeResidueMenu(parent);
    createTerminalMenu(parent);
}
项目:GlycanBuilderVaadin7Version    文件:VaadinGlycanCanvas.java   
public void createAddResidueMenu(MenuItem parent) {
    String notation=theCanvas.getWorkspace().getGlycanRenderer().getGraphicOptions().NOTATION;

    MenuItem structureMenu=parent.addItem("Add residue", null);

    for (String superclass : ResidueDictionary.getSuperclasses()) {
        MenuItem superClassMenu=structureMenu.addItem(superclass,null);
        for (ResidueType t : ResidueDictionary.getResidues(superclass)) {
            if (t.canHaveParent()){
                superClassMenu.addItem(t.getName(), new Command(){
                    private static final long serialVersionUID=4750928193466060500L;

                    @Override
                    public void menuSelected(MenuItem selectedItem) {
                        theCanvas.addResidueByNameToSelected(selectedItem.getText());
                    }       
                }).setIcon(new ThemeResource("icons"+File.separator+"residues"+File.separator+notation+File.separator+t.getName()+".png"));
            }       
        }

        if(superClassMenu.getChildren()==null){
            structureMenu.removeChild(superClassMenu);
        }
    }
}
项目:GlycanBuilderVaadin7Version    文件:VaadinGlycanCanvas.java   
private void createChangeResidueMenu(MenuItem parent) {
    MenuItem structureMenu=parent.addItem("Change residue", null);

    String notation=theCanvas.getWorkspace().getGlycanRenderer().getGraphicOptions().NOTATION;

    for (String superclass : ResidueDictionary.getSuperclasses()) {
        MenuItem superClassMenu=structureMenu.addItem(superclass,null);
        for (ResidueType t : ResidueDictionary.getResidues(superclass)){
            superClassMenu.addItem(t.getName(), new Command(){
                private static final long serialVersionUID=-7886271503255704127L;

                @Override
                public void menuSelected(MenuItem selectedItem) {
                    theCanvas.changeSelectedToResidueByName(selectedItem.getText());
                }
            }).setIcon(new ThemeResource("icons"+File.separator+"residues"+File.separator+notation+File.separator+t.getName()+".png"));
        }
        if(superClassMenu.getChildren()==null){
            structureMenu.removeChild(superClassMenu);
        }
    }

    structureMenu.setEnabled(false);
    menuItemsWithResidueSelectionDependency.add(structureMenu);
}
项目:mideaas    文件:GitPlugin.java   
@Override
public void extendMenu(MenuBar menuBar, SharedProject project) {

    Command commit = createCommitCommand();
    Command github = createGitHubCommand();

    MenuItem gitItem = menuBar.addItem("Git", null);

    if (commit != null) {
        gitItem.addItem("Commit", commit);
    }

    if (github != null) {
        gitHubItem = gitItem.addItem("GitHub", github);
        gitHubItem.setIcon(new ClassResource("/org/vaadin/addon/oauthpopupbuttons/icons/github16.png"));
        gitHubItem.setEnabled(repo.hasCommit());
    }
}
项目:SecureBPMN    文件:ToolbarPopupEntry.java   
/**
 * Add a menu-item, which executes the given command when clicked.
 */
public MenuItem addMenuItem(String title, final ToolbarCommand command) {
  return rootItem.addItem(title, new Command() {
    private static final long serialVersionUID = 1L;
    public void menuSelected(MenuItem selectedItem) {
      if(command != null) {
        command.toolBarItemSelected();
      }
    }
  });
}
项目:cherry-web    文件:HelpNavigation.java   
public HelpNavigation(Map<String, Command> commands, String helpUrl) {

    if (commands != null && !commands.isEmpty()) {
        MenuBar menuBar = new MenuBar();
        MenuItem menu = menuBar.addItem("Menü", null);
        menu.setIcon(FontAwesome.NAVICON);
        for (Entry<String, Command> entry : commands.entrySet()) {
            menu.addItem(entry.getKey(), entry.getValue());
        }
        addComponent(menuBar);
        setComponentAlignment(menuBar, Alignment.MIDDLE_CENTER);
    }

    if (MString.isSetTrim(helpUrl)) {
        Button helpBtn = new Button("Hilfe");
        helpBtn.setIcon(FontAwesome.QUESTION);
        helpBtn.setDescription("Hier klicken, um Hilfe zu erhalten");
        helpBtn.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 1L;
            @Override
            public void buttonClick(ClickEvent event) {
                getUI().getPage().open(helpUrl, "_blank", false);
            }
        });
        addComponent(helpBtn);
        setComponentAlignment(helpBtn, Alignment.MIDDLE_CENTER);
    }

    setHeight(100, Unit.PERCENTAGE);
    setSpacing(true);
}
项目:openeos    文件:VaadinMenuContributor.java   
private Command createAction(IMenuDefinition menu, IUnoVaadinApplication application) {
    switch (menu.getType()) {
    case MENU:
    case SEPARATOR:
        return null;
    case WINDOW:
        return createWindowAction(menu, application);
    case CUSTOM:
        return createCustomAction(menu, application);
    }
    return null;
}
项目:openeos    文件:VaadinMenuContributor.java   
private Command createWindowAction(IMenuDefinition menu, IUnoVaadinApplication application) {
    IWindowDefinition window = windowManagerService.getWindowDefinition(menu.getWindowId());
    if (window == null) {
        LOG.warn("Window not found: '{}'", menu.getWindowId());
        return null;
    } else {
        // TODO Make with service factory or prototype bean blueprint
        return new OpenWindowCommand(window, applicationFactory.createApplication(application), windowFactory);
    }
}
项目:openeos    文件:VaadinMenuContributor.java   
private Command createCustomAction(IMenuDefinition menu, IUnoVaadinApplication application) {
    CustomAction customAction = customActionManagerService.getCustomAction(menu.getCustomActionId());
    if (customAction == null) {
        LOG.warn("Custom action not found: '{}'", menu.getCustomActionId());
        return null;
    } else {
        return new CustomActionCommand(customAction, applicationFactory.createApplication(application));
    }
}
项目:FiWare-Template-Handler    文件:ToolbarPopupEntry.java   
/**
 * Add a menu-item, which executes the given command when clicked.
 */
public MenuItem addMenuItem(String title, final ToolbarCommand command) {
  return rootItem.addItem(title, new Command() {
    private static final long serialVersionUID = 1L;
    public void menuSelected(MenuItem selectedItem) {
      if(command != null) {
        command.toolBarItemSelected();
      }
    }
  });
}
项目:opennmszh    文件:MenuBarBuilder.java   
public MenuBar get() {
    MenuBar menuBar = new MenuBar();

    for(Entry<String, Object> entry : m_menuBar.entrySet()) {
        if(entry.getValue() instanceof Map) {
            MenuBar.MenuItem menuItem = menuBar.addItem(entry.getKey(), null);
            addMenuItems(menuItem, (Map<String, Object>) entry.getValue());
        }else {
            menuBar.addItem(entry.getKey(), (Command) entry.getValue());
        }

    }
    return menuBar;
}
项目:opennmszh    文件:MenuBarBuilder.java   
private void addMenuItems(MenuItem subMenu, Map<String, Object> value) {
    for(Entry<String, Object> entry : value.entrySet()) {
        if(entry.getValue() instanceof Map) {
            MenuBar.MenuItem subMenuItem = subMenu.addItem(entry.getKey(), null);
            addMenuItems(subMenuItem, (Map<String, Object>) entry.getValue());
        }else {
            subMenu.addItem(entry.getKey(), (Command) entry.getValue());
        }

    }
}
项目:konekti    文件:MenuLayout.java   
@Override
public MenuItem addMenuItem(String caption, String hint, MenuItem menuItem, Command command) {
    MenuItem itm = menuItem.addItem(caption, command);
    itm.setDescription(hint);

    return itm;

}
项目:konekti    文件:MenuLayout.java   
@Override
public MenuItem addMenuItem(String caption, String hint, Resource icon, MenuItem menuItem, Command command) {
    MenuItem itm = menuItem.addItem(caption, icon, command);
    itm.setDescription(hint);

    return itm;

}
项目:konekti    文件:Main.java   
private void setModuleResource(MetadataModule metadataModule) throws Exception {
    final Resource resource = resourceManager.getResource(metadataModule.getId() + "#" + metadataModule.getVersion());

    if (resource != null) {
        IViewContainer viewContainer = metadataModule.getModule().createViewComponent(workbenchContext);

        viewContainer.addListener((IViewChangeListener) toolbarManager);

        resource.setComponentView(viewContainer);

        // set command (handler) to item menu
        resource.getMenu().setCommand(new Command() {
            @Override
            public void menuSelected(MenuItem selectedItem) {
                konektiLayout.addModule(resource.getId(),
                        resource.getCaption(), resource.getComponentView(), resource.isCloseable(),
                        resource.getResource(), resource.getLocation());

            }
        });

        // autostart if the flag is active
        if (resource.isAutoStart())
            konektiLayout.addModule(resource.getId(),
                    resource.getCaption(), resource.getComponentView(), resource.isCloseable(),
                    resource.getResource(), resource.getLocation());
    }
}
项目:konekti    文件:Main.java   
@Override
public void metadataModuleUnregistered(IModuleService source, final MetadataModule metadataModule) {
    String id = metadataModule.getId() + "#" + metadataModule.getVersion();

    Resource resource = resourceManager.getResource(id);

    if (resource != null) {
        // remove the bundle tab resource if it's opened
        try {
            konektiLayout.removeModule(resource.getId());
            resource.setTab(null);
        } catch (Exception e) {
            e.getMessage();
        }

        // set default command to the bundle menu resource
        Command defaultCommand = new Command() {
            @Override
            public void menuSelected(MenuItem selectedItem) {
                window.showNotification("Module Warning",
                        "The Module: " + metadataModule.getId() + "["
                                + metadataModule.getVersion()
                                + "] is not deploy",
                        Window.Notification.TYPE_WARNING_MESSAGE);

            }
        };
        resource.getMenu().setCommand(defaultCommand);

        // reset the bundle component resource
        resource.setComponentView(null);

    }

}
项目:GlycanBuilderVaadin7Version    文件:VaadinGlycanCanvas.java   
private void createTerminalMenu(MenuItem parent){
    MenuItem structureMenu=parent.addItem("Add terminal", null);
    for(String superclass : TerminalDictionary.getSuperclasses()){
        MenuItem superClassMenu=structureMenu.addItem(superclass,null);
        for (TerminalType t : TerminalDictionary.getTerminals(superclass)) {
            MenuItem terminalType=superClassMenu.addItem(t.getDescription(),null);

            final String type=t.getName();
            Command addTerminal=new Command(){
                private static final long serialVersionUID=6872577027235164629L;

                @Override
                public void menuSelected(MenuItem selectedItem) {
                    String longForm=selectedItem.getText();

                    if(longForm.equals("Unknown linkage")){
                        theCanvas.addTerminal(type);
                    }else{
                        theCanvas.addTerminal(longForm.charAt(0)+"-"+type);
                    }
                }
            };

            terminalType.addItem("Unknown linkage", addTerminal);
            for (int l = 1; l < 9; l++) {
                terminalType.addItem(l+"-linked", addTerminal);
            }
        }
    }
}
项目:GlycanBuilderVaadin7Version    文件:VaadinGlycanCanvas.java   
public void createInsertResidueMenu(MenuItem parent){
    MenuItem structureMenu=parent.addItem("Insert residue", null);

    String notation=theCanvas.getWorkspace().getGlycanRenderer().getGraphicOptions().NOTATION;

    for (String superclass : ResidueDictionary.getSuperclasses()) {
        MenuItem superClassMenu=structureMenu.addItem(superclass,null);
        for (ResidueType t : ResidueDictionary.getResidues(superclass)) {
            if (t.canHaveParent() && t.canHaveChildren()
                    && t.getMaxLinkages() >= 2){
                superClassMenu.addItem(t.getName(), new Command(){
                    private static final long serialVersionUID=2685831199169131556L;

                    @Override
                    public void menuSelected(MenuItem selectedItem) {
                        theCanvas.insertResidueByNameBeforeSelected(selectedItem.getText());
                    }
                }).setIcon(new ThemeResource("icons"+File.separator+"residues"+File.separator+notation+File.separator+t.getName()+".png"));

            }   
        }
        if(superClassMenu.getChildren()==null){
            structureMenu.removeChild(superClassMenu);
        }
    }
    structureMenu.setEnabled(false);
    menuItemsWithResidueSelectionDependency.add(structureMenu);
}
项目:mideaas    文件:FeedbackPlugin.java   
@SuppressWarnings("serial")
@Override
public void extendMenu(MenuBar menuBar, SharedProject project) {
    menuBar.addItem("Feedback", null).addItem("Send feedback", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            openSendWindow();               
        }

    });
}
项目:mideaas    文件:TestPlugin.java   
@SuppressWarnings("serial")
private Command createRunTestCommand() {
    return new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            if (testWindow==null || !testWindow.isAttached()) {
                UI.getCurrent().addWindow(getTestWindow());
            }
        }
    };
}
项目:mideaas    文件:GitPlugin.java   
private Command createGitHubCommand() {
    if (GITHUB_KEY==null || GITHUB_SECRET==null) {
        return null;
    }

    return new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            GitHubWindow w = new GitHubWindow(user, repo, project.getName());
            w.center();
            UI.getCurrent().addWindow(w);
        }
    };
}
项目:mideaas    文件:GitPlugin.java   
private Command createCommitCommand() {
    return new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            Window w = new GitCommitWindow(GitPlugin.this, repo, project.getName());
            w.center();
            UI.getCurrent().addWindow(w);
        }
    };
}
项目:mideaas    文件:SettingsPlugin.java   
@SuppressWarnings("serial")
private Command createWidgetSetCommand() {
    return new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            UI.getCurrent().addWindow(new WidgetsetSettingsWindow(settings));
        }
    };
}
项目:mideaas    文件:DebugPlugin.java   
@SuppressWarnings("serial")
private Command createWidgetSetCommand() {
    return new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            UI.getCurrent().getSession().close();
        }
    };
}
项目:mideaas    文件:MenuBarUtil.java   
public static void addAddonMenu(MenuBar menuBar, final SharedProject project) {
    MenuItem menu = menuBar.addItem("Dependencies", null);
    menu.addItem("Manage", new Command() {
@Override
public void menuSelected(MenuItem selectedItem) {
    UI.getCurrent().addWindow(new AddonManagementWindow(project));
}
    });
 }
项目:mideaas    文件:MenuBarUtil.java   
public static void addMenuItem(final MenuBar menuBar, final String text, final Runnable runnable) {
    menuBar.addItem(text, new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            runnable.run();
        }
    });
}
项目:mideaas    文件:MenuBarUtil.java   
public static void addMenuItemBefore(final MenuBar menuBar, final String text, final Runnable runnable, MenuItem item) {
    menuBar.addItemBefore(text, null, new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            runnable.run();
        }
    }, item);
}
项目:mideaas    文件:MenuBarUtil.java   
public static void addZipMenu(MenuBar menuBar, final Runnable zipProject) {
    menuBar.addItem("Zip", new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            zipProject.run();
        }
    });     
}
项目:mideaas    文件:MideaasEditor.java   
private void addCloseMenu() {
    menu.addItemBefore("Close", null, new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            closeHandler.closeRequested(project);
        }}, menu.getItems().get(0) /* assuming at least one item */);
}
项目:VaadinSpringShiroMongoDB    文件:Menu.java   
public Menu(Navigator navigator) {
    this.navigator = navigator;
    setPrimaryStyleName(ValoTheme.MENU_ROOT);
    menuPart = new CssLayout();
    menuPart.addStyleName(ValoTheme.MENU_PART);

    // header of the menu
    final HorizontalLayout top = new HorizontalLayout();
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName(ValoTheme.MENU_TITLE);
    top.setSpacing(true);
    Label title = new Label("My CRUD");
    title.addStyleName(ValoTheme.LABEL_H3);
    title.setSizeUndefined();
    Image image = new Image(null, new ThemeResource("img/table-logo.png"));
    image.setStyleName("logo");
    top.addComponent(image);
    top.addComponent(title);
    menuPart.addComponent(top);

    // logout menu item
    MenuBar logoutMenu = new MenuBar();
    logoutMenu.addItem("Logout", FontAwesome.SIGN_OUT, new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            VaadinSession.getCurrent().getSession().invalidate();
            Page.getCurrent().reload();
        }
    });

    logoutMenu.addStyleName("user-menu");
    menuPart.addComponent(logoutMenu);

    // button for toggling the visibility of the menu when on a small screen
    final Button showMenu = new Button("Menu", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) {
                menuPart.removeStyleName(VALO_MENU_VISIBLE);
            } else {
                menuPart.addStyleName(VALO_MENU_VISIBLE);
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName(VALO_MENU_TOGGLE);
    showMenu.setIcon(FontAwesome.NAVICON);
    menuPart.addComponent(showMenu);

    // container for the navigation buttons, which are added by addView()
    menuItemsLayout = new CssLayout();
    menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS);
    menuPart.addComponent(menuItemsLayout);

    addComponent(menuPart);
}
项目:metl    文件:TopBar.java   
public TopBar(ViewManager vm, ApplicationContext context) {
    setWidth(100, Unit.PERCENTAGE);
    this.context = context;
    this.viewManager = vm;
    this.viewManager.addViewChangeListener(this);

    viewToButtonMapping = new HashMap<String, MenuItem>();

    menuBar = new MenuBar();
    menuBar.setWidth(100, Unit.PERCENTAGE);
    addComponent(menuBar);
    setExpandRatio(menuBar, 1.0f);

    String systemText = getGlobalSetting(GlobalSetting.SYSTEM_TEXT, "").getValue();
    if (isNotBlank(systemText)) {
        Button systemLabel = new Button(systemText, FontAwesome.WARNING);
        systemLabel.setHtmlContentAllowed(true);
        addComponent(systemLabel);
    }

    Button helpButton = new Button("Help", FontAwesome.QUESTION_CIRCLE);
    helpButton.addClickListener(event -> openHelp(event));
    addComponent(helpButton);

    Button settingsButton = new Button(context.getUser().getLoginId(), FontAwesome.GEAR);
    settingsButton.addClickListener((e) -> ChangePasswordDialog.show(context));
    addComponent(settingsButton);

    Button logoutButton = new Button("Logout", FontAwesome.SIGN_OUT);
    logoutButton.addClickListener(event -> logout());
    addComponent(logoutButton);

    Map<Category, List<TopBarLink>> menuItemsByCategory = viewManager.getMenuItemsByCategory();
    Set<Category> categories = menuItemsByCategory.keySet();
    for (Category category : categories) {
        if (!context.getUser().hasPrivilege(category.name())) {
            log.info("'{}' does not have access to the {} menu tab", context.getUser(), category.name());
            continue;
        }
        List<TopBarLink> links = menuItemsByCategory.get(category);
        boolean needDefaultView = viewManager.getDefaultView() == null && links.size() > 0;
        MenuItem categoryItem = null;
        if (links.size() > 1) {
            categoryItem = menuBar.addItem(category.name(), null);
            categoryItems.add(categoryItem);
        }

        if (needDefaultView) {
            viewManager.setDefaultView(links.get(0).id());
        }

        for (final TopBarLink menuLink : links) {
            Command command = new Command() {

                private static final long serialVersionUID = 1L;

                @Override
                public void menuSelected(MenuItem selectedItem) {
                    uncheckAll();
                    selectedItem.setChecked(true);
                    viewManager.navigateTo(menuLink.id());
                }
            };
            MenuItem menuItem = null;
            if (categoryItem == null) {
                menuItem = menuBar.addItem(menuLink.name(), command);
            } else {
                menuItem = categoryItem.addItem(menuLink.name(), command);
            }
            menuItem.setCheckable(true);
            viewToButtonMapping.put(menuLink.id(), menuItem);
        }
    }
    viewManager.navigateTo(Page.getCurrent().getUriFragment());
}
项目:sqlexplorer-vaadin    文件:TriggerInfoPanel.java   
protected void refreshSource(final Trigger trigger) {
    VerticalLayout source = new VerticalLayout();
    source.setSizeFull();
    source.setSpacing(false);

    String sourceText = trigger.getSource();
    if (wrapSourceText) sourceText = wrapSource(sourceText);

    AceEditor editor = CommonUiUtils.createAceEditor();
    editor.setMode(AceMode.sql);
    editor.setValue(sourceText);
    editor.setSizeFull();
    source.addComponent(editor);
    source.setExpandRatio(editor, 1);

    HorizontalLayout bar = new HorizontalLayout();
    bar.setWidth(100, Unit.PERCENTAGE);
       bar.setMargin(new MarginInfo(false, true, false, true));

       MenuBar wrapSelect = new MenuBar();
       wrapSelect.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
       wrapSelect.addStyleName(ValoTheme.MENUBAR_SMALL);
       MenuItem wrapButton = wrapSelect.addItem("Wrap text", new Command() {
        private static final long serialVersionUID = 1L;
           @Override
           public void menuSelected(MenuItem selectedItem) {
               wrapSourceText = !wrapSourceText;
               tabSheet.removeTab(tabSheet.getTab(1));
               refreshSource(trigger);                
           }
       });
       wrapButton.setIcon(FontAwesome.ALIGN_JUSTIFY);

       bar.addComponent(wrapSelect);
       bar.setComponentAlignment(wrapSelect, Alignment.TOP_RIGHT);
       bar.setHeight((float)(2.5), Unit.REM);
       source.addComponent(bar);

    tabSheet.addTab(source, "Source");
    tabSheet.setSelectedTab(source);
}
项目:sqlexplorer-vaadin    文件:TriggerTableLayout.java   
public void createTabularLayout() {
    this.setSizeFull();
    this.setSpacing(false);

    HorizontalLayout bar = new HorizontalLayout();
    bar.setWidth(100, Unit.PERCENTAGE);
       bar.setMargin(new MarginInfo(false, true, false, true));

       HorizontalLayout leftBar = new HorizontalLayout();
       leftBar.setSpacing(true);
       final Label label = new Label(trigger.getFullyQualifiedName(), ContentMode.HTML);
       leftBar.addComponent(label);

       bar.addComponent(leftBar);
       bar.setComponentAlignment(leftBar, Alignment.MIDDLE_LEFT);
       bar.setExpandRatio(leftBar, 1);

       MenuBar rightBar = new MenuBar();
       rightBar.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
       rightBar.addStyleName(ValoTheme.MENUBAR_SMALL);

       MenuItem refreshButton = rightBar.addItem("", new Command() {
           private static final long serialVersionUID = 1L;

           @Override
           public void menuSelected(MenuItem selectedItem) {
               refresher.refresh();
           }
       });
       refreshButton.setIcon(FontAwesome.REFRESH);

       bar.addComponent(rightBar);
       bar.setComponentAlignment(rightBar, Alignment.MIDDLE_RIGHT);

       this.addComponent(bar);

       grid = fillGrid(settings);
       grid.setSizeFull();

       grid.addItemClickListener(new ItemClickListener() {

           private static final long serialVersionUID = 1L;

           @Override
           public void itemClick(ItemClickEvent event) {
               MouseButton button = event.getButton();
               if (button == MouseButton.LEFT) {
                   Object object = event.getPropertyId();
                   if (object != null && !object.toString().equals("")) {
                       if (event.isDoubleClick()) {

                           Object prop = event.getPropertyId();
                           String header = grid.getColumn(prop).getHeaderCaption();
                           Property<?> p = event.getItem().getItemProperty(prop);
                           if (p != null) {
                               String data = String.valueOf(p.getValue());
                               ReadOnlyTextAreaDialog.show(header, data, false);
                           }

                       } else {
                           Object row = event.getItemId();
                           if (!grid.getSelectedRows().contains(row)) {
                               grid.deselectAll();
                               grid.select(row);
                           } else {
                               grid.deselect(row);
                           }
                       }
                   }
               }
           }
       });

       this.addComponent(grid);
       this.setExpandRatio(grid, 1);
}
项目:archetype-application-example    文件:Menu.java   
public Menu(Navigator navigator) {
    this.navigator = navigator;
    setPrimaryStyleName(ValoTheme.MENU_ROOT);
    menuPart = new CssLayout();
    menuPart.addStyleName(ValoTheme.MENU_PART);

    // header of the menu
    final HorizontalLayout top = new HorizontalLayout();
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName(ValoTheme.MENU_TITLE);
    top.setSpacing(true);
    Label title = new Label("My CRUD");
    title.addStyleName(ValoTheme.LABEL_H3);
    title.setSizeUndefined();
    Image image = new Image(null, new ThemeResource("img/table-logo.png"));
    image.setStyleName("logo");
    top.addComponent(image);
    top.addComponent(title);
    menuPart.addComponent(top);

    // logout menu item
    MenuBar logoutMenu = new MenuBar();
    logoutMenu.addItem("Logout", FontAwesome.SIGN_OUT, new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            VaadinSession.getCurrent().getSession().invalidate();
            Page.getCurrent().reload();
        }
    });

    logoutMenu.addStyleName("user-menu");
    menuPart.addComponent(logoutMenu);

    // button for toggling the visibility of the menu when on a small screen
    final Button showMenu = new Button("Menu", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) {
                menuPart.removeStyleName(VALO_MENU_VISIBLE);
            } else {
                menuPart.addStyleName(VALO_MENU_VISIBLE);
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName(VALO_MENU_TOGGLE);
    showMenu.setIcon(FontAwesome.NAVICON);
    menuPart.addComponent(showMenu);

    // container for the navigation buttons, which are added by addView()
    menuItemsLayout = new CssLayout();
    menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS);
    menuPart.addComponent(menuItemsLayout);

    addComponent(menuPart);
}
项目:opennmszh    文件:MenuBarBuilder.java   
public void add(LinkedList<String> menuPath, Command command) {
    add(menuPath, command, m_menuBar);
}
项目:opennmszh    文件:MenuBarBuilder.java   
public void addMenuCommand(Command command, String menuPosition) {
    if(menuPosition != null) {
        LinkedList<String> menuPath = new LinkedList(Arrays.asList(menuPosition.split("\\|")));
        add(menuPath, command);
    }
}