List of usage examples for com.vaadin.ui HorizontalLayout setSizeFull
@Override public void setSizeFull()
From source file:org.ikasan.dashboard.ui.topology.window.ExclusionEventViewWindow.java
License:BSD License
protected Panel createExclusionEventDetailsPanel() { Panel exclusionEventDetailsPanel = new Panel(); exclusionEventDetailsPanel.setSizeFull(); exclusionEventDetailsPanel.setStyleName("dashboard"); GridLayout layout = new GridLayout(4, 7); layout.setSpacing(true);//from w w w. j ava 2s. c o m layout.setColumnExpandRatio(0, .10f); layout.setColumnExpandRatio(1, .30f); layout.setColumnExpandRatio(2, .05f); layout.setColumnExpandRatio(3, .30f); layout.setWidth("100%"); Label exclusionEvenDetailsLabel = new Label("Exclusion Event Details"); exclusionEvenDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE); layout.addComponent(exclusionEvenDetailsLabel, 0, 0, 3, 0); Label label = new Label("Module Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 1); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf1 = new TextField(); tf1.setValue(this.exclusionEvent.getModuleName()); tf1.setReadOnly(true); tf1.setWidth("80%"); layout.addComponent(tf1, 1, 1); label = new Label("Flow Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 2); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf2 = new TextField(); tf2.setValue(this.exclusionEvent.getFlowName()); tf2.setReadOnly(true); tf2.setWidth("80%"); layout.addComponent(tf2, 1, 2); label = new Label("Event Id:"); label.setSizeUndefined(); layout.addComponent(label, 0, 3); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf3 = new TextField(); tf3.setValue(this.errorOccurrence.getEventLifeIdentifier()); tf3.setReadOnly(true); tf3.setWidth("80%"); layout.addComponent(tf3, 1, 3); label = new Label("Date/Time:"); label.setSizeUndefined(); layout.addComponent(label, 0, 4); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf4 = new TextField(); tf4.setValue(new Date(this.exclusionEvent.getTimestamp()).toString()); tf4.setReadOnly(true); tf4.setWidth("80%"); layout.addComponent(tf4, 1, 4); label = new Label("Error URI:"); label.setSizeUndefined(); layout.addComponent(label, 0, 5); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf5 = new TextField(); tf5.setValue(exclusionEvent.getErrorUri()); tf5.setReadOnly(true); tf5.setWidth("80%"); layout.addComponent(tf5, 1, 5); label = new Label("Action:"); label.setSizeUndefined(); layout.addComponent(label, 2, 1); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); final TextField tf6 = new TextField(); if (this.action != null) { tf6.setValue(action.getAction()); } tf6.setReadOnly(true); tf6.setWidth("80%"); layout.addComponent(tf6, 3, 1); label = new Label("Actioned By:"); label.setSizeUndefined(); layout.addComponent(label, 2, 2); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); final TextField tf7 = new TextField(); if (this.action != null) { tf7.setValue(action.getActionedBy()); } tf7.setReadOnly(true); tf7.setWidth("80%"); layout.addComponent(tf7, 3, 2); label = new Label("Actioned Time:"); label.setSizeUndefined(); layout.addComponent(label, 2, 3); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); final TextField tf8 = new TextField(); if (this.action != null) { tf8.setValue(new Date(action.getTimestamp()).toString()); } tf8.setReadOnly(true); tf8.setWidth("80%"); layout.addComponent(tf8, 3, 3); final Button resubmitButton = new Button("Re-submit"); final Button ignoreButton = new Button("Ignore"); resubmitButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(authentication.getName(), (String) authentication.getCredentials()); ClientConfig clientConfig = new ClientConfig(); clientConfig.register(feature); Client client = ClientBuilder.newClient(clientConfig); Module module = topologyService.getModuleByName(exclusionEvent.getModuleName()); if (module == null) { Notification .show("Unable to find server information for module we are attempting to re-submit to: " + exclusionEvent.getModuleName(), Type.ERROR_MESSAGE); return; } Server server = module.getServer(); String url = "http://" + server.getUrl() + ":" + server.getPort() + module.getContextRoot() + "/rest/resubmission/resubmit/" + exclusionEvent.getModuleName() + "/" + exclusionEvent.getFlowName() + "/" + exclusionEvent.getErrorUri(); logger.info("Resubmission Url: " + url); WebTarget webTarget = client.target(url); Response response = webTarget.request() .put(Entity.entity(exclusionEvent.getEvent(), MediaType.APPLICATION_OCTET_STREAM)); if (response.getStatus() != 200) { response.bufferEntity(); String responseMessage = response.readEntity(String.class); Notification.show("An error was received trying to resubmit event: " + responseMessage, Type.ERROR_MESSAGE); } else { Notification.show("Event resumitted successfully."); resubmitButton.setVisible(false); ignoreButton.setVisible(false); ExclusionEventAction action = hospitalManagementService .getExclusionEventActionByErrorUri(exclusionEvent.getErrorUri()); tf6.setReadOnly(false); tf7.setReadOnly(false); tf8.setReadOnly(false); tf6.setValue(action.getAction()); tf7.setValue(action.getActionedBy()); tf8.setValue(new Date(action.getTimestamp()).toString()); tf6.setReadOnly(true); tf7.setReadOnly(true); tf8.setReadOnly(true); } } }); ignoreButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(authentication.getName(), (String) authentication.getCredentials()); ClientConfig clientConfig = new ClientConfig(); clientConfig.register(feature); Client client = ClientBuilder.newClient(clientConfig); Module module = topologyService.getModuleByName(exclusionEvent.getModuleName()); if (module == null) { Notification .show("Unable to find server information for module we are submitting the ignore to: " + exclusionEvent.getModuleName(), Type.ERROR_MESSAGE); return; } Server server = module.getServer(); String url = "http://" + server.getUrl() + ":" + server.getPort() + module.getContextRoot() + "/rest/resubmission/ignore/" + exclusionEvent.getModuleName() + "/" + exclusionEvent.getFlowName() + "/" + exclusionEvent.getErrorUri(); logger.info("Ignore Url: " + url); WebTarget webTarget = client.target(url); Response response = webTarget.request() .put(Entity.entity(exclusionEvent.getEvent(), MediaType.APPLICATION_OCTET_STREAM)); if (response.getStatus() != 200) { response.bufferEntity(); String responseMessage = response.readEntity(String.class); Notification.show("An error was received trying to resubmit event: " + responseMessage, Type.ERROR_MESSAGE); } else { Notification.show("Event ignored successfully."); resubmitButton.setVisible(false); ignoreButton.setVisible(false); ExclusionEventAction action = hospitalManagementService .getExclusionEventActionByErrorUri(exclusionEvent.getErrorUri()); tf6.setReadOnly(false); tf7.setReadOnly(false); tf8.setReadOnly(false); tf6.setValue(action.getAction()); tf7.setValue(action.getActionedBy()); tf8.setValue(new Date(action.getTimestamp()).toString()); tf6.setReadOnly(true); tf7.setReadOnly(true); tf8.setReadOnly(true); } } }); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setHeight("100%"); buttonLayout.setSpacing(true); buttonLayout.setWidth(200, Unit.PIXELS); buttonLayout.setMargin(true); buttonLayout.addComponent(resubmitButton); buttonLayout.addComponent(ignoreButton); if (this.action == null) { layout.addComponent(buttonLayout, 0, 6, 3, 6); layout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER); } final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) && !authentication.hasGrantedAuthority(SecurityConstants.ACTION_EXCLUSIONS_AUTHORITY))) { resubmitButton.setVisible(false); ignoreButton.setVisible(false); } AceEditor eventEditor = new AceEditor(); eventEditor.setCaption("Event Payload"); logger.info("Setting exclusion event to: " + new String(this.exclusionEvent.getEvent())); Object event = this.serialiserFactory.getDefaultSerialiser().deserialise(this.exclusionEvent.getEvent()); eventEditor.setValue(event.toString()); eventEditor.setReadOnly(true); eventEditor.setMode(AceMode.java); eventEditor.setTheme(AceTheme.eclipse); eventEditor.setWidth("100%"); eventEditor.setHeight(600, Unit.PIXELS); HorizontalLayout eventEditorLayout = new HorizontalLayout(); eventEditorLayout.setSizeFull(); eventEditorLayout.setMargin(true); eventEditorLayout.addComponent(eventEditor); AceEditor errorEditor = new AceEditor(); errorEditor.setCaption("Error Details"); errorEditor.setValue(this.errorOccurrence.getErrorDetail()); errorEditor.setReadOnly(true); errorEditor.setMode(AceMode.xml); errorEditor.setTheme(AceTheme.eclipse); errorEditor.setWidth("100%"); errorEditor.setHeight(600, Unit.PIXELS); HorizontalLayout errorEditorLayout = new HorizontalLayout(); errorEditorLayout.setSizeFull(); errorEditorLayout.setMargin(true); errorEditorLayout.addComponent(errorEditor); VerticalSplitPanel splitPanel = new VerticalSplitPanel(); splitPanel.addStyleName(ValoTheme.SPLITPANEL_LARGE); splitPanel.setWidth("100%"); splitPanel.setHeight(800, Unit.PIXELS); HorizontalLayout h1 = new HorizontalLayout(); h1.setSizeFull(); h1.setMargin(true); h1.addComponent(eventEditorLayout); splitPanel.setFirstComponent(eventEditorLayout); HorizontalLayout h2 = new HorizontalLayout(); h2.setSizeFull(); h2.setMargin(true); h2.addComponent(errorEditorLayout); splitPanel.setSecondComponent(errorEditorLayout); HorizontalLayout formLayout = new HorizontalLayout(); formLayout.setWidth("100%"); formLayout.setHeight(240, Unit.PIXELS); formLayout.addComponent(layout); GridLayout wrapperLayout = new GridLayout(1, 4); wrapperLayout.setMargin(true); wrapperLayout.setWidth("100%"); wrapperLayout.addComponent(formLayout); wrapperLayout.addComponent(splitPanel); exclusionEventDetailsPanel.setContent(wrapperLayout); return exclusionEventDetailsPanel; }
From source file:org.investovator.ui.main.AdminGameConfigLayout.java
License:Open Source License
private void init() { //final GameModes gameMode= GameControllerFacade.getInstance().getCurrentGameMode(); //final GameStates gameState=GameControllerFacade.getInstance().getCurrentGameState(); Button agentGames = new Button("Agent Gaming Engine", new Button.ClickListener() { @Override/*from w ww.java2 s . c o m*/ public void buttonClick(Button.ClickEvent event) { if (authenticator.isLoggedIn()) { startAgentCreateWizard(); } else { getUI().getNavigator().navigateTo(UIConstants.LOGIN_VIEW); } } }); Button dataPlayback = new Button("Data Playback Engine", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { startDailySummaryAddGameWizard(); /*//if there is no game running if(gameState==GameStates.NEW){ startDailySummaryAddGameWizard(); } //if there is a game running else if(gameState==GameStates.RUNNING && gameMode==GameModes.PAYBACK_ENG){ if(DataPlaybackEngineStates.gameConfig.getPlayerType()== PlayerTypes.REAL_TIME_DATA_PLAYER){ try { //if the game is multi player //todo - modify to data player parentnew (no need to even check the follwoing if conditions it seems) if(DataPlayerFacade.getInstance().getRealTimeDataPlayer().isMultiplayer()){ getUI().getNavigator().navigateTo(UIConstants.DATA_PLAYBACK_ADMIN_DASH); } else{ //loads single player real time data playback view getUI().getNavigator().navigateTo(UIConstants.DATAPLAY_USR_DASH); } } catch (PlayerStateException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } else if(DataPlaybackEngineStates.gameConfig.getPlayerType()==PlayerTypes.DAILY_SUMMARY_PLAYER){ // try { //if this is a multiplayer game // if (DataPlayerFacade.getInstance().getCurrentPlayer().isMultiplayer()){ if (DataPlaybackEngineStates.isMultiplayer){ getUI().getNavigator().navigateTo(UIConstants.DATA_PLAYBACK_ADMIN_DASH); } else{ //loads single player daily summary data playback view getUI().getNavigator().navigateTo(UIConstants.DATAPLAY_USR_DASH); } // } catch (PlayerStateException e) { // e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. // } } }*/ } }); Button nnGames = new Button("NN Gaming Engine", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (authenticator.isLoggedIn()) { startNNCreateWizard(); } else { getUI().getNavigator().navigateTo(UIConstants.LOGIN_VIEW); } } }); Label agentGamesLabel = new Label("Agent based game"); Label agentGamesStatusLabel = new Label("Not Running"); Label dataPlaybackGamesStatusLabel = new Label("Not Running"); Label annGamesStatusLabel = new Label("Not Running"); /*if(gameMode==GameModes.AGENT_GAME && gameState==GameStates.RUNNING){ agentGamesStatusLabel.setValue("<b> <p style=\"color:red\">Running<b>"); agentGamesStatusLabel.setContentMode(ContentMode.HTML); dataPlaybackGamesStatusLabel.setValue("Not Running"); annGamesStatusLabel.setValue("Not Running"); }*/ Label dataPlaybackGamesLabel = new Label("Data Playback based game"); /*if(gameMode==GameModes.PAYBACK_ENG && gameState==GameStates.RUNNING){ dataPlaybackGamesStatusLabel.setValue("<b> <p style=\"color:red\">Running<b>"); dataPlaybackGamesStatusLabel.setContentMode(ContentMode.HTML); annGamesStatusLabel.setValue("Not Running"); agentGamesStatusLabel.setValue("Not Running"); }*/ Label annGamesLabel = new Label("ANN based game"); /* if(gameMode==GameModes.NN_GAME && gameState==GameStates.RUNNING){ annGamesStatusLabel.setValue("<b> <p style=\"color:red\">Running<b>"); annGamesStatusLabel.setContentMode(ContentMode.HTML); dataPlaybackGamesStatusLabel.setValue("Not Running"); agentGamesStatusLabel.setValue("Not Running"); }*/ //add a stop button for DPE Button stopDpeButton = new Button("Stop DPE", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { /* if(gameState==GameStates.RUNNING && gameMode==GameModes.PAYBACK_ENG){ if(DataPlaybackEngineStates.gameConfig.getPlayerType()== PlayerTypes.REAL_TIME_DATA_PLAYER){ try { DataPlaybackGameFacade.getDataPlayerFacade().getRealTimeDataPlayer().stopGame(); GameControllerFacade.getInstance().stopGame(GameModes.PAYBACK_ENG); } catch (PlayerStateException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } else if(DataPlaybackEngineStates.gameConfig.getPlayerType()==PlayerTypes.DAILY_SUMMARY_PLAYER){ try { DataPlaybackGameFacade.getDataPlayerFacade().getDailySummaryDataPLayer().stopGame(); GameControllerFacade.getInstance().stopGame(GameModes.PAYBACK_ENG); } catch (PlayerStateException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } }*/ } }); HorizontalLayout agentLayout = new HorizontalLayout(agentGamesLabel, agentGames, agentGamesStatusLabel); agentLayout.setSizeFull(); HorizontalLayout dataPlaybackLayout; //if(GameControllerFacade.getInstance().getCurrentGameState()==GameStates.RUNNING){ // dataPlaybackLayout=new HorizontalLayout(dataPlaybackGamesLabel, // dataPlayback,stopDpeButton,dataPlaybackGamesStatusLabel); //} //else{ dataPlaybackLayout = new HorizontalLayout(dataPlaybackGamesLabel, dataPlayback, dataPlaybackGamesStatusLabel); // } dataPlaybackLayout.setSizeFull(); HorizontalLayout annLayout = new HorizontalLayout(annGamesLabel, nnGames, annGamesStatusLabel); annLayout.setSizeFull(); this.addComponent(agentLayout); this.addComponent(dataPlaybackLayout); this.addComponent(annLayout); }
From source file:org.jdal.vaadin.ui.form.FormDialog.java
License:Apache License
public void init() { setContent(form);/* w ww . j ava 2s. c om*/ getContent().setSizeUndefined(); center(); acceptButtonListener = new AcceptButtonListener(); cancelButtonListener = new CancelButtonListener(); HorizontalLayout buttonLayout = new HorizontalLayout(); Button acceptButton = FormUtils.newButton(acceptButtonListener); Button cancelButton = FormUtils.newButton(cancelButtonListener); buttonLayout.setSpacing(true); buttonLayout.addComponent(acceptButton); buttonLayout.addComponent(cancelButton); HorizontalLayout footer = new HorizontalLayout(); footer.addComponent(buttonLayout); footer.setSizeFull(); footer.setComponentAlignment(buttonLayout, Alignment.TOP_CENTER); form.setFooter(footer); form.setSizeFull(); form.getLayout().setSizeFull(); }
From source file:org.jdal.vaadin.ui.FormUtils.java
License:Apache License
/** * Show a YES/NO confirm dialog//w w w.j av a 2 s . c o m * @param window Window to attach the dialog * @param msg the msg */ public static void showConfirmDialog(UI ui, final Command command, String msg) { final Window dlg = new Window("Please Confirm"); VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); vl.setSpacing(true); vl.setMargin(true); Label label = new Label(msg, Label.CONTENT_XHTML); vl.addComponent(label); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); Button ok = new Button(StaticMessageSource.getMessage("yes")); ok.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { command.execute(null); closeWindow(dlg); } }); Button cancel = new Button(StaticMessageSource.getMessage("no")); cancel.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { closeWindow(dlg); } }); hl.setSpacing(true); hl.addComponent(ok); hl.addComponent(cancel); hl.setSizeFull(); vl.addComponent(hl); vl.setComponentAlignment(hl, Alignment.TOP_CENTER); dlg.setContent(vl); dlg.setModal(true); vl.setSizeUndefined(); ui.addWindow(dlg); }
From source file:org.jpos.qi.minigl.AccountsView.java
License:Open Source License
private Panel createEntriesPanel() { Panel entriesPanel = new Panel(getCaptionFromId("entries")); entriesPanel.setIcon(VaadinIcons.EXCHANGE); entriesPanel.addStyleName("color1"); entriesPanel.addStyleName("margin-top-panel"); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);/*from w ww.j a v a 2s. c o m*/ layout.setSpacing(true); Panel filterPanel = new Panel(); filterPanel.addStyleName("v-panel-well"); journals = new JournalsCombo(true); rangeLabelTitle = new Label(); rangeLabelTitle.addStyleName(ValoTheme.LABEL_BOLD); dateRangeComponent = new DateRangeComponent(DateRange.ALL_TIME, true) { @Override protected Button.ClickListener createRefreshListener() { return event -> { refreshDetails(); }; } }; VerticalLayout detailsLayout = new VerticalLayout(); entryGrid = new EntryGrid(null, false); formatEntriesGrid(); detailsLayout.addComponent(entryGrid); detailsLayout.setMargin(false); HorizontalLayout layersLayout = new HorizontalLayout(); layersLayout.setSizeFull(); layersLayout.setSpacing(true); layersCheckBox = new CheckBoxGroup<>(getCaptionFromId("layers").toUpperCase()); layersCheckBox.setItemCaptionGenerator(item -> item.getId() + " - " + item.getName()); layersCheckBox.addValueChangeListener(listener -> refreshDetails()); layersLayout.addComponentsAndExpand(layersCheckBox); VerticalLayout vbar = new VerticalLayout(journals, dateRangeComponent, layersLayout); vbar.setSpacing(true); vbar.setMargin(true); filterPanel.setContent(vbar); layout.addComponents(rangeLabelTitle, detailsLayout, filterPanel); entriesPanel.setContent(layout); refreshDetails(); return entriesPanel; }
From source file:org.jpos.qi.QILayout.java
License:Open Source License
public QILayout() { setSizeFull();//from w w w . ja va2s.c om setMargin(false); setSpacing(false); headerLayout.setWidth("100%"); headerLayout.setPrimaryStyleName("header"); HorizontalLayout center = new HorizontalLayout(); center.setSizeFull(); center.setSpacing(false); menuLayout.setPrimaryStyleName("valo-menu"); contentLayout.setPrimaryStyleName("valo-content"); contentLayout.addStyleName("v-scrollable"); contentLayout.setSizeFull(); center.addComponents(menuLayout, contentLayout); center.setExpandRatio(contentLayout, 1); addComponents(headerLayout, center); setExpandRatio(center, 1); }
From source file:org.jumpmind.vaadin.ui.common.NotifyDialog.java
License:Open Source License
public NotifyDialog(String caption, String text, final Throwable ex, Type type) { super(caption); setWidth(400, Unit.PIXELS);// w w w. j a va 2s. c om setHeight(300, Unit.PIXELS); final HorizontalLayout messageArea = new HorizontalLayout(); messageArea.addStyleName("v-scrollable"); messageArea.setMargin(true); messageArea.setSpacing(true); messageArea.setSizeFull(); text = isNotBlank(text) ? text : (ex != null ? ex.getMessage() : ""); if (type == Type.ERROR_MESSAGE) { setIcon(FontAwesome.BAN); } final String message = text; final Label textLabel = new Label(message, ContentMode.HTML); messageArea.addComponent(textLabel); messageArea.setExpandRatio(textLabel, 1); content.addComponent(messageArea); content.setExpandRatio(messageArea, 1); final Button detailsButton = new Button("Details"); detailsButton.setVisible(ex != null); detailsButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { detailsMode = !detailsMode; if (detailsMode) { String msg = "<pre>" + ExceptionUtils.getStackTrace(ex).trim() + "</pre>"; msg = msg.replace("\t", " "); textLabel.setValue(msg); detailsButton.setCaption("Message"); messageArea.setMargin(new MarginInfo(false, false, false, true)); setHeight(600, Unit.PIXELS); setWidth(1000, Unit.PIXELS); setPosition(getPositionX() - 300, getPositionY() - 150); } else { textLabel.setValue(message); detailsButton.setCaption("Details"); messageArea.setMargin(true); setWidth(400, Unit.PIXELS); setHeight(300, Unit.PIXELS); setPosition(getPositionX() + 300, getPositionY() + 150); } } }); content.addComponent(buildButtonFooter(detailsButton, buildCloseButton())); }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.QueryPanel.java
License:Open Source License
protected boolean execute(final boolean runAsScript, String sqlText, final int tabPosition, final boolean forceNewTab) { boolean scheduled = false; if (runnersInProgress == null) { runnersInProgress = new HashSet<SqlRunner>(); }// w w w. j av a 2 s .c o m if (sqlText == null) { if (!runAsScript) { sqlText = selectSqlToRun(); } else { sqlText = sqlArea.getValue(); } sqlText = sqlText != null ? sqlText.trim() : null; } if (StringUtils.isNotBlank(sqlText)) { final HorizontalLayout executingLayout = new HorizontalLayout(); executingLayout.setMargin(true); executingLayout.setSizeFull(); final Label label = new Label("Executing:\n\n" + StringUtils.abbreviate(sqlText, 250), ContentMode.PREFORMATTED); label.setEnabled(false); executingLayout.addComponent(label); executingLayout.setComponentAlignment(label, Alignment.TOP_LEFT); final String sql = sqlText; final Tab executingTab; if (!forceNewTab && generalResultsTab != null) { replaceGeneralResultsWith(executingLayout, FontAwesome.SPINNER); executingTab = null; } else { executingTab = resultsTabs.addTab(executingLayout, StringUtils.abbreviate(sql, 20), FontAwesome.SPINNER, tabPosition); } if (executingTab != null) { executingTab.setClosable(true); resultsTabs.setSelectedTab(executingTab); } final SqlRunner runner = new SqlRunner(sql, runAsScript, user, db, settingsProvider.get(), this, generalResultsTab != null); runnersInProgress.add(runner); runner.setConnection(connection); runner.setListener(new SqlRunner.ISqlRunnerListener() { private static final long serialVersionUID = 1L; @Override public void writeSql(String sql) { QueryPanel.this.appendSql(sql); } @Override public void reExecute(String sql) { QueryPanel.this.reExecute(sql); } public void finished(final FontAwesome icon, final List<Component> results, final long executionTimeInMs, final boolean transactionStarted, final boolean transactionEnded) { VaadinSession.getCurrent().access(new Runnable() { @Override public void run() { try { if (transactionEnded) { transactionEnded(); } else if (transactionStarted) { rollbackButtonValue = true; commitButtonValue = true; setButtonsEnabled(); sqlArea.setStyleName("transaction-in-progress"); connection = runner.getConnection(); } addToSqlHistory(StringUtils.abbreviate(sql, 1024 * 8), runner.getStartTime(), executionTimeInMs, user); for (Component resultComponent : results) { resultComponent.setSizeFull(); if (forceNewTab || generalResultsTab == null || results.size() > 1) { if (resultComponent instanceof TabularResultLayout) { resultComponent = ((TabularResultLayout) resultComponent) .refreshWithoutSaveButton(); } addResultsTab(resultComponent, StringUtils.abbreviate(sql, 20), icon, tabPosition); } else { replaceGeneralResultsWith(resultComponent, icon); resultsTabs.setSelectedTab(generalResultsTab.getComponent()); } String statusVal; if (canceled) { statusVal = "Sql canceled after " + executionTimeInMs + " ms for " + db.getName() + ". Finished at " + SimpleDateFormat.getTimeInstance().format(new Date()); } else { statusVal = "Sql executed in " + executionTimeInMs + " ms for " + db.getName() + ". Finished at " + SimpleDateFormat.getTimeInstance().format(new Date()); } status.setValue(statusVal); resultStatuses.put(resultComponent, statusVal); canceled = false; } } finally { setButtonsEnabled(); if (executingTab != null) { resultsTabs.removeTab(executingTab); } else if (results.size() > 1) { resetGeneralResultsTab(); } runnersInProgress.remove(runner); runner.setListener(null); } } }); } }); final Button cancel = new Button("Cancel"); cancel.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { log.info("Canceling sql: " + sql); label.setValue("Canceling" + label.getValue().substring(9)); executingLayout.removeComponent(cancel); canceled = true; new Thread(new Runnable() { @Override public void run() { runner.cancel(); } }).start(); } }); executingLayout.addComponent(cancel); scheduled = true; runner.start(); } setButtonsEnabled(); return scheduled; }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.TableInfoPanel.java
License:Open Source License
protected void refreshData(final org.jumpmind.db.model.Table table, final String user, final IDb db, final Settings settings, boolean isInit) { if (!isInit) { tabSheet.removeTab(tabSheet.getTab(1)); }/*w w w . ja v a2 s .co m*/ IDatabasePlatform platform = db.getPlatform(); DmlStatement dml = platform.createDmlStatement(DmlType.SELECT_ALL, table, null); final HorizontalLayout executingLayout = new HorizontalLayout(); executingLayout.setSizeFull(); final ProgressBar p = new ProgressBar(); p.setIndeterminate(true); final int oldPollInterval = UI.getCurrent().getPollInterval(); UI.getCurrent().setPollInterval(100); executingLayout.addComponent(p); executingLayout.setData(isInit); tabSheet.addTab(executingLayout, "Data", isInit ? null : FontAwesome.SPINNER, 1); if (!isInit) { tabSheet.setSelectedTab(executingLayout); } SqlRunner runner = new SqlRunner(dml.getSql(), false, user, db, settings, explorer, new ISqlRunnerListener() { private static final long serialVersionUID = 1L; @Override public void writeSql(String sql) { explorer.openQueryWindow(db).appendSql(sql); } @Override public void reExecute(String sql) { refreshData(table, user, db, settings, false); } @Override public void finished(final FontAwesome icon, final List<Component> results, long executionTimeInMs, boolean transactionStarted, boolean transactionEnded) { VaadinSession.getCurrent().access(new Runnable() { @Override public void run() { tabSheet.removeComponent(executingLayout); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSizeFull(); if (results.size() > 0) { layout.addComponent(results.get(0)); } tabSheet.addTab(layout, "Data", null, 1); UI.getCurrent().setPollInterval(oldPollInterval); tabSheet.setSelectedTab(layout); } }); } }); runner.setShowSqlOnResults(false); runner.setLogAtDebug(true); if (!isInit) { runner.start(); } }
From source file:org.lunifera.example.vaadin.osgi.bootstrap.ds.SimpleDSUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { HorizontalLayout layout = new HorizontalLayout(); setContent(layout);//from w w w . j av a2 s . co m layout.setStyleName(Reindeer.LAYOUT_BLUE); layout.setSizeFull(); Label label = new Label(); label.setValue("<h1>Vaadin wired to Servlet by OSGi-DS component</h1>"); label.setContentMode(ContentMode.HTML); layout.addComponent(label); layout.setComponentAlignment(label, Alignment.TOP_CENTER); }