Example usage for com.vaadin.ui Button setStyleName

List of usage examples for com.vaadin.ui Button setStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui Button setStyleName.

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:eu.livotov.labs.webskel.app.MainUI.java

License:Apache License

protected void init(final VaadinRequest vaadinRequest) {
    Label hello = new Label("Hello Web Skeleton WebApp User !");
    hello.setStyleName(ValoTheme.LABEL_H1);

    Button b = new Button("Log me now !");
    b.setStyleName(ValoTheme.BUTTON_DANGER);
    b.addClickListener(new Button.ClickListener() {
        public void buttonClick(final Button.ClickEvent event) {
            logsDao.addLogEntry("Hello, it is me you looking for...");
        }/*from  w ww  .  jav  a2  s  .  c om*/
    });

    VerticalLayout root = new VerticalLayout();
    root.setSizeFull();
    root.setMargin(true);
    root.setSpacing(true);
    root.addComponent(hello);
    root.addComponent(b);
    root.setExpandRatio(hello, 1.0f);

    setContent(root);
}

From source file:eu.lod2.LOD2Demo.java

License:Apache License

@Override
public void init() {
    state = new LOD2DemoState();

    mainWindow = new Window("LOD2 Prototype");
    setTheme("lod2");
    mainContainer = new VerticalLayout();
    mainWindow.addComponent(mainContainer);
    mainContainer.setSizeFull();/*from w  w w  . jav a2 s .  co  m*/

    final AbsoluteLayout welcomeSlagzin = new AbsoluteLayout();
    welcomeSlagzin.setWidth("370px");
    welcomeSlagzin.setHeight("75px");
    final Link homepage = new Link();
    homepage.setResource(new ExternalResource("http://lod2.eu"));
    final ThemeResource logo = new ThemeResource("app_images/logo-lod2-small.png");
    homepage.setIcon(logo);
    welcomeSlagzin.addComponent(homepage, "top:0px; left:5px");
    homepage.setSizeFull();
    homepage.addStyleName("logo");

    // the current graph as label
    /*
    currentgraphlabel = new Label("no current graph selected");
    currentgraphlabel.addStyleName("currentgraphlabel");
    */

    Button homeb = new Button("home");
    homeb.setDebugId(this.getClass().getSimpleName() + "_homeb");
    homeb.addListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            home();
        }
    });
    homeb.setStyleName(BaseTheme.BUTTON_LINK);
    homeb.addStyleName("currentgraphlabel");

    currentgraphlabel = state.cGraph;
    currentgraphlabel.addStyleName("currentgraphlabel");
    // Create an horizontal container
    HorizontalLayout welcomeContainer = new HorizontalLayout();

    //menubarContainer.addComponent(lod2logo);
    welcomeContainer.addComponent(welcomeSlagzin);
    welcomeContainer.setComponentAlignment(welcomeSlagzin, Alignment.TOP_LEFT);
    welcomeContainer.addComponent(homeb);
    welcomeContainer.setComponentAlignment(homeb, Alignment.TOP_RIGHT);
    welcomeContainer.addComponent(currentgraphlabel);
    welcomeContainer.setComponentAlignment(currentgraphlabel, Alignment.TOP_RIGHT);

    final VerticalLayout welcome = new VerticalLayout();
    welcome.addComponent(welcomeContainer);
    // unfortunately, we need to be able to build components from outside
    // this initialization function and the welcome component needs to be
    // resized properly afterward
    this.welcome = welcome;

    mainContainer.addComponent(welcome);

    //************************************************************************
    //  menu bar style
    //
    MenuBar menubar = new MenuBar();
    menubar.setDebugId(this.getClass().getSimpleName() + "_menubar");

    // First define all menu commands

    MenuBar.Command me1c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            ELoadRDFFile content = new ELoadRDFFile(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command me3c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            EXML me3c_content = new EXML(state);
            workspace.addComponent(me3c_content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            me3c_content.setSizeFull();
        }
    };
    MenuBar.Command me3cbis = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            EXMLExtended content = new EXMLExtended(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
        }
    };

    MenuBar.Command me4c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            ESpotlight content = new ESpotlight(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command me5c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            EPoolPartyExtractor me5c_content = new EPoolPartyExtractor(state);
            workspace.addComponent(me5c_content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            me5c_content.setHeight("90%");
        }
    };

    MenuBar.Command me6c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            D2RCordis content = new D2RCordis(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command me7c_1 = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            IframedUrl content = new IframedUrl(state, "http://publicdata.eu/dataset?res_format=RDF&q=rdf");
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command me7c_2 = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            IframedUrl content = new IframedUrl(state, "http://datahub.io/dataset?groups=lodcloud");
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command me8c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            EURL content = new EURL(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setHeight("90%");
        }
    };

    MenuBar.Command me9c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            EPoolPartyLabel content = new EPoolPartyLabel(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setHeight("90%");
        }
    };

    MenuBar.Command silk = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            LinkingTab lsilk = new LinkingTab(state);
            workspace.addComponent(lsilk);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            lsilk.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(lsilk, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command limes = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            Limes limes = new Limes(state);
            workspace.addComponent(limes);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            limes.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(limes, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command sameaslinking = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            SameAsLinking content = new SameAsLinking(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
        }
    };

    MenuBar.Command ore = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            ORE content = new ORE(state);
            workspace.addComponent(content);
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command lodrefine = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            Lodrefine content = new Lodrefine(state);
            workspace.addComponent(content);
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mconfiguration = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            ConfigurationTab content = new ConfigurationTab(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setHeight("500px");
        }
    };

    MenuBar.Command mabout = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            About content = new About(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
        }
    };

    MenuBar.Command mau = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            OntoWiki content = new OntoWiki(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mq1c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            SesameSPARQL content = new SesameSPARQL(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mq2c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            OntoWikiQuery content = new OntoWikiQuery(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mq3c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            VirtuosoSPARQL content = new VirtuosoSPARQL(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mq4c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            VirtuosoISPARQL content = new VirtuosoISPARQL(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    /** Deprecated temporarily
    MenuBar.Command mq5c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            GeoSpatial content = new GeoSpatial(state);
            workspace.addComponent(content);
          resetSizeFull(workspace);
            welcome.setHeight("110px");
          workspace.setSizeFull();
          workspace.setHeight("500px");
          workspace.setExpandRatio(content,1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
        }
    };
            
    MenuBar.Command mq_s_6c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
           workspace.removeAllComponents();
            Sparqled content = new Sparqled(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };
            
    MenuBar.Command mq_s_7c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
           workspace.removeAllComponents();
            SparqledManager content = new SparqledManager(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };
    */

    MenuBar.Command mo1c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            SameAs content = new SameAs(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setHeight("500px");
        }
    };

    /** Deprecated temporarily
    MenuBar.Command mo2c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            Sigma content = new Sigma(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };
    */

    MenuBar.Command mo3c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            LODCloud content = new LODCloud(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mo4c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            DBpedia content = new DBpedia(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mo5c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            SPARQLPoolParty content = new SPARQLPoolParty(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mo6c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            OnlinePoolParty content = new OnlinePoolParty(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mo7c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            MondecaSPARQLList content = new MondecaSPARQLList(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mo8c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            CKAN content = new CKAN(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mo9c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            IframedUrl content = new IframedUrl(state, "http://publicdata.eu");
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    /** Deprecated temporarily
    MenuBar.Command mo10c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            IframedUrl content = new IframedUrl(state, "http://sig.ma");
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };
    */

    MenuBar.Command mo11c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            IframedUrl content = new IframedUrl(state, "http://sindice.com");
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command userinfoCommand = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            showInWorkspace(/*new Authenticator(*/new UserInformation(state)/*, state)*/);
        }
    };

    MenuBar.Command publishCommand = new Command() {
        public void menuSelected(MenuItem selectedItem) {
            // publishing should be protected with an authenticator, otherwise a store could be published
            // without provenance information!
            showInWorkspace(/*new Authenticator(*/new CKANPublisherPanel(state)/*, state)*/);
        }
    };

    MenuBar.Command mDeleteGraphs = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            showInWorkspace(/*new Authenticator(*/new DeleteGraphs(state)/*, state)*/);
        }
    };

    // Secondly define menu layout
    // root menu's
    MenuBar.MenuItem extraction = menubar.addItem("Extraction & Loading", null, null);
    MenuBar.MenuItem querying = menubar.addItem("Querying & Exploration", null, null);
    MenuBar.MenuItem authoring = menubar.addItem("Authoring", null, null);
    MenuBar.MenuItem linking = menubar.addItem("Linking", null, null);
    MenuBar.MenuItem enrichment = menubar.addItem("Enrichment & Data Cleaning", null, null);
    MenuBar.MenuItem onlinetools = menubar.addItem("Online Tools & Services", null, null);
    MenuBar.MenuItem configuration = menubar.addItem("Configuration", null, null);

    // sub menu's 
    MenuBar.MenuItem me1 = extraction.addItem("Upload RDF file or RDF from URL", null, me1c);
    //       MenuBar.MenuItem me1b = extraction.addItem("Import RDF data from URL", null, me8c);
    MenuBar.MenuItem me2_1 = extraction.addItem("Load RDF data from publicdata.eu", null, me7c_1);
    MenuBar.MenuItem me2_2 = extraction.addItem("Load LOD cloud RDF data from the Data Hub", null, me7c_2);
    MenuBar.MenuItem me3 = extraction.addItem("Extract RDF from XML", null, null);
    MenuBar.MenuItem me6 = extraction.addItem("Extract RDF from SQL", null, me6c);
    MenuBar.MenuItem me4 = extraction.addItem("Extract RDF from text w.r.t. DBpedia", null, me4c);
    MenuBar.MenuItem me5 = extraction.addItem("Extract RDF from text w.r.t. a controlled vocabulary", null,
            me5c);
    //       MenuBar.MenuItem me9  = extraction.addItem("Complete RDF w.r.t. a controlled vocabulary", null, me9c);

    MenuBar.MenuItem exml = me3.addItem("Basic extraction", null, me3c);
    MenuBar.MenuItem extended = me3.addItem("Extended extraction", null, me3cbis);

    MenuBar.MenuItem mq1 = querying.addItem("SPARQL querying", null, null);
    // Deprecated temporarily
    //MenuBar.MenuItem mq2 = querying.addItem("Sig.ma EE", null, mo2c);
    //MenuBar.MenuItem mq3 = querying.addItem("Geo-spatial exploration", null, mq5c);
    // TODO: replace this with a menu with two entries, editor and manager, after stephane fixes the manager
    //MenuBar.MenuItem mqs5 = mq1.addItem("SparQLed - Assisted Querying", null, mq_s_6c);
    //MenuBar.MenuItem mqsparqled1 = mqs5.addItem("Use currently selected graph", null, mq_s_6c);
    //MenuBar.MenuItem mqsparqled2 = mqs5.addItem("Use manager to calculate summary graph", null, mq_s_7c);
    //MenuBar.MenuItem mqs1 = mq1.addItem("Direct via Sesame API", null, mq1c);
    MenuBar.MenuItem mqs2 = mq1.addItem("OntoWiki SPARQL endpoint", null, mq2c);
    MenuBar.MenuItem mqs3 = mq1.addItem("Virtuoso SPARQL endpoint", null, mq3c);
    MenuBar.MenuItem mqs4 = mq1.addItem("Virtuoso interactive SPARQL endpoint", null, mq4c);

    MenuBar.MenuItem ma = authoring.addItem("OntoWiki", null, mau);
    MenuBar.MenuItem publishing = authoring.addItem("Publish to CKAN", null, publishCommand);

    MenuBar.MenuItem linking1 = linking.addItem("Silk", null, silk);
    MenuBar.MenuItem linking2 = linking.addItem("Limes", null, limes);
    MenuBar.MenuItem linking3 = linking.addItem("SameAs Linking", null, sameaslinking);

    MenuBar.MenuItem enrichment1 = enrichment.addItem("ORE", null, ore);
    MenuBar.MenuItem enrichment2 = enrichment.addItem("LOD enabled Refine", null, lodrefine);

    MenuBar.MenuItem sameAs = onlinetools.addItem("SameAs", null, mo1c);
    MenuBar.MenuItem sindice = onlinetools.addItem("Sindice", null, mo11c);
    //Deprecated temporarily
    //MenuBar.MenuItem sigmaOnline  = onlinetools.addItem("Sigma", null, mo10c);
    MenuBar.MenuItem ckan = onlinetools.addItem("CKAN", null, mo8c);
    MenuBar.MenuItem publicdata = onlinetools.addItem("Europe's Public Data", null, mo9c);
    MenuBar.MenuItem poolparty = onlinetools.addItem("PoolParty", null, mo6c);
    MenuBar.MenuItem sparqlonline = onlinetools.addItem("Online SPARQL endpoints", null, null);
    MenuBar.MenuItem lodcloud = sparqlonline.addItem("LOD cloud", null, mo3c);
    MenuBar.MenuItem dbpedia = sparqlonline.addItem("DBpedia", null, mo4c);
    MenuBar.MenuItem sparqlpoolparty = sparqlonline.addItem("PoolParty SPARQL endpoint", null, mo5c);
    MenuBar.MenuItem mondecalist = sparqlonline.addItem("Mondeca SPARQL endpoint Collection", null, mo7c);

    MenuBar.MenuItem conf = configuration.addItem("Demonstrator configuration", null, mconfiguration);
    MenuBar.MenuItem userconf = configuration.addItem("UserConfiguration", null, userinfoCommand);
    MenuBar.MenuItem about = configuration.addItem("About", null, mabout);
    MenuBar.MenuItem delgraphs = configuration.addItem("Delete Graphs", null, mDeleteGraphs);

    HorizontalLayout menubarContainer = new HorizontalLayout();
    menubarContainer.addComponent(menubar);
    menubarContainer.addStyleName("menubarContainer");
    menubarContainer.setWidth("100%");
    welcome.addComponent(menubarContainer);
    welcome.setHeight("110px");

    //************************************************************************
    // add workspace
    workspace = new VerticalLayout();

    mainContainer.addComponent(workspace);

    //create login/logout component that shows currently logged in user
    LoginStatus login = new LoginStatus(state, this.workspace);
    welcomeContainer.addComponent(login);
    welcomeContainer.setComponentAlignment(login, Alignment.TOP_RIGHT);
    welcomeContainer.setWidth("100%");

    /*
    workspace.setHeight("80%");
            
    HorizontalLayout introH = new HorizontalLayout();
    Embedded lod2cycle = new Embedded("", new ThemeResource("app_images/lod-lifecycle-small.png"));
    lod2cycle.setMimeType("image/png");
    introH.addComponent(lod2cycle);
    introH.setComponentAlignment(lod2cycle, Alignment.MIDDLE_LEFT);
            
    VerticalLayout introV =  new VerticalLayout();
    introH.addComponent(introV);
            
    Label introtextl =  new Label(introtext, Label.CONTENT_XHTML);
    introV.addComponent(introtextl);
    introtextl.setWidth("400px");
            
    HorizontalLayout introVH =  new HorizontalLayout();
    introV.addComponent(introVH);
            
    Embedded euflag = new Embedded("", new ThemeResource("app_images/eu-flag.gif"));
    euflag.setMimeType("image/gif");
    introVH.addComponent(euflag);
    euflag.addStyleName("eugif");
    euflag.setHeight("50px");
    Embedded fp7 = new Embedded("", new ThemeResource("app_images/fp7-gen-rgb_small.gif"));
    fp7.setMimeType("image/gif");
    fp7.addStyleName("eugif");
    fp7.setHeight("50px");
    introVH.addComponent(fp7);
            
    workspace.addComponent(introH);
    */
    home();

    // Create a tracker for the demo.lod2.eu domain.
    if (!state.googleAnalyticsID.equals("")) {
        //            GoogleAnalyticsTracker tracker = new GoogleAnalyticsTracker("UA-26375798-1", "demo.lod2.eu");
        GoogleAnalyticsTracker tracker = new GoogleAnalyticsTracker(state.googleAnalyticsID,
                state.googleAnalyticsDomain);
        mainWindow.addComponent(tracker);
        tracker.trackPageview("/lod2statworkbench");
    }
    ;

    setMainWindow(mainWindow);

    //       mainWindow.setExpandRatio(workspace, 1.0f);

    if (!state.InitStatus) {
        mainWindow.showNotification("Initialization Demonstration Failed", state.ErrorMessage,
                Notification.TYPE_ERROR_MESSAGE);
    }
    ;

}

From source file:eu.lod2.stat.StatLOD2Demo.java

License:Apache License

@Override
public void init() {
    ensureState();//from  w  ww. j  ava2 s . c om

    customComponentFactory = new CustomComponentFactory(state);

    mainWindow = new Window("LOD2 Statistical Workbench DEMO");
    setTheme("lod2");
    mainContainer = new VerticalLayout();
    mainWindow.addComponent(mainContainer);
    mainContainer.setSizeFull();

    final AbsoluteLayout welcomeSlagzin = new AbsoluteLayout();
    welcomeSlagzin.setWidth("370px");
    welcomeSlagzin.setHeight("75px");
    final Link homepage = new Link();
    homepage.setResource(new ExternalResource("http://lod2.eu"));
    final ThemeResource logo = new ThemeResource("app_images/logo-lod2-small.png");
    homepage.setIcon(logo);
    welcomeSlagzin.addComponent(homepage, "top:0px; left:5px");
    homepage.setSizeFull();
    homepage.addStyleName("logo");

    // the current graph as label
    /*
    currentgraphlabel = new Label("no current graph selected");
    currentgraphlabel.addStyleName("currentgraphlabel");
    */

    Button homeb = new Button("home");
    homeb.setDebugId(this.getClass().getSimpleName() + "_homeb");
    homeb.addListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            home();
        }
    });
    homeb.setStyleName(BaseTheme.BUTTON_LINK);
    homeb.addStyleName("currentgraphlabel");

    currentgraphlabel = state.cGraph;
    currentgraphlabel.addStyleName("currentgraphlabel");
    // Create an horizontal container
    HorizontalLayout welcomeContainer = new HorizontalLayout();
    HorizontalLayout stateContainer = new HorizontalLayout();
    VerticalLayout toolsContainer = new VerticalLayout();
    toolsContainer.setWidth("100%");
    welcomeContainer.setWidth("100%");

    //menubarContainer.addComponent(lod2logo);
    welcomeContainer.addComponent(welcomeSlagzin);
    welcomeContainer.addComponent(toolsContainer);
    toolsContainer.addComponent(stateContainer);
    welcomeContainer.setComponentAlignment(welcomeSlagzin, Alignment.TOP_LEFT);
    stateContainer.addComponent(homeb);
    welcomeContainer.setComponentAlignment(toolsContainer, Alignment.TOP_RIGHT);
    stateContainer.addComponent(currentgraphlabel);
    stateContainer.setComponentAlignment(homeb, Alignment.TOP_LEFT);
    stateContainer.setComponentAlignment(currentgraphlabel, Alignment.TOP_RIGHT);

    final VerticalLayout welcome = new VerticalLayout();
    welcome.addComponent(welcomeContainer);
    // unfortunately, we need to be able to build components from outside
    // this initialization function and the welcome component needs to be
    // resized properly afterward
    this.welcome = welcome;

    mainContainer.addComponent(welcome);

    //************************************************************************
    //  menu bar style
    //
    MenuBar menubar = new MenuBar();
    menubar.setDebugId(this.getClass().getSimpleName() + "_menubar");

    // First define all menu commands

    String sparqlAuthURL;
    if (state.getHostName().equals("http://localhost:8080")) {
        sparqlAuthURL = "http://localhost:8890/sparql-auth";
    } else {
        sparqlAuthURL = state.getHostName() + "/virtuoso/sparql-auth";
    }
    ;

    MenuBar.Command cmdOntoWikiCreateKB = getCustomComponentCommand(CompType.CreateKB);
    MenuBar.Command cmdOntoWikiImport = getCustomComponentCommand(CompType.ImportCSV);

    MenuBar.Command cmdSearchCubes = getCustomComponentCommand(CompType.SearchCubes);
    //        MenuBar.Command cmdConfigGUI = getCustomComponentCommand(CompType.ConfigGUIStat);
    MenuBar.Command cmdManageDSD = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            showInWorkspace(new DSDRepoComponentWrapper(state, workspace));
            //                showInWorkspace(new DSDRepoComponent(state.getRdfStore(), state.getCurrentGraph()));
        }
    };
    MenuBar.Command cmdValidation = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            showInWorkspace(new Validation(state, workspace));
        }
    };
    //MenuBar.Command cmdUploadRDF = getCustomComponentCommand(CompType.UploadRDF);
    //MenuBar.Command cmdExtractXML = getCustomComponentCommand(CompType.ExtractFromXML, false);
    //MenuBar.Command cmdExtractXMLE = getCustomComponentCommand(CompType.ExtractFromXMLExtended, false);
    MenuBar.Command cmdLoadFromPublicData = getFramedUrlCommand(
            "http://publicdata.eu/dataset?q=statistical&res_format=application%2Frdf%2Bxml&_res_format_limit=0&sort=relevance+asc");
    MenuBar.Command cmdLoadFromDataHub = getFramedUrlCommand(
            "http://datahub.io/dataset?tags=statistics&q=&groups=lodcloud");
    //MenuBar.Command cmdD2R = getCustomComponentCommand(CompType.D2R);
    MenuBar.Command cmdSparqled = getCustomComponentCommand(CompType.Sparqled);
    MenuBar.Command cmdSparqledManager = getCustomComponentCommand(CompType.SparqledManager);
    MenuBar.Command cmdSparqlOntowiki = getCustomComponentCommand(CompType.SparqlOW);
    MenuBar.Command cmdSparqlVirtuoso = getCustomComponentCommand(CompType.SparqlVirtuoso);
    MenuBar.Command cmdSparqlVirtuosoI = getCustomComponentCommand(CompType.SparqlIVirtuoso);
    MenuBar.Command cmdOntoWikiEdit = getCustomComponentCommand(CompType.EditWithOW);
    MenuBar.Command cmdSparqlUpdateVirtuoso = getFramedUrlCommand(sparqlAuthURL);
    MenuBar.Command cmdPoolPartyEdit = getCustomComponentCommand(CompType.OnlinePoolParty);
    MenuBar.Command cmdMergeDatasets = getCustomComponentCommand(CompType.MergeDatasets);
    MenuBar.Command cmdMergeDimensions = getCustomComponentCommand(CompType.MergeDimensions);
    MenuBar.Command cmdSliceDatasets = getCustomComponentCommand(CompType.SliceDatasets);
    //MenuBar.Command cmdCkan = getCustomComponentCommand(CompType.CKAN);
    MenuBar.Command cmdGeoSpatial = getCustomComponentCommand(CompType.GeoSpatial);
    MenuBar.Command cmdSilk = getCustomComponentCommand(CompType.Silk);
    MenuBar.Command cmdLodRefine = getCustomComponentCommand(CompType.LodRefine);
    MenuBar.Command cmdLimes = getCustomComponentCommand(CompType.Limes);
    MenuBar.Command cmdSameAs = getCustomComponentCommand(CompType.SameAs);
    //MenuBar.Command cmdPublicData = getFramedUrlCommand("http://publicdata.eu");
    //MenuBar.Command cmdSigMa = getFramedUrlCommand("http://sig.ma");
    MenuBar.Command cmdSindice = getFramedUrlCommand("http://sindice.com/main/submit");
    //MenuBar.Command cmdLODCloud = getCustomComponentCommand(CompType.LODCloud);
    MenuBar.Command cmdDBPedia = getCustomComponentCommand(CompType.DBPedia);
    MenuBar.Command cmdSPARQLPoolParty = getCustomComponentCommand(CompType.SPARQLPoolParty);
    MenuBar.Command cmdMondecaSPARQLList = getCustomComponentCommand(CompType.MondecaSPARQLList);
    MenuBar.Command cmdEditDataset = this.getEditDatasetCommand(this.state);
    MenuBar.Command cmdEditStructureDef = this.getEditStructureDefinition(this.state);
    MenuBar.Command cmdEditComponentProp = this.getEditComponentPropertyCommand(this.state);
    MenuBar.Command cmdVisualizeCubeviz = getCustomComponentCommand(CompType.VisualizeCubeviz);

    MenuBar.Command cmdDemoConfig = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            ConfigurationTab content = new ConfigurationTab(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setHeight("500px");
        }
    };
    /*MenuBar.Command userinfoCommand = new MenuBar.Command() {
    public void menuSelected(MenuItem selectedItem) {
        showInWorkspace(new Authenticator(new UserInformation(state), new HashSet<String>(Arrays.asList(state.userRole)), state));
    }
    }; removed due to WebID issues */

    MenuBar.Command publishCommand = new Command() {
        public void menuSelected(MenuItem selectedItem) {
            showInWorkspace(new CKANPublisherPanel(state));
        }
    };

    MenuBar.Command publishDataHubCommand = new Command() {
        public void menuSelected(MenuItem selectedItem) {
            showInWorkspace(new DataHubPublisher(state));
        }
    };

    MenuBar.Command mDeleteGraphs = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            showInWorkspace(new DeleteGraphs(state));
        }
    };

    MenuBar.Command extractXML = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            showInWorkspace(new EXML(state));
        }
    };
    MenuBar.Command extractXMLExtended = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            showInWorkspace(new EXMLExtended(state));
        }
    };
    MenuBar.Command extractSDMX = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            showInWorkspace(new LinkedSDMX(state));
        }
    };

    MenuBar.Command importDirectly = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            showInWorkspace(new OntoWikiPathExtended(state, "/model/add", true));
        }
    };

    MenuBar.Command exportRDFXML = getOWExportCommand("rdfxml");
    MenuBar.Command exportTurtle = getOWExportCommand("turtle");
    MenuBar.Command exportRDFJson = getOWExportCommand("rdfjson");
    MenuBar.Command exportRDFN3 = getOWExportCommand("rdfn3");

    MenuBar.Command cmdExamples = getFramedUrlCommand(
            "http://wiki.lod2.eu/display/LOD2DOC/LOD2+Statistical+Workbench");

    /*
     legend for menu item names:
     - *: stub
     - !: incomplete functionality
     */

    // root menus
    MenuBar.MenuItem menuGraph = menubar.addItem("Manage Graph", null, null);
    MenuBar.MenuItem menuExtraction = menubar.addItem("Find more Data Online", null, null);
    MenuBar.MenuItem menuEdit = menubar.addItem("Edit & Transform", null, null);
    //MenuBar.MenuItem menuQuery      = menubar.addItem("Querying & Exploration", null, null);
    MenuBar.MenuItem menuEnrich = menubar.addItem("Enrich Datacube", null, null);
    //MenuBar.MenuItem menuOnline      = menubar.addItem("Online Tools & Services", null, null);
    MenuBar.MenuItem menuPresent = menubar.addItem("Present & Publish", null, null);
    MenuBar.MenuItem menuHelp = menubar.addItem("Help", null, null);

    //graph menu
    menuGraph.addItem("Select Default Graph", null, cmdDemoConfig);
    menuGraph.addItem("Create Graph", null, cmdOntoWikiCreateKB);
    menuGraph.addItem("Search Cubes", cmdSearchCubes);
    //        menuGraph.addItem("Configure URIs", cmdConfigGUI);
    MenuBar.MenuItem menuImport = menuGraph.addItem("Import", null, null);
    menuImport.addItem("Import from CSV", null, cmdOntoWikiImport);
    MenuBar.MenuItem excelImport = menuImport.addItem("Import from XML", null, null);
    MenuBar.MenuItem directImport = menuImport.addItem("Import triples from file", null, importDirectly);
    excelImport.addItem("From Text", null, extractXML);
    excelImport.addItem("From File", null, extractXMLExtended);
    excelImport.addItem("From SDMX", null, extractSDMX);
    MenuBar.MenuItem menuExport = menuGraph.addItem("Export", null, null);
    menuExport.addItem("Export as RDF/XML", null, exportRDFXML);
    menuExport.addItem("Export as Turtle", null, exportTurtle);
    menuExport.addItem("Export as RDF/JSON", null, exportRDFJson);
    menuExport.addItem("Export as Notation 3", null, exportRDFN3);
    menuGraph.addItem("DSD Management", cmdManageDSD);
    menuGraph.addItem("Validate", null, cmdValidation);
    menuGraph.addItem("Remove Graphs", null, mDeleteGraphs);

    // edit menu
    MenuItem editmenu = menuEdit.addItem("Edit Graph (OntoWiki)", null, cmdOntoWikiEdit);
    editmenu.addItem("Edit qb:Dataset", null, cmdEditDataset);
    editmenu.addItem("Edit qb:StructureDefinition", null, cmdEditStructureDef);
    editmenu.addItem("Edit qb:ComponentProperty", null, cmdEditComponentProp);
    menuEdit.addItem("Edit Code Lists (PoolParty)", null, cmdPoolPartyEdit);
    menuEdit.addItem("Reconcile dimensions", null, cmdMergeDimensions);
    menuEdit.addItem("Merge datasets", null, cmdMergeDatasets);
    menuEdit.addItem("Slice datasets", null, cmdSliceDatasets);
    menuEdit.addItem("Transform and Update Graph (SPARQL Update Endpoint)", null, cmdSparqlUpdateVirtuoso);
    menuEdit.addItem("Transform and Update Graph (R2R rules)", null, getCustomComponentCommand(CompType.R2R));

    // extraction menus
    //menuExtraction.addItem("Upload RDF File or RDF from URL", null, cmdUploadRDF);
    //MenuBar.MenuItem itemExtractFromXML = menuExtraction.addItem("Extract RDF from XML", null, null);
    //itemExtractFromXML.addItem("Basic extraction", null, cmdExtractXML);
    //itemExtractFromXML.addItem("Extended extraction", null, cmdExtractXMLE);
    menuExtraction.addItem("Load RDF data from publicdata.eu", null, cmdLoadFromPublicData);
    menuExtraction.addItem("Load RDF data from Data Hub", null, cmdLoadFromDataHub);
    //menuExtraction.addItem("Extract RDF from SQL", null, cmdD2R);

    // querying menu
    // many sparql query frontends are attached to the same endpoint (virtuoso) Removing duplicates
    //MenuBar.MenuItem itemSparqlQuerying = menuEdit.addItem("SPARQL querying", null, null);
    //Deprecated temporarily
    //MenuBar.MenuItem itemSparqled = menuEdit.addItem("SparQLed - Assisted Querying", null, cmdSparqled);
    //itemSparqled.addItem("Use currently selected graph", null, cmdSparqled);
    //itemSparqled.addItem("Use manager to calculate summary graph", null, cmdSparqledManager);
    //itemSparqlQuerying.addItem("OntoWiki SPARQL endpoint", null, cmdSparqlOntowiki);
    //itemSparqlQuerying.addItem("Virtuoso SPARQL endpoint", null, cmdSparqlVirtuoso);
    //itemSparqlQuerying.addItem("Virtuoso interactive SPARQL endpoint", null, cmdSparqlVirtuosoI);
    //        menuQuery.addItem("Find RDF Data Cubes", null, null);
    //        menuQuery.addItem("RDF Data Cube Matching Analysis", null, null);
    menuPresent.addItem("Visualization with CubeViz", null, cmdVisualizeCubeviz);
    // seems like duplicate of publicdata.eu
    //menuQuery.addItem("CKAN", null, cmdCkan);
    //menuPresent.addItem("Geo-Spatial exploration", null, cmdGeoSpatial);
    menuPresent.addItem("Publish to CKAN", null, publishCommand);
    menuPresent.addItem("Publish to datahub.io", null, publishDataHubCommand);

    // enrichment menu
    menuEnrich.addItem("Interlinking dimensions (Silk)", null, cmdSilk);
    menuEnrich.addItem("Data enrichment and reconciliation (LODRefine)", null, cmdLodRefine);
    menuEnrich.addItem("Interlinking with Limes", null, cmdLimes);
    menuEnrich.addItem("Interlinking with SameAs", null, cmdSameAs);

    // online menu
    //moved to present and publish
    menuPresent.addItem("Publish to Sindice", null, cmdSindice);
    //menuOnline.addItem("Sig.ma", null, cmdSigMa); // not a fitting case for stat wb?
    // duplicate?
    //menuOnline.addItem("Europe's Public Data", null, cmdPublicData);
    //MenuBar.MenuItem itemOnlineSparql = menuOnline.addItem("Online SPARQL Endpoints", null, null);
    // no longer working
    //itemOnlineSparql.addItem("LOD cloud", null, cmdLODCloud);
    // moved to find more data
    menuExtraction.addItem("DBPedia", null, cmdDBPedia);
    // moved to sparql querying
    menuEdit.addItem("PoolParty Code Lists SPARQL endpoint", null, cmdSPARQLPoolParty);
    // moved to extract
    menuExtraction.addItem("Mondeca SPARQL endpoint Collection", null, cmdMondecaSPARQLList);

    // help menu
    /* menuHelp.addItem("User Configuration", null, userinfoCommand); removed due to WebID issues */
    //menuHelp.addItem("*Documentation", null, null);
    menuHelp.addItem("Examples", null, cmdExamples);
    //menuHelp.addItem("*About", null, null);

    HorizontalLayout menubarContainer = new HorizontalLayout();
    menubarContainer.addComponent(menubar);
    menubarContainer.addStyleName("menubarContainer");
    menubarContainer.setWidth("100%");
    welcome.addComponent(menubarContainer);
    welcome.setHeight("110px");

    //************************************************************************
    // add workspace
    workspace = new VerticalLayout();

    mainContainer.addComponent(workspace);

    //create login/logout component that shows currently logged in user
    LoginStatus login = new LoginStatus(state, workspace);
    toolsContainer.addComponent(login);
    //welcome.setComponentAlignment(login, Alignment.TOP_RIGHT);

    /*
        workspace.setHeight("80%");
            
        HorizontalLayout introH = new HorizontalLayout();
        Embedded lod2cycle = new Embedded("", new ThemeResource("app_images/lod-lifecycle-small.png"));
        lod2cycle.setMimeType("image/png");
        introH.addComponent(lod2cycle);
        introH.setComponentAlignment(lod2cycle, Alignment.MIDDLE_LEFT);
            
        VerticalLayout introV =  new VerticalLayout();
        introH.addComponent(introV);
            
        Label introtextl =  new Label(introtext, Label.CONTENT_XHTML);
        introV.addComponent(introtextl);
        introtextl.setWidth("400px");
            
        HorizontalLayout introVH =  new HorizontalLayout();
        introV.addComponent(introVH);
            
        Embedded euflag = new Embedded("", new ThemeResource("app_images/eu-flag.gif"));
        euflag.setMimeType("image/gif");
        introVH.addComponent(euflag);
        euflag.addStyleName("eugif");
        euflag.setHeight("50px");
        Embedded fp7 = new Embedded("", new ThemeResource("app_images/fp7-gen-rgb_small.gif"));
        fp7.setMimeType("image/gif");
        fp7.addStyleName("eugif");
        fp7.setHeight("50px");
        introVH.addComponent(fp7);
            
        workspace.addComponent(introH);
        */
    home();

    // Create a tracker for the demo.lod2.eu domain.
    if (!state.googleAnalyticsID.equals("")) {
        //            GoogleAnalyticsTracker tracker = new GoogleAnalyticsTracker("UA-26375798-1", "demo.lod2.eu");
        GoogleAnalyticsTracker tracker = new GoogleAnalyticsTracker(state.googleAnalyticsID,
                state.googleAnalyticsDomain);
        mainWindow.addComponent(tracker);
        tracker.trackPageview("/lod2statworkbench");
    }
    ;

    setMainWindow(mainWindow);

    //       mainWindow.setExpandRatio(workspace, 1.0f);

    if (!state.InitStatus) {
        mainWindow.showNotification("Initialization Demonstration Failed", state.ErrorMessage,
                Notification.TYPE_ERROR_MESSAGE);
    }
    ;

}

From source file:fi.semantum.strategia.widget.Meter.java

License:Open Source License

public static void updateMeters(final Main main, boolean canWrite) {

    if (main.getUIState().currentItem instanceof Strategiakartta)
        return;/*from w  w w. jav  a 2  s.  c o  m*/

    final Database database = main.getDatabase();

    final Base base = main.getUIState().currentItem;

    List<MeterDescription> descs = makeMeterDescriptions(main, base, false);
    if (!descs.isEmpty() || canWrite) {

        HorizontalLayout meterHeader = new HorizontalLayout();
        meterHeader.setSpacing(true);

        Label header = new Label("Mittarit");
        main.propertyCells.add(Utils.excelRow(header.getValue()));
        header.setHeight("32px");
        header.addStyleName(ValoTheme.LABEL_HUGE);
        header.addStyleName(ValoTheme.LABEL_BOLD);
        meterHeader.addComponent(header);
        meterHeader.setComponentAlignment(header, Alignment.BOTTOM_CENTER);

        if (canWrite) {

            final Image editMeters = new Image(null, new ThemeResource("chart_bar_edit.png"));
            editMeters.setHeight("24px");
            editMeters.setWidth("24px");
            editMeters.addClickListener(new MouseEvents.ClickListener() {

                private static final long serialVersionUID = 2661060702097338722L;

                @Override
                public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                    Utils.loseFocus(editMeters);
                    manageMeters(main, main.getUIState().currentItem);
                }

            });

            meterHeader.addComponent(editMeters);
            meterHeader.setComponentAlignment(editMeters, Alignment.BOTTOM_CENTER);

        }

        main.properties.addComponent(meterHeader);
        main.properties.setComponentAlignment(meterHeader, Alignment.MIDDLE_CENTER);

        VerticalLayout meters = new VerticalLayout();

        boolean showYears = main.getUIState().time.equals(Property.AIKAVALI_KAIKKI);

        Property time = Property.find(database, Property.AIKAVALI);

        int index = 0;
        for (final MeterDescription desc : descs) {

            ArrayList<String> excelRow = new ArrayList<String>();

            final Meter meter = desc.meter;

            final HorizontalLayout hl = new HorizontalLayout();
            hl.addStyleName((((index++) & 1) == 0) ? "evenProperty" : "oddProperty");
            hl.setSpacing(true);

            Label l = new Label(desc.caption);
            excelRow.add(l.getValue().replace("%nbsp", ""));
            l.setContentMode(ContentMode.HTML);
            l.setWidth("450px");
            l.addStyleName("propertyName");
            l.setData(desc);
            hl.addComponent(l);
            hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT);

            String value = updateMeterValue(main, hl, base, meter, canWrite);
            excelRow.add(value);

            String shortComment = "";
            Indicator indicator = meter.getPossibleIndicator(database);
            if (indicator != null)
                shortComment = indicator.getValueShortComment();
            Label comment = new Label(shortComment);
            comment.setWidth("150px");
            hl.addComponent(comment);
            hl.setComponentAlignment(comment, Alignment.MIDDLE_LEFT);
            excelRow.add(comment.getValue());

            if (showYears) {

                HorizontalLayout hl2 = new HorizontalLayout();
                hl2.setWidth("70px");
                hl2.setHeight("100%");
                hl.addComponent(hl2);
                hl.setComponentAlignment(hl2, Alignment.MIDDLE_LEFT);

                String years = time.getPropertyValue(meter);
                if (years == null)
                    years = Property.AIKAVALI_KAIKKI;

                final Label region = new Label(years);
                region.setWidthUndefined();

                excelRow.add(region.getValue());

                hl2.addComponent(region);
                hl2.setComponentAlignment(region, Alignment.MIDDLE_CENTER);

            }

            AbsoluteLayout image = new AbsoluteLayout();
            image.setWidth("32px");
            image.setHeight("32px");
            image.addStyleName("meterColor" + index);

            String color = meter.getTrafficColor(database);

            Styles styles = Page.getCurrent().getStyles();
            styles.add(
                    ".fi_semantum_strategia div." + "meterColor" + index + " { background: " + color + "; }");

            hl.addComponent(image);
            hl.setComponentAlignment(image, Alignment.MIDDLE_CENTER);
            hl.setExpandRatio(image, 0.0f);

            meters.addComponent(hl);
            meters.setComponentAlignment(hl, Alignment.MIDDLE_CENTER);

            ThemeResource res = desc.meter.showInMap ? new ThemeResource("zoom.png")
                    : new ThemeResource("zoom_out.png");

            final Image show = new Image();
            show.setSource(res);
            show.setHeight("24px");
            show.setWidth("24px");
            if (canWrite) {
                show.setDescription("Klikkaamalla voit valita, nytetnk mittaria strategiakartassa");
                show.addClickListener(new MouseEvents.ClickListener() {

                    private static final long serialVersionUID = 7156984656942915939L;

                    @Override
                    public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                        desc.meter.setShowInMap(!desc.meter.showInMap);
                        Updates.update(main, true);
                    }

                });
            }

            hl.addComponent(show);
            hl.setComponentAlignment(show, Alignment.MIDDLE_CENTER);

            final Image wiki = new Image();
            wiki.setSource(new ThemeResource("table_edit.png"));
            wiki.setHeight("24px");
            wiki.setWidth("24px");
            wiki.setDescription("Klikkaamalla voit siirty tausta-asiakirjaan");
            wiki.addClickListener(new MouseEvents.ClickListener() {

                private static final long serialVersionUID = 7156984656942915939L;

                @Override
                public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                    Wiki.openWiki(main, desc.meter);
                }

            });

            hl.addComponent(wiki);
            hl.setComponentAlignment(wiki, Alignment.MIDDLE_CENTER);

            if (canWrite) {
                final Button principalButton = new Button();
                if (meter.isPrincipal) {
                    principalButton.setCaption("Poista kokonaisarvio");
                } else {
                    principalButton.setCaption("Aseta kokonaisarvioksi");
                }
                principalButton.setStyleName(ValoTheme.BUTTON_TINY);
                principalButton.addClickListener(new ClickListener() {

                    private static final long serialVersionUID = 8247560202892661226L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        if (meter.isPrincipal) {
                            meter.isPrincipal = false;
                        } else {
                            for (Meter m : base.getMeters(database))
                                m.isPrincipal = false;
                            meter.isPrincipal = true;
                        }
                        Updates.update(main, true);

                    }

                });
                hl.addComponent(principalButton);
                hl.setComponentAlignment(principalButton, Alignment.MIDDLE_CENTER);
            }

            main.propertyCells.add(excelRow);

        }

        meters.addLayoutClickListener(new LayoutClickListener() {

            private static final long serialVersionUID = 3295743025581923380L;

            private String extractData(Component c) {
                if (c instanceof AbstractComponent) {
                    Object data = ((AbstractComponent) c).getData();
                    if (data instanceof MeterDescription) {
                        MeterDescription desc = (MeterDescription) data;
                        return desc.meter.getDescription(database);
                    }
                }
                return null;
            }

            @Override
            public void layoutClick(LayoutClickEvent event) {

                String desc = extractData(event.getClickedComponent());
                if (desc == null)
                    return;

                String content = "<div style=\"width: 700px; border: 2px solid; padding: 5px\">";
                content += "<div style=\"text-align: center; white-space:normal; font-size: 36px; padding: 10px\">"
                        + desc + "</div>";
                content += "</div>";

                Notification n = new Notification(content, Notification.Type.HUMANIZED_MESSAGE);
                n.setHtmlContentAllowed(true);
                n.show(Page.getCurrent());

            }

        });

        main.properties.addComponent(meters);
        main.properties.setComponentAlignment(meters, Alignment.MIDDLE_CENTER);

    }

}

From source file:fi.vtt.RVaadin.RContainer.java

License:Apache License

/**
 * Get a Vaadin Window element that contains the corresponding R plot
 * generated by submitting and evaluating the RPlotCall String. The
 * imageName corresponds to the downloadable .png image name. The full name
 * of the images shown in the browser are of the format
 * {@code imageName_ISODate_runningId_[sessionId].png}, e.g.
 * 'Image_2012-08-29_001_[bmgolmfgvk].png' to keep them chronologically
 * ordered.//  ww w.j a v a2s  .  c  o m
 * 
 * @param RPlotCall
 *            the String to be evaluated by R
 * @param width
 *            the width of the graphical image
 * @param height
 *            the height of the graphical image
 * @param imageName
 *            the image name attached to the right-click downloadable file
 * @param windowName
 *            the title name of the Vaadin window element
 * @return Vaadin Window object
 */
public Window getGraph(final String RPlotCall, final int width, final int height, final String imageName,
        String windowName) {

    /* Construct a Window to show the graphics */
    Window RGraphics = new Window(windowName);
    HorizontalLayout root = new HorizontalLayout();
    root.setMargin(true);

    RGraphics.setContent(root);
    RGraphics.setSizeUndefined();

    /* Control the image position */
    final int imageXoffset = 180;
    final int imageYoffset = 60;

    int imageYpos = rand.nextInt(50);
    int imageXpos = rand.nextInt(90);

    RGraphics.setPositionX(imageXoffset + imageXpos);
    RGraphics.setPositionY(imageYoffset + imageYpos);

    /* Call R for the graphics */
    Embedded rPlot = getEmbeddedGraph(RPlotCall, width, height, imageName);
    root.addComponent(rPlot);

    /*
     * Button bar to generate PDF (and for other options in the future)
     */
    if (showButtonsInGraph) {
        final HorizontalLayout buttonLayout = new HorizontalLayout();
        Button open = new Button("PDF");
        open.setStyleName(Reindeer.BUTTON_SMALL);
        buttonLayout.addComponent(open);

        Button.ClickListener openClicked = new Button.ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                StreamResource s = getImageResource(RPlotCall, width / screen_dpi, height / screen_dpi,
                        imageName, "pdf");

                Link pdfLink = new Link("Open pdf", s);
                pdfLink.setTargetName("_blank");

                buttonLayout.removeAllComponents();
                buttonLayout.addComponent(pdfLink);
            }
        };
        open.addClickListener(openClicked);
        root.addComponent(buttonLayout);
    }

    return RGraphics;
}

From source file:fr.univlorraine.mondossierweb.utils.Utils.java

License:Apache License

public static void setButtonStyle(Button b) {
    b.setStyleName("v-nav-button");
    b.addStyleName("link");
    b.addStyleName("v-link");
}

From source file:fr.univlorraine.mondossierweb.views.AdressesView.java

License:Apache License

/**
 * Initialise la vue/*from w  ww .  j a va  2s . co  m*/
 */
@PostConstruct
public void init() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MainUI && (userController.isEnseignant() || userController.isEtudiant())
            && MainUI.getCurrent() != null && MainUI.getCurrent().getEtudiant() != null) {
        removeAllComponents();

        /* Style */
        setMargin(true);
        setSpacing(true);

        /* Titre */
        Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale()));
        title.addStyleName(ValoTheme.LABEL_H1);
        addComponent(title);

        VerticalLayout globalLayout = new VerticalLayout();
        globalLayout.setSizeFull();
        globalLayout.setSpacing(true);

        //Layout avec les infos etatcivil et contact
        CssLayout idLayout = new CssLayout();
        idLayout.setSizeFull();
        idLayout.setStyleName("flexwrap");

        globalLayout.addComponent(idLayout);
        // Enable Responsive CSS selectors for the layout
        Responsive.makeResponsive(idLayout);

        if (MainUI.getCurrent().getEtudiant().getAdresseAnnuelle() != null) {

            FormLayout formAdresseAnnuelleLayout = new FormLayout();
            formAdresseAnnuelleLayout.setSpacing(true);
            formAdresseAnnuelleLayout.setMargin(true);

            Panel panelAdresseAnnuelle = new Panel(
                    applicationContext.getMessage(NAME + ".adresseannuelle.title", null, getLocale()) + " "
                            + MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAnnee());

            String captionAdresseAnnuelle = applicationContext.getMessage(NAME + ".adresse.title", null,
                    getLocale());
            Label fieldAdresseAnnuelle = new Label();
            formatLabel(fieldAdresseAnnuelle, captionAdresseAnnuelle,
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresse1());
            formAdresseAnnuelleLayout.addComponent(fieldAdresseAnnuelle);

            String annuelle2 = valuateTextFieldFromMultipleValues(
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresse2(),
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresse3());
            if (annuelle2 != null) {
                Label fieldAdresseAnnuelle2 = new Label();
                formatLabel(fieldAdresseAnnuelle2, null, annuelle2);
                formAdresseAnnuelleLayout.addComponent(fieldAdresseAnnuelle2);
            }
            String captionVilleAnnuelle = applicationContext.getMessage(NAME + ".ville.title", null,
                    getLocale());
            Label fieldVilleAnnuelle = new Label();
            formatLabel(fieldVilleAnnuelle, captionVilleAnnuelle,
                    valuateTextFieldFromMultipleValues(
                            MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresseetranger(),
                            MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getCodePostal(),
                            MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getVille()));
            formAdresseAnnuelleLayout.addComponent(fieldVilleAnnuelle);

            String captionPaysAnnuelle = applicationContext.getMessage(NAME + ".pays.title", null, getLocale());
            Label fieldPaysAnnuelle = new Label();
            formatLabel(fieldPaysAnnuelle, captionPaysAnnuelle,
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getPays());
            formAdresseAnnuelleLayout.addComponent(fieldPaysAnnuelle);

            String captionTelephoneAnnuelle = applicationContext.getMessage(NAME + ".telephone.title", null,
                    getLocale());
            Label fieldTelephoneAnnuelle = new Label();
            formatLabel(fieldTelephoneAnnuelle, captionTelephoneAnnuelle,
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getNumerotel());
            formAdresseAnnuelleLayout.addComponent(fieldTelephoneAnnuelle);

            panelAdresseAnnuelle.setContent(formAdresseAnnuelleLayout);

            HorizontalLayout adresseAnnuelleGlobalLayout = new HorizontalLayout();
            adresseAnnuelleGlobalLayout.setSizeUndefined();
            adresseAnnuelleGlobalLayout.setStyleName("firstitembox");
            adresseAnnuelleGlobalLayout.addComponent(panelAdresseAnnuelle);
            adresseAnnuelleGlobalLayout.setExpandRatio(panelAdresseAnnuelle, 1);
            idLayout.addComponent(adresseAnnuelleGlobalLayout);
        }

        if (MainUI.getCurrent().getEtudiant().getAdresseFixe() != null) {
            FormLayout formAdresseFixeLayout = new FormLayout();
            formAdresseFixeLayout.setSpacing(true);
            formAdresseFixeLayout.setMargin(true);

            Panel panelAdresseFixe = new Panel(
                    applicationContext.getMessage(NAME + ".adressefixe.title", null, getLocale()));

            String captionAdresseFixe = applicationContext.getMessage(NAME + ".adresse.title", null,
                    getLocale());
            Label fieldAdresseFixe = new Label();
            formatLabel(fieldAdresseFixe, captionAdresseFixe,
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresse1());
            formAdresseFixeLayout.addComponent(fieldAdresseFixe);

            String adfixe2 = valuateTextFieldFromMultipleValues(
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresse2(),
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresse3());
            if (adfixe2 != null) {
                Label fieldAdresseFixe2 = new Label();
                formatLabel(fieldAdresseFixe2, null, adfixe2);
                formAdresseFixeLayout.addComponent(fieldAdresseFixe2);
            }

            String captionVilleFixe = applicationContext.getMessage(NAME + ".ville.title", null, getLocale());
            Label fieldVilleFixe = new Label();
            formatLabel(fieldVilleFixe, captionVilleFixe,
                    valuateTextFieldFromMultipleValues(
                            MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresseetranger(),
                            MainUI.getCurrent().getEtudiant().getAdresseFixe().getCodePostal(),
                            MainUI.getCurrent().getEtudiant().getAdresseFixe().getVille()));
            formAdresseFixeLayout.addComponent(fieldVilleFixe);

            String captionPaysFixe = applicationContext.getMessage(NAME + ".pays.title", null, getLocale());
            Label fieldPaysFixe = new Label();
            formatLabel(fieldPaysFixe, captionPaysFixe,
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getPays());
            formAdresseFixeLayout.addComponent(fieldPaysFixe);

            String captionTelephoneFixe = applicationContext.getMessage(NAME + ".telephone.title", null,
                    getLocale());
            Label fieldTelephoneFixe = new Label();
            formatLabel(fieldTelephoneFixe, captionTelephoneFixe,
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getNumerotel());
            formAdresseFixeLayout.addComponent(fieldTelephoneFixe);

            panelAdresseFixe.setContent(formAdresseFixeLayout);

            HorizontalLayout adresseFixeGlobalLayout = new HorizontalLayout();
            adresseFixeGlobalLayout.setSizeUndefined();
            adresseFixeGlobalLayout.setStyleName("itembox");
            adresseFixeGlobalLayout.addComponent(panelAdresseFixe);
            adresseFixeGlobalLayout.setExpandRatio(panelAdresseFixe, 1);
            idLayout.addComponent(adresseFixeGlobalLayout);

        }

        addComponent(globalLayout);

        if (userController.isEtudiant() && configController.isModificationAdressesAutorisee()
                && MainUI.getCurrent().getEtudiant().getAdresseAnnuelle() != null) {
            HorizontalLayout btnLayout = new HorizontalLayout();
            btnLayout.setSizeFull();
            btnLayout.setSpacing(true);

            Button btnModifAdresses = new Button(
                    applicationContext.getMessage(NAME + ".bouton.modifieradresses", null, getLocale()));
            btnModifAdresses.setStyleName(ValoTheme.BUTTON_PRIMARY);
            btnModifAdresses.setIcon(FontAwesome.EDIT);
            btnModifAdresses.addClickListener(e -> {
                ModificationAdressesWindow maw = new ModificationAdressesWindow(
                        MainUI.getCurrent().getEtudiant());
                maw.addCloseListener(f -> {
                    init();
                });
                UI.getCurrent().addWindow(maw);
            });
            btnLayout.addComponent(btnModifAdresses);
            btnLayout.setComponentAlignment(btnModifAdresses, Alignment.MIDDLE_LEFT);
            addComponent(btnLayout);
        }
    }
}

From source file:fr.univlorraine.mondossierweb.views.CalendrierView.java

License:Apache License

/**
 * Initialise la vue//from   w w w  .  ja va  2 s  . c o  m
 */
@PostConstruct
public void init() {
    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MainUI && (userController.isEnseignant() || userController.isEtudiant())
            && MainUI.getCurrent() != null && MainUI.getCurrent().getEtudiant() != null) {
        /* Style */
        setMargin(true);
        setSpacing(true);

        //Si on n'a pas dj essayer de rcuprer le calendrier
        if (!MainUI.getCurrent().getEtudiant().isCalendrierRecupere()) {
            etudiantController.recupererCalendrierExamens();
        }

        /* Titre */
        HorizontalLayout titleLayout = new HorizontalLayout();
        titleLayout.setWidth("100%");
        Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale()));
        title.addStyleName(ValoTheme.LABEL_H1);
        titleLayout.addComponent(title);
        titleLayout.setComponentAlignment(title, Alignment.MIDDLE_LEFT);
        //Test si on a des diplomes ou des etapes
        if (MainUI.getCurrent().getEtudiant().getCalendrier() != null
                && MainUI.getCurrent().getEtudiant().getCalendrier().size() > 0) {
            Button pdfButton = new Button();
            pdfButton.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
            pdfButton.addStyleName("button-big-icon");
            pdfButton.addStyleName("red-button-icon");
            pdfButton.setIcon(FontAwesome.FILE_PDF_O);
            pdfButton.setDescription(
                    applicationContext.getMessage(NAME + ".btn.pdf.description", null, getLocale()));
            if (PropertyUtils.isPushEnabled()) {
                MyFileDownloader fd = new MyFileDownloader(calendrierController.exportPdf());
                fd.extend(pdfButton);
            } else {
                FileDownloader fd = new FileDownloader(calendrierController.exportPdf());
                fd.setOverrideContentType(false);
                fd.extend(pdfButton);
            }
            titleLayout.addComponent(pdfButton);
            titleLayout.setComponentAlignment(pdfButton, Alignment.MIDDLE_RIGHT);
        }
        addComponent(titleLayout);

        VerticalLayout globalLayout = new VerticalLayout();
        globalLayout.setSizeFull();
        globalLayout.setSpacing(true);

        /* Message d'info */
        if (applicationContext.getMessage(NAME + ".message.info", null, getLocale()) != null) {
            Panel panelVue = new Panel();

            HorizontalLayout vueLayout = new HorizontalLayout();
            vueLayout.setMargin(true);
            vueLayout.setSpacing(true);
            vueLayout.setSizeFull();

            Label vueLabel = new Label(
                    applicationContext.getMessage(NAME + ".message.info", null, getLocale()));
            vueLabel.setContentMode(ContentMode.HTML);
            vueLabel.setStyleName(ValoTheme.LABEL_SMALL);
            vueLayout.addComponent(vueLabel);
            vueLayout.setExpandRatio(vueLabel, 1);

            panelVue.setContent(vueLayout);
            globalLayout.addComponent(panelVue);
        }

        /* Le Calendrier */
        Panel panelCalendrier = new Panel(
                applicationContext.getMessage(NAME + ".calendrier.title", null, getLocale()));
        panelCalendrier.setSizeFull();

        if (MainUI.getCurrent().getEtudiant() != null
                && MainUI.getCurrent().getEtudiant().getCalendrier() != null
                && MainUI.getCurrent().getEtudiant().getCalendrier().size() > 0) {

            BeanItemContainer<Examen> bic = new BeanItemContainer<>(Examen.class,
                    MainUI.getCurrent().getEtudiant().getCalendrier());
            Table calendrierTable = new Table(null, bic);
            calendrierTable.setWidth("100%");
            String[] colonnes_to_create = CAL_FIELDS;
            if (configController.isAffNumPlaceExamen()) {
                colonnes_to_create = CAL_FIELDS_AVEC_PLACE;
            }
            for (String fieldName : colonnes_to_create) {
                calendrierTable.setColumnHeader(fieldName,
                        applicationContext.getMessage(NAME + ".table." + fieldName, null, getLocale()));
            }
            calendrierTable.addGeneratedColumn("batiment", new BatimentColumnGenerator());
            calendrierTable.addGeneratedColumn("salle", new SalleColumnGenerator());
            calendrierTable.setColumnHeader("batiment",
                    applicationContext.getMessage(NAME + ".table.batiment", null, getLocale()));
            calendrierTable.setColumnHeader("salle",
                    applicationContext.getMessage(NAME + ".table.salle", null, getLocale()));
            String[] colonnes_to_display = CAL_FIELDS_ORDER;
            if (configController.isAffNumPlaceExamen()) {
                colonnes_to_display = CAL_FIELDS_ORDER_AVEC_PLACE;
            }
            calendrierTable.setVisibleColumns((Object[]) colonnes_to_display);
            calendrierTable.setColumnCollapsingAllowed(true);
            calendrierTable.setColumnReorderingAllowed(true);
            calendrierTable.setSelectable(false);
            calendrierTable.setImmediate(true);
            calendrierTable.setStyleName("noscrollabletable");
            calendrierTable.setPageLength(calendrierTable.getItemIds().size());

            panelCalendrier.setContent(calendrierTable);
        } else {
            HorizontalLayout labelExamenLayout = new HorizontalLayout();
            labelExamenLayout.setMargin(true);
            labelExamenLayout.setSizeFull();
            Label aucunExamen = new Label(
                    applicationContext.getMessage(NAME + ".examen.aucun", null, getLocale()));
            aucunExamen.setStyleName(ValoTheme.LABEL_COLORED);
            aucunExamen.addStyleName(ValoTheme.LABEL_BOLD);
            labelExamenLayout.addComponent(aucunExamen);
            panelCalendrier.setContent(labelExamenLayout);
        }
        globalLayout.addComponent(panelCalendrier);

        addComponent(globalLayout);
    }
}

From source file:fr.univlorraine.mondossierweb.views.FavorisMobileView.java

License:Apache License

/**
 * Initialise la vue/*from www  . j  a v  a2 s .c o m*/
 */
@PostConstruct
public void init() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI && userController.isEnseignant()) {
        removeAllComponents();

        /* Style */
        setSizeFull();

        liste_types_inscrits = new LinkedList<String>();
        liste_types_inscrits.add("ELP");
        liste_types_inscrits.add("VET");

        liste_type_arbo = new LinkedList<String>();
        liste_type_arbo.add("CMP");
        liste_type_arbo.add("VET");

        List<Favoris> lfav = favorisController.getFavoris();

        //NAVBAR
        HorizontalLayout navbar = new HorizontalLayout();
        navbar.setSizeFull();
        navbar.setHeight("40px");
        navbar.setStyleName("navigation-bar");

        //Bouton info
        infoButton = new Button();
        infoButton.setIcon(FontAwesome.INFO);
        infoButton.setStyleName("v-nav-button");
        infoButton.addClickListener(e -> {
            /**
             * NOUVELLE VERSION
             */
            Notification note = new Notification(
                    applicationContext.getMessage("helpWindowMobile.text.enseignant", null, getLocale()), "",
                    Notification.TYPE_TRAY_NOTIFICATION, true);
            note.setPosition(Position.MIDDLE_CENTER);
            note.setDelayMsec(6000);
            note.show(UI.getCurrent().getPage());
            /**
             * ANCIENNE VERSION
             */
            /*
            //afficher message
            HelpMobileWindow hbw = new HelpMobileWindow(applicationContext.getMessage("helpWindowMobile.text.enseignant", null, getLocale()),applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale()),false);
                    
            UI.getCurrent().addWindow(hbw);
            */
        });
        navbar.addComponent(infoButton);
        navbar.setComponentAlignment(infoButton, Alignment.MIDDLE_LEFT);

        //Title
        Label labelFav = new Label(applicationContext.getMessage(NAME + ".title.label", null, getLocale()));
        labelFav.setStyleName("v-label-navbar");
        navbar.addComponent(labelFav);
        navbar.setComponentAlignment(labelFav, Alignment.MIDDLE_CENTER);

        //Bouton Search
        Button searchButton = new Button();
        searchButton.setIcon(FontAwesome.SEARCH);
        searchButton.setStyleName("v-nav-button");
        navbar.addComponent(searchButton);
        navbar.setComponentAlignment(searchButton, Alignment.MIDDLE_RIGHT);
        searchButton.addClickListener(e -> {
            ((MdwTouchkitUI) MdwTouchkitUI.getCurrent()).navigateToRecherche(NAME);
        });
        navbar.setExpandRatio(labelFav, 1);
        addComponent(navbar);

        VerticalLayout globalLayout = new VerticalLayout();
        globalLayout.setSizeFull();
        globalLayout.setSpacing(true);
        globalLayout.setMargin(true);

        FormLayout labelLayout = new FormLayout();
        labelLayout.setSizeFull();
        labelLayout.setMargin(false);
        labelLayout.setSpacing(false);

        Label infoLabel = new Label(applicationContext.getMessage(NAME + ".info.label", null, getLocale()));
        infoLabel.setStyleName(ValoTheme.LABEL_SMALL);
        infoLabel.setIcon(FontAwesome.INFO_CIRCLE);
        infoLabel.setWidth("100%");

        labelLayout.addComponent(infoLabel);
        globalLayout.addComponent(labelLayout);

        if (lfav != null && lfav.size() > 0) {
            if (favorisContientVet(lfav)) {

                Panel vetPanel = new Panel(
                        applicationContext.getMessage(NAME + ".vetpanel.title", null, getLocale()));
                vetPanel.setStyleName("centertitle-panel");
                vetPanel.addStyleName("v-colored-panel-caption");
                vetPanel.setSizeFull();

                VerticalLayout vetLayout = new VerticalLayout();
                vetLayout.setSizeFull();
                vetLayout.setHeight(null);
                int i = 0;
                for (Favoris fav : lfav) {
                    if (fav.getId().getTypfav().equals(Utils.VET)) {
                        i++;

                        HorizontalLayout favVetLayout = new HorizontalLayout();
                        favVetLayout.setSizeFull();
                        favVetLayout.setMargin(true);
                        favVetLayout.setSpacing(true);
                        favVetLayout.setStyleName("v-layout-multiline");
                        favVetLayout.setWidth("100%");
                        favVetLayout.setHeight("100%");

                        Button codeButton = new Button(fav.getId().getIdfav());
                        codeButton.setCaption(fav.getId().getIdfav());
                        Utils.setButtonStyle(codeButton);
                        codeButton.setWidth("90px");
                        codeButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        Button libButton = new Button(favorisController.getLibObjFavori(fav.getId().getTypfav(),
                                fav.getId().getIdfav()));
                        Utils.setButtonStyle(libButton);
                        libButton.setHeight("100%");
                        libButton.setWidth("100%");
                        libButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        favVetLayout.addComponent(codeButton);
                        //favVetLayout.setComponentAlignment(codeButton, Alignment.MIDDLE_CENTER);
                        favVetLayout.addComponent(libButton);
                        favVetLayout.setComponentAlignment(libButton, Alignment.MIDDLE_CENTER);
                        favVetLayout.setExpandRatio(libButton, 1);
                        vetLayout.addComponent(favVetLayout);
                        if (i > 1) {
                            favVetLayout.addStyleName("line-separator");
                        }
                    }
                }
                vetPanel.setContent(vetLayout);
                globalLayout.addComponent(vetPanel);

            }

            if (favorisContientElp(lfav)) {
                Panel elpPanel = new Panel(
                        applicationContext.getMessage(NAME + ".elppanel.title", null, getLocale()));
                elpPanel.setStyleName("centertitle-panel");
                elpPanel.addStyleName("v-colored-panel-caption");
                elpPanel.setSizeFull();

                VerticalLayout elpLayout = new VerticalLayout();
                elpLayout.setSizeFull();
                elpLayout.setHeight(null);
                int i = 0;
                for (Favoris fav : lfav) {
                    if (fav.getId().getTypfav().equals(Utils.ELP)) {
                        i++;
                        HorizontalLayout favElpLayout = new HorizontalLayout();
                        favElpLayout.setSizeFull();
                        favElpLayout.setMargin(true);
                        favElpLayout.setSpacing(true);
                        favElpLayout.setStyleName("v-layout-multiline");
                        favElpLayout.setWidth("100%");
                        favElpLayout.setHeight("100%");

                        Button codeButton = new Button(fav.getId().getIdfav());
                        Utils.setButtonStyle(codeButton);
                        codeButton.setWidth("90px");
                        codeButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        Button libButton = new Button(favorisController.getLibObjFavori(fav.getId().getTypfav(),
                                fav.getId().getIdfav()));
                        Utils.setButtonStyle(libButton);
                        libButton.setHeight("100%");
                        libButton.setWidth("100%");
                        libButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        favElpLayout.addComponent(codeButton);
                        favElpLayout.addComponent(libButton);
                        favElpLayout.setComponentAlignment(libButton, Alignment.MIDDLE_CENTER);
                        favElpLayout.setExpandRatio(libButton, 1);
                        elpLayout.addComponent(favElpLayout);
                        if (i > 1) {
                            favElpLayout.addStyleName("line-separator");
                        }
                    }
                }
                elpPanel.setContent(elpLayout);
                globalLayout.addComponent(elpPanel);
            }

        }

        labelAucunFavoriLayout = new HorizontalLayout();
        labelAucunFavoriLayout.setMargin(true);
        labelAucunFavoriLayout.setSizeFull();
        Button aucunFavoris = new Button(
                applicationContext.getMessage(NAME + ".favoris.aucun", null, getLocale()));
        aucunFavoris.setStyleName("v-nav-button");
        aucunFavoris.addStyleName(ValoTheme.BUTTON_LINK);
        aucunFavoris.addClickListener(e -> {
            ((MdwTouchkitUI) MdwTouchkitUI.getCurrent()).navigateToRecherche(NAME);
        });

        labelAucunFavoriLayout.addComponent(aucunFavoris);
        labelAucunFavoriLayout.setVisible(false);
        globalLayout.addComponent(labelAucunFavoriLayout);

        if (lfav == null || lfav.size() == 0) {
            labelAucunFavoriLayout.setVisible(true);
        }

        //addComponent(globalLayout);
        contentLayout.setStyleName("v-scrollableelement");
        contentLayout.addComponent(globalLayout);
        addComponent(contentLayout);
        setExpandRatio(contentLayout, 1);

    }
}

From source file:fr.univlorraine.mondossierweb.views.InformationsAnnuellesMobileView.java

License:Apache License

public void refresh() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI
            && (userController.isEnseignant() || userController.isEtudiant())
            && MdwTouchkitUI.getCurrent() != null && MdwTouchkitUI.getCurrent().getEtudiant() != null) {
        removeAllComponents();/*from   w w  w  . jav a2  s. co  m*/

        /* Style */
        setMargin(false);
        setSpacing(false);
        setSizeFull();

        //NAVBAR
        HorizontalLayout navbar = new HorizontalLayout();
        navbar.setSizeFull();
        navbar.setHeight("40px");
        navbar.setStyleName("navigation-bar");

        //Bouton retour
        if (userController.isEnseignant()) {
            returnButton = new Button();
            returnButton.setIcon(FontAwesome.ARROW_LEFT);
            //returnButton.setStyleName(ValoTheme.BUTTON_ICON_ONLY);
            returnButton.setStyleName("v-nav-button");
            returnButton.addClickListener(e -> {
                if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() != null && MdwTouchkitUI.getCurrent()
                        .getDossierEtuFromView().equals(ListeInscritsMobileView.NAME)) {
                    MdwTouchkitUI.getCurrent().navigateToListeInscrits();
                } else {

                    if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() != null && MdwTouchkitUI.getCurrent()
                            .getDossierEtuFromView().equals(RechercheMobileView.NAME)) {
                        MdwTouchkitUI.getCurrent().navigateToRecherche(null);
                    }
                }
            });
            navbar.addComponent(returnButton);
            navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT);
        }

        //Title
        Label labelTrombi = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getNom());
        labelTrombi.setStyleName("v-label-navbar");
        navbar.addComponent(labelTrombi);
        navbar.setComponentAlignment(labelTrombi, Alignment.MIDDLE_CENTER);

        if (userController.isEnseignant()) {
            //Si on ne peut pas dj revenir sur la recherche via le bouton 'retour'
            if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() == null
                    || !MdwTouchkitUI.getCurrent().getDossierEtuFromView().equals(RechercheMobileView.NAME)) {
                //Bouton Search
                Button searchButton = new Button();
                searchButton.setIcon(FontAwesome.SEARCH);
                searchButton.setStyleName("v-nav-button");
                navbar.addComponent(searchButton);
                navbar.setComponentAlignment(searchButton, Alignment.MIDDLE_RIGHT);
                searchButton.addClickListener(e -> {
                    ((MdwTouchkitUI) MdwTouchkitUI.getCurrent()).navigateToRecherche(NAME);
                });
            }
        }

        navbar.setExpandRatio(labelTrombi, 1);
        addComponent(navbar);

        VerticalLayout globalLayout = new VerticalLayout();
        //globalLayout.setSizeFull();
        globalLayout.setSpacing(true);
        globalLayout.setMargin(true);
        globalLayout.setStyleName("v-scrollableelement");

        VerticalLayout slimLayout = new VerticalLayout();
        slimLayout.setSpacing(false);
        slimLayout.setMargin(false);
        //slimLayout.setStyleName("v-scrollableelement");

        String mail = MdwTouchkitUI.getCurrent().getEtudiant().getEmail();
        if (StringUtils.hasText(mail)) {
            Panel mailPanel = new Panel();
            mailPanel.setStyleName("panel-without-bottom-line-separator");
            HorizontalLayout mailLayout = new HorizontalLayout();
            mailLayout.setSizeFull();
            mailLayout.setHeight("25px");
            Label mailLabel = new Label();

            mail = "<a href=\"mailto:" + mail + "\">" + mail + "</a>";
            mailLabel.setValue(mail);
            mailLabel.setContentMode(ContentMode.HTML);

            mailLabel.setSizeFull();
            mailLabel.addStyleName("label-centre");
            mailLayout.addComponent(mailLabel);
            mailLayout.setComponentAlignment(mailLabel, Alignment.MIDDLE_CENTER);
            mailPanel.setContent(mailLayout);
            slimLayout.addComponent(mailPanel);
            slimLayout.setComponentAlignment(mailPanel, Alignment.MIDDLE_CENTER);
        }

        Panel etuPanel = new Panel();
        HorizontalLayout photoLayout = new HorizontalLayout();
        photoLayout.setId(MdwTouchkitUI.getCurrent().getEtudiant().getCod_ind());
        photoLayout.setSizeFull();
        if (MdwTouchkitUI.getCurrent().getEtudiant().getPhoto() != null) {
            Image fotoEtudiant = new Image(null,
                    new ExternalResource(MdwTouchkitUI.getCurrent().getEtudiant().getPhoto()));
            fotoEtudiant.setWidth("120px");
            fotoEtudiant.setStyleName(ValoTheme.BUTTON_LINK);
            photoLayout.addComponent(fotoEtudiant);

        }
        VerticalLayout nomCodeLayout = new VerticalLayout();
        //nomCodeLayout.setSizeFull();
        nomCodeLayout.setSpacing(false);

        Label labelNomEtudiant = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getNom());
        labelNomEtudiant.setSizeFull();
        labelNomEtudiant.setStyleName(ValoTheme.LABEL_BOLD);
        labelNomEtudiant.addStyleName("label-centre");
        nomCodeLayout.addComponent(labelNomEtudiant);
        nomCodeLayout.setComponentAlignment(labelNomEtudiant, Alignment.MIDDLE_CENTER);
        //nomCodeLayout.setExpandRatio(labelNomEtudiant, 1);

        Label codetuLabel = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getCod_etu());
        codetuLabel.setSizeFull();
        codetuLabel.setStyleName(ValoTheme.LABEL_TINY);
        codetuLabel.addStyleName("label-centre");
        nomCodeLayout.addComponent(codetuLabel);
        nomCodeLayout.setComponentAlignment(codetuLabel, Alignment.MIDDLE_CENTER);

        photoLayout.addComponent(nomCodeLayout);
        photoLayout.setComponentAlignment(nomCodeLayout, Alignment.MIDDLE_CENTER);
        photoLayout.setExpandRatio(nomCodeLayout, 1);

        etuPanel.setContent(photoLayout);

        slimLayout.addComponent(etuPanel);
        slimLayout.setComponentAlignment(etuPanel, Alignment.MIDDLE_CENTER);

        globalLayout.addComponent(slimLayout);

        Panel panelInfos = new Panel(applicationContext.getMessage(NAME + ".infos.title", null, getLocale())
                + " " + Utils.getAnneeUniversitaireEnCours(
                        etudiantController.getAnneeUnivEnCours(MdwTouchkitUI.getCurrent())));
        panelInfos.setStyleName("centertitle-panel");
        panelInfos.addStyleName("v-colored-panel-caption");

        //Si l'tudiant est inscrit pour l'anne en cours
        if (MdwTouchkitUI.getCurrent().getEtudiant().isInscritPourAnneeEnCours()) {

            FormLayout formInfosLayout = new FormLayout();
            formInfosLayout.setSpacing(true);
            formInfosLayout.setMargin(true);

            //Numro Anonymat visible que si l'utilisateur est tudiant
            List<Anonymat> lano = null;
            if (!userController.isEnseignant() && userController.isEtudiant()) {
                lano = MdwTouchkitUI.getCurrent().getEtudiant().getNumerosAnonymat();
                if (lano != null) {
                    //Si l'tudiant n'a qu'un seul numro d'anonymat
                    if (lano.size() == 1) {
                        String captionNumAnonymat = applicationContext.getMessage(NAME + ".numanonymat.title",
                                null, getLocale());
                        TextField fieldNumAnonymat = new TextField(captionNumAnonymat, MdwTouchkitUI
                                .getCurrent().getEtudiant().getNumerosAnonymat().get(0).getCod_etu_ano());
                        formatTextField(fieldNumAnonymat);
                        //fieldNumAnonymat.setIcon(FontAwesome.INFO_CIRCLE);
                        //fieldNumAnonymat.setDescription(applicationContext.getMessage(NAME+".numanonymat.description", null, getLocale()));
                        formInfosLayout.addComponent(fieldNumAnonymat);
                    }
                    //Si l'tudiant a plusieurs numros d'anonymat
                    if (lano.size() > 1) {
                        int i = 0;
                        for (Anonymat ano : lano) {
                            String captionNumAnonymat = "";
                            if (i == 0) {
                                //Pour le premier numro affich on affiche le libell du champ
                                captionNumAnonymat = applicationContext.getMessage(NAME + ".numanonymats.title",
                                        null, getLocale());
                            }
                            TextField fieldNumAnonymat = new TextField(captionNumAnonymat,
                                    ano.getCod_etu_ano() + " (" + ano.getLib_man() + ")");
                            formatTextField(fieldNumAnonymat);
                            if (i == 0) {
                                //Pour le premier numro affich on affiche l'info bulle
                                //fieldNumAnonymat.setIcon(FontAwesome.INFO_CIRCLE);
                                //fieldNumAnonymat.setDescription(applicationContext.getMessage(NAME+".numanonymat.description", null, getLocale()));
                            }
                            formInfosLayout.addComponent(fieldNumAnonymat);
                            i++;
                        }
                    }
                }
            }

            String captionBousier = applicationContext.getMessage(NAME + ".boursier.title", null, getLocale());
            TextField fieldNumBoursier = new TextField(captionBousier,
                    MdwTouchkitUI.getCurrent().getEtudiant().isBoursier()
                            ? applicationContext.getMessage(NAME + ".boursier.oui", null, getLocale())
                            : applicationContext.getMessage(NAME + ".boursier.non", null, getLocale()));
            formatTextField(fieldNumBoursier);
            formInfosLayout.addComponent(fieldNumBoursier);

            String captionSalarie = applicationContext.getMessage(NAME + ".salarie.title", null, getLocale());
            TextField fieldSalarie = new TextField(captionSalarie,
                    MdwTouchkitUI.getCurrent().getEtudiant().isTemSalarie() == true
                            ? applicationContext.getMessage(NAME + ".salarie.oui", null, getLocale())
                            : applicationContext.getMessage(NAME + ".salarie.non", null, getLocale()));
            formatTextField(fieldSalarie);
            formInfosLayout.addComponent(fieldSalarie);

            String captionAmenagementEtude = applicationContext.getMessage(NAME + ".amenagementetude.title",
                    null, getLocale());
            TextField fieldAmenagementEtude = new TextField(captionAmenagementEtude,
                    MdwTouchkitUI.getCurrent().getEtudiant().isTemAmenagementEtude() == true
                            ? applicationContext.getMessage(NAME + ".amenagementetude.oui", null, getLocale())
                            : applicationContext.getMessage(NAME + ".amenagementetude.non", null, getLocale()));
            formatTextField(fieldAmenagementEtude);
            formInfosLayout.addComponent(fieldAmenagementEtude);

            panelInfos.setContent(formInfosLayout);
        } else {

            HorizontalLayout labelNonInscritLayout = new HorizontalLayout();
            labelNonInscritLayout.setMargin(true);
            labelNonInscritLayout.setSizeFull();
            Label labelNonInscrit = new Label(
                    applicationContext.getMessage(NAME + ".inscrit.non", null, getLocale()));
            labelNonInscrit.setStyleName(ValoTheme.LABEL_COLORED);
            labelNonInscrit.addStyleName(ValoTheme.LABEL_BOLD);
            labelNonInscrit.setWidth("100%");
            labelNonInscrit.addStyleName("label-centre");
            labelNonInscritLayout.addComponent(labelNonInscrit);
            panelInfos.setContent(labelNonInscritLayout);

        }
        globalLayout.addComponent(panelInfos);

        addComponent(globalLayout);
        setExpandRatio(globalLayout, 1);

    }
}