List of usage examples for com.vaadin.ui Label setValue
public void setValue(String value)
From source file:org.ikasan.dashboard.ui.topology.window.StartupControlConfigurationWindow.java
License:BSD License
/** * Helper method to initialise this object. * /* w ww . j a v a 2s .c o m*/ * @param message */ protected void init() { setModal(true); setResizable(false); setHeight("320px"); setWidth("550px"); GridLayout gridLayout = new GridLayout(2, 6); gridLayout.setWidth("500px"); gridLayout.setColumnExpandRatio(0, .15f); gridLayout.setColumnExpandRatio(1, .85f); gridLayout.setSpacing(true); gridLayout.setMargin(true); Label startupControlLabel = new Label("Startup Control"); startupControlLabel.addStyleName(ValoTheme.LABEL_HUGE); gridLayout.addComponent(startupControlLabel, 0, 0, 1, 0); Label moduleNameLabel = new Label(); moduleNameLabel.setContentMode(ContentMode.HTML); moduleNameLabel.setValue(VaadinIcons.ARCHIVE.getHtml() + " Module Name:"); moduleNameLabel.setSizeUndefined(); gridLayout.addComponent(moduleNameLabel, 0, 1); gridLayout.setComponentAlignment(moduleNameLabel, Alignment.MIDDLE_RIGHT); startupControl = this.startupControlService.getStartupControl(flow.getModule().getName(), flow.getName()); startupControlItem = new BeanItem<StartupControl>(startupControl); moduleNameTextField = new TextField(); moduleNameTextField.setRequired(true); moduleNameTextField.setPropertyDataSource(startupControlItem.getItemProperty("moduleName")); moduleNameTextField.setReadOnly(true); moduleNameTextField.setWidth("90%"); gridLayout.addComponent(moduleNameTextField, 1, 1); Label flowNameLabel = new Label(); flowNameLabel.setContentMode(ContentMode.HTML); flowNameLabel.setValue(VaadinIcons.AUTOMATION.getHtml() + " Flow Name:"); flowNameLabel.setSizeUndefined(); gridLayout.addComponent(flowNameLabel, 0, 2); gridLayout.setComponentAlignment(flowNameLabel, Alignment.MIDDLE_RIGHT); flowNameTextField = new TextField(); flowNameTextField.setRequired(true); flowNameTextField.setPropertyDataSource(startupControlItem.getItemProperty("flowName")); flowNameTextField.setReadOnly(true); flowNameTextField.setWidth("90%"); gridLayout.addComponent(flowNameTextField, 1, 2); Label startupTypeLabel = new Label("Startup Type:"); startupTypeLabel.setSizeUndefined(); this.startupType = new ComboBox(); this.startupType.addItem(StartupType.MANUAL); this.startupType.setItemCaption(StartupType.MANUAL, "Manual"); this.startupType.addItem(StartupType.AUTOMATIC); this.startupType.setItemCaption(StartupType.AUTOMATIC, "Automatic"); this.startupType.addItem(StartupType.DISABLED); this.startupType.setItemCaption(StartupType.DISABLED, "Disabled"); this.startupType.setPropertyDataSource(startupControlItem.getItemProperty("startupType")); this.startupType.setNullSelectionAllowed(false); this.startupType.addValidator(new StringLengthValidator("A name must be entered.", 1, null, false)); this.startupType.setWidth("90%"); this.startupType.setValidationVisible(false); gridLayout.addComponent(startupTypeLabel, 0, 3); gridLayout.setComponentAlignment(startupTypeLabel, Alignment.MIDDLE_RIGHT); gridLayout.addComponent(this.startupType, 1, 3); Label commentLabel = new Label("Comment:"); commentLabel.setSizeUndefined(); this.comment = new TextArea(); this.comment.setRows(3); this.comment.addValidator(new StringLengthValidator("A name must be entered.", 1, null, false)); this.comment.setWidth("90%"); this.comment.setValidationVisible(false); this.comment.setNullRepresentation(""); this.comment.setPropertyDataSource(startupControlItem.getItemProperty("comment")); gridLayout.addComponent(commentLabel, 0, 4); gridLayout.setComponentAlignment(commentLabel, Alignment.MIDDLE_RIGHT); gridLayout.addComponent(this.comment, 1, 4); Button saveButton = new Button("Save"); Button cancelButton = new Button("Cancel"); GridLayout buttonLayout = new GridLayout(2, 1); buttonLayout.setSpacing(true); buttonLayout.addComponent(saveButton); buttonLayout.setComponentAlignment(saveButton, Alignment.MIDDLE_CENTER); buttonLayout.addComponent(cancelButton); buttonLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER); gridLayout.addComponent(buttonLayout, 0, 5, 1, 5); gridLayout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { StartupControl sc = startupControlItem.getBean(); if (((StartupType) startupType.getValue()) == StartupType.DISABLED && (comment.getValue() == null || comment.getValue().length() == 0)) { Notification.show("A comment must be entered for a 'Disabled' start up type!", Type.ERROR_MESSAGE); return; } else { final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService .getCurrentRequest().getWrappedSession() .getAttribute(DashboardSessionValueConstants.USER); StartupControlConfigurationWindow.this.startupControlService.setStartupType(sc.getModuleName(), sc.getFlowName(), (StartupType) startupType.getValue(), comment.getValue(), authentication.getName()); Notification.show("Saved!"); } } }); cancelButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { UI.getCurrent().removeWindow(StartupControlConfigurationWindow.this); } }); this.setContent(gridLayout); }
From source file:org.ikasan.dashboard.ui.topology.window.WiretapConfigurationWindow.java
License:BSD License
/** * Helper method to initialise this object. * // w w w .j a v a 2 s . c o m * @param message */ protected void init() { setModal(true); setHeight("90%"); setWidth("90%"); GridLayout layout = new GridLayout(2, 10); layout.setSizeFull(); layout.setSpacing(true); layout.setMargin(true); layout.setColumnExpandRatio(0, .25f); layout.setColumnExpandRatio(1, .75f); Label wiretapLabel = new Label("Wiretap Configuration"); wiretapLabel.setStyleName(ValoTheme.LABEL_HUGE); layout.addComponent(wiretapLabel); Label moduleNameLabel = new Label(); moduleNameLabel.setContentMode(ContentMode.HTML); moduleNameLabel.setValue(VaadinIcons.ARCHIVE.getHtml() + " Module Name:"); moduleNameLabel.setSizeUndefined(); layout.addComponent(moduleNameLabel, 0, 1); layout.setComponentAlignment(moduleNameLabel, Alignment.MIDDLE_RIGHT); TextField moduleNameTextField = new TextField(); moduleNameTextField.setRequired(true); moduleNameTextField.setValue(this.component.getFlow().getModule().getName()); moduleNameTextField.setReadOnly(true); moduleNameTextField.setWidth("80%"); layout.addComponent(moduleNameTextField, 1, 1); Label flowNameLabel = new Label(); flowNameLabel.setContentMode(ContentMode.HTML); flowNameLabel.setValue(VaadinIcons.AUTOMATION.getHtml() + " Flow Name:"); flowNameLabel.setSizeUndefined(); layout.addComponent(flowNameLabel, 0, 2); layout.setComponentAlignment(flowNameLabel, Alignment.MIDDLE_RIGHT); TextField flowNameTextField = new TextField(); flowNameTextField.setRequired(true); flowNameTextField.setValue(this.component.getFlow().getName()); flowNameTextField.setReadOnly(true); flowNameTextField.setWidth("80%"); layout.addComponent(flowNameTextField, 1, 2); Label componentNameLabel = new Label(); componentNameLabel.setContentMode(ContentMode.HTML); componentNameLabel.setValue(VaadinIcons.COG.getHtml() + " Component Name:"); componentNameLabel.setSizeUndefined(); layout.addComponent(componentNameLabel, 0, 3); layout.setComponentAlignment(componentNameLabel, Alignment.MIDDLE_RIGHT); TextField componentNameTextField = new TextField(); componentNameTextField.setRequired(true); componentNameTextField.setValue(this.component.getName()); componentNameTextField.setReadOnly(true); componentNameTextField.setWidth("80%"); layout.addComponent(componentNameTextField, 1, 3); Label errorCategoryLabel = new Label("Relationship:"); errorCategoryLabel.setSizeUndefined(); layout.addComponent(errorCategoryLabel, 0, 4); layout.setComponentAlignment(errorCategoryLabel, Alignment.MIDDLE_RIGHT); final ComboBox relationshipCombo = new ComboBox(); // relationshipCombo.addValidator(new StringLengthValidator( // "An relationship must be selected!", 1, -1, false)); relationshipCombo.setImmediate(false); relationshipCombo.setValidationVisible(false); relationshipCombo.setRequired(true); relationshipCombo.setRequiredError("A relationship must be selected!"); relationshipCombo.setHeight("30px"); relationshipCombo.setNullSelectionAllowed(false); layout.addComponent(relationshipCombo, 1, 4); relationshipCombo.addItem("before"); relationshipCombo.setItemCaption("before", "Before"); relationshipCombo.addItem("after"); relationshipCombo.setItemCaption("after", "After"); Label jobTypeLabel = new Label("Job Type:"); jobTypeLabel.setSizeUndefined(); layout.addComponent(jobTypeLabel, 0, 5); layout.setComponentAlignment(jobTypeLabel, Alignment.MIDDLE_RIGHT); final ComboBox jobTopCombo = new ComboBox(); // jobTopCombo.addValidator(new StringLengthValidator( // "A job type must be selected!", 1, -1, false)); jobTopCombo.setImmediate(false); jobTopCombo.setValidationVisible(false); jobTopCombo.setRequired(true); jobTopCombo.setRequiredError("A job type must be selected!"); jobTopCombo.setHeight("30px"); jobTopCombo.setNullSelectionAllowed(false); layout.addComponent(jobTopCombo, 1, 5); jobTopCombo.addItem("loggingJob"); jobTopCombo.setItemCaption("loggingJob", "Logging Job"); jobTopCombo.addItem("wiretapJob"); jobTopCombo.setItemCaption("wiretapJob", "Wiretap Job"); final Label timeToLiveLabel = new Label("Time to Live:"); timeToLiveLabel.setSizeUndefined(); timeToLiveLabel.setVisible(false); layout.addComponent(timeToLiveLabel, 0, 6); layout.setComponentAlignment(timeToLiveLabel, Alignment.MIDDLE_RIGHT); final TextField timeToLiveTextField = new TextField(); timeToLiveTextField.setRequired(true); timeToLiveTextField.setValidationVisible(false); jobTopCombo.setRequiredError("A time to live value must be entered!"); timeToLiveTextField.setVisible(false); timeToLiveTextField.setWidth("40%"); layout.addComponent(timeToLiveTextField, 1, 6); jobTopCombo.addValueChangeListener(new ComboBox.ValueChangeListener() { /* (non-Javadoc) * @see com.vaadin.data.Property.ValueChangeListener#valueChange(com.vaadin.data.Property.ValueChangeEvent) */ @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); if (value.equals("wiretapJob")) { timeToLiveLabel.setVisible(true); timeToLiveTextField.setVisible(true); } else { timeToLiveLabel.setVisible(false); timeToLiveTextField.setVisible(false); } } }); GridLayout buttonLayouts = new GridLayout(3, 1); buttonLayouts.setSpacing(true); Button saveButton = new Button("Save"); saveButton.setStyleName(ValoTheme.BUTTON_SMALL); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { relationshipCombo.validate(); jobTopCombo.validate(); if (timeToLiveTextField.isVisible()) { timeToLiveTextField.validate(); } } catch (InvalidValueException e) { relationshipCombo.setValidationVisible(true); relationshipCombo.markAsDirty(); jobTopCombo.setValidationVisible(true); jobTopCombo.markAsDirty(); if (timeToLiveTextField.isVisible()) { timeToLiveTextField.setValidationVisible(true); timeToLiveTextField.markAsDirty(); } Notification.show("There are errors on the wiretap creation form!", Type.ERROR_MESSAGE); return; } createWiretap((String) relationshipCombo.getValue(), (String) jobTopCombo.getValue(), timeToLiveTextField.getValue()); } }); Button cancelButton = new Button("Cancel"); cancelButton.setStyleName(ValoTheme.BUTTON_SMALL); cancelButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { close(); } }); buttonLayouts.addComponent(saveButton); buttonLayouts.addComponent(cancelButton); layout.addComponent(buttonLayouts, 0, 7, 1, 7); layout.setComponentAlignment(buttonLayouts, Alignment.MIDDLE_CENTER); Panel paramPanel = new Panel(); paramPanel.setStyleName("dashboard"); paramPanel.setWidth("100%"); paramPanel.setContent(layout); triggerTable = new Table(); Label existingWiretapLabel = new Label("Existing Wiretaps"); existingWiretapLabel.setStyleName(ValoTheme.LABEL_HUGE); layout.addComponent(existingWiretapLabel, 0, 8, 1, 8); layout.addComponent(triggerTable, 0, 9, 1, 9); layout.setComponentAlignment(triggerTable, Alignment.TOP_CENTER); this.triggerTable.setWidth("80%"); this.triggerTable.setHeight(150, Unit.PIXELS); this.triggerTable.setCellStyleGenerator(new IkasanCellStyleGenerator()); this.triggerTable.addStyleName(ValoTheme.TABLE_SMALL); this.triggerTable.addStyleName("ikasan"); this.triggerTable.addContainerProperty("Job Type", String.class, null); this.triggerTable.addContainerProperty("Relationship", String.class, null); this.triggerTable.addContainerProperty("Trigger Parameters", String.class, null); this.triggerTable.addContainerProperty("", Button.class, null); refreshTriggerTable(); GridLayout wrapper = new GridLayout(1, 1); wrapper.setMargin(true); wrapper.setSizeFull(); wrapper.addComponent(paramPanel); this.setContent(wrapper); }
From source file:org.inakirj.imagerulette.screens.DiceURLSetupView.java
License:Open Source License
/** * Sets the layout.// ww w . j a v a 2 s. c o m */ private void setLayout() { imagesLayout = new VerticalComponentGroup(); imagesLayout.setWidth(100, Unit.PERCENTAGE); ImageUtils.getAllImageURL().stream().forEach(i -> { HorizontalLayout sliderLAyout = new HorizontalLayout(); if (imagesLayout.getComponentCount() % 2 == 0) { sliderLAyout.addStyleName("dice-banner-1"); } else { sliderLAyout.addStyleName("dice-banner-2"); } sliderLAyout.setWidth(100, Unit.PERCENTAGE); Image img = new Image("", i.getSource()); img.addStyleName("dice-image"); img.setData(i.getData()); Slider slider = new Slider(); slider.addStyleName("dice-slider"); Label total = new Label(); total.addStyleName("size-24");// TODO is not working // Adding image sliderLAyout.addComponent(img); // Adding slider slider.setMin(0); slider.setMax(5); slider.setWidth(80, Unit.PERCENTAGE); slider.addValueChangeListener(s -> { total.setValue("x " + slider.getValue().intValue()); enableDiceTabOrNot(); }); sliderLAyout.addComponent(slider); // Adding label total.setValue("x 0"); sliderLAyout.addComponent(total); sliderLAyout.setExpandRatio(img, 2); sliderLAyout.setExpandRatio(slider, 7); sliderLAyout.setExpandRatio(total, 1); sliderLAyout.setComponentAlignment(img, Alignment.BOTTOM_LEFT); sliderLAyout.setComponentAlignment(slider, Alignment.BOTTOM_LEFT); sliderLAyout.setComponentAlignment(total, Alignment.BOTTOM_LEFT); // Adding layout imagesLayout.addComponent(sliderLAyout); }); addComponent(imagesLayout); }
From source file:org.investovator.ui.dataplayback.admin.DataPlaybackEngineAdminDashboard.java
License:Open Source License
public Component setupGameConfigBox() { FormLayout layout = new FormLayout(); layout.setCaption("Game Configuration"); layout.addStyleName("center-caption"); GameTypes config = DataPlaybackEngineStates.gameConfig; //show the game description Label gameDescription = new Label(config.getDescription()); layout.addComponent(gameDescription); gameDescription.setContentMode(ContentMode.HTML); gameDescription.setWidth(320, Unit.PIXELS); gameDescription.setCaption("Game: "); //add the player type Label playerType = new Label(); layout.addComponent(playerType);//from ww w.j a v a2 s.c om playerType.setCaption("Player Type: "); playerType.setValue(player.getName()); //show the attributes Label attributes = new Label(config.getInterestedAttributes().toString()); layout.addComponent(attributes); attributes.setContentMode(ContentMode.HTML); attributes.setCaption("Attributes: "); //matching attribute Label matchingAttr = new Label(config.getAttributeToMatch().toString()); layout.addComponent(matchingAttr); matchingAttr.setContentMode(ContentMode.HTML); matchingAttr.setCaption("Played On: "); return layout; }
From source file:org.investovator.ui.dataplayback.admin.DataPlaybackEngineAdminDashboard.java
License:Open Source License
public Component setupGameStatsBox() { FormLayout layout = new FormLayout(); layout.setCaption("Game Stats"); layout.addStyleName("center-caption"); //show game runtime final Label runTime = new Label(); //push the changes UI.getCurrent().access(new Runnable() { @Override// w w w.ja v a 2 s . c o m public void run() { TimeZone defaultTz = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("GMT")); SimpleDateFormat sDate = new SimpleDateFormat("HH:mm:ss"); runTime.setValue(sDate.format(new Date(player.getGameRuntime()))); TimeZone.setDefault(defaultTz); getUI().push(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } }); runTime.setCaption("Up Time: "); layout.addComponent(runTime); //start the time updating thread new Thread() { public void run() { //update forever while (true) { UI.getCurrent().access(new Runnable() { @Override public void run() { TimeZone defaultTz = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("GMT")); SimpleDateFormat sDate = new SimpleDateFormat("HH:mm:ss"); runTime.setValue(sDate.format(new Date(player.getGameRuntime()))); TimeZone.setDefault(defaultTz); getUI().push(); } }); //wait before updating try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } }.start(); //show market turnover Label turnover = new Label(Float.toString(player.getMarketTurnover())); turnover.setCaption("Market Turnover: "); layout.addComponent(turnover); //show total trades Label totalTrades = new Label(Integer.toString(player.getTotalTrades())); totalTrades.setCaption("Total Trades: "); layout.addComponent(totalTrades); return layout; }
From source file:org.investovator.ui.utils.dashboard.dataplayback.BasicGameOverWindow.java
License:Open Source License
public void setupUI() { VerticalLayout content = new VerticalLayout(); //create the leaderboard Table leaderboard = getLeaderboard(); Portfolio myPortfolio = this.getMyPortfolio(username); if (myPortfolio == null) { this.close(); return;/*from www.j av a 2 s . c o m*/ } Label rankLabel = new Label( "<H2 align=\"center\">Congratulations " + myPortfolio.getUsername() + ". You Won..!</H2>"); //if this player has not won the game if (!leaderboard.isFirstId(username)) { rankLabel.setValue("<H2 align=\"center\">Game Over!</H2>"); } rankLabel.setContentMode(ContentMode.HTML); content.addComponent(rankLabel); content.addComponent(leaderboard); //add the exit game button Button exitGame = new Button("Exit Game"); exitGame.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { //if admin if (userType == Authenticator.UserType.ADMIN) { getUI().getNavigator().navigateTo(UIConstants.MAINVIEW); } else { getUI().getNavigator().navigateTo(UIConstants.USER_VIEW); } close(); } }); content.addComponent(exitGame); this.setContent(content); }
From source file:org.investovator.ui.utils.dashboard.DecisionMakerPanel.java
License:Open Source License
/** * Loads the description for a decision making algorithm * @return/*from w w w. j ava 2s. com*/ */ private Component getToolDescription() { VerticalLayout descriptionContainer = new VerticalLayout(); SigGenMAType type = (SigGenMAType) this.indicators.getValue(); String description = "<p>" + SigGenMAType.getDescription(type) + "</p>"; Label descriptionLabel = new Label(); descriptionContainer.addComponent(descriptionLabel); descriptionLabel.setContentMode(ContentMode.HTML); descriptionLabel.setValue(description); return descriptionContainer; }
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);/*from w w w . ja va 2 s. c o m*/ 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>(); }/* ww w. j a va2 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.TabularResultLayout.java
License:Open Source License
private void createMenuBar() { HorizontalLayout resultBar = new HorizontalLayout(); resultBar.setWidth(100, Unit.PERCENTAGE); resultBar.setMargin(new MarginInfo(false, true, false, true)); HorizontalLayout leftBar = new HorizontalLayout(); leftBar.setSpacing(true);/*from w w w . ja v a 2s . c om*/ resultLabel = new Label("", ContentMode.HTML); leftBar.addComponent(resultLabel); final Label sqlLabel = new Label("", ContentMode.TEXT); sqlLabel.setWidth(800, Unit.PIXELS); leftBar.addComponent(sqlLabel); resultBar.addComponent(leftBar); resultBar.setComponentAlignment(leftBar, Alignment.MIDDLE_LEFT); resultBar.setExpandRatio(leftBar, 1); MenuBar rightBar = new MenuBar(); rightBar.addStyleName(ValoTheme.MENUBAR_BORDERLESS); rightBar.addStyleName(ValoTheme.MENUBAR_SMALL); MenuBar.MenuItem refreshButton = rightBar.addItem("", new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(MenuBar.MenuItem selectedItem) { listener.reExecute(sql); } }); refreshButton.setIcon(FontAwesome.REFRESH); MenuBar.MenuItem exportButton = rightBar.addItem("", new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(MenuBar.MenuItem selectedItem) { new ExportDialog(grid, db.getName(), sql).show(); } }); exportButton.setIcon(FontAwesome.UPLOAD); if (isInQueryGeneralResults) { MenuBar.MenuItem keepResultsButton = rightBar.addItem("", new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(com.vaadin.ui.MenuBar.MenuItem selectedItem) { queryPanel.addResultsTab(refreshWithoutSaveButton(), StringUtils.abbreviate(sql, 20), queryPanel.getGeneralResultsTab().getIcon()); queryPanel.resetGeneralResultsTab(); } }); keepResultsButton.setIcon(FontAwesome.CLONE); keepResultsButton.setDescription("Save these results to a new tab"); } if (showSql) { sqlLabel.setValue(StringUtils.abbreviate(sql, 200)); } resultBar.addComponent(rightBar); resultBar.setComponentAlignment(rightBar, Alignment.MIDDLE_RIGHT); this.addComponent(resultBar, 0); }