List of usage examples for com.vaadin.server Page getCurrent
public static Page getCurrent()
From source file:com.mycollab.vaadin.ui.ThemeManager.java
License:Open Source License
public static void loadDesktopTheme(int sAccountId) { AccountThemeService themeService = AppContextUtil.getSpringBean(AccountThemeService.class); AccountTheme accountTheme = themeService.findTheme(sAccountId); if (accountTheme == null) { accountTheme = themeService.findDefaultTheme(MyCollabUI.getAccountId()); if (accountTheme == null) { throw new UserInvalidInputException( UserUIContext.getMessage(ShellI18nEnum.ERROR_CAN_NOT_LOAD_THEME)); }//from ww w .j a v a 2 s . c om } StringBuilder extraStyles = new StringBuilder(); /* Top Menu */ if (accountTheme.getTopmenubg() != null) { extraStyles.append(".topNavigation { background-color: #" + accountTheme.getTopmenubg() + "; }"); extraStyles.append("#login-header { background-color: #" + accountTheme.getTopmenubg() + "; }"); extraStyles .append(".topNavigation #mainLogo { background-color: #" + accountTheme.getTopmenubg() + "; }"); } if (accountTheme.getTopmenubgselected() != null) { extraStyles.append(".topNavigation .serviceMenuContainer .service-menu .v-button.selected {" + " background-color: #" + accountTheme.getTopmenubgselected() + "; }"); extraStyles.append( ".topNavigation .serviceMenuContainer .service-menu .v-button:hover { background-color: #" + accountTheme.getTopmenubgselected() + "; }"); extraStyles.append(".v-button.add-btn-popup:hover { background-color: #" + accountTheme.getTopmenubgselected() + "; }"); extraStyles.append(".topNavigation .v-button.ad { background-color: #" + accountTheme.getTopmenubgselected() + "; }"); } if (accountTheme.getTopmenutext() != null) { extraStyles.append(".topNavigation .v-button { color: #" + accountTheme.getTopmenutext() + "; }"); extraStyles.append(".subDomain { color: #" + accountTheme.getTopmenutext() + "; }"); extraStyles.append(".accountMenuContainer .v-popup-indicator::before { color: #" + accountTheme.getTopmenutext() + "; }"); } if (accountTheme.getTopmenutextselected() != null) { extraStyles.append(".topNavigation .serviceMenuContainer .service-menu .v-button.selected { color: #" + accountTheme.getTopmenutextselected() + "; }"); extraStyles.append(".topNavigation .serviceMenuContainer .service-menu .v-button:hover { color: #" + accountTheme.getTopmenutextselected() + "; }"); extraStyles.append( ".v-button.add-btn-popup:hover { color: #" + accountTheme.getTopmenutextselected() + "; }"); extraStyles.append( ".topNavigation .v-button.ad { color: #" + accountTheme.getTopmenutextselected() + "; }"); extraStyles.append(".topNavigation .v-button.ad .v-icon { color: #" + accountTheme.getTopmenutextselected() + "; }"); } /* Vertical Tabsheet */ if (accountTheme.getVtabsheetbg() != null) { extraStyles.append(".vertical-tabsheet .navigator-wrap { background-color: #" + accountTheme.getVtabsheetbg() + "; }"); } if (accountTheme.getVtabsheettext() != null) { extraStyles.append(".vertical-tabsheet .v-button-tab > .v-button-wrap { color: #" + accountTheme.getVtabsheettext() + "; }"); extraStyles.append( ".closed-button .v-button-wrap .v-icon { color: #" + accountTheme.getVtabsheettext() + "; }"); extraStyles.append( ".expand-button .v-button-wrap .v-icon { color: #" + accountTheme.getVtabsheettext() + "; }"); extraStyles.append(".project-info .header { color: #" + accountTheme.getVtabsheettext() + "; }"); extraStyles.append(".crmContainer .navigator-wrap .basic-info { color: #" + accountTheme.getVtabsheettext() + "; }"); extraStyles.append(".intro-text-wrap .v-label { color: #" + accountTheme.getVtabsheettext() + "; }"); } if (accountTheme.getVtabsheetbgselected() != null) { extraStyles.append(".vertical-tabsheet .v-button-tab.tab-selected { background-color: #" + accountTheme.getVtabsheetbgselected() + "; }"); extraStyles.append(".vertical-tabsheet .v-button-tab:hover {background-color: #" + accountTheme.getVtabsheetbgselected() + ";}"); } if (accountTheme.getVtabsheettextselected() != null) { extraStyles.append(".vertical-tabsheet .v-button-tab.tab-selected > .v-button-wrap { color: #" + accountTheme.getVtabsheettextselected() + "; }"); //Color while hover on sidebar menu extraStyles.append(".vertical-tabsheet .v-button-tab .v-button-wrap:hover {color: #" + accountTheme.getVtabsheettextselected() + "!important;}"); extraStyles.append(".vertical-tabsheet .v-button-tab:hover .v-button-wrap {color: #" + accountTheme.getVtabsheettextselected() + "!important;}"); //Volume text display bar in file manager extraStyles.append( ".v-label.volumeUsageInfo div { color: #" + accountTheme.getVtabsheettextselected() + ";}"); } /* Action Buttons */ if (accountTheme.getActionbtn() != null) { extraStyles.append(".v-button.v-button-greenbtn, .v-button-greenbtn:focus { background-color: #" + accountTheme.getActionbtn() + "; }"); extraStyles.append(".splitbutton:hover .v-button.v-button-greenbtn, .v-button-greenbtn:hover { " + "background-color: " + ColorUtils.darkerColor("#" + accountTheme.getActionbtn()) + "; }"); extraStyles.append(".upload-field .v-upload-immediate .v-button {background-color: #" + accountTheme.getActionbtn() + ";}"); extraStyles.append(".upload-field .v-upload-immediate .v-button:hover {background-color: " + ColorUtils.darkerColor("#" + accountTheme.getActionbtn()) + ";}"); extraStyles.append(".optionPopupContent .action-wrap:hover {" + "background-color: #" + accountTheme.getActionbtn() + "};"); extraStyles.append(".v-buttongroup.toggle-btn-group .v-button.active { background-color: #" + accountTheme.getActionbtn() + "; }"); //Button paging extraStyles.append(".v-button.buttonPaging.current, .v-button.buttonPaging:hover { background-color:#" + accountTheme.getActionbtn() + "; }"); //Selection background of selected item extraStyles.append(".v-filterselect-suggestpopup .gwt-MenuItem-selected { background-color:#" + accountTheme.getActionbtn() + "; }"); //Year block of activity stream extraStyles.append(".v-label.year-lbl { box-shadow: 0 0 0 5px #" + accountTheme.getActionbtn() + ";}"); //Date label of activity stream extraStyles.append(".activity-list .feed-block-wrap .date-lbl { background-color:#" + accountTheme.getActionbtn() + ";}"); extraStyles.append(".activity-list .feed-block-wrap .date-lbl::after{ border-left-color:#" + accountTheme.getActionbtn() + ";}"); extraStyles.append(".activity-list .feed-block-wrap:hover .date-lbl { background-color:" + ColorUtils.darkerColor("#" + accountTheme.getActionbtn()) + ";}"); extraStyles.append(".activity-list .feed-block-wrap:hover .date-lbl::after{ border-left-color:" + ColorUtils.darkerColor("#" + accountTheme.getActionbtn()) + ";}"); // Button group default button extraStyles.append(".v-buttongroup.toggle-btn-group .v-button.btn-group-default {background-color:#" + accountTheme.getActionbtn() + ";}"); extraStyles .append(".v-buttongroup.toggle-btn-group .v-button.btn-group-default:hover {background-color:" + ColorUtils.darkerColor("#" + accountTheme.getActionbtn()) + ";}"); extraStyles.append(".v-context-menu-container .v-context-menu .v-context-submenu:hover " + "{background-color:#" + accountTheme.getActionbtn() + ";}"); } if (accountTheme.getActionbtntext() != null) { extraStyles.append(".v-button.v-button-greenbtn, .v-button-greenbtn:focus { color: #" + accountTheme.getActionbtntext() + "; }"); extraStyles.append(".upload-field .v-upload-immediate .v-button, .upload-field .v-upload-immediate " + ".v-button:focus {color: #" + accountTheme.getActionbtntext() + ";}"); extraStyles.append(".optionPopupContent .action-wrap .v-button-action .v-button-wrap:hover" + " {" + "color: #" + accountTheme.getActionbtntext() + "};"); //Button paging extraStyles.append(".v-button.buttonPaging.current, .v-button.buttonPaging:hover { color:#" + accountTheme.getActionbtntext() + "; }"); //Selection text color of selected item extraStyles.append(".v-filterselect-suggestpopup .gwt-MenuItem-selected { color:#" + accountTheme.getActionbtntext() + "; }"); //Date label of activity stream extraStyles.append( ".activity-list .feed-block-wrap .date-lbl { color:#" + accountTheme.getActionbtntext() + ";}"); extraStyles.append(".v-button.v-button-block {color:#" + accountTheme.getActionbtntext() + ";}"); extraStyles.append(".v-context-menu-container .v-context-menu .v-context-submenu:hover " + "{color:#" + accountTheme.getActionbtntext() + ";}"); } /* Option Buttons */ if (accountTheme.getOptionbtn() != null) { extraStyles.append(".v-button.v-button-graybtn, .v-button-graybtn:focus { background-color: #" + accountTheme.getOptionbtn() + ";}"); extraStyles.append(".splitbutton:hover .v-button-graybtn, .v-button-graybtn:hover { background-color: " + ColorUtils.darkerColor("#" + accountTheme.getOptionbtn()) + ";}"); //Set toggle button group background extraStyles.append(".v-buttongroup.toggle-btn-group .v-button { background-color: #" + accountTheme.getOptionbtn() + ";}"); extraStyles.append(".v-buttongroup.toggle-btn-group .v-button:hover { background-color: " + ColorUtils.darkerColor("#" + accountTheme.getOptionbtn()) + ";}"); } if (accountTheme.getOptionbtntext() != null) { extraStyles.append(".v-button.v-button-graybtn, .v-button-graybtn:focus { color: #" + accountTheme.getOptionbtntext() + "; }"); extraStyles.append(".v-buttongroup.toggle-btn-group .v-button { color: #" + accountTheme.getOptionbtntext() + "; }"); } /* Danger Buttons */ if (accountTheme.getDangerbtn() != null) { extraStyles.append(".v-button.v-button-redbtn, .v-button-redbtn:focus { background-color: #" + accountTheme.getDangerbtn() + "; }"); extraStyles.append(".v-button-redbtn:hover { background-color: " + ColorUtils.darkerColor("#" + accountTheme.getDangerbtn(), 0.1) + "; }"); //Set style of popup content action extraStyles.append(".optionPopupContent .action-wrap.danger .v-button-action { color: #" + accountTheme.getDangerbtn() + "; }"); extraStyles.append(".optionPopupContent .action-wrap.danger:hover {" + "background-color: #" + accountTheme.getDangerbtn() + ";}"); } if (accountTheme.getDangerbtntext() != null) { extraStyles.append(".v-button.v-button-redbtn, .v-button-redbtn:focus { color: #" + accountTheme.getDangerbtntext() + "; }"); } if (extraStyles.length() > 0) { Page.getCurrent().getStyles().add(extraStyles.toString()); } }
From source file:com.mycollab.vaadin.ui.ThemeManager.java
License:Open Source License
public static void loadDemoTheme(AccountTheme accountTheme) { StringBuilder demoExtraStyles = new StringBuilder(); /* Top Menu */ if (accountTheme.getTopmenubg() != null) { demoExtraStyles.append(//from w ww . ja va2 s . c o m ".example-block .topNavigation { background-color: #" + accountTheme.getTopmenubg() + "; }"); } if (accountTheme.getTopmenubgselected() != null) { demoExtraStyles.append( ".example-block .topNavigation .service-menu.v-buttongroup .v-button.selected { background-color: #" + accountTheme.getTopmenubgselected() + "; }"); } if (accountTheme.getTopmenutext() != null) { demoExtraStyles.append(".example-block .topNavigation .v-button-caption { color: #" + accountTheme.getTopmenutext() + "; }"); } if (accountTheme.getTopmenutextselected() != null) { demoExtraStyles.append( ".example-block .topNavigation .service-menu.v-buttongroup .v-button.selected .v-button-caption { color: #" + accountTheme.getTopmenutextselected() + "; }"); } /* Vertical Tabsheet */ if (accountTheme.getVtabsheetbg() != null) { demoExtraStyles.append( ".example-block .navigator-wrap { background-color: #" + accountTheme.getVtabsheetbg() + "; }"); } if (accountTheme.getVtabsheetbgselected() != null) { demoExtraStyles .append(".example-block .vertical-tabsheet .v-button-tab.tab-selected { background-color: #" + accountTheme.getVtabsheetbgselected() + "; }"); } if (accountTheme.getVtabsheettext() != null) { demoExtraStyles.append( ".example-block .vertical-tabsheet .v-button-tab > .v-button-wrap > .v-button-caption { color: #" + accountTheme.getVtabsheettext() + "; }"); } if (accountTheme.getVtabsheettextselected() != null) { demoExtraStyles.append( ".example-block .vertical-tabsheet .v-button-tab.tab-selected > .v-button-wrap > .v-button-caption { color: #" + accountTheme.getVtabsheettextselected() + "; }"); } /* Action Buttons */ if (accountTheme.getActionbtn() != null) { demoExtraStyles.append( ".example-block .v-button.v-button-greenbtn, .example-block .v-button-greenbtn:focus { background-color: #" + accountTheme.getActionbtn() + "; }"); } if (accountTheme.getActionbtntext() != null) { demoExtraStyles.append( ".example-block .v-button.v-button-greenbtn, .example-block .v-button-greenbtn:focus { color: #" + accountTheme.getActionbtntext() + "; }"); } /* Option Buttons */ if (accountTheme.getOptionbtn() != null) { demoExtraStyles.append( ".example-block .v-button.v-button-graybtn, .example-block .v-button-graybtn:focus { background-color: #" + accountTheme.getOptionbtn() + "; }"); } if (accountTheme.getOptionbtntext() != null) { demoExtraStyles.append( ".example-block .v-button.v-button-graybtn, .example-block .v-button-graybtn:focus { color: #" + accountTheme.getOptionbtntext() + "; }"); } /* Danger Buttons */ if (accountTheme.getDangerbtn() != null) { demoExtraStyles.append( ".example-block .v-button.v-button-redbtn, .example-block .v-button-redbtn:focus { background-color: #" + accountTheme.getDangerbtn() + "; }"); } if (accountTheme.getDangerbtntext() != null) { demoExtraStyles.append( ".example-block .v-button.v-button-redbtn, .example-block .v-button-redbtn:focus { color: #" + accountTheme.getDangerbtntext() + "; }"); } if (demoExtraStyles.length() > 0) { Page.getCurrent().getStyles().add(demoExtraStyles.toString()); } }
From source file:com.mycollab.vaadin.web.ui.VerticalTabsheet.java
License:Open Source License
public void addTab(Component component, String id, int level, String caption, String link, Resource resource) { if (!hasTab(id)) { final ButtonTabImpl button = new ButtonTabImpl(id, level, caption, link); button.addClickListener(clickEvent -> { if (!clickEvent.isCtrlKey() && !clickEvent.isMetaKey()) { if (selectedButton != button) { clearTabSelection(true); selectedButton = button; selectedButton.addStyleName(TAB_SELECTED_STYLENAME); selectedComp = compMap.get(button.getTabId()); }//from ww w . ja va2 s . co m fireTabChangeEvent(new SelectedTabChangeEvent(VerticalTabsheet.this)); } else { Page.getCurrent().open(button.link, "_blank", false); } }); button.setIcon(resource); button.withStyleName(TAB_STYLENAME, UIConstants.TEXT_ELLIPSIS).withWidth("90%"); if (button.getLevel() > 0) { int insertIndex = 0; for (int i = 0; i < navigatorContainer.getComponentCount(); i++) { ButtonTabImpl buttonTmp = (ButtonTabImpl) navigatorContainer.getComponent(i); if (buttonTmp.getLevel() > level) { break; } else { insertIndex++; } } navigatorContainer.addComponent(button, insertIndex); navigatorContainer.setComponentAlignment(button, Alignment.MIDDLE_CENTER); } else { navigatorContainer.addComponent(button); navigatorContainer.setComponentAlignment(button, Alignment.MIDDLE_CENTER); } TabImpl tabImpl = new TabImpl(id, caption, component); compMap.put(id, tabImpl); } }
From source file:com.mycollab.web.DesktopApplication.java
License:Open Source License
private void handleException(VaadinRequest request, Throwable e) { IgnoreException ignoreException = getExceptionType(e, IgnoreException.class); if (ignoreException != null) { return;/*from w w w. j a v a2s . c o m*/ } DebugException debugException = getExceptionType(e, DebugException.class); if (debugException != null) { LOG.error("Debug error", e); return; } SessionExpireException sessionExpireException = getExceptionType(e, SessionExpireException.class); if (sessionExpireException != null) { Page.getCurrent().getJavaScript().execute("window.location.reload();"); return; } UsageExceedBillingPlanException usageBillingException = getExceptionType(e, UsageExceedBillingPlanException.class); if (usageBillingException != null) { if (UserUIContext.isAdmin()) { ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.WINDOW_ATTENTION_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage(GenericI18Enum.EXCEED_BILLING_PLAN_MSG_FOR_ADMIN), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { Collection<Window> windowsList = UI.getCurrent().getWindows(); for (Window window : windowsList) { window.close(); } EventBusFactory.getInstance().post( new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" })); } }); } else { NotificationUtil.showErrorNotification( UserUIContext.getMessage(GenericI18Enum.EXCEED_BILLING_PLAN_MSG_FOR_USER)); } return; } UserInvalidInputException invalidException = getExceptionType(e, UserInvalidInputException.class); if (invalidException != null) { NotificationUtil.showWarningNotification(UserUIContext .getMessage(GenericI18Enum.ERROR_USER_INPUT_MESSAGE, invalidException.getMessage())); return; } UnsupportedFeatureException unsupportedException = getExceptionType(e, UnsupportedFeatureException.class); if (unsupportedException != null) { NotificationUtil.showFeatureNotPresentInSubscription(); return; } ResourceNotFoundException resourceNotFoundException = getExceptionType(e, ResourceNotFoundException.class); if (resourceNotFoundException != null) { NotificationUtil.showWarningNotification(UserUIContext.getMessage(ErrorI18nEnum.RESOURCE_NOT_FOUND)); LOG.error("404", resourceNotFoundException); return; } SecureAccessException secureAccessException = getExceptionType(e, SecureAccessException.class); if (secureAccessException != null) { NotificationUtil.showWarningNotification("You can not access the specific resource"); EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" })); return; } for (Class systemEx : systemExceptions) { Exception ex = (Exception) getExceptionType(e, systemEx); if (ex != null) { ConfirmDialog dialog = ConfirmDialogExt.show(DesktopApplication.this, UserUIContext.getMessage(GenericI18Enum.WINDOW_ERROR_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage(GenericI18Enum.ERROR_USER_SYSTEM_ERROR, ex.getMessage()), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { }); Button okBtn = dialog.getOkButton(); BrowserWindowOpener opener = new BrowserWindowOpener("http://support.mycollab.com"); opener.extend(okBtn); return; } } IllegalStateException asyncNotSupport = getExceptionType(e, IllegalStateException.class); if (asyncNotSupport != null && asyncNotSupport.getMessage().contains("!asyncSupported")) { ConfirmDialog dialog = ConfirmDialogExt.show(DesktopApplication.this, UserUIContext.getMessage(GenericI18Enum.WINDOW_ERROR_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage(ErrorI18nEnum.WEBSOCKET_NOT_SUPPORT), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { }); Button okBtn = dialog.getOkButton(); BrowserWindowOpener opener = new BrowserWindowOpener("http://support.mycollab.com"); opener.extend(okBtn); if (request != null) { String remoteAddress = request.getRemoteHost(); if (remoteAddress != null) { if (!ipLists.contains(remoteAddress)) { LOG.error("Async not supported: " + printRequest(request)); ipLists.add(remoteAddress); } } } return; } EofException eofException = getExceptionType(e, EofException.class); if (eofException != null) { return; } LOG.error("Error", e); ConfirmDialog dialog = ConfirmDialogExt.show(DesktopApplication.this, UserUIContext.getMessage(GenericI18Enum.WINDOW_ERROR_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage(GenericI18Enum.ERROR_USER_NOTICE_INFORMATION_MESSAGE), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { }); Button okBtn = dialog.getOkButton(); BrowserWindowOpener opener = new BrowserWindowOpener("http://support.mycollab.com"); opener.extend(okBtn); }
From source file:com.neatresults.mgnltweaks.ui.action.ExportMultipleAction.java
License:Open Source License
/** * Once all items are exported, zip it all and send to client. *//* w w w . java2s. c om*/ @Override protected void onPostExecute() throws Exception { IOUtils.closeQuietly(fileOutputStream); postExecCount++; if (getItems().size() > 1) { ExportCommand exportCommand = (ExportCommand) getCommand(); String fileName = exportCommand.getFileName(); tempFiles.put(fileName, fileOutput); } if (getItems().size() > 1 && postExecCount == getItems().size()) { // last run on multi-run String fileName = "magnoliaExport.zip"; String mimeType = MIMEMapping.getMIMEType("zip"); // will get deleted by stream after it is streamed through http request TempFileStreamResource tempFileStreamResource = new TempFileStreamResource(); tempFileStreamResource.setTempFileName("magnoliaExport" + (Math.random() * 1000)); tempFileStreamResource.setTempFileExtension("zip"); ArchiveOutputStream zipOutput = new ArchiveStreamFactory().createArchiveOutputStream("zip", tempFileStreamResource.getTempFileOutputStream()); try { for (Entry<String, File> entry : tempFiles.entrySet()) { zipOutput.putArchiveEntry(new ZipArchiveEntry(entry.getValue(), entry.getKey())); FileInputStream fis = new FileInputStream(entry.getValue()); IOUtils.copy(fis, zipOutput); zipOutput.closeArchiveEntry(); IOUtils.closeQuietly(fis); } } finally { zipOutput.finish(); IOUtils.closeQuietly(zipOutput); } tempFileStreamResource.setFilename(fileName); tempFileStreamResource.setMIMEType(mimeType); // is this really necessary? tempFileStreamResource.getStream().setParameter("Content-Disposition", "attachment; filename=" + fileName + "\""); // Opens the resource for download Page.getCurrent().open(tempFileStreamResource, "", true); } else if (getItems().size() == 1) { // single item run final ExportCommand exportCommand = (ExportCommand) getCommand(); tempFileStreamResource.setFilename(exportCommand.getFileName()); tempFileStreamResource.setMIMEType(exportCommand.getMimeExtension()); // Opens the resource for download Page.getCurrent().open(tempFileStreamResource, "", true); } }
From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.ArticleEditorSubAppViewImpl.java
License:Open Source License
public ArticleEditorSubAppViewImpl() { layout.addStyleName("article-editor"); layout.setWidth("100%"); // calculate height dynamically using browser window height. Not doing so will display a gray block at the bottom of the app. layout.setHeight(Page.getCurrent().getBrowserWindowHeight(), Unit.PIXELS); layout.setMargin(true);//from www . j a va 2 s.co m layout.setSpacing(true); }
From source file:com.ocs.dynamo.ui.utils.VaadinUtils.java
License:Apache License
/** * Enables copy/paste behavior for Internet Explorer *//* w ww . j ava 2s . co m*/ public static void enableCopyPaste() { String js = "$(document).ready(function() {" + " $('input').off('paste'); " + " $('input').on('paste', function(e) { " + " if (clipboardData) { " + " setTimeout(function() {" + " var pasted = clipboardData.getData('text');" + " pasted = pasted.replace(/(\\r\\n|\\r|\\n)/g,'\t');" + " clipboardData.setData('text', pasted); $(e.target).val(pasted);} " + " , 100); " + " }" + " }) " + "});"; Page.getCurrent().getJavaScript().execute(js); }
From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java
License:Open Source License
/** * Get page location and navigate to//from w ww . j av a2 s .c o m */ private void navigateToPageLocation() { String f = Page.getCurrent().getUriFragment(); if (f != null && f.startsWith("!")) { f = f.substring(1); } if (f == null) { viewNavigator.navigateTo("/"); } else { viewNavigator.navigateTo(f); } }
From source file:com.peergreen.webconsole.scope.system.internal.bundle.BundleTab.java
License:Open Source License
private void init() { setMargin(true);/*from w w w .j a v a 2s .co m*/ setSpacing(true); // ---------------------------------------------------- // Title // ---------------------------------------------------- HorizontalLayout header = new HorizontalLayout(); header.setSpacing(true); header.setMargin(true); Label title = new Label(format("Bundle %d: %s (%s)", bundle.getBundleId(), getHeader(bundle, Constants.BUNDLE_NAME), bundle.getVersion())); title.addStyleName("h1"); header.addComponent(title); header.setComponentAlignment(title, Alignment.MIDDLE_LEFT); addComponent(header); // ---------------------------------------------------- // Action(s) Bar // ---------------------------------------------------- HorizontalLayout actions = new HorizontalLayout(); 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(getClass(), "/images/32x32/go-next.png")); actions.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"); changeState.setIcon(new ClassResource(getClass(), "/images/32x32/media-record.png")); actions.addComponent(changeState); } // Update Button update = new Button(); update.addClickListener(new UpdateBundleClickListener(bundle, notifierService)); //update.addStyleName("no-padding"); update.setCaption("Update"); update.setIcon(new ClassResource(getClass(), "/images/32x32/view-refresh.png")); actions.addComponent(update); // Trash Button trash = new Button(); trash.addClickListener(new UninstallBundleClickListener(bundle, notifierService)); //trash.addStyleName("no-padding"); trash.setCaption("Remove"); trash.setIcon(new ClassResource(getClass(), "/images/32x32/user-trash-full.png")); actions.addComponent(trash); addComponent(actions); setComponentAlignment(actions, Alignment.MIDDLE_RIGHT); // ---------------------------------------------------- // Standard Section // ---------------------------------------------------- Table table = new Table(); table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN); table.setWidth("100%"); Section mainSection = new Section("Standard", table); addComponent(mainSection); table.addContainerProperty("label", Label.class, null); table.addContainerProperty("value", Label.class, null); table.addItem(new Object[] { label("Bundle ID"), label(String.valueOf(bundle.getBundleId())) }, "bundle.id"); for (Map.Entry<String, String> entry : HEADERS.entrySet()) { String value = getHeader(bundle, entry.getKey()); if (value != null) { table.addItem(new Object[] { label(entry.getValue()), label(value) }, entry.getKey()); } } table.addItem(new Object[] { label("Location"), label(bundle.getLocation()) }, "bundle.location"); Date date = new Date(bundle.getLastModified()); table.addItem(new Object[] { label("Last Modified"), label(date.toString()) }, "last.modified"); // ---------------------------------------------------- // Packages Section // ---------------------------------------------------- FilteredPackageTable exported = new FilteredPackageTable("Exported"); FilteredPackageTable imported = new FilteredPackageTable("Imported"); GridLayout packages = new GridLayout(2, 1); packages.addComponent(exported); packages.addComponent(imported); packages.setSpacing(true); packages.setWidth("100%"); Section packagesSection = new Section("Packages", packages); addComponent(packagesSection); BundleWiring wiring = bundle.adapt(BundleWiring.class); if (wiring != null) { for (BundleCapability capability : wiring.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE)) { String name = (String) capability.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE); Version version = (Version) capability.getAttributes() .get(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE); exported.addPackage(format("%s (%s)", name, version)); } for (BundleRequirement requirement : wiring.getRequirements(PackageNamespace.PACKAGE_NAMESPACE)) { String filter = requirement.getDirectives().get(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE); imported.addPackage(filter); } } // ---------------------------------------------------- // Services Section // ---------------------------------------------------- FilteredServiceTable registered = new FilteredServiceTable("Registered"); FilteredServiceTable used = new FilteredServiceTable("Used Services"); VerticalLayout services = new VerticalLayout(registered, used); services.setSpacing(true); services.setWidth("100%"); ServiceReference<?>[] registeredServices = bundle.getRegisteredServices(); if (registeredServices != null) { for (ServiceReference<?> reference : registeredServices) { registered.addService(reference); } } ServiceReference<?>[] inUseServices = bundle.getServicesInUse(); if (inUseServices != null) { for (ServiceReference<?> reference : inUseServices) { used.addService(reference); } } if (!registered.isEmpty() || !used.isEmpty()) { Section servicesSection = new Section("Services", services); addComponent(servicesSection); } // ---------------------------------------------------- // Raw Manifest Section // ---------------------------------------------------- Page.Styles styles = Page.getCurrent().getStyles(); styles.add(".monospaced-font {font-family: monospace !important; }"); Table manifest = new Table(); manifest.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN); manifest.setWidth("100%"); manifest.addStyleName("monospaced-font"); manifest.setPageLength(15); manifest.addContainerProperty("name", String.class, null); manifest.addContainerProperty("value", String.class, null); Dictionary<String, String> headers = bundle.getHeaders(); for (String key : Collections.list(headers.keys())) { manifest.addItem(new Object[] { key, headers.get(key) }, null); } Section manifestSection = new Section("Manifest", manifest); addComponent(manifestSection); }
From source file:com.piccritic.website.Home.java
/** * Sets up menu based on auth// ww w. ja v a2 s . co m */ private void setupMenu() { Button home = new Button("Home", e -> { navigator.navigateTo(DefaultView.NAME); }); menu.addComponent(home); LoginStatus loginStatus = getLoginStatus(); if (loginStatus == LoginStatus.LOGGED_IN) { Button logout = new Button("Log out"); logout.addClickListener(e -> { logoutUser(); Page.getCurrent().reload(); }); menu.addComponent(logout); Button button = new Button("Create Post"); button.addClickListener(e -> { Window createPost = new CreatePost(getHandle()); UI.getCurrent().addWindow(createPost); }); menu.addComponent(button); } else { Button loginUser = new Button("Login"); loginUser.addClickListener(e -> { Window login = new LoginWindow(); addWindow(login); }); menu.addComponent(loginUser); } Button createUser = new Button(((loginStatus == LoginStatus.LOGGED_IN) ? "Update" : "Create") + "User"); createUser.addClickListener(e -> { Window userForm = new Window(); userForm.setModal(true); userForm.setContent(new VerticalLayout(new UserForm(getHandle()))); addWindow(userForm); }); menu.addComponent(createUser); menu.setMargin(true); menu.setSpacing(true); }