List of usage examples for com.vaadin.ui Alignment TOP_LEFT
Alignment TOP_LEFT
To view the source code for com.vaadin.ui Alignment TOP_LEFT.
Click Source Link
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 . jav a2 s . com*/ 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.lunifera.mobile.vaadin.ecview.presentation.internal.NavigationPagePresentation.java
License:Open Source License
/** * Sets the alignment to the component./*from www. j a v a 2 s . c om*/ * * @param child * @param yAlignment */ protected void applyAlignment(Component child, YAlignment yAlignment) { if (yAlignment != null) { child.setSizeUndefined(); switch (yAlignment) { case BOTTOM_CENTER: verticalLayout.setComponentAlignment(child, Alignment.BOTTOM_CENTER); break; case BOTTOM_FILL: verticalLayout.setComponentAlignment(child, Alignment.BOTTOM_LEFT); child.setWidth("100%"); break; case BOTTOM_LEFT: verticalLayout.setComponentAlignment(child, Alignment.BOTTOM_LEFT); break; case BOTTOM_RIGHT: verticalLayout.setComponentAlignment(child, Alignment.BOTTOM_RIGHT); break; case MIDDLE_CENTER: verticalLayout.setComponentAlignment(child, Alignment.MIDDLE_CENTER); break; case MIDDLE_FILL: verticalLayout.setComponentAlignment(child, Alignment.MIDDLE_LEFT); child.setWidth("100%"); break; case MIDDLE_LEFT: verticalLayout.setComponentAlignment(child, Alignment.MIDDLE_LEFT); break; case MIDDLE_RIGHT: verticalLayout.setComponentAlignment(child, Alignment.MIDDLE_RIGHT); break; case TOP_CENTER: verticalLayout.setComponentAlignment(child, Alignment.TOP_CENTER); break; case TOP_FILL: verticalLayout.setComponentAlignment(child, Alignment.TOP_LEFT); child.setWidth("100%"); break; case TOP_LEFT: verticalLayout.setComponentAlignment(child, Alignment.TOP_LEFT); break; case TOP_RIGHT: verticalLayout.setComponentAlignment(child, Alignment.TOP_RIGHT); break; case FILL_CENTER: verticalLayout.setComponentAlignment(child, Alignment.TOP_CENTER); child.setHeight("100%"); break; case FILL_FILL: verticalLayout.setComponentAlignment(child, Alignment.TOP_LEFT); child.setWidth("100%"); child.setHeight("100%"); break; case FILL_LEFT: verticalLayout.setComponentAlignment(child, Alignment.TOP_LEFT); child.setHeight("100%"); break; case FILL_RIGHT: verticalLayout.setComponentAlignment(child, Alignment.TOP_RIGHT); child.setHeight("100%"); break; default: break; } } }
From source file:org.lunifera.runtime.web.ecview.presentation.vaadin.internal.FormLayoutPresentation.java
License:Open Source License
/** * Sets the alignment to the component./*from w w w . j a va 2s .c om*/ * * @param child * @param yAlignment */ protected void applyAlignment(Component child, YAlignment yAlignment) { if (yAlignment != null) { child.setWidth("-1%"); child.setHeight("-1%"); switch (yAlignment) { case BOTTOM_CENTER: formLayout.setComponentAlignment(child, Alignment.BOTTOM_CENTER); break; case BOTTOM_FILL: formLayout.setComponentAlignment(child, Alignment.BOTTOM_LEFT); child.setWidth("100%"); break; case BOTTOM_LEFT: formLayout.setComponentAlignment(child, Alignment.BOTTOM_LEFT); break; case BOTTOM_RIGHT: formLayout.setComponentAlignment(child, Alignment.BOTTOM_RIGHT); break; case MIDDLE_CENTER: formLayout.setComponentAlignment(child, Alignment.MIDDLE_CENTER); break; case MIDDLE_FILL: formLayout.setComponentAlignment(child, Alignment.MIDDLE_LEFT); child.setWidth("100%"); break; case MIDDLE_LEFT: formLayout.setComponentAlignment(child, Alignment.MIDDLE_LEFT); break; case MIDDLE_RIGHT: formLayout.setComponentAlignment(child, Alignment.MIDDLE_RIGHT); break; case TOP_CENTER: formLayout.setComponentAlignment(child, Alignment.TOP_CENTER); break; case TOP_FILL: formLayout.setComponentAlignment(child, Alignment.TOP_LEFT); child.setWidth("100%"); break; case TOP_LEFT: formLayout.setComponentAlignment(child, Alignment.TOP_LEFT); break; case TOP_RIGHT: formLayout.setComponentAlignment(child, Alignment.TOP_RIGHT); break; case FILL_CENTER: formLayout.setComponentAlignment(child, Alignment.TOP_CENTER); child.setHeight("100%"); break; case FILL_FILL: formLayout.setComponentAlignment(child, Alignment.TOP_LEFT); child.setWidth("100%"); child.setHeight("100%"); break; case FILL_LEFT: formLayout.setComponentAlignment(child, Alignment.TOP_LEFT); child.setHeight("100%"); break; case FILL_RIGHT: formLayout.setComponentAlignment(child, Alignment.TOP_RIGHT); child.setHeight("100%"); break; default: break; } } }
From source file:org.lunifera.runtime.web.ecview.presentation.vaadin.internal.GridLayoutPresentation.java
License:Open Source License
/** * Sets the alignment to the component.//w ww . j a v a2 s. co m * * @param child * @param yAlignment */ protected void applyAlignment(Component child, YAlignment yAlignment) { if (yAlignment != null) { child.setWidth("-1%"); child.setHeight("-1%"); switch (yAlignment) { case BOTTOM_CENTER: gridlayout.setComponentAlignment(child, Alignment.BOTTOM_CENTER); break; case BOTTOM_FILL: gridlayout.setComponentAlignment(child, Alignment.BOTTOM_LEFT); child.setWidth("100%"); break; case BOTTOM_LEFT: gridlayout.setComponentAlignment(child, Alignment.BOTTOM_LEFT); break; case BOTTOM_RIGHT: gridlayout.setComponentAlignment(child, Alignment.BOTTOM_RIGHT); break; case MIDDLE_CENTER: gridlayout.setComponentAlignment(child, Alignment.MIDDLE_CENTER); break; case MIDDLE_FILL: gridlayout.setComponentAlignment(child, Alignment.MIDDLE_LEFT); child.setWidth("100%"); break; case MIDDLE_LEFT: gridlayout.setComponentAlignment(child, Alignment.MIDDLE_LEFT); break; case MIDDLE_RIGHT: gridlayout.setComponentAlignment(child, Alignment.MIDDLE_RIGHT); break; case TOP_CENTER: gridlayout.setComponentAlignment(child, Alignment.TOP_CENTER); break; case TOP_FILL: gridlayout.setComponentAlignment(child, Alignment.TOP_LEFT); child.setWidth("100%"); break; case TOP_LEFT: gridlayout.setComponentAlignment(child, Alignment.TOP_LEFT); break; case TOP_RIGHT: gridlayout.setComponentAlignment(child, Alignment.TOP_RIGHT); break; case FILL_CENTER: gridlayout.setComponentAlignment(child, Alignment.TOP_CENTER); child.setHeight("100%"); break; case FILL_FILL: gridlayout.setComponentAlignment(child, Alignment.TOP_LEFT); child.setWidth("100%"); child.setHeight("100%"); break; case FILL_LEFT: gridlayout.setComponentAlignment(child, Alignment.TOP_LEFT); child.setHeight("100%"); break; case FILL_RIGHT: gridlayout.setComponentAlignment(child, Alignment.TOP_RIGHT); child.setHeight("100%"); break; default: break; } } }
From source file:org.lunifera.runtime.web.ecview.presentation.vaadin.internal.HorizontalLayoutPresentation.java
License:Open Source License
/** * Sets the alignment to the component.//w w w . j a v a 2 s . c om * * @param child * @param yAlignment */ protected void applyAlignment(Component child, YAlignment yAlignment) { if (yAlignment != null) { child.setWidth("-1%"); child.setHeight("-1%"); switch (yAlignment) { case BOTTOM_CENTER: horizontalLayout.setComponentAlignment(child, Alignment.BOTTOM_CENTER); break; case BOTTOM_FILL: horizontalLayout.setComponentAlignment(child, Alignment.BOTTOM_LEFT); child.setWidth("100%"); break; case BOTTOM_LEFT: horizontalLayout.setComponentAlignment(child, Alignment.BOTTOM_LEFT); break; case BOTTOM_RIGHT: horizontalLayout.setComponentAlignment(child, Alignment.BOTTOM_RIGHT); break; case MIDDLE_CENTER: horizontalLayout.setComponentAlignment(child, Alignment.MIDDLE_CENTER); break; case MIDDLE_FILL: horizontalLayout.setComponentAlignment(child, Alignment.MIDDLE_LEFT); child.setWidth("100%"); break; case MIDDLE_LEFT: horizontalLayout.setComponentAlignment(child, Alignment.MIDDLE_LEFT); break; case MIDDLE_RIGHT: horizontalLayout.setComponentAlignment(child, Alignment.MIDDLE_RIGHT); break; case TOP_CENTER: horizontalLayout.setComponentAlignment(child, Alignment.TOP_CENTER); break; case TOP_FILL: horizontalLayout.setComponentAlignment(child, Alignment.TOP_LEFT); child.setWidth("100%"); break; case TOP_LEFT: horizontalLayout.setComponentAlignment(child, Alignment.TOP_LEFT); break; case TOP_RIGHT: horizontalLayout.setComponentAlignment(child, Alignment.TOP_RIGHT); break; case FILL_CENTER: horizontalLayout.setComponentAlignment(child, Alignment.TOP_CENTER); child.setHeight("100%"); break; case FILL_FILL: horizontalLayout.setComponentAlignment(child, Alignment.TOP_LEFT); child.setWidth("100%"); child.setHeight("100%"); break; case FILL_LEFT: horizontalLayout.setComponentAlignment(child, Alignment.TOP_LEFT); child.setHeight("100%"); break; case FILL_RIGHT: horizontalLayout.setComponentAlignment(child, Alignment.TOP_RIGHT); child.setHeight("100%"); break; default: break; } } }
From source file:org.lunifera.runtime.web.ecview.presentation.vaadin.internal.VerticalLayoutPresentation.java
License:Open Source License
/** * Sets the alignment to the component./*from w w w. j a v a2 s . c om*/ * * @param child * @param yAlignment */ protected void applyAlignment(Component child, YAlignment yAlignment) { if (yAlignment != null) { child.setWidth("-1%"); child.setHeight("-1%"); switch (yAlignment) { case BOTTOM_CENTER: verticalLayout.setComponentAlignment(child, Alignment.BOTTOM_CENTER); break; case BOTTOM_FILL: verticalLayout.setComponentAlignment(child, Alignment.BOTTOM_LEFT); child.setWidth("100%"); break; case BOTTOM_LEFT: verticalLayout.setComponentAlignment(child, Alignment.BOTTOM_LEFT); break; case BOTTOM_RIGHT: verticalLayout.setComponentAlignment(child, Alignment.BOTTOM_RIGHT); break; case MIDDLE_CENTER: verticalLayout.setComponentAlignment(child, Alignment.MIDDLE_CENTER); break; case MIDDLE_FILL: verticalLayout.setComponentAlignment(child, Alignment.MIDDLE_LEFT); child.setWidth("100%"); break; case MIDDLE_LEFT: verticalLayout.setComponentAlignment(child, Alignment.MIDDLE_LEFT); break; case MIDDLE_RIGHT: verticalLayout.setComponentAlignment(child, Alignment.MIDDLE_RIGHT); break; case TOP_CENTER: verticalLayout.setComponentAlignment(child, Alignment.TOP_CENTER); break; case TOP_FILL: verticalLayout.setComponentAlignment(child, Alignment.TOP_LEFT); child.setWidth("100%"); break; case TOP_LEFT: verticalLayout.setComponentAlignment(child, Alignment.TOP_LEFT); break; case TOP_RIGHT: verticalLayout.setComponentAlignment(child, Alignment.TOP_RIGHT); break; case FILL_CENTER: verticalLayout.setComponentAlignment(child, Alignment.TOP_CENTER); child.setHeight("100%"); break; case FILL_FILL: verticalLayout.setComponentAlignment(child, Alignment.TOP_LEFT); child.setWidth("100%"); child.setHeight("100%"); break; case FILL_LEFT: verticalLayout.setComponentAlignment(child, Alignment.TOP_LEFT); child.setHeight("100%"); break; case FILL_RIGHT: verticalLayout.setComponentAlignment(child, Alignment.TOP_RIGHT); child.setHeight("100%"); break; default: break; } } }
From source file:org.openeos.usertask.ui.internal.vaadin.TasksWindow.java
License:Apache License
private Component createTaskSummary(UserTask task) { // TextField name = new TextField("Name"); // name.setValue(task.getName()); // name.setReadOnly(true); // name.setWidth("100%"); TextField priority = new TextField("Priority"); priority.setValue(Integer.toString(task.getPriority())); priority.setReadOnly(true);/* www .j av a2 s. co m*/ TextField status = new TextField("Status"); status.setValue(task.getStatus().getDescription()); status.setReadOnly(true); TextArea description = new TextArea("Description"); description.setSizeFull(); description.setValue(task.getDescription()); description.setReadOnly(true); description.setRows(3); ComponentContainer buttons = createSummaryButtons(task); VerticalLayout secondColumnFields = new VerticalLayout(); secondColumnFields.setMargin(false); secondColumnFields.setSizeFull(); secondColumnFields.addComponent(priority); secondColumnFields.addComponent(status); HorizontalLayout fieldsLayout = new HorizontalLayout(); fieldsLayout.setSizeFull(); fieldsLayout.setMargin(false); fieldsLayout.setSpacing(false); fieldsLayout.addComponent(description); fieldsLayout.addComponent(secondColumnFields); fieldsLayout.setExpandRatio(description, 4.0f); fieldsLayout.setExpandRatio(secondColumnFields, 1.0f); HorizontalLayout mainLayout = new HorizontalLayout(); mainLayout.setMargin(true); mainLayout.setSpacing(false); mainLayout.setSizeFull(); mainLayout.addComponent(fieldsLayout); mainLayout.addComponent(buttons); mainLayout.setComponentAlignment(buttons, Alignment.TOP_LEFT); mainLayout.setExpandRatio(fieldsLayout, 1.0f); Panel panel = new Panel("Summary"); panel.setStyleName("background-transparent"); panel.setContent(mainLayout); return panel; }
From source file:org.opennms.features.vaadin.dashboard.dashlets.KscDashlet.java
License:Open Source License
@Override public DashletComponent getWallboardComponent() { if (m_wallboardComponent == null) { m_wallboardComponent = new AbstractDashletComponent() { private GridLayout m_gridLayout = new GridLayout(); {//from w ww . j a v a 2 s. c o m m_gridLayout.setCaption(getName()); m_gridLayout.setSizeFull(); m_gridLayout.setColumns(1); m_gridLayout.setRows(1); } @Override public void refresh() { m_gridLayout.removeAllComponents(); /** * initializing the parameters */ int columns = 0; int rows = 0; String kscReportName = getDashletSpec().getParameters().get("kscReport"); if (kscReportName == null || "".equals(kscReportName)) { return; } KSC_PerformanceReportFactory kscPerformanceReportFactory = KSC_PerformanceReportFactory .getInstance(); Map<Integer, String> reportsMap = kscPerformanceReportFactory.getReportList(); int kscReportId = -1; for (Map.Entry<Integer, String> entry : reportsMap.entrySet()) { if (kscReportName.equals(entry.getValue())) { kscReportId = entry.getKey(); break; } } if (kscReportId == -1) { return; } Report kscReport = kscPerformanceReportFactory.getReportByIndex(kscReportId); columns = kscReport.getGraphs_per_line(); if (columns == 0) { columns = 1; } rows = kscReport.getGraphCount() / columns; if (rows == 0) { rows = 1; } if (kscReport.getGraphCount() % columns > 0) { rows++; } /** * setting new columns/rows */ m_gridLayout.setColumns(columns); m_gridLayout.setRows(rows); int i = 0; /** * adding the components */ Page.getCurrent().getStyles().add( ".box { margin: 5px; background-color: #444; border: 1px solid #999; border-top: 0; overflow: auto; }"); Page.getCurrent().getStyles().add( ".text { color:#ffffff; line-height: 11px; font-size: 9px; font-family: 'Lucida Grande', Verdana, sans-serif; font-weight: bold; }"); Page.getCurrent().getStyles().add(".margin { margin:5px; }"); for (int y = 0; y < m_gridLayout.getRows(); y++) { for (int x = 0; x < m_gridLayout.getColumns(); x++) { if (i < kscReport.getGraphCount()) { Graph graph = kscReport.getGraph(i); Map<String, String> data = getDataForResourceId(graph.getNodeId(), graph.getResourceId()); Calendar beginTime = Calendar.getInstance(); Calendar endTime = Calendar.getInstance(); KSC_PerformanceReportFactory.getBeginEndTime(graph.getTimespan(), beginTime, endTime); GraphContainer graphContainer = getGraphContainer(graph, beginTime.getTime(), endTime.getTime()); VerticalLayout verticalLayout = new VerticalLayout(); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.addStyleName("box"); horizontalLayout.setWidth("100%"); horizontalLayout.setHeight("42px"); VerticalLayout leftLayout = new VerticalLayout(); leftLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT); leftLayout.addStyleName("margin"); Label labelTitle; if (graph.getTitle() == null || "".equals(graph.getTitle())) { labelTitle = new Label(" "); labelTitle.setContentMode(ContentMode.HTML); } else { labelTitle = new Label(graph.getTitle()); } labelTitle.addStyleName("text"); Label labelFrom = new Label("From: " + beginTime.getTime().toString()); labelFrom.addStyleName("text"); Label labelTo = new Label("To: " + endTime.getTime().toString()); labelTo.addStyleName("text"); Label labelNodeLabel = new Label(data.get("nodeLabel")); labelNodeLabel.addStyleName("text"); Label labelResourceLabel = new Label( data.get("resourceTypeLabel") + ": " + data.get("resourceLabel")); labelResourceLabel.addStyleName("text"); leftLayout.addComponent(labelTitle); leftLayout.addComponent(labelFrom); leftLayout.addComponent(labelTo); VerticalLayout rightLayout = new VerticalLayout(); rightLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT); rightLayout.addStyleName("margin"); rightLayout.addComponent(labelNodeLabel); rightLayout.addComponent(labelResourceLabel); horizontalLayout.addComponent(leftLayout); horizontalLayout.addComponent(rightLayout); horizontalLayout.setExpandRatio(leftLayout, 1.0f); horizontalLayout.setExpandRatio(rightLayout, 1.0f); verticalLayout.addComponent(horizontalLayout); verticalLayout.addComponent(graphContainer); verticalLayout.setWidth(DEFAULT_GRAPH_WIDTH_PX, Unit.PIXELS); m_gridLayout.addComponent(verticalLayout, x, y); verticalLayout.setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER); verticalLayout.setComponentAlignment(graphContainer, Alignment.MIDDLE_CENTER); m_gridLayout.setComponentAlignment(verticalLayout, Alignment.MIDDLE_CENTER); } i++; } } } @Override public Component getComponent() { return m_gridLayout; } }; } return m_wallboardComponent; }
From source file:org.opennms.features.vaadin.dashboard.dashlets.KscDashlet.java
License:Open Source License
@Override public DashletComponent getDashboardComponent() { if (m_dashboardComponent == null) { m_dashboardComponent = new AbstractDashletComponent() { private VerticalLayout m_verticalLayout = new VerticalLayout(); {/*from www. j a v a 2 s .c o m*/ m_verticalLayout.setCaption(getName()); m_verticalLayout.setSizeFull(); } @Override public void refresh() { m_verticalLayout.removeAllComponents(); String kscReportName = getDashletSpec().getParameters().get("kscReport"); if (kscReportName == null || "".equals(kscReportName)) { return; } KSC_PerformanceReportFactory kscPerformanceReportFactory = KSC_PerformanceReportFactory .getInstance(); Map<Integer, String> reportsMap = kscPerformanceReportFactory.getReportList(); int kscReportId = -1; for (Map.Entry<Integer, String> entry : reportsMap.entrySet()) { if (kscReportName.equals(entry.getValue())) { kscReportId = entry.getKey(); break; } } if (kscReportId == -1) { return; } Report kscReport = kscPerformanceReportFactory.getReportByIndex(kscReportId); Page.getCurrent().getStyles().add( ".box { margin: 5px; background-color: #444; border: 1px solid #999; border-top: 0; overflow: auto; }"); Page.getCurrent().getStyles().add( ".text { color:#ffffff; line-height: 11px; font-size: 9px; font-family: 'Lucida Grande', Verdana, sans-serif; font-weight: bold; }"); Page.getCurrent().getStyles().add(".margin { margin:5px; }"); Accordion accordion = new Accordion(); accordion.setSizeFull(); m_verticalLayout.addComponent(accordion); for (Graph graph : kscReport.getGraph()) { Map<String, String> data = getDataForResourceId(graph.getNodeId(), graph.getResourceId()); Calendar beginTime = Calendar.getInstance(); Calendar endTime = Calendar.getInstance(); KSC_PerformanceReportFactory.getBeginEndTime(graph.getTimespan(), beginTime, endTime); GraphContainer graphContainer = getGraphContainer(graph, beginTime.getTime(), endTime.getTime()); VerticalLayout verticalLayout = new VerticalLayout(); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.addStyleName("box"); horizontalLayout.setWidth("100%"); horizontalLayout.setHeight("42px"); VerticalLayout leftLayout = new VerticalLayout(); leftLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT); leftLayout.addStyleName("margin"); Label labelTitle; if (graph.getTitle() == null || "".equals(graph.getTitle())) { labelTitle = new Label(" "); labelTitle.setContentMode(ContentMode.HTML); } else { labelTitle = new Label(graph.getTitle()); } labelTitle.addStyleName("text"); Label labelFrom = new Label("From: " + beginTime.getTime().toString()); labelFrom.addStyleName("text"); Label labelTo = new Label("To: " + endTime.getTime().toString()); labelTo.addStyleName("text"); Label labelNodeLabel = new Label(data.get("nodeLabel")); labelNodeLabel.addStyleName("text"); Label labelResourceLabel = new Label( data.get("resourceTypeLabel") + ": " + data.get("resourceLabel")); labelResourceLabel.addStyleName("text"); leftLayout.addComponent(labelTitle); leftLayout.addComponent(labelFrom); leftLayout.addComponent(labelTo); VerticalLayout rightLayout = new VerticalLayout(); rightLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT); rightLayout.addStyleName("margin"); rightLayout.addComponent(labelNodeLabel); rightLayout.addComponent(labelResourceLabel); horizontalLayout.addComponent(leftLayout); horizontalLayout.addComponent(rightLayout); horizontalLayout.setExpandRatio(leftLayout, 1.0f); horizontalLayout.setExpandRatio(rightLayout, 1.0f); verticalLayout.addComponent(horizontalLayout); verticalLayout.addComponent(graphContainer); verticalLayout.setWidth(DEFAULT_GRAPH_WIDTH_PX, Unit.PIXELS); accordion.addTab(verticalLayout, data.get("nodeLabel") + "/" + data.get("resourceTypeLabel") + ": " + data.get("resourceLabel")); verticalLayout.setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER); verticalLayout.setComponentAlignment(graphContainer, Alignment.MIDDLE_CENTER); verticalLayout.setMargin(true); } } @Override public Component getComponent() { return m_verticalLayout; } }; } return m_dashboardComponent; }
From source file:org.opennms.features.vaadin.dashboard.dashlets.RrdDashlet.java
License:Open Source License
/** * Returns the graph component for a given graph of the {@link DashletSpec}. * * @param i the entry id//from w ww . ja va 2 s. c o m * @param width the width * @param height the height * @param timeFrameType the timeframe type * @param timeFrameValue the timeframe value * @return the component */ private Component getGraphComponent(int i, int width, int height, int timeFrameType, int timeFrameValue) { String graphTitle = getDashletSpec().getParameters().get("graphLabel" + i); String graphName = RrdGraphHelper .getGraphNameFromQuery(getDashletSpec().getParameters().get("graphUrl" + i)); String resourceId = getDashletSpec().getParameters().get("resourceId" + i); GraphContainer graph = new GraphContainer(graphName, resourceId); graph.setTitle(graphTitle); // Setup the time span Calendar cal = new GregorianCalendar(); graph.setEnd(cal.getTime()); cal.add(timeFrameType, -timeFrameValue); graph.setStart(cal.getTime()); // Use all of the available width graph.setWidthRatio(1.0d); VerticalLayout verticalLayout = new VerticalLayout(); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.addStyleName("box"); horizontalLayout.setWidth("100%"); horizontalLayout.setHeight("42px"); VerticalLayout leftLayout = new VerticalLayout(); leftLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT); leftLayout.addStyleName("margin"); Label labelFrom = new Label(getDashletSpec().getParameters().get("nodeLabel" + i)); labelFrom.addStyleName("text"); Label labelTo = new Label(getDashletSpec().getParameters().get("resourceTypeLabel" + i) + ": " + getDashletSpec().getParameters().get("resourceLabel" + i)); labelTo.addStyleName("text"); leftLayout.addComponent(labelFrom); leftLayout.addComponent(labelTo); horizontalLayout.addComponent(leftLayout); horizontalLayout.setExpandRatio(leftLayout, 1.0f); verticalLayout.addComponent(horizontalLayout); verticalLayout.addComponent(graph); verticalLayout.setWidth(width, Unit.PIXELS); verticalLayout.setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER); verticalLayout.setComponentAlignment(graph, Alignment.MIDDLE_CENTER); verticalLayout.setMargin(true); return verticalLayout; }