List of usage examples for com.vaadin.ui HorizontalLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:org.jumpmind.metl.ui.mapping.EditMappingPanel.java
License:Open Source License
protected void buildUI() { if (!readOnly) { ButtonBar buttonBar = new ButtonBar(); addComponent(buttonBar);/*from ww w . j a va 2 s. c om*/ Button autoMapButton = buttonBar.addButton("Auto Map", FontAwesome.FLASH); removeButton = buttonBar.addButton("Remove", FontAwesome.TRASH_O); removeButton.setEnabled(false); autoMapButton.addClickListener(new AutoMapListener()); removeButton.addClickListener(new RemoveListener()); } HorizontalLayout titleHeader = new HorizontalLayout(); titleHeader.setSpacing(true); titleHeader.setMargin(new MarginInfo(false, true, false, true)); titleHeader.setWidth(100f, Unit.PERCENTAGE); titleHeader.addComponent(new Label( "<b>Input Model:</b> " + (component.getInputModel() != null ? component.getInputModel().getName() : "?"), ContentMode.HTML)); titleHeader.addComponent(new Label( "<b>Output Model:</b> " + (component.getOutputModel() != null ? component.getOutputModel().getName() : "?"), ContentMode.HTML)); addComponent(titleHeader); HorizontalLayout filterHeader = new HorizontalLayout(); filterHeader.setSpacing(true); filterHeader.setMargin(new MarginInfo(true, true, true, true)); filterHeader.setWidth(100f, Unit.PERCENTAGE); HorizontalLayout srcFilterHeader = new HorizontalLayout(); srcFilterHeader.setSpacing(true); srcFilterHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); filterHeader.addComponent(srcFilterHeader); HorizontalLayout dstFilterHeader = new HorizontalLayout(); dstFilterHeader.setSpacing(true); dstFilterHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); filterHeader.addComponent(dstFilterHeader); addComponent(filterHeader); srcTextFilter = new TextField(); srcTextFilter.setInputPrompt("Filter"); srcTextFilter.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); srcTextFilter.setIcon(FontAwesome.SEARCH); srcTextFilter.setImmediate(true); srcTextFilter.setTextChangeEventMode(TextChangeEventMode.LAZY); srcTextFilter.setTextChangeTimeout(200); srcTextFilter.addTextChangeListener(new FilterInputTextListener()); srcFilterHeader.addComponent(srcTextFilter); srcMapFilter = new CheckBox("Mapped Only"); srcMapFilter.addValueChangeListener(new FilterSrcMapListener()); srcFilterHeader.addComponent(srcMapFilter); dstTextFilter = new TextField(); dstTextFilter.setInputPrompt("Filter"); dstTextFilter.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); dstTextFilter.setIcon(FontAwesome.SEARCH); dstTextFilter.setImmediate(true); dstTextFilter.setTextChangeEventMode(TextChangeEventMode.LAZY); dstTextFilter.setTextChangeTimeout(200); dstTextFilter.addTextChangeListener(new FilterOutputTextListener()); dstFilterHeader.addComponent(dstTextFilter); dstMapFilter = new CheckBox("Mapped Only"); dstMapFilter.addValueChangeListener(new FilterDstMapListener()); dstFilterHeader.addComponent(dstMapFilter); Panel panel = new Panel(); VerticalLayout vlay = new VerticalLayout(); vlay.setSizeFull(); diagram = new MappingDiagram(context, component, readOnly); diagram.setSizeFull(); vlay.addComponent(diagram); panel.setContent(vlay); panel.setSizeFull(); addComponent(panel); setExpandRatio(panel, 1.0f); diagram.addListener(new EventListener()); }
From source file:org.jumpmind.metl.ui.views.deploy.EditAgentPanel.java
License:Open Source License
public EditAgentPanel(ApplicationContext context, TabbedPanel tabbedPanel, Agent agent) { this.context = context; this.tabbedPanel = tabbedPanel; this.agent = agent; this.backgroundRefresherService = context.getBackgroundRefresherService(); HorizontalLayout editAgentLayout = new HorizontalLayout(); editAgentLayout.setSpacing(true);/*from w w w . j a va 2 s. c o m*/ editAgentLayout.setMargin(new MarginInfo(true, false, false, true)); editAgentLayout.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING); addComponent(editAgentLayout); final ComboBox startModeCombo = new ComboBox("Start Mode"); startModeCombo.setImmediate(true); startModeCombo.setNullSelectionAllowed(false); AgentStartMode[] modes = AgentStartMode.values(); for (AgentStartMode agentStartMode : modes) { startModeCombo.addItem(agentStartMode.name()); } startModeCombo.setValue(agent.getStartMode()); startModeCombo.addValueChangeListener(event -> { agent.setStartMode((String) startModeCombo.getValue()); context.getConfigurationService().save((AbstractObject) EditAgentPanel.this.agent); }); editAgentLayout.addComponent(startModeCombo); editAgentLayout.setComponentAlignment(startModeCombo, Alignment.BOTTOM_LEFT); Button parameterButton = new Button("Parameters"); parameterButton.addClickListener(new ParameterClickListener()); editAgentLayout.addComponent(parameterButton); editAgentLayout.setComponentAlignment(parameterButton, Alignment.BOTTOM_LEFT); HorizontalLayout buttonGroup = new HorizontalLayout(); final TextField hostNameField = new TextField("Hostname"); hostNameField.setImmediate(true); hostNameField.setTextChangeEventMode(TextChangeEventMode.LAZY); hostNameField.setTextChangeTimeout(100); hostNameField.setWidth(20, Unit.EM); hostNameField.setNullRepresentation(""); hostNameField.setValue(agent.getHost()); hostNameField.addValueChangeListener(event -> { agent.setHost((String) hostNameField.getValue()); EditAgentPanel.this.context.getConfigurationService().save((AbstractObject) agent); EditAgentPanel.this.context.getAgentManager().refresh(agent); }); buttonGroup.addComponent(hostNameField); buttonGroup.setComponentAlignment(hostNameField, Alignment.BOTTOM_LEFT); Button getHostNameButton = new Button("Get Host"); getHostNameButton.addClickListener(event -> hostNameField.setValue(AppUtils.getHostName())); buttonGroup.addComponent(getHostNameButton); buttonGroup.setComponentAlignment(getHostNameButton, Alignment.BOTTOM_LEFT); editAgentLayout.addComponent(buttonGroup); editAgentLayout.setComponentAlignment(buttonGroup, Alignment.BOTTOM_LEFT); Button exportButton = new Button("Export Agent Config", event -> exportConfiguration()); editAgentLayout.addComponent(exportButton); editAgentLayout.setComponentAlignment(exportButton, Alignment.BOTTOM_LEFT); CheckBox autoRefresh = new CheckBox("Auto Refresh", Boolean.valueOf(agent.isAutoRefresh())); autoRefresh.setImmediate(true); autoRefresh.addValueChangeListener(event -> { agent.setAutoRefresh(autoRefresh.getValue()); EditAgentPanel.this.context.getConfigurationService().save((AbstractObject) agent); EditAgentPanel.this.context.getAgentManager().refresh(agent); }); editAgentLayout.addComponent(autoRefresh); editAgentLayout.setComponentAlignment(autoRefresh, Alignment.BOTTOM_LEFT); CheckBox allowTestFlowsField = new CheckBox("Allow Test Flows", Boolean.valueOf(agent.isAllowTestFlows())); allowTestFlowsField.setImmediate(true); allowTestFlowsField.addValueChangeListener(event -> { agent.setAllowTestFlows(allowTestFlowsField.getValue()); EditAgentPanel.this.context.getConfigurationService().save((AbstractObject) agent); EditAgentPanel.this.context.getAgentManager().refresh(agent); }); editAgentLayout.addComponent(allowTestFlowsField); editAgentLayout.setComponentAlignment(allowTestFlowsField, Alignment.BOTTOM_LEFT); ButtonBar buttonBar = new ButtonBar(); addComponent(buttonBar); addDeploymentButton = buttonBar.addButton("Add Deployment", Icons.DEPLOYMENT); addDeploymentButton.addClickListener(new AddDeploymentClickListener()); editButton = buttonBar.addButton("Edit", FontAwesome.EDIT); editButton.addClickListener(event -> editClicked()); enableButton = buttonBar.addButton("Enable", FontAwesome.CHAIN); enableButton.addClickListener(event -> enableClicked()); disableButton = buttonBar.addButton("Disable", FontAwesome.CHAIN_BROKEN); disableButton.addClickListener(event -> disableClicked()); removeButton = buttonBar.addButton("Remove", FontAwesome.TRASH_O); removeButton.addClickListener(event -> removeClicked()); runButton = buttonBar.addButton("Run", Icons.RUN); runButton.addClickListener(event -> runClicked()); container = new BeanItemContainer<AgentDeploymentSummary>(AgentDeploymentSummary.class); container.setItemSorter(new TableItemSorter()); table = new Table(); table.setSizeFull(); table.setCacheRate(100); table.setPageLength(100); table.setImmediate(true); table.setSelectable(true); table.setMultiSelect(true); table.setContainerDataSource(container); table.setVisibleColumns("name", "projectName", "type", "status", "logLevel", "startType", "startExpression"); table.setColumnHeaders("Deployment", "Project", "Type", "Status", "Log Level", "Start Type", "Start Expression"); table.addGeneratedColumn("status", new StatusRenderer()); table.addItemClickListener(new TableItemClickListener()); table.addValueChangeListener(new TableValueChangeListener()); table.setSortContainerPropertyId("type"); table.setSortAscending(true); addComponent(table); setExpandRatio(table, 1.0f); refresh(); setButtonsEnabled(); backgroundRefresherService.register(this); }
From source file:org.jumpmind.metl.ui.views.DeployNavigator.java
License:Open Source License
protected HorizontalLayout buildSearchBar() { HorizontalLayout layout = new HorizontalLayout(); layout.setMargin(new MarginInfo(false, true, true, true)); layout.setWidth(100, Unit.PERCENTAGE); layout.setVisible(false);/*from w w w . j a va2 s . c o m*/ TextField search = new TextField(); search.setIcon(Icons.SEARCH); search.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); search.setWidth(100, Unit.PERCENTAGE); layout.addComponent(search); return layout; }
From source file:org.jumpmind.metl.ui.views.manage.ExecutionRunPanel.java
License:Open Source License
public ExecutionRunPanel(String executionId, ApplicationContext context, TabbedPanel parentTabSheet, IFlowRunnable flowRunnable) {//from w w w . j a v a 2s . co m this.executionService = context.getExecutionService(); this.executionId = executionId; this.context = context; this.parentTabSheet = parentTabSheet; this.flowRunnable = flowRunnable; Execution execution = executionService.findExecution(executionId); this.flow = context.getConfigurationService().findFlow(execution.getFlowId()); HorizontalLayout topBar = new HorizontalLayout(); topBar.setMargin(new MarginInfo(true, true, false, true)); topBar.setWidth(100, Unit.PERCENTAGE); HorizontalLayout left = new HorizontalLayout(); topBar.addComponent(left); HorizontalLayout right = new HorizontalLayout(); right.setSpacing(true); topBar.addComponent(right); topBar.setComponentAlignment(right, Alignment.MIDDLE_RIGHT); Label limitLabel = new Label("Max Log Messages To Show :"); right.addComponent(limitLabel); right.setComponentAlignment(limitLabel, Alignment.MIDDLE_RIGHT); limitField = new ImmediateUpdateTextField(null) { private static final long serialVersionUID = 1L; @Override protected void save(String text) { Setting setting = context.getUser().findSetting(UserSetting.SETTING_MAX_LOG_MESSAGE_TO_SHOW); setting.setValue(Integer.toString(getMaxToShow(text))); context.getConfigurationService().save(setting); } }; limitField.setWidth("5em"); limitField.setValue(context.getUser().get(UserSetting.SETTING_MAX_LOG_MESSAGE_TO_SHOW, "1000")); right.addComponent(limitField); right.setComponentAlignment(limitField, Alignment.MIDDLE_RIGHT); showDiagramCheckbox = new CheckBox("Show Diagram"); showDiagramCheckbox.addValueChangeListener((event) -> { if (showDiagramCheckbox.getValue()) { showDiagram(); } else { showDetails(); } }); right.addComponent(showDiagramCheckbox); right.setComponentAlignment(showDiagramCheckbox, Alignment.MIDDLE_RIGHT); addComponent(topBar); ButtonBar buttonBar = new ButtonBar(); rerunButton = buttonBar.addButton("Rerun", Icons.RUN, event -> rerun()); rerunButton.setVisible(false); removeButton = buttonBar.addButton("Remove", Icons.DELETE, event -> remove()); removeButton.setVisible(false); cancelButton = buttonBar.addButton("Cancel", Icons.CANCEL, event -> cancel()); addComponent(buttonBar); HorizontalLayout header1 = new HorizontalLayout(); header1.addComponent(new Label("<b>Flow:</b>", ContentMode.HTML)); header1.addComponent(flowLabel); header1.addComponent(new Label("<b>Start:</b>", ContentMode.HTML)); header1.addComponent(startLabel); header1.setSpacing(true); header1.setMargin(new MarginInfo(false, true, false, true)); header1.setWidth("100%"); addComponent(header1); HorizontalLayout header2 = new HorizontalLayout(); header2.addComponent(new Label("<b>Status:</b>", ContentMode.HTML)); header2.addComponent(statusLabel); header2.addComponent(new Label("<b>End:</b>", ContentMode.HTML)); header2.addComponent(endLabel); header2.setSpacing(true); header2.setMargin(new MarginInfo(false, true, true, true)); header2.setWidth("100%"); addComponent(header2); stepContainer.setBeanIdProperty("id"); diagramLayout = new VerticalLayout(); diagramLayout.setWidth(10000, Unit.PIXELS); diagramLayout.setHeight(10000, Unit.PIXELS); flowPanel = new Panel(); flowPanel.setSizeFull(); flowPanel.addStyleName(ValoTheme.PANEL_WELL); flowPanel.setContent(diagramLayout); stepTable.setContainerDataSource(stepContainer); stepTable.setSelectable(true); stepTable.setMultiSelect(true); stepTable.setImmediate(true); stepTable.setSizeFull(); stepTable.setVisibleColumns( new Object[] { "componentName", "threadNumber", "status", "payloadReceived", "messagesReceived", "messagesProduced", "payloadProduced", "startTime", "endTime", "handleDurationString" }); stepTable.setColumnHeaders(new String[] { "Component Name", "Thread", "Status", "Payload Recvd", "Msgs Recvd", "Msgs Sent", "Payload Sent", "Start", "End", "Run Duration" }); stepTable.setColumnWidth("status", 100); stepTable.setColumnWidth("messagesReceived", 100); stepTable.setColumnWidth("messagesProduced", 100); stepTable.setColumnWidth("payloadReceived", 100); stepTable.setColumnWidth("payloadProduced", 100); stepTable.setColumnWidth("threadNumber", 100); stepTable.setColumnWidth("startTime", 170); stepTable.setColumnWidth("endTime", 170); stepTable.setColumnExpandRatio("handleDurationString", 1); stepTable.addValueChangeListener(event -> { @SuppressWarnings("unchecked") Set<String> executionStepIds = (Set<String>) event.getProperty().getValue(); logContainer.removeAllItems(); List<ExecutionStepLog> logs = executionService.findExecutionStepLogs(executionStepIds, getMaxToShow()); logContainer.addAll(logs); }); stepTable.addValueChangeListener(event -> { @SuppressWarnings("unchecked") Set<String> executionStepIds = (Set<String>) event.getProperty().getValue(); logContainer.removeAllItems(); List<ExecutionStepLog> logs = executionService.findExecutionStepLogs(executionStepIds, getMaxToShow()); logContainer.addAll(logs); }); logTable = new Grid(); logTable.addColumn("level", String.class).setHeaderCaption("Level").setWidth(110).setMaximumWidth(200); logTable.addColumn("createTime", Date.class).setHeaderCaption("Time").setWidth(120).setMaximumWidth(200) .setRenderer(new DateRenderer(UiConstants.TIME_FORMAT)); logTable.addColumn("logText", String.class).setHeaderCaption("Message").setExpandRatio(1); logTable.setContainerDataSource(logContainer); logTable.setSizeFull(); logTable.addItemClickListener(event -> logTableCellClicked(logTable, event)); logTable.addSortListener(event -> { lastSortOrder = event.getSortOrder(); }); HeaderRow filteringHeader = logTable.appendHeaderRow(); HeaderCell logTextFilterCell = filteringHeader.getCell("logText"); TextField filterField = new TextField(); filterField.setInputPrompt("Filter"); filterField.addStyleName(ValoTheme.TEXTFIELD_TINY); filterField.setWidth("100%"); // Update filter When the filter input is changed filterField.addTextChangeListener(change -> { // Can't modify filters so need to replace logContainer.removeContainerFilters("logText"); // (Re)create the filter if necessary if (!change.getText().isEmpty()) logContainer.addContainerFilter(new SimpleStringFilter("logText", change.getText(), true, false)); }); logTextFilterCell.setComponent(filterField); HeaderCell levelFilterCell = filteringHeader.getCell("level"); ComboBox levelFilter = new ComboBox(); levelFilter.setWidth(8, Unit.EM); levelFilter.setNullSelectionAllowed(true); LogLevel[] levels = LogLevel.values(); for (LogLevel logLevel : levels) { levelFilter.addItem(logLevel.name()); } levelFilter.addValueChangeListener(change -> { logContainer.removeContainerFilters("level"); String text = (String) levelFilter.getValue(); if (isNotBlank(text)) { logContainer.addContainerFilter(new SimpleStringFilter("level", text, true, false)); } }); levelFilterCell.setComponent(levelFilter); levelFilter.addStyleName(ValoTheme.COMBOBOX_TINY); splitPanel = new VerticalSplitPanel(); splitPanel.setFirstComponent(flowPanel); splitPanel.setSecondComponent(logTable); splitPanel.setSplitPosition(50f); splitPanel.setSizeFull(); addComponent(splitPanel); setExpandRatio(splitPanel, 1.0f); showDiagramCheckbox.setValue(context.getUser().getBoolean(UserSetting.SETTING_SHOW_RUN_DIAGRAM, true)); if (!showDiagramCheckbox.getValue()) { showDetails(); } context.getBackgroundRefresherService().register(this); }
From source file:org.jumpmind.metl.ui.views.ManageView.java
License:Open Source License
@SuppressWarnings("serial") @PostConstruct/*from www .jav a 2 s .c o m*/ protected void init() { viewButton = new Button("View Log"); viewButton.setEnabled(false); viewButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { viewLog(table.getValue()); } }); VerticalLayout mainTab = new VerticalLayout(); mainTab.setSizeFull(); HorizontalLayout header = new HorizontalLayout(); header.addComponent(viewButton); header.setComponentAlignment(viewButton, Alignment.BOTTOM_RIGHT); statusSelect = new ComboBox("Status"); statusSelect.setNewItemsAllowed(false); statusSelect.setNullSelectionAllowed(false); statusSelect.addItem(ANY); statusSelect.setValue(ANY); for (ExecutionStatus status : ExecutionStatus.values()) { statusSelect.addItem(status.toString()); } ; statusSelect.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { refreshUI(getBackgroundData()); } }); header.addComponent(statusSelect); header.setComponentAlignment(statusSelect, Alignment.BOTTOM_RIGHT); HorizontalLayout limitLayout = new HorizontalLayout(); limitLayout.setSpacing(true); Label limitLabel = new Label("Limit:"); limitLayout.addComponent(limitLabel); limitLayout.setComponentAlignment(limitLabel, Alignment.MIDDLE_CENTER); TextField limitField = new TextField(null, String.valueOf(DEFAULT_LIMIT)); limitField.setWidth("5em"); limitField.setImmediate(true); limitField.setTextChangeEventMode(TextChangeEventMode.LAZY); limitField.setTextChangeTimeout(200); limitField.addTextChangeListener(new TextChangeListener() { public void textChange(TextChangeEvent event) { try { limit = Integer.parseInt(event.getText()); } catch (Exception e) { } refreshUI(getBackgroundData()); } }); limitLayout.addComponent(limitField); limitLayout.setComponentAlignment(limitField, Alignment.BOTTOM_RIGHT); header.addComponent(limitLayout); header.setComponentAlignment(limitLayout, Alignment.BOTTOM_RIGHT); header.setExpandRatio(limitLayout, 1.0f); TextField filterField = new TextField(); filterField.setInputPrompt("Filter"); filterField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); filterField.setIcon(FontAwesome.SEARCH); filterField.setImmediate(true); filterField.setTextChangeEventMode(TextChangeEventMode.LAZY); filterField.setTextChangeTimeout(200); filterField.addTextChangeListener(new TextChangeListener() { public void textChange(TextChangeEvent event) { executionContainer.removeAllContainerFilters(); if (!StringUtils.isBlank(event.getText())) { executionContainer.addContainerFilter(new MultiPropertyFilter(event.getText(), new String[] { "agentName", "hostName", "flowName", "status", "startTime", "endTime" })); } } }); header.addComponent(filterField); header.setComponentAlignment(filterField, Alignment.BOTTOM_RIGHT); header.setSpacing(true); header.setMargin(true); header.setWidth("100%"); mainTab.addComponent(header); table = new Table(); table.setContainerDataSource(executionContainer); table.setSelectable(true); table.setMultiSelect(false); table.setSizeFull(); table.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (event.isDoubleClick()) { viewLog(event.getItemId()); } } }); table.setVisibleColumns( new Object[] { "agentName", "deploymentName", "hostName", "status", "startTime", "endTime" }); table.setColumnHeaders(new String[] { "Agent", "Deployment", "Host", "Status", "Start", "End" }); table.setSortContainerPropertyId("startTime"); table.setSortAscending(false); table.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { viewButton.setEnabled(table.getValue() != null); } }); mainTab.addComponent(table); mainTab.setExpandRatio(table, 1.0f); tabs = new TabbedPanel(); tabs.setMainTab("Executions", Icons.EXECUTION, mainTab); HorizontalSplitPanel split = new HorizontalSplitPanel(); split.setSizeFull(); split.setSplitPosition(AppConstants.DEFAULT_LEFT_SPLIT, Unit.PIXELS, false); manageNavigator = new ManageNavigator(FolderType.AGENT, context); manageNavigator.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { refreshUI(getBackgroundData()); } }); split.setFirstComponent(manageNavigator); VerticalLayout container = new VerticalLayout(); container.setSizeFull(); container.addComponent(tabs); split.setSecondComponent(container); addComponent(split); setSizeFull(); context.getBackgroundRefresherService().register(this); }
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 v a 2s .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
public QueryPanel(IDb db, ISettingsProvider settingsProvider, IButtonBar buttonBar, String user) { this.settingsProvider = settingsProvider; this.db = db; this.user = user; this.buttonBar = buttonBar; this.sqlArea = buildSqlEditor(); this.shortCutListeners.add(createExecuteSqlShortcutListener()); VerticalLayout resultsLayout = new VerticalLayout(); resultsLayout.setSizeFull();//from w ww. ja v a 2s .c o m resultsTabs = CommonUiUtils.createTabSheet(); resultStatuses = new HashMap<Component, String>(); HorizontalLayout statusBar = new HorizontalLayout(); statusBar.addStyleName(ValoTheme.PANEL_WELL); statusBar.setMargin(new MarginInfo(true, true, true, true)); statusBar.setWidth(100, Unit.PERCENTAGE); status = new Label("No Results"); statusBar.addComponent(status); setSelectedTabChangeListener(); resultsLayout.addComponents(resultsTabs, statusBar); resultsLayout.setExpandRatio(resultsTabs, 1); addComponents(sqlArea, resultsLayout); setSplitPosition(400, Unit.PIXELS); emptyResults = new VerticalLayout(); emptyResults.setSizeFull(); Label label = new Label("New results will appear here"); label.setWidthUndefined(); emptyResults.addComponent(label); emptyResults.setComponentAlignment(label, Alignment.MIDDLE_CENTER); resultStatuses.put(emptyResults, "No Results"); if (!settingsProvider.get().getProperties().is(SQL_EXPLORER_SHOW_RESULTS_IN_NEW_TABS)) { createGeneralResultsTab(); } }
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>(); }/*from w ww . j a va 2s .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);// www . j av a2 s. co m 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); }
From source file:org.kani.Application.java
License:Apache License
private Layout getHeader() { HorizontalLayout header = new HorizontalLayout(); header.setWidth("100%"); header.setMargin(true); header.setSpacing(true);/*from w w w . ja va 2 s. c o m*/ CssLayout titleLayout = new CssLayout(); String applicationTitle = getMessage("title"); H1 title = new H1(applicationTitle); titleLayout.addComponent(title); String applicationDescription = getMessage("description"); SmallText description = new SmallText(applicationDescription); description.setSizeUndefined(); titleLayout.addComponent(description); titleLayout.addComponent(description); header.addComponent(titleLayout); return header; }