List of usage examples for com.vaadin.ui Window setContent
@Override public void setContent(Component content)
From source file:org.opennms.features.topology.app.internal.TopologyUI.java
License:Open Source License
@Override public void menuBarUpdated(CommandManager commandManager) { if (m_menuBar != null) { m_rootLayout.removeComponent(m_menuBar); }//from w w w. j ava 2 s. c o m if (m_contextMenu != null) { m_contextMenu.detach(); } m_menuBar = commandManager.getMenuBar(m_graphContainer, this); m_menuBar.setWidth(100, Unit.PERCENTAGE); // Set expand ratio so that extra space is not allocated to this vertical component if (m_showHeader) { m_rootLayout.addComponent(m_menuBar, 1); } else { m_rootLayout.addComponent(m_menuBar, 0); } m_contextMenu = commandManager .getContextMenu(new DefaultOperationContext(this, m_graphContainer, DisplayLocation.CONTEXTMENU)); m_contextMenu.setAsContextMenuOf(this); // Add Menu Item to share the View with others m_menuBar.addItem("Share", FontAwesome.SHARE, new MenuBar.Command() { @Override public void menuSelected(MenuItem selectedItem) { // create the share link String fragment = getPage().getLocation().getFragment(); String url = getPage().getLocation().toString().replace("#" + getPage().getLocation().getFragment(), ""); String shareLink = String.format("%s?%s=%s", url, TopologyUIRequestHandler.PARAMETER_HISTORY_FRAGMENT, fragment); // Create the Window Window shareWindow = new Window(); shareWindow.setCaption("Share Link"); shareWindow.setModal(true); shareWindow.setClosable(true); shareWindow.setResizable(false); shareWindow.setWidth(400, Unit.PIXELS); TextArea shareLinkField = new TextArea(); shareLinkField.setValue(shareLink); shareLinkField.setReadOnly(true); shareLinkField.setRows(3); shareLinkField.setWidth(100, Unit.PERCENTAGE); // Close Button Button close = new Button("Close"); close.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); close.addClickListener(event -> shareWindow.close()); // Layout for Buttons HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(true); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); buttonLayout.addComponent(close); buttonLayout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT); // Content Layout VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setMargin(true); verticalLayout.setSpacing(true); verticalLayout.addComponent( new Label("Please use the following link to share the current view with others.")); verticalLayout.addComponent(shareLinkField); verticalLayout.addComponent(buttonLayout); shareWindow.setContent(verticalLayout); getUI().addWindow(shareWindow); } }); updateMenuItems(); }
From source file:org.opennms.features.topology.app.internal.ui.ToolbarPanel.java
License:Open Source License
public ToolbarPanel(final ToolbarPanelController controller) { addStyleName(Styles.TOOLBAR);//from ww w . j a v a 2 s .c om this.layoutManager = controller.getLayoutManager(); final Property<Double> scale = controller.getScaleProperty(); final Boolean[] eyeClosed = new Boolean[] { false }; final Button showFocusVerticesBtn = new Button(); showFocusVerticesBtn.setIcon(FontAwesome.EYE); showFocusVerticesBtn.setDescription("Toggle Highlight Focus Nodes"); showFocusVerticesBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (eyeClosed[0]) { showFocusVerticesBtn.setIcon(FontAwesome.EYE); } else { showFocusVerticesBtn.setIcon(FontAwesome.EYE_SLASH); } eyeClosed[0] = !eyeClosed[0]; // toggle controller.toggleHighlightFocus(); } }); final Button magnifyBtn = new Button(); magnifyBtn.setIcon(FontAwesome.PLUS); magnifyBtn.setDescription("Magnify"); magnifyBtn.addClickListener( (Button.ClickListener) event -> scale.setValue(Math.min(1, scale.getValue() + 0.25))); final Button demagnifyBtn = new Button(); demagnifyBtn.setIcon(FontAwesome.MINUS); demagnifyBtn.setDescription("Demagnify"); demagnifyBtn.addClickListener( (Button.ClickListener) event -> scale.setValue(Math.max(0, scale.getValue() - 0.25))); m_szlOutBtn = new Button(); m_szlOutBtn.setId("szlOutBtn"); m_szlOutBtn.setIcon(FontAwesome.ANGLE_DOWN); m_szlOutBtn.setDescription("Decrease Semantic Zoom Level"); m_szlOutBtn.setEnabled(controller.getSemanticZoomLevel() > 0); m_szlOutBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { int szl = controller.getSemanticZoomLevel(); if (szl > 0) { setSemanticZoomLevel(controller, szl - 1); controller.saveHistory(); } } }); final Button szlInBtn = new Button(); szlInBtn.setId("szlInBtn"); szlInBtn.setIcon(FontAwesome.ANGLE_UP); szlInBtn.setDescription("Increase Semantic Zoom Level"); szlInBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { setSemanticZoomLevel(controller, controller.getSemanticZoomLevel() + 1); controller.saveHistory(); } }); m_zoomLevelLabel.setId("szlInputLabel"); m_panBtn = new Button(); m_panBtn.setIcon(FontAwesome.ARROWS); m_panBtn.setDescription("Pan Tool"); m_panBtn.addStyleName(Styles.SELECTED); m_selectBtn = new Button(); m_selectBtn.setIcon(IonicIcons.ANDROID_EXPAND); m_selectBtn.setDescription("Selection Tool"); m_selectBtn.setStyleName("toolbar-button"); m_selectBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { m_selectBtn.addStyleName(Styles.SELECTED); m_panBtn.removeStyleName(Styles.SELECTED); controller.setActiveTool(ActiveTool.select); } }); m_panBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { m_panBtn.addStyleName(Styles.SELECTED); m_selectBtn.removeStyleName(Styles.SELECTED); controller.setActiveTool(ActiveTool.pan); } }); Button showAllMapBtn = new Button(); showAllMapBtn.setId("showEntireMapBtn"); showAllMapBtn.setIcon(FontAwesome.GLOBE); showAllMapBtn.setDescription("Show Entire Map"); showAllMapBtn.addClickListener((Button.ClickListener) event -> controller.showAllMap()); Button centerSelectionBtn = new Button(); centerSelectionBtn.setIcon(FontAwesome.LOCATION_ARROW); centerSelectionBtn.setDescription("Center On Selection"); centerSelectionBtn.addClickListener((Button.ClickListener) event -> controller.centerMapOnSelection()); Button shareButton = new Button("", FontAwesome.SHARE_SQUARE_O); shareButton.setDescription("Share"); shareButton.addClickListener((x) -> { // Create the share link String fragment = getUI().getPage().getLocation().getFragment(); String url = getUI().getPage().getLocation().toString().replace("#" + fragment, ""); String shareLink = String.format("%s?%s=%s", url, PARAMETER_HISTORY_FRAGMENT, fragment); // Create the Window Window shareWindow = new Window(); shareWindow.setCaption("Share Link"); shareWindow.setModal(true); shareWindow.setClosable(true); shareWindow.setResizable(false); shareWindow.setWidth(400, Sizeable.Unit.PIXELS); TextArea shareLinkField = new TextArea(); shareLinkField.setValue(shareLink); shareLinkField.setReadOnly(true); shareLinkField.setRows(3); shareLinkField.setWidth(100, Sizeable.Unit.PERCENTAGE); // Close Button Button close = new Button("Close"); close.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); close.addClickListener(event -> shareWindow.close()); // Layout for Buttons HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(true); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); buttonLayout.addComponent(close); buttonLayout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT); // Content Layout VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setMargin(true); verticalLayout.setSpacing(true); verticalLayout.addComponent( new Label("Please use the following link to share the current view with others.")); verticalLayout.addComponent(shareLinkField); verticalLayout.addComponent(buttonLayout); shareWindow.setContent(verticalLayout); getUI().addWindow(shareWindow); }); // Refresh Button Button refreshButton = new Button(); refreshButton.setId("refreshNow"); refreshButton.setIcon(FontAwesome.REFRESH); refreshButton.setDescription("Refresh Now"); refreshButton.addClickListener((event) -> controller.refreshUI()); // Layer Layout layerLayout = new VerticalLayout(); layerLayout.setId("layerComponent"); layerLayout.setSpacing(true); layerLayout.setMargin(true); // Layer Button layerButton = new Button(); layerButton.setId("layerToggleButton"); layerButton.setIcon(FontAwesome.BARS); layerButton.setDescription("Layers"); layerButton.addClickListener((event) -> { boolean isCollapsed = layerButton.getStyleName().contains(Styles.EXPANDED); setLayerLayoutVisible(!isCollapsed); }); // Save button layerSaveButton = new Button(); layerSaveButton.setId("saveLayerButton"); layerSaveButton.setIcon(FontAwesome.FLOPPY_O); layerSaveButton.addClickListener((event) -> controller.saveLayout()); // Actual Layout for the Toolbar CssLayout contentLayout = new CssLayout(); contentLayout.addStyleName("toolbar-component"); contentLayout.addComponent(createGroup(szlInBtn, m_zoomLevelLabel, m_szlOutBtn)); contentLayout.addComponent( createGroup(refreshButton, centerSelectionBtn, showAllMapBtn, layerButton, showFocusVerticesBtn)); contentLayout.addComponent(createGroup(m_panBtn, m_selectBtn)); contentLayout.addComponent(createGroup(magnifyBtn, demagnifyBtn)); contentLayout.addComponent(createGroup(shareButton)); contentLayout.addComponent(createGroup(layerSaveButton)); // Toolbar addComponent(contentLayout); }
From source file:org.opennms.features.topology.plugins.ncs.ShowNCSPathOperation.java
License:Open Source License
@Override public void execute(List<VertexRef> targets, final OperationContext operationContext) { //Get the current NCS criteria from here you can get the foreignIds foreignSource and deviceA and Z for (Criteria criterium : operationContext.getGraphContainer().getCriteria()) { try {/*from ww w. ja v a 2s . c om*/ NCSServiceCriteria ncsCriterium = (NCSServiceCriteria) criterium; if (ncsCriterium.getServiceCount() > 0) { m_storedCriteria = ncsCriterium; break; } } catch (ClassCastException e) { } } final VertexRef defaultVertRef = targets.get(0); final SelectionManager selectionManager = operationContext.getGraphContainer().getSelectionManager(); final Collection<VertexRef> vertexRefs = getVertexRefsForNCSService(m_storedCriteria); //selectionManager.getSelectedVertexRefs(); final UI mainWindow = operationContext.getMainWindow(); final Window ncsPathPrompt = new Window("Show NCS Path"); ncsPathPrompt.setModal(true); ncsPathPrompt.setResizable(false); ncsPathPrompt.setWidth("300px"); ncsPathPrompt.setHeight("220px"); //Items used in form field final PropertysetItem item = new PropertysetItem(); item.addItemProperty("Device A", new ObjectProperty<String>("", String.class)); item.addItemProperty("Device Z", new ObjectProperty<String>("", String.class)); FormFieldFactory fieldFactory = new FormFieldFactory() { private static final long serialVersionUID = 1L; @Override public Field<?> createField(Item item, Object propertyId, Component uiContext) { String pid = (String) propertyId; ComboBox select = new ComboBox(); for (VertexRef vertRef : vertexRefs) { select.addItem(vertRef.getId()); select.setItemCaption(vertRef.getId(), vertRef.getLabel()); } select.setNewItemsAllowed(false); select.setNullSelectionAllowed(false); select.setImmediate(true); select.setScrollToSelectedItem(true); if ("Device A".equals(pid)) { select.setCaption("Device A"); } else { select.setCaption("Device Z"); } return select; } }; final Form promptForm = new Form() { @Override public void commit() { String deviceA = (String) getField("Device A").getValue(); String deviceZ = (String) getField("Device Z").getValue(); if (deviceA.equals(deviceZ)) { Notification.show("Device A and Device Z cannot be the same", Notification.Type.WARNING_MESSAGE); throw new Validator.InvalidValueException("Device A and Device Z cannot be the same"); } OnmsNode nodeA = m_nodeDao.get(Integer.valueOf(deviceA)); String deviceANodeForeignId = nodeA.getForeignId(); //Use nodeA's foreignSource, deviceZ should have the same foreignSource. It's an assumption // which might need to changed in the future. Didn't want to hard code it it "space" if they // change it in the future String nodeForeignSource = nodeA.getForeignSource(); String deviceZNodeForeignId = m_nodeDao.get(Integer.valueOf(deviceZ)).getForeignId(); NCSComponent ncsComponent = m_dao.get(m_storedCriteria.getServiceIds().get(0)); String foreignSource = ncsComponent.getForeignSource(); String foreignId = ncsComponent.getForeignId(); String serviceName = ncsComponent.getName(); try { NCSServicePath path = getNcsPathProvider().getPath(foreignId, foreignSource, deviceANodeForeignId, deviceZNodeForeignId, nodeForeignSource, serviceName); if (path.getStatusCode() == 200) { NCSServicePathCriteria criteria = new NCSServicePathCriteria(path.getEdges()); m_serviceManager.registerCriteria(criteria, operationContext.getGraphContainer().getSessionId()); //Select only the vertices in the path selectionManager.setSelectedVertexRefs(path.getVertices()); } else { LoggerFactory.getLogger(this.getClass()).warn( "An error occured while retrieving the NCS Path, Juniper NetworkAppsApi send error code: " + path.getStatusCode()); mainWindow.showNotification("An error occurred while retrieving the NCS Path\nStatus Code: " + path.getStatusCode(), Notification.TYPE_ERROR_MESSAGE); } } catch (Exception e) { if (e.getCause() instanceof ConnectException) { LoggerFactory.getLogger(this.getClass()) .warn("Connection Exception Occurred while retreiving path {}", e); Notification.show("Connection Refused when attempting to reach the NetworkAppsApi", Notification.Type.TRAY_NOTIFICATION); } else if (e.getCause() instanceof HttpOperationFailedException) { HttpOperationFailedException httpException = (HttpOperationFailedException) e.getCause(); if (httpException.getStatusCode() == 401) { LoggerFactory.getLogger(this.getClass()).warn( "Authentication error when connecting to NetworkAppsApi {}", httpException); Notification.show( "Authentication error when connecting to NetworkAppsApi, please check the username and password", Notification.Type.TRAY_NOTIFICATION); } else { LoggerFactory.getLogger(this.getClass()) .warn("An error occured while retrieving the NCS Path {}", httpException); Notification.show("An error occurred while retrieving the NCS Path\n" + httpException.getMessage(), Notification.Type.TRAY_NOTIFICATION); } } else if (e.getCause() instanceof Validator.InvalidValueException) { Notification.show(e.getMessage(), Notification.Type.ERROR_MESSAGE); } else { LoggerFactory.getLogger(this.getClass()).warn("Exception Occurred while retreiving path {}", e); Notification.show( "An error occurred while calculating the path please check the karaf.log file for the exception: \n" + e.getMessage(), Notification.Type.TRAY_NOTIFICATION); } } } }; promptForm.setBuffered(true); promptForm.setFormFieldFactory(fieldFactory); promptForm.setItemDataSource(item); Button ok = new Button("OK"); ok.addClickListener(new ClickListener() { private static final long serialVersionUID = -2742886456007926688L; @Override public void buttonClick(ClickEvent event) { promptForm.commit(); mainWindow.removeWindow(ncsPathPrompt); } }); promptForm.getFooter().addComponent(ok); Button cancel = new Button("Cancel"); cancel.addClickListener(new ClickListener() { private static final long serialVersionUID = -9026067481179449095L; @Override public void buttonClick(ClickEvent event) { mainWindow.removeWindow(ncsPathPrompt); } }); promptForm.getFooter().addComponent(cancel); ncsPathPrompt.setContent(promptForm); mainWindow.addWindow(ncsPathPrompt); promptForm.getField("Device A").setValue(defaultVertRef.getId()); }
From source file:org.opennms.features.vaadin.dashboard.config.ui.HelpClickListener.java
License:Open Source License
@Override public void buttonClick(Button.ClickEvent clickEvent) { final Window window = new Window("Help"); window.setModal(true);//w w w . j a v a 2s. com window.setClosable(false); window.setResizable(false); window.setWidth("55%"); window.setHeight("80%"); m_component.getUI().addWindow(window); window.setContent(new VerticalLayout() { { setMargin(true); setSpacing(true); setSizeFull(); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSizeFull(); horizontalLayout.setSpacing(true); Tree tree = new Tree(); tree.setNullSelectionAllowed(false); tree.setMultiSelect(false); tree.setImmediate(true); tree.addItem("Overview"); tree.setChildrenAllowed("Overview", false); tree.addItem("Installed Dashlets"); tree.setChildrenAllowed("Installed Dashlets", true); final List<DashletFactory> factories = m_dashletSelector.getDashletFactoryList(); for (DashletFactory dashletFactory : factories) { tree.addItem(dashletFactory.getName()); tree.setParent(dashletFactory.getName(), "Installed Dashlets"); tree.setChildrenAllowed(dashletFactory.getName(), false); } horizontalLayout.addComponent(tree); for (final Object id : tree.rootItemIds()) { tree.expandItemsRecursively(id); } final Panel panel = new Panel(); panel.setSizeFull(); horizontalLayout.addComponent(panel); horizontalLayout.setExpandRatio(panel, 1.0f); addComponent(horizontalLayout); setExpandRatio(horizontalLayout, 1.0f); tree.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { String itemId = String.valueOf(valueChangeEvent.getProperty().getValue()); if ("Installed Dashlets".equals(itemId)) { return; } if ("Overview".equals(itemId)) { VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSpacing(true); verticalLayout.setMargin(true); verticalLayout.addComponent(new Label(getOverviewHelpHTML(), ContentMode.HTML)); panel.setContent(verticalLayout); } else { DashletFactory dashletFactory = m_dashletSelector.getDashletFactoryForName(itemId); if (dashletFactory != null) { if (dashletFactory.providesHelpComponent()) { VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSpacing(true); verticalLayout.setMargin(true); Label helpTitle = new Label( "Help for Dashlet '" + dashletFactory.getName() + "'"); helpTitle.addStyleName("help-title"); verticalLayout.addComponent(helpTitle); verticalLayout.addComponent(dashletFactory.getHelpComponent()); panel.setContent(verticalLayout); } } } } }); tree.select("Overview"); addComponent(new HorizontalLayout() { { setMargin(true); setSpacing(true); setWidth("100%"); Button closeButton = new Button("Close"); addComponent(closeButton); setComponentAlignment(closeButton, Alignment.MIDDLE_RIGHT); closeButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { window.close(); } }); } }); } }); }
From source file:org.opennms.features.vaadin.dashboard.config.ui.PreviewClickListener.java
License:Open Source License
@Override public void buttonClick(Button.ClickEvent clickEvent) { final Window window = new Window("Preview"); window.setModal(true);/*w w w . j av a 2 s . co m*/ window.setClosable(false); window.setResizable(false); window.setWidth("80%"); window.setHeight("90%"); m_component.getUI().addWindow(window); final WallboardBody wallboardBody = new WallboardBody(); window.setContent(new VerticalLayout() { { setMargin(true); setSpacing(true); setSizeFull(); addComponent(wallboardBody); setExpandRatio(wallboardBody, 1.0f); addComponent(new HorizontalLayout() { { setMargin(true); setSpacing(true); setWidth("100%"); Button closeButton = new Button("Close"); addComponent(closeButton); setComponentAlignment(closeButton, Alignment.MIDDLE_RIGHT); closeButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { window.close(); } }); } }); } }); wallboardBody.setDashletSpecs(m_wallboard.getDashletSpecs()); }
From source file:org.opennms.features.vaadin.dashboard.config.ui.WallboardConfigView.java
License:Open Source License
/** * This method is used to add a new {@link TabSheet.Tab} component. It creates a new window querying the user for the name of the new {@link Wallboard}. *//*from ww w. j ava 2s. co m*/ protected void addNewTabComponent() { final Window window = new Window("New Ops Board"); window.setModal(true); window.setClosable(false); window.setResizable(false); window.addCloseListener(new Window.CloseListener() { @Override public void windowClose(Window.CloseEvent e) { m_dashboardOverview.refreshTable(); } }); getUI().addWindow(window); window.setContent(new VerticalLayout() { TextField name = new TextField("Ops Board Name"); { addComponent(new FormLayout() { { setSizeUndefined(); setMargin(true); String newName = "Untitled"; int i = 1; if (WallboardProvider.getInstance().containsWallboard(newName)) { do { i++; newName = "Untitled #" + i; } while (WallboardProvider.getInstance().containsWallboard(newName)); } name.setValue(newName); addComponent(name); name.focus(); name.selectAll(); name.addValidator(new AbstractStringValidator("Title must be unique") { @Override protected boolean isValidValue(String s) { return (!WallboardProvider.getInstance().containsWallboard(s) && !"".equals(s)); } }); } }); addComponent(new HorizontalLayout() { { setMargin(true); setSpacing(true); setWidth("100%"); Button cancel = new Button("Cancel"); cancel.setDescription("Cancel editing"); cancel.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { // NMS-7560: Toggle the tab in order to allow us to click it again m_tabSheet.togglePlusTab(); window.close(); } }); cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); addComponent(cancel); setExpandRatio(cancel, 1); setComponentAlignment(cancel, Alignment.TOP_RIGHT); Button ok = new Button("Save"); ok.setDescription("Save configuration"); ok.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (name.isValid()) { Wallboard wallboard = new Wallboard(); wallboard.setTitle(name.getValue()); WallboardProvider.getInstance().addWallboard(wallboard); WallboardProvider.getInstance().save(); WallboardEditor wallboardEditor = new WallboardEditor(m_dashletSelector, wallboard); TabSheet.Tab tab = m_tabSheet.addTab(wallboardEditor, wallboard.getTitle()); wallboardEditor.setTab(tab); m_wallboardEditorMap.put(wallboard, tab); tab.setClosable(true); m_tabSheet.setSelectedTab(tab); window.close(); } } }); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); addComponent(ok); } }); } }); }
From source file:org.opennms.features.vaadin.surveillanceviews.ui.PreviewClickListener.java
License:Open Source License
/** * {@inheritDoc}/*from www. j ava 2s. c o m*/ */ @Override public void buttonClick(Button.ClickEvent clickEvent) { final Window window = new Window("Preview"); window.setModal(true); window.setClosable(true); window.setResizable(false); window.setWidth("80%"); window.setHeight("90%"); m_component.getUI().addWindow(window); window.setContent(new VerticalLayout() { { addComponent(new VerticalLayout() { { setMargin(true); setSpacing(true); setSizeFull(); addComponent(new SurveillanceView(m_view, m_surveillanceViewService, false, false)); } }); } }); }
From source file:org.processbase.ui.portlet.ChartPortlet.java
License:Open Source License
public void handleResourceRequest(ResourceRequest request, ResourceResponse response, Window window) { if (request.getPortletMode() == PortletMode.EDIT) { window.setContent(configPanel); } else if (request.getPortletMode() == PortletMode.VIEW) { window.setContent(viewPanel);/*from ww w. jav a2s . com*/ } }
From source file:org.semanticsoft.vaaclipse.app.VaadinApplication.java
License:Open Source License
@Override public void init() { context = VaadinE4Application.getInstance().getAppContext(); logger = VaadinE4Application.getInstance().getLogger(); //--user agent detection // if (this.getContext() instanceof WebApplicationContext) { // String userAgent = ((WebApplicationContext)this.getContext()).getBrowser().getBrowserApplication(); // if (userAgent.contains("MSIE")) // {//from w w w.j a va 2s .co m // String str = "<html><br/>Vaaclipse currently does not support Internet Explorer.<br/><br/>" + // "Please use one of the browser from list:<br/><ul><li>Mozilla Firefox (recomended)</li> <li>Google Chrome or Chromium</li> <li>Opera</li> <li>Safari</li> <li>Rekonq</li> <li>Any other not listed browser based on Webkit</li></ul></html>"; // Label errorLabel = new Label(str, Label.CONTENT_XHTML); // mainWindow.getContent().addComponent(errorLabel); // return; // } // } //-- //------------------------------------- prepareEnvironment(context); IEventBroker eventBroker = appContext.get(EventBroker.class); eventBroker.subscribe(ThemeConstants.Events.setThemeEvent, new EventHandler() { @Override public void handleEvent(Event event) { Theme theme = (Theme) event.getProperty(IEventBroker.DATA); if (theme != null) { HttpSession session = ((WebApplicationContext) getContext()).getHttpSession(); session.setAttribute(ThemeConstants.Attrubutes.themeid, theme.getId()); setThemeInternal(theme.getWebId()); } } }); String themeId = VaadinE4Application.getInstance().getCssTheme(); ThemeManager themeManager = appContext.get(ThemeManager.class); themeManager.setTheme(themeId); String authProvider = VaadinE4Application.getInstance().getApplicationAuthenticationProvider(); if (authProvider == null || authProvider.trim().isEmpty()) { //start workbench as usually e4Workbench = createE4Workbench(context); e4Workbench.createAndRunUI(e4Workbench.getApplication()); } else { final Window window = new Window("Login"); window.setSizeFull(); setMainWindow(window); eventBroker.subscribe(AuthenticationConstants.Events.Authentication, new EventHandler() { @Override public void handleEvent(Event event) { Object data = event.getProperty(EventUtils.DATA); if (data instanceof User) { //login user: user = (User) data; //TODO: Now we can load persistande model of this user (not implemented yet, just load initial model) e4Workbench = createE4Workbench(context); e4Workbench.createAndRunUI(e4Workbench.getApplication()); } } }); IContributionFactory contributionFactory = (IContributionFactory) appContext .get(IContributionFactory.class.getName()); IEclipseContext authConext = appContext.createChild(); VerticalLayout windowContent = new VerticalLayout(); windowContent.setSizeFull(); window.setContent(windowContent); authConext.set(ComponentContainer.class, windowContent); authConext.set(VerticalLayout.class, windowContent); Object authProviderObj = contributionFactory.create(authProvider, authConext); System.out.println(authProvider); } }
From source file:org.tltv.gantt.demo.DemoUI.java
License:Apache License
private void openStepEditor(AbstractStep step) { final Window win = new Window("Step Editor"); win.setResizable(false);/*from w w w . j a va 2 s . c o m*/ win.center(); final Collection<Component> hidden = new ArrayList<Component>(); BeanItem<AbstractStep> item = new BeanItem<AbstractStep>(step); final FieldGroup group = new FieldGroup(item); group.setBuffered(true); TextField captionField = new TextField("Caption"); captionField.setNullRepresentation(""); group.bind(captionField, "caption"); TextField descriptionField = new TextField("Description"); descriptionField.setNullRepresentation(""); group.bind(descriptionField, "description"); descriptionField.setVisible(false); hidden.add(descriptionField); NativeSelect captionMode = new NativeSelect("Caption Mode"); captionMode.addItem(Step.CaptionMode.TEXT); captionMode.addItem(Step.CaptionMode.HTML); group.bind(captionMode, "captionMode"); captionMode.setVisible(false); hidden.add(captionMode); CheckBox showProgress = new CheckBox("Show progress"); group.bind(showProgress, "showProgress"); showProgress.setVisible(false); hidden.add(showProgress); Slider progress = new Slider("Progress"); progress.setWidth(100, Unit.PERCENTAGE); group.bind(progress, "progress"); progress.setVisible(false); hidden.add(progress); NativeSelect predecessorSelect = new NativeSelect("Predecessor Step"); predecessorSelect.setWidth(100, Unit.PERCENTAGE); fillPredecessorCanditatesToSelect(step, predecessorSelect); predecessorSelect.setEnabled(step instanceof Step); if (step instanceof Step) { group.bind(predecessorSelect, "predecessor"); } predecessorSelect.setVisible(false); hidden.add(predecessorSelect); final NativeSelect parentStepSelect = new NativeSelect("Parent Step"); parentStepSelect.setWidth(100, Unit.PERCENTAGE); parentStepSelect.setEnabled(false); fillParentStepCanditatesToSelect(step, parentStepSelect); parentStepSelect.setVisible(false); hidden.add(parentStepSelect); HorizontalLayout colorLayout = new HorizontalLayout(); colorLayout.setWidth(100, Unit.PERCENTAGE); colorLayout.setVisible(false); hidden.add(colorLayout); final TextField bgField = new TextField("Background color"); bgField.setNullRepresentation(""); group.bind(bgField, "backgroundColor"); bgField.setEnabled(false); final ColorPicker bgColorPicker = new ColorPicker(); bgColorPicker.setPosition(300, 100); bgColorPicker.setColor(new CssColorToColorPickerConverter().convertToModel(step.getBackgroundColor())); bgColorPicker.addColorChangeListener(new ColorChangeListener() { @Override public void colorChanged(ColorChangeEvent event) { bgField.setValue(event.getColor().getCSS()); } }); colorLayout.addComponent(bgField); colorLayout.addComponent(bgColorPicker); colorLayout.setExpandRatio(bgField, 1); colorLayout.setComponentAlignment(bgColorPicker, Alignment.BOTTOM_LEFT); DateField startDate = new DateField("Start date"); startDate.setLocale(gantt.getLocale()); startDate.setTimeZone(gantt.getTimeZone()); startDate.setResolution(Resolution.SECOND); startDate.setConverter(new DateToLongConverter()); group.bind(startDate, "startDate"); DateField endDate = new DateField("End date"); endDate.setLocale(gantt.getLocale()); endDate.setTimeZone(gantt.getTimeZone()); endDate.setResolution(Resolution.SECOND); endDate.setConverter(new DateToLongConverter()); group.bind(endDate, "endDate"); CheckBox showMore = new CheckBox("Show all settings"); showMore.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { for (Component c : hidden) { c.setVisible((Boolean) event.getProperty().getValue()); } win.center(); } }); VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSpacing(true); win.setContent(content); content.addComponent(captionField); content.addComponent(captionMode); content.addComponent(descriptionField); content.addComponent(showProgress); content.addComponent(progress); content.addComponent(predecessorSelect); content.addComponent(parentStepSelect); content.addComponent(colorLayout); content.addComponent(startDate); content.addComponent(endDate); content.addComponent(showMore); HorizontalLayout buttons = new HorizontalLayout(); content.addComponent(buttons); Button ok = new Button("Ok", new ClickListener() { @Override public void buttonClick(ClickEvent event) { commit(win, group, parentStepSelect); } }); Button cancel = new Button("Cancel", new ClickListener() { @Override public void buttonClick(ClickEvent event) { cancel(win, group); } }); Button delete = new Button("Delete", new ClickListener() { @Override public void buttonClick(ClickEvent event) { delete(win, group); } }); buttons.addComponent(ok); buttons.addComponent(cancel); buttons.addComponent(delete); win.setClosable(true); getUI().addWindow(win); }