Java tutorial
package com.grimesco.gcocentralapp; import com.grimesco.gcocentralapp.Axys.AxysView; import com.grimesco.gcocentralapp.Fidelity.FidelityView; import com.grimesco.gcocentralapp.Resource.ResourceView; import com.grimesco.gcocentralapp.Salentica.SalenticaView; import com.grimesco.gcocentralapp.Schwab.SchwabView; import com.grimesco.gcocentralapp.TD.TDView; import com.grimesco.gcocentralapp.Chart.AccountView; import com.grimesco.gcocentralapp.Chart.ChartView; import com.vaadin.ui.UI; import com.vaadin.annotations.Theme; import com.vaadin.annotations.Title; import com.vaadin.navigator.Navigator; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.server.VaadinRequest; import com.vaadin.ui.Accordion; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; import com.vaadin.ui.Panel; import com.vaadin.ui.TabSheet; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.themes.Runo; //--@Configurable(preConstruction = true) //@Theme("runo") //-- make sure "runo" is the low case @Theme("dawn") @Title("GCOcentral") public class MainApplication extends UI { private static final long serialVersionUID = 511085335415683713L; Navigator navigator; //-- starting Vaadin 7 use Navigator instead protected static final String TDVIEW = "TDview"; protected static final String FIVIEW = "Fidelityview"; protected static final String SWVIEW = "Schwabview"; protected static final String AXYSVIEW = "AXYSview"; protected static final String SALENTICAVIEW = "Salenticaview"; protected static final String HOMEVIEW = "Homeview"; protected static final String CHARTVIEW = "Chartview"; protected static final String ACCOUNTVIEW = "Accountview"; protected static final String RESOURCEVIEW = "Resourceview"; //-- Build the left pane components public final HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(); public Panel leftPanel = new Panel("Menu"); public VerticalLayout rightLayout = new VerticalLayout(); //-- use layout instead of panel to get rid of border public Accordion accordion = new Accordion(); public TabSheet tdView = new TDView(); public TabSheet fidelityView = new FidelityView(); public TabSheet schwabView = new SchwabView(); public TabSheet axysView = new AxysView(); public TabSheet salenticaView = new SalenticaView(); public TabSheet dashboardView = new ChartView(); public TabSheet accountView = new AccountView(); public TabSheet resourceView = new ResourceView(); //-- vertical layout components private VerticalLayout rootLayout = new VerticalLayout(); //-- main layout public VerticalLayout custodianMenuLayout = new VerticalLayout(); public VerticalLayout databaseMenuLayout = new VerticalLayout(); public VerticalLayout chartMenuLayout = new VerticalLayout(); //-- Database sync Menu button public Button Axysbutton = new Button("Sync AXYS db"); public Button Salenticabutton = new Button("Sync Salentica db"); //-- Custodian Menu button public Button TDbutton = new Button("TD"); public Button Fidelitybutton = new Button("Fidelity"); public Button Schwabbutton = new Button("Schwab"); public Button Resourcebutton = new Button("Resources"); //-- Chart Menu button public Button Chart1button = new Button("Chart"); public Button AccountViewbutton = new Button("Account View"); public Label titleLabel = new Label("Welcome to GCO central"); public Label sloganLabel = new Label("Portfolio Accounting System for Grimes & Company"); public Label spacer = new Label(""); //=========================================================================================== //-- init() method //=========================================================================================== @Override protected void init(VaadinRequest request) { //System.setProperty("vaadin.charts.developer.license", "b8893a97-13d3-4ff8-ab9f-93560af33972"); getPage().setTitle("GCOcentral"); initLayout(); initButtons(); //-- Create a navigator to control the vies navigator = new Navigator(this, rightLayout); //-- Create and register the views navigator.addView("", new StartView()); //navigator.addView("", (View) dashboardView); navigator.addView(AXYSVIEW, (View) axysView); navigator.addView(SALENTICAVIEW, (View) salenticaView); navigator.addView(TDVIEW, (View) tdView); navigator.addView(FIVIEW, (View) fidelityView); navigator.addView(SWVIEW, (View) schwabView); navigator.addView(RESOURCEVIEW, (View) resourceView); navigator.addView(CHARTVIEW, (View) dashboardView); navigator.addView(ACCOUNTVIEW, (View) accountView); } //-- end of init function private void initLayout() { setContent(rootLayout); rootLayout.setMargin(true); rootLayout.setSizeFull(); titleLabel.addStyleName(Runo.LABEL_H1); titleLabel.setSizeUndefined(); sloganLabel.addStyleName(Runo.LABEL_SMALL); sloganLabel.setSizeUndefined(); rootLayout.addComponent(titleLabel); rootLayout.setComponentAlignment(titleLabel, Alignment.TOP_CENTER); rootLayout.addComponent(sloganLabel); rootLayout.setComponentAlignment(sloganLabel, Alignment.TOP_CENTER); spacer.setHeight("20px"); rootLayout.addComponent(spacer); splitPanel.setStyleName(Runo.SPLITPANEL_REDUCED); splitPanel.setSplitPosition(25, Unit.PERCENTAGE); splitPanel.setLocked(false); rootLayout.addComponent(splitPanel); rootLayout.setExpandRatio(splitPanel, 1); leftPanel.setSizeFull(); splitPanel.setFirstComponent(leftPanel); accordion.setSizeFull(); leftPanel.setContent(accordion); //-- add custodian menus this.custodianMenuLayout.setMargin(true); // Have margin on all sides around the layout this.custodianMenuLayout.setSpacing(true); // add spacing this.custodianMenuLayout.addComponent(TDbutton); this.custodianMenuLayout.addComponent(Schwabbutton); this.custodianMenuLayout.addComponent(Fidelitybutton); this.custodianMenuLayout.addComponent(Resourcebutton); //-- add database sync menus this.databaseMenuLayout.setMargin(true); // Have margin on all sides around the layout this.databaseMenuLayout.setSpacing(true); // add spacing this.databaseMenuLayout.addComponent(Axysbutton); this.databaseMenuLayout.addComponent(Salenticabutton); //-- add chart menus this.chartMenuLayout.setMargin(true); // Have margin on all sides around the layout this.chartMenuLayout.setSpacing(true); // add spacing this.chartMenuLayout.addComponent(Chart1button); this.chartMenuLayout.addComponent(AccountViewbutton); accordion.addTab(this.databaseMenuLayout, "Database Sync", null); accordion.addTab(this.custodianMenuLayout, "Transactions by Custodian", null); accordion.addTab(this.chartMenuLayout, "Charts", null); accordion.addTab(new Label(""), "Preferences", null); accordion.addTab(new Label(""), "Quick Search", null); splitPanel.setSecondComponent(rightLayout); splitPanel.setLocked(false); } private void initButtons() { //-- configure database sync menu buttons Axysbutton.setWidth("150px"); Axysbutton.setStyleName(Runo.BUTTON_DEFAULT); Salenticabutton.setWidth("150px"); Salenticabutton.setStyleName(Runo.BUTTON_DEFAULT); //-- configure custodian menu buttons TDbutton.setWidth("150px"); TDbutton.setStyleName(Runo.BUTTON_DEFAULT); Fidelitybutton.setWidth("150px"); Fidelitybutton.setStyleName(Runo.BUTTON_DEFAULT); Schwabbutton.setWidth("150px"); Schwabbutton.setStyleName(Runo.BUTTON_DEFAULT); Resourcebutton.setWidth("150px"); Resourcebutton.setStyleName(Runo.BUTTON_DEFAULT); //------------------------------------------- //-- listerner for TDbutton ( for menu ) //------------------------------------------- this.TDbutton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { //tdView.setSizeFull(); //splitPanel.setSecondComponent(tdView); navigator.navigateTo(TDVIEW); } }); //------------------------------------------- //-- listerner for Fidelitybutton ( for menu ) //------------------------------------------- this.Fidelitybutton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { //fidelityView.setSizeFull(); //splitPanel.setSecondComponent(fidelityView); navigator.navigateTo(FIVIEW); } }); //------------------------------------------- //-- listerner for Schwabbutton ( for menu ) //------------------------------------------- this.Schwabbutton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { //schwabView.setSizeFull(); //splitPanel.setSecondComponent(schwabView); navigator.navigateTo(SWVIEW); } }); //------------------------------------------- //-- listerner for Resourcebutton ( for menu ) //------------------------------------------- this.Resourcebutton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { navigator.navigateTo(RESOURCEVIEW); } }); //------------------------------------------- //-- listerner for Axysbutton ( for menu ) //------------------------------------------- this.Axysbutton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { //axysView.setSizeFull(); //splitPanel.setSecondComponent(axysView); navigator.navigateTo(AXYSVIEW); } }); //------------------------------------------- //-- listerner for Salenticabutton ( for menu ) //------------------------------------------- this.Salenticabutton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { navigator.navigateTo(SALENTICAVIEW); } }); //------------------------------------------- //-- listerner for Chart1button ( for menu ) //------------------------------------------- this.Chart1button.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { navigator.navigateTo(CHARTVIEW); } }); //------------------------------------------- //-- listerner for AccountViewbutton ( for menu ) //------------------------------------------- this.AccountViewbutton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { navigator.navigateTo(ACCOUNTVIEW); } }); } //-- start view for the GCOcentral application public class StartView extends VerticalLayout implements View { //-- this is rootLayout private static final long serialVersionUID = -3398565663865641952L; //-- Constructor public StartView() { setSizeFull(); } @Override public void enter(ViewChangeEvent event) { Notification.show("Welcome to the GCOcentral app"); } } } //-- end of Applicaction class