private void buildCategoryTree() {
    tree = categoryTree.initialize();
    tree.addItemClickListener(this);
    tree.setSizeUndefined();

    treePanel.addStyleName(Runo.PANEL_LIGHT);
    treePanel.setHeight("100%");
    treePanel.setContent(treeLayout);

    treeLayout.setImmediate(true);
    treeLayout.setMargin(true);
    treeLayout.setSizeUndefined();
    treeLayout.addStyleName(Reindeer.LAYOUT_WHITE);
    treeLayout.addComponent(tree);

    topTreeLayout.setHeight("100%");
    topTreeLayout.setCaption("Categories");
    topTreeLayout.addStyleName(Runo.LAYOUT_DARKER);
    // topTreeLayout.addComponent(lblCategoryCaption);
    topTreeLayout.addComponent(treePanel);

    btnCreate.addClickListener(this);
    btnUpdate.addClickListener(this);
    btnDelete.addClickListener(this);
  }
  public SettingsLayout(String userName, MainPage mainPage) {
    this.mainPage = mainPage;
    this.userName = userName;

    WebApplicationContext context = (WebApplicationContext) mainPage.getContext();
    WebBrowser webBrowser = context.getBrowser();
    height = webBrowser.getScreenHeight() - 310;

    setMargin(true);
    setSpacing(true);
    vl.setMargin(true);
    vl.setSpacing(true);
    panelEmail.setWidth("100%");
    addComponent(hl);

    hl.setFirstComponent(panelEmail);
    hl.setSecondComponent(panelPassword);

    oldEmail.setValue(GeneralController.getEmailFromUserName(userName));
    oldEmail.setWidth("250");
    oldEmail.setReadOnly(false);

    newEmail.setWidth("250");
    newEmail.addValidator(new EmailValidator("Email должен содержать знак '@' и полный домен."));

    saveButton = new Button("Сохранить изменения");
    saveButton.setVisible(true);
    saveButton.setIcon(new ThemeResource("icons/32/save.png"));

    resetUserPasswordButton.setVisible(true);
    resetUserPasswordButton.setIcon(new ThemeResource("icons/32/group_key.png"));
    resetUserPasswordButton.addListener(this);

    oldEmailInscription.setReadOnly(true);
    panelEmail.addComponent(oldEmailInscription);
    panelEmail.addComponent(oldEmail);
    panelEmail.addComponent(newEmail);
    panelEmail.addComponent(saveButton);
    panelPassword.addComponent(label);
    panelPassword.addComponent(resetUserPasswordButton);

    panelEmail.setHeight(height);
    panelPassword.setHeight(height);

    saveButton.addListener(this);
  }
  private void addBanner() {
    Panel bannerPanel = new Panel();
    bannerPanel.setHeight(Global.APP_BANNER_HEIGHT);
    bannerPanel.setStyleName(BANNERPANEL.toString());

    VerticalLayout banner = new VerticalLayout();
    banner.addComponent(bannerPanel);
    banner.setHeightUndefined();

    header.addComponent(banner);
    header.setComponentAlignment(banner, Alignment.TOP_CENTER);
  }
  private void refreshHeight(final int dataSize) {
    WebBrowser browser = Page.getCurrent().getWebBrowser();
    int maxFitRows = (int) (browser.getScreenHeight() * 0.775f) / 50;
    float multiplyFactor = (50.0f / (browser.getScreenHeight() * 0.775f)) * 100;
    /*		Page.getCurrent().getBrowserWindowWidth();

    int screenWidth = browser.getScreenWidth();
    int screenHeight = browser.getScreenHeight();*/
    float height = dataSize > maxFitRows ? dataSize * multiplyFactor : 100.0f;
    panel.setHeight(height, Unit.PERCENTAGE);
    panel.markAsDirty();
  }
  @AutoGenerated
  private Panel buildPanel_1() {
    // common part: create layout
    panel_1 = new Panel();
    panel_1.setImmediate(false);
    panel_1.setWidth("100.0%");
    panel_1.setHeight("100.0%");

    // verticalLayout_1
    verticalLayout_1 = buildVerticalLayout_1();
    panel_1.setContent(verticalLayout_1);

    return panel_1;
  }
  @AutoGenerated
  private Panel buildPanCaracteristicas() {
    // common part: create layout
    panCaracteristicas = new Panel();
    panCaracteristicas.setImmediate(false);
    panCaracteristicas.setWidth("100.0%");
    panCaracteristicas.setHeight("-1px");

    // verLCaracteristicas
    verLCaracteristicas = buildVerLCaracteristicas();
    panCaracteristicas.setContent(verLCaracteristicas);

    return panCaracteristicas;
  }
  @Override
  public void attach() {
    super.attach();

    rootPanel = new Panel("Connect to...");
    rootPanel.addStyleName(ValoTheme.PANEL_WELL);
    rootPanel.setWidth("500px");
    rootPanel.setHeight("300px");
    recreateRootLayout();

    setSizeFull();
    addComponent(rootPanel);
    setComponentAlignment(rootPanel, Alignment.MIDDLE_CENTER);
  }
  @AutoGenerated
  private Panel buildPanAvanceRecesion() {
    // common part: create layout
    panAvanceRecesion = new Panel();
    panAvanceRecesion.setCaption("Avance-Recesión");
    panAvanceRecesion.setImmediate(false);
    panAvanceRecesion.setWidth("100.0%");
    panAvanceRecesion.setHeight("-1px");

    // absLAvanceRecesion
    absLAvanceRecesion = buildAbsLAvanceRecesion();
    panAvanceRecesion.setContent(absLAvanceRecesion);

    return panAvanceRecesion;
  }
Exemple #9
0
 @Override
 protected void setup(VaadinRequest request) {
   Panel panel = new Panel();
   panel.setId("mainPanel");
   panel.setWidth("200px");
   panel.setHeight("200px");
   VerticalLayout layout = new VerticalLayout();
   layout.setWidth("500px");
   layout.setHeight("500px");
   Button btn = new Button("Button 1");
   Button btn2 = new Button("Button 2");
   layout.addComponent(btn);
   layout.setComponentAlignment(btn, Alignment.TOP_RIGHT);
   layout.addComponent(btn2);
   layout.setComponentAlignment(btn2, Alignment.BOTTOM_LEFT);
   panel.setContent(layout);
   addComponent(panel);
 }
  private void addLayoutTest(Layout l) {
    l.setSizeFull();

    Label lbl = new Label("First (expand ratio 1)");
    lbl.setSizeUndefined();
    l.addComponent(lbl);

    lbl = new Label("Second (margin 10px)");
    lbl.setSizeUndefined();
    lbl.addStyleName("hugemargin");
    l.addComponent(lbl);

    lbl = new Label("Third (margin+xr)");
    lbl.setSizeUndefined();
    lbl.addStyleName("hugemargin");
    l.addComponent(lbl);

    Panel p = new Panel(l.getClass().getSimpleName(), l);
    p.setWidth("600px");
    p.setHeight("200px");
    addComponent(p);
  }
  public Component getComponent() {
    Responsive.makeResponsive(panel);
    panel.setSizeFull();

    panel.setHeight(100, Unit.PERCENTAGE);

    // p.setHeight(200, Unit.PERCENTAGE);
    HorizontalLayout layout = new HorizontalLayout();

    layout.setSizeFull();

    layout.addComponent(projectInfo);
    layout.addComponent(dataPart);
    layout.addComponent(commentsGrid);

    layout.setExpandRatio(projectInfo, 2.8f);
    layout.setExpandRatio(dataPart, 6.2f);
    layout.setExpandRatio(commentsGrid, 2.1f);

    panel.setContent(layout);

    return panel;
  }
    public Layout buildLayout() {
      VerticalLayout layout = new VerticalLayout();
      VerticalLayout panelLayout = new VerticalLayout();
      panelLayout.setMargin(true);
      final Panel widePanel = new Panel("too big", panelLayout);
      widePanel.setSizeUndefined();
      widePanel.setWidth("2000px");
      widePanel.setHeight("200px");
      layout.addComponent(widePanel);
      Button button =
          new Button(
              "Change panel size",
              new ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                  switch (step++ % 4) {
                    case 0:
                      widePanel.setWidth("200px");
                      break;
                    case 1:
                      widePanel.setHeight("2000px");
                      break;
                    case 2:
                      widePanel.setWidth("2000px");
                      break;
                    case 3:
                      widePanel.setHeight("200px");
                      break;
                  }
                }
              });
      panelLayout.addComponent(button);
      layout.setSizeUndefined();
      return layout;
    }
Exemple #13
0
  private Panel designLoginPanel() {

    final Panel loginPanel = new Panel("Login");
    HashMap<String, String> users = null;

    loginPanel.setWidth("100%");
    loginPanel.setHeight("100%");
    // Create absolute layout specifying its properties
    final AbsoluteLayout loginLayout = new AbsoluteLayout();
    loginLayout.setSizeFull();
    // Create components Objects and specify their properties
    int startLeft = 200, startTop = 300;
    try {
      users = getLoginInfo("jdbc:mysql://localhost:3306/", "linkeval", "root", "mofo");
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    Button btnLogin = new Button("Login");
    final ComboBox cmbUser = new ComboBox("Select your USER ID");
    final ComboBox cmbTask = new ComboBox("Select your TASK");
    cmbUser.setNullSelectionAllowed(false);
    cmbTask.setNullSelectionAllowed(false);
    // Add data
    Iterator it = users.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry pairs = (Map.Entry) it.next();
      cmbUser.addItem(pairs.getKey());
      cmbUser.setItemCaption(pairs.getKey(), pairs.getValue().toString());
      it.remove(); // avoids a ConcurrentModificationException
    }

    cmbUser.setValue(cmbUser.getItemIds().iterator().next());

    // Listeners

    btnLogin.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            userId =
                String.valueOf(
                    cmbUser
                        .getValue()); // which is his Id in tabel as this combo box shows names as
            // captions and Ids as values
            userName = cmbUser.getItemCaption(userId);
            task = String.valueOf(cmbTask.getValue());
            if (task != "" && userId != "") {
              VerticalSplitPanel vsplit = new VerticalSplitPanel();
              displayedPanel = designMainPanel();
              vsplit.setSecondComponent(displayedPanel);
              vsplit.setFirstComponent(allLinksDetails());
              UI.getCurrent().setContent(vsplit);
            }
          }
        });
    cmbUser.addFocusListener(
        new FocusListener() {

          @Override
          public void focus(FocusEvent event) {
            // TODO Auto-generated method stub
            cmbUser.setValue(cmbUser.getItemIds().iterator().next());
          }
        });
    cmbUser.addValueChangeListener(
        new ValueChangeListener() {
          @Override
          public void valueChange(final ValueChangeEvent event) {
            final String valueString = String.valueOf(event.getProperty().getValue());

            try {
              List<String> tasks =
                  getTasksInfo(
                      "jdbc:mysql://localhost:3306/", "linkeval", "root", "mofo", valueString);

              cmbTask.removeAllItems();
              if (tasks != null) {
                for (String task : tasks) {
                  cmbTask.addItem(task);
                }
                cmbTask.setValue(cmbTask.getItemIds().iterator().next());
              }
            } catch (SQLException e) {
              // TODO Auto-generated catch block
              Notification.show(e.getMessage());
            }
          }
        });

    loginLayout.addComponent(cmbUser, "left: 800px; top: 200px;");
    loginLayout.addComponent(cmbTask, "left: 800px; top: 300px;");
    loginLayout.addComponent(btnLogin, "left: 900px; top: 400px;");

    loginPanel.setContent(loginLayout);

    return loginPanel;
  }
Exemple #14
0
  private Panel designMainPanel() {
    // positioning indices
    final int leftStart = 450, topStart = 10, space = 100;
    // create the panel that will hold all components

    Panel pnlURIsProperties = new Panel("URI Display");

    pnlURIsProperties.setWidth("100%");
    pnlURIsProperties.setHeight("100%");

    // Create absolute layout specifying its properties
    final AbsoluteLayout layout = new AbsoluteLayout();
    layout.setWidth("100%");
    layout.setHeight("100%");
    layout.setSizeFull();

    // Create components Objects and specify their properties

    Button btnCorrect = new Button("Correct");
    Button btnIncorrect = new Button("Incorrect");
    Button btnUnsure = new Button("Unsure");
    Button btnGetProperties = new Button("Get properties");

    final NativeSelect cmbSourceEndpoint = new NativeSelect("Source Endpoint");
    final NativeSelect cmbDestinationEndpoint = new NativeSelect("Destination Endpoint");
    final ListSelect lstSuggestedProperties = new ListSelect("Lookup Properties");
    // to load properties of loaded resources automatically
    final CheckBox chkAutomaticPropertiesLoad =
        new CheckBox("Automatic Properties loading (next time)");
    chkAutomaticPropertiesLoad.setValue(false);

    cmbSourceEndpoint.setNullSelectionAllowed(false);
    cmbDestinationEndpoint.setNullSelectionAllowed(false);

    lstSuggestedProperties.setRows(4);
    lstSuggestedProperties.setNullSelectionAllowed(false);

    source = new Label("Source URI");
    destination = new Label("Destination URI");

    final Table tblSourcePropertiesMapping = new Table("Source Properties");
    final Table tblDestinationPropertiesMapping = new Table("Destination Properties");
    tblSourcePropertiesParam = tblSourcePropertiesMapping;
    tblDestinationPropertiesParam = tblDestinationPropertiesMapping;

    tblSourcePropertiesMapping.setWidth("50%");
    tblDestinationPropertiesMapping.setWidth("100%");
    tblSourcePropertiesMapping.setSelectable(true);
    tblDestinationPropertiesMapping.setSelectable(true);
    /* Define the names and data types of columns.
     * The "default value" parameter is meaningless here. */
    tblSourcePropertiesMapping.addContainerProperty("Property", String.class, null);
    tblSourcePropertiesMapping.addContainerProperty("Value", String.class, null);

    tblDestinationPropertiesMapping.addContainerProperty("Property", String.class, null);
    tblDestinationPropertiesMapping.addContainerProperty("Value", String.class, null);
    tblDestinationPropertiesMapping.setMultiSelect(true);
    /// get data for comboboxes
    SQLContainer cmbContainer = connectToDB("root", "mofo", "Endpoints");
    // fill endpoints
    cmbSourceEndpoint.setContainerDataSource(cmbContainer);
    cmbDestinationEndpoint.setContainerDataSource(cmbContainer);

    cmbSourceEndpoint.setValue(cmbSourceEndpoint.getItemIds().iterator().next());
    cmbDestinationEndpoint.setValue(cmbDestinationEndpoint.getItemIds().iterator().next());

    SQLContainer lstContainer = getSuggestedProperties("root", "mofo");
    int lstSize = lstContainer.size();
    int i = 0;
    for (Object cityItemId : lstContainer.getItemIds()) {
      lstSuggestedProperties.addItem(i);
      String g = lstContainer.getItem(cityItemId).getItemProperty("property").getValue().toString();
      lstSuggestedProperties.setItemCaption(i, g);
      i++;
    }
    lstSuggestedProperties.setValue(lstSuggestedProperties.getItemIds().iterator().next());

    btnCorrect.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            try {
              Object rowId = tblSourceDestinationparam.getValue();
              Item myitem = tblSourceDestinationparam.getItem(tblSourceDestinationparam.getValue());
              lEndTime = System.currentTimeMillis();
              long lEllapsedTime = lEndTime - lStartTime;
              tblSourceDestinationparam.setEditable(true);
              tblSourceDestinationparam.getContainerProperty(rowId, "decision").setValue("Correct");
              tblSourceDestinationparam
                  .getContainerProperty(rowId, "time")
                  .setValue(String.valueOf(lEllapsedTime));

              tblSourceDestinationparam.setEditable(false);
              SQLContainer c = (SQLContainer) tblSourceDestinationparam.getContainerDataSource();
              try {
                c.commit();
              } catch (UnsupportedOperationException | SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
              int maxindex = tblSourceDestination.size();
              SQLContainer s = (SQLContainer) tblSourceDestination.getContainerDataSource();
              // Item x=s.getItem(tblSourceDestination.getValue());
              if (!(tblSourceDestination.getValue().equals(tblSourceDestination.lastItemId()))) {
                int index = s.indexOfId(tblSourceDestination.getValue());
                index++;
                tblSourceDestination.setValue(s.getIdByIndex(index));
                try {
                  Object rowId2 = tblSourceDestination.getValue();
                  Property sourceProperty =
                      tblSourceDestination.getContainerProperty(rowId2, "sourceURI");
                  Property destinationProperty =
                      tblSourceDestination.getContainerProperty(rowId2, "destinationURI");

                  source.setValue(sourceProperty.toString());
                  destination.setValue(destinationProperty.toString());
                  tblSourcePropertiesParam.removeAllItems();
                  tblDestinationPropertiesParam.removeAllItems();

                  Notification loadURI = new Notification("");
                  loadURI.show("Links' URIs are successfully loaded ");
                  if (chkAutomaticPropertiesLoad.getValue()) // the automatic buton i schecked
                  {
                    // load the properties automatically
                    String sourceEndpoint = "", destinationEndpoint = "";
                    sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue());
                    destinationEndpoint =
                        cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue());
                    try {
                      String sparqlQuery = source.getValue();
                      getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping);
                      sparqlQuery = destination.getValue();
                      getURIProperties(
                          sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping);
                    } catch (Exception e) {
                      Notification.show("ERROR");
                    }
                    lStartTime = System.currentTimeMillis();
                    // start time for next one
                  }
                } catch (Exception e) {
                  Notification error = new Notification("Error");
                  error.show("You did not select an item in the links table");
                }
              }
            } catch (Exception e) {
              Notification.show(e.getMessage());
            }

            ///////////////////////////////////

          }
        });
    btnIncorrect.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            try {
              Object rowId = tblSourceDestinationparam.getValue();
              Item myitem = tblSourceDestinationparam.getItem(tblSourceDestinationparam.getValue());
              lEndTime = System.currentTimeMillis();
              long lEllapsedTime = lEndTime - lStartTime;
              tblSourceDestinationparam.setEditable(true);
              tblSourceDestinationparam
                  .getContainerProperty(rowId, "decision")
                  .setValue("Incorrect");
              tblSourceDestinationparam
                  .getContainerProperty(rowId, "time")
                  .setValue(String.valueOf(lEllapsedTime));
              tblSourceDestinationparam.setEditable(false);
              SQLContainer c = (SQLContainer) tblSourceDestinationparam.getContainerDataSource();
              try {
                c.commit();
              } catch (UnsupportedOperationException | SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
              int maxindex = tblSourceDestination.size();
              SQLContainer s = (SQLContainer) tblSourceDestination.getContainerDataSource();
              // Item x=s.getItem(tblSourceDestination.getValue());
              if (!(tblSourceDestination.getValue().equals(tblSourceDestination.lastItemId()))) {
                int index = s.indexOfId(tblSourceDestination.getValue());
                index++;
                tblSourceDestination.setValue(s.getIdByIndex(index));
                try {
                  Object rowId2 = tblSourceDestination.getValue();
                  Property sourceProperty =
                      tblSourceDestination.getContainerProperty(rowId2, "sourceURI");
                  Property destinationProperty =
                      tblSourceDestination.getContainerProperty(rowId2, "destinationURI");

                  source.setValue(sourceProperty.toString());
                  destination.setValue(destinationProperty.toString());
                  tblSourcePropertiesParam.removeAllItems();
                  tblDestinationPropertiesParam.removeAllItems();

                  Notification loadURI = new Notification("");
                  loadURI.show("Links' URIs are successfully loaded ");

                  if (chkAutomaticPropertiesLoad.getValue()) // the automatic buton i schecked
                  {
                    // load the properties automatically
                    String sourceEndpoint = "", destinationEndpoint = "";
                    sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue());
                    destinationEndpoint =
                        cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue());
                    try {
                      String sparqlQuery = source.getValue();
                      getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping);
                      sparqlQuery = destination.getValue();
                      getURIProperties(
                          sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping);
                    } catch (Exception e) {
                      Notification.show("ERROR Not Properties queried");
                    }
                    lStartTime = System.currentTimeMillis();
                    // start time for next one
                  }
                } catch (Exception e) {
                  Notification error = new Notification("Error");
                  error.show("You did not select an item in the links table");
                }
              }
            } catch (Exception e) {
              Notification.show(e.getMessage());
            }
            ///////////////////////////////////

          }
        });
    btnUnsure.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            try {
              Object rowId = tblSourceDestinationparam.getValue();
              Item myitem = tblSourceDestinationparam.getItem(tblSourceDestinationparam.getValue());
              lEndTime = System.currentTimeMillis();
              float lEllapsedTime = lEndTime - lStartTime;
              String elapsedTime = String.valueOf(lEllapsedTime);
              tblSourceDestinationparam.setEditable(true);
              tblSourceDestinationparam.getContainerProperty(rowId, "decision").setValue("Unsure");
              tblSourceDestinationparam.getContainerProperty(rowId, "time").setValue(elapsedTime);
              tblSourceDestinationparam.setEditable(false);
              SQLContainer c = (SQLContainer) tblSourceDestinationparam.getContainerDataSource();
              try {
                c.commit();
              } catch (UnsupportedOperationException | SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }

              // int selectedId=Integer.parseInt(tblSourceDestination.getValue().toString());
              int maxindex = tblSourceDestination.size();
              SQLContainer s = (SQLContainer) tblSourceDestination.getContainerDataSource();
              // Item x=s.getItem(tblSourceDestination.getValue());
              if (!(tblSourceDestination.getValue().equals(tblSourceDestination.lastItemId()))) {
                int index = s.indexOfId(tblSourceDestination.getValue());
                index++;
                tblSourceDestination.setValue(s.getIdByIndex(index));
                try {
                  Object rowId2 = tblSourceDestination.getValue();
                  Property sourceProperty =
                      tblSourceDestination.getContainerProperty(rowId2, "sourceURI");
                  Property destinationProperty =
                      tblSourceDestination.getContainerProperty(rowId2, "destinationURI");

                  source.setValue(sourceProperty.toString());
                  destination.setValue(destinationProperty.toString());
                  tblSourcePropertiesParam.removeAllItems();
                  tblDestinationPropertiesParam.removeAllItems();

                  Notification loadURI = new Notification("");
                  loadURI.show("Links' URIs are successfully loaded ");
                  if (chkAutomaticPropertiesLoad.getValue()) // the automatic buton i schecked
                  {
                    // load the properties automatically
                    String sourceEndpoint = "", destinationEndpoint = "";
                    sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue());
                    destinationEndpoint =
                        cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue());
                    try {
                      String sparqlQuery = source.getValue();
                      getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping);
                      sparqlQuery = destination.getValue();
                      getURIProperties(
                          sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping);
                    } catch (Exception e) {
                      Notification.show("ERROR Not Properties queried");
                    }
                    lStartTime = System.currentTimeMillis();
                    // start time for next one
                  }
                } catch (Exception e) {
                  Notification error = new Notification("Error");
                  error.show("You did not select an item in the links table");
                }
              }
            } catch (Exception e) {
              Notification.show(e.getMessage());
            }
          }
        });
    btnGetProperties.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            String sourceEndpoint = "", destinationEndpoint = "";
            sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue());
            destinationEndpoint =
                cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue());
            lStartTime = System.currentTimeMillis();

            try {
              String sparqlQuery = source.getValue();
              getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping);
              sparqlQuery = destination.getValue();
              getURIProperties(sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping);
            } catch (Exception e) {
              Notification.show(
                  "ERROR while sparqling the endpoint for resources' properties (Are they selected/loaded ?)");
            }
            // cachingForTriples(tblSourceDestination, sourceEndpoint);
          }
        });

    lstSuggestedProperties.addValueChangeListener(
        new ValueChangeListener() {
          @Override
          public void valueChange(final ValueChangeEvent event) {
            final String valueString = String.valueOf(event.getProperty().getValue());
            // Notification.show(valueString);
            List<Object> Ids = new ArrayList<Object>();
            Object first = null;
            for (Iterator i = tblSourcePropertiesMapping.getItemIds().iterator(); i.hasNext(); ) {
              // Get the current item identifier, which is an integer.
              first = i.next();
              int iid = (Integer) first;
              String other =
                  tblSourcePropertiesMapping.getItem(iid).getItemProperty("Property").toString();
              // Notification.show(other);
              if (other.equals(valueString)) // if(other.equals(property))
              {
                Ids.add(iid);
                break;
              }
            }
            tblSourcePropertiesMapping.setImmediate(true);
            tblSourcePropertiesMapping.setValue(Ids);
            tblDestinationPropertiesMapping.setCurrentPageFirstItemId(first);
          }
        });

    tblSourcePropertiesMapping.addItemClickListener(
        new ItemClickEvent.ItemClickListener() {

          @Override
          public void itemClick(ItemClickEvent event) {
            String property =
                tblSourcePropertiesMapping
                    .getContainerProperty(event.getItemId(), event.getPropertyId())
                    .toString();
            List<String> res = getRelatedProperties(property);

            if (res == null) {
              Notification.show("No related Properties");
              return;
            }
            boolean Found = false;
            List<Object> Ids = new ArrayList<Object>();
            Object first = null;
            int x = 0;
            for (String relatedProperty : res) {
              for (Iterator i = tblDestinationPropertiesMapping.getItemIds().iterator();
                  i.hasNext(); ) {
                // Get the current item identifier, which is an integer.
                Object theId = i.next();
                int iid = (Integer) theId;
                String other =
                    tblDestinationPropertiesMapping
                        .getItem(iid)
                        .getItemProperty(event.getPropertyId())
                        .toString();

                if (other.equals(relatedProperty)) // if(other.equals(property))
                {
                  Ids.add(iid);
                  if (x == 0) {
                    first = theId;
                    x = 1;
                  }
                  Found = true;
                }
              }
            }
            if (!Found)
              Notification.show(
                  "Related property is not Found in destination table try manual search");
            else {
              Notification.show("Found in destination table");
              tblDestinationPropertiesMapping.setValue(Ids);
              tblDestinationPropertiesMapping.setCurrentPageFirstItemId(first);
            }
          }
        });
    // add component to the layout specifying its position on the layout

    layout.addComponent(btnCorrect, "left: " + leftStart + "px; top: " + (topStart + 450) + "px;");
    layout.addComponent(
        btnIncorrect, "left: " + (leftStart + space) + "px; top: " + (topStart + 450) + "px;");
    layout.addComponent(
        btnUnsure, "left: " + (leftStart + 2 * space) + "px; top: " + (topStart + 450) + "px;");
    layout.addComponent(
        btnGetProperties,
        "left: " + (leftStart + 3 * space + 50) + "px; top: " + (topStart + 450) + "px;");
    layout.addComponent(
        chkAutomaticPropertiesLoad,
        "left: " + (leftStart + 3 * space + 250) + "px; top: " + (topStart + 450) + "px;");

    /*layout.addComponent(sourceURI,"left: "+(leftStart-space/2)+"px; top: "+(topStart+space/2)+"px;");
    layout.addComponent(destinationURI,"left: "+(leftStart+2*space)+"px; top: "+(topStart+space/2)+"px;");*/

    layout.addComponent(source, "left: 30px; top: " + (topStart + space / 2) + "px;");
    layout.addComponent(
        destination,
        "left: " + (leftStart + 3 * space + 200) + "px; top: " + (topStart + space / 2) + "px;");

    layout.addComponent(cmbSourceEndpoint, "left: 50px; top: " + (topStart + 20) + "px;");
    layout.addComponent(
        cmbDestinationEndpoint,
        "left: " + (leftStart + 3 * space + 200) + "px; top: " + (topStart + 20) + "px;");
    layout.addComponent(
        lstSuggestedProperties,
        "left: " + (leftStart + 100) + "px; top: " + (topStart + 20) + "px;");

    layout.addComponent(
        tblSourcePropertiesMapping, "left: 10px; top: " + (topStart + space) + "px;");
    layout.addComponent(
        tblDestinationPropertiesMapping,
        "left: " + (leftStart + 3 * space + 200) + "px; top: " + (topStart + space) + "px;");

    pnlURIsProperties.setContent(layout);

    return pnlURIsProperties;
  }
Exemple #15
0
  private Panel allLinksDetails() {
    // positioning indices
    // final int leftStart=10,topStart=10, space=100;
    // create the panel that will hold all components
    Panel linksDetails = new Panel("Links Details");
    // set panel's properties
    linksDetails.setWidth("100%");
    linksDetails.setHeight("100%");

    // Create absolute layout specifying its properties
    final AbsoluteLayout layout = new AbsoluteLayout();
    // set layout's properties
    layout.setSizeFull();

    // Create components Objects and specify their properties
    Button btnLoad = new Button("Load task");
    // final Table tblSourceDestination = new Table("Source and Destination URIs");
    tblSourceDestination.setSelectable(true);
    tblSourceDestination.setWidth("90%");
    // fill the Source and Destination URIs table
    SQLContainer container = connectToDB("root", "mofo", userName);
    Notification.show("Welcome " + userName + " you loaded task Nr.: " + task);
    Compare.Equal suburbFilter = new Compare.Equal("taskId", Integer.valueOf(task));
    container.addContainerFilter(suburbFilter);
    // Fill the main (tblSourceDestination) table with resources
    tblSourceDestination.setContainerDataSource(container);
    tblSourceDestinationparam = tblSourceDestination;

    // add component to the layout specifying its position on the layout
    int tableWidth = (int) tblSourceDestination.getWidth();
    layout.addComponent(btnLoad, "left:1500px; top: 10px;");
    layout.addComponent(tblSourceDestination, "left: 10px; top: 20px;");

    linksDetails.setContent(layout);
    // Add EventHandlers for some of the components

    btnLoad.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            // lStartTime= System.currentTimeMillis();

            try {
              Object rowId = tblSourceDestination.getValue();
              Property sourceProperty =
                  tblSourceDestination.getContainerProperty(rowId, "sourceURI");
              Property destinationProperty =
                  tblSourceDestination.getContainerProperty(rowId, "destinationURI");

              source.setValue(sourceProperty.toString());
              destination.setValue(destinationProperty.toString());
              tblSourcePropertiesParam.removeAllItems();
              tblDestinationPropertiesParam.removeAllItems();

              Notification loadURI = new Notification("");
              loadURI.show("Links' URIs are successfully loaded ");
            } catch (Exception e) {
              Notification error = new Notification("Error");
              error.show("You did not select an item in the links table");
            }
          }
        });

    tblSourceDestination.addItemClickListener(
        new ItemClickEvent.ItemClickListener() {

          @Override
          public void itemClick(ItemClickEvent event) {
            /*lStartTime= System.currentTimeMillis();

            try
            {
            	Object rowId =tblSourceDestination.getValue();
                Property sourceProperty=tblSourceDestination.getContainerProperty(rowId,"sourceURI");
                Property destinationProperty=tblSourceDestination.getContainerProperty(rowId,"destinationURI");

                source.setValue(sourceProperty.toString());
                destination.setValue(destinationProperty.toString());
                tblSourcePropertiesParam.removeAllItems();
                tblDestinationPropertiesParam.removeAllItems();


                Notification loadURI= new Notification("");
                loadURI.show("Links' URIs are successfully loaded ");
            }
            catch(Exception e)
            {
            	Notification error= new Notification("Error");
            	error.show("You did not select an item in the links table");
            }*/
          }
        });

    return linksDetails;
  }
Exemple #16
0
  public ExceptionDialog(Throwable ex, String caption) {
    this.cause = ex;
    Preconditions.checkNotNull(ex);

    layout = new VerticalLayout();
    setContent(layout);
    layout.setWidth("100%");
    layout.setHeight("-1");

    if (caption == null) {
      setCaption("Unexpected error");
    } else {
      setCaption(caption);
    }

    Label lblInfo =
        new Label("An unexpected error occured.<br />The error message was:", ContentMode.HTML);
    lblInfo.setHeight("-1px");
    lblInfo.setWidth("100%");
    layout.addComponent(lblInfo);
    lblInfo.addStyleName("exception-message-caption");

    String message = ex.getMessage();
    if (message == null || message.isEmpty()) {
      message = "<no message>";
    }
    Label lblMessage = new Label(message);
    lblMessage.addStyleName("exception-message-content");
    lblMessage.setHeight("-1px");
    lblMessage.setWidth("100%");
    layout.addComponent(lblMessage);

    actionsLayout = new HorizontalLayout();
    actionsLayout.addStyleName("exception-dlg-details");
    actionsLayout.setWidth("100%");
    actionsLayout.setHeight("-1px");
    layout.addComponent(actionsLayout);

    btDetails = new Button("Show Details", this);
    btDetails.setStyleName(BaseTheme.BUTTON_LINK);
    actionsLayout.addComponent(btDetails);

    btReportBug = new Button("Report Problem", this);
    btReportBug.setStyleName(BaseTheme.BUTTON_LINK);
    btReportBug.setVisible(false);
    btReportBug.setIcon(FontAwesome.ENVELOPE_O);
    UI ui = UI.getCurrent();
    if (ui instanceof SearchUI) {
      btReportBug.setVisible(((SearchUI) ui).canReportBugs());
    }
    actionsLayout.addComponent(btReportBug);
    actionsLayout.setComponentAlignment(btDetails, Alignment.TOP_LEFT);
    actionsLayout.setComponentAlignment(btReportBug, Alignment.TOP_RIGHT);

    lblStacktrace = new Label(Helper.convertExceptionToMessage(ex), ContentMode.PREFORMATTED);
    detailsPanel = new Panel(lblStacktrace);
    detailsPanel.setWidth("100%");
    detailsPanel.setHeight("300px");
    detailsPanel.setVisible(false);
    lblStacktrace.setSizeUndefined();
    lblStacktrace.setVisible(true);
    layout.addComponent(detailsPanel);

    btClose = new Button("OK", this);
    layout.addComponent(btClose);

    layout.setComponentAlignment(btClose, Alignment.BOTTOM_CENTER);
    layout.setExpandRatio(detailsPanel, 0.0f);
    layout.setExpandRatio(actionsLayout, 1.0f);
  }
  @Override
  public void buildComponent(
      String date, String title, String content, Long id, String authorName) {

    addStyleName("subjectNews");

    Label subjectDate = new Label();
    subjectDate.setContentMode(labelContentMode);
    subjectDate.setValue("Publicado: " + date);
    subjectDate.setStyleName(ValoTheme.LABEL_TINY);
    subjectDate.setSizeUndefined();

    // subject
    Label subject = new Label();
    subject.setContentMode(labelContentMode);
    subject.setValue(this.subjectName);

    // content
    Label contentSubject = new Label();
    contentSubject.setContentMode(labelContentMode);
    contentSubject.setValue(content);
    contentSubject.setWidth("100%");

    // title
    Label titleSubject = new Label();
    titleSubject.setContentMode(labelContentMode);
    titleSubject.setValue(title);
    titleSubject.setStyleName(ValoTheme.LABEL_BOLD);

    // author
    Label autName = new Label();
    autName.setContentMode(labelContentMode);
    autName.setValue("Autor: " + authorName);
    autName.setStyleName(ValoTheme.LABEL_TINY);
    autName.setSizeUndefined();

    Panel panel = new Panel();
    panel.setContent(contentSubject);
    panel.setSizeFull();
    panel.setHeight("100px");
    panel.setStyleName(ValoTheme.PANEL_WELL);

    HorizontalLayout topHorizontalLayout = new HorizontalLayout();
    HorizontalLayout botHorizontalLayout = new HorizontalLayout();
    HorizontalLayout auxHorizontalLayout = new HorizontalLayout();
    VerticalLayout elementLayout = new VerticalLayout();

    topHorizontalLayout.setSizeFull();
    topHorizontalLayout.setSpacing(false);
    topHorizontalLayout.setMargin(false);
    topHorizontalLayout.addComponents(autName, subjectDate);
    topHorizontalLayout.setComponentAlignment(subjectDate, Alignment.MIDDLE_RIGHT);
    topHorizontalLayout.setComponentAlignment(autName, Alignment.MIDDLE_LEFT);

    Button editButton = new Button("Editar");
    editButton.setData(id);
    editButton.addClickListener(parentView);
    editButton.addStyleName(ValoTheme.BUTTON_TINY);
    editButton.setWidth("70%");
    editButton.setHeight("70%");

    Button deleteButton = new Button("Eliminar");
    deleteButton.setData(id);
    deleteButton.addClickListener(parentView);
    deleteButton.addStyleName(ValoTheme.BUTTON_TINY);
    deleteButton.setWidth("70%");
    deleteButton.setHeight("70%");

    botHorizontalLayout.setSizeUndefined();
    botHorizontalLayout.setSpacing(false);
    botHorizontalLayout.addComponents(editButton, deleteButton);

    auxHorizontalLayout.setSizeFull();
    auxHorizontalLayout.setSpacing(false);

    elementLayout.setMargin(false);
    elementLayout.setSizeFull();
    elementLayout.setSpacing(false);

    if (id == null) auxHorizontalLayout.addComponents(titleSubject);
    else {
      auxHorizontalLayout.addComponents(titleSubject, botHorizontalLayout);
      auxHorizontalLayout.setComponentAlignment(botHorizontalLayout, Alignment.MIDDLE_RIGHT);
    }

    elementLayout.addComponents(auxHorizontalLayout, panel, topHorizontalLayout, new Hr());

    this.mainLayout.addComponent(elementLayout);
  }
  public void init(final Window main) {
    VerticalLayout mainLayout = new VerticalLayout();
    main.setContent(mainLayout);
    mainLayout.setSizeFull();

    HorizontalLayout titlebar = new HorizontalLayout();
    titlebar.addStyleName("titlebar");
    titlebar.setWidth("100%");
    Label title = new Label("Book of Vaadin Examples");
    title.addStyleName("title");
    titlebar.addComponent(title);
    titlebar.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);
    Embedded logo = new Embedded(null, new ThemeResource("img/vaadin-logo.png"));
    titlebar.addComponent(logo);
    titlebar.setComponentAlignment(logo, Alignment.MIDDLE_RIGHT);
    main.addComponent(titlebar);

    HorizontalLayout hor = new HorizontalLayout();
    hor.setSizeFull();
    main.addComponent(hor);
    mainLayout.setExpandRatio(hor, 1.0f);

    final Panel menupanel = new Panel("Examples");
    menupanel.addStyleName("menupanel");
    menupanel.setWidth(null);
    menupanel.setHeight("100%");
    menupanel.getContent().setWidth(null);
    // menupanel.getContent().setHeight("100%");
    hor.addComponent(menupanel);

    final Tree menu = new Tree();
    menu.setWidth(null);
    // menu.setHeight("100%");
    menu.setImmediate(true);
    menupanel.addComponent(menu);

    final Panel viewpanel = new Panel("Selected Example");
    viewpanel.addStyleName("viewpanel");
    viewpanel.setSizeFull();
    VerticalLayout viewlayout = new VerticalLayout();
    viewlayout.addStyleName("viewlayout");
    viewlayout.setSpacing(true);
    viewlayout.setMargin(true);
    viewpanel.setContent(viewlayout);

    hor.addComponent(viewpanel);
    hor.setExpandRatio(viewpanel, 1.0f);

    WebApplicationContext ctx = (WebApplicationContext) getContext();
    BookExampleLibrary library = BookExampleLibrary.getInstance(ctx.getBaseDirectory());

    AbstractExampleItem[] examples = library.getAllExamples();

    // Collect redirects here
    final HashMap<String, String> redirects = new HashMap<String, String>();

    // Collect examples here
    final HashMap<String, CaptionedExampleItem> exampleitems =
        new HashMap<String, CaptionedExampleItem>();

    // Build the menu and collect redirections
    for (int i = 0; i < examples.length; i++)
      if (examples[i] instanceof BookExample || examples[i] instanceof ExampleCtgr) {
        CaptionedExampleItem example = (CaptionedExampleItem) examples[i];
        exampleitems.put(example.getExampleId(), example);

        String itemid = example.getExampleId();
        menu.addItem(itemid);
        menu.setItemCaption(itemid, example.getShortName());

        if (examples[i].getParentId() != null) menu.setParent(itemid, examples[i].getParentId());
      } else if (examples[i] instanceof RedirctItem) {
        RedirctItem redirect = (RedirctItem) examples[i];
        redirects.put(redirect.getExampleId(), redirect.redirectid);
      }

    // Expand the menu
    for (int i = 0; i < examples.length; i++) {
      if (examples[i].getParentId() == null)
        menu.expandItemsRecursively(examples[i].getExampleId());

      if (examples[i].isCollapsed()) menu.collapseItem(examples[i].getExampleId());

      if (menu.getChildren(examples[i].getExampleId()) == null)
        menu.setChildrenAllowed(examples[i].getExampleId(), false);
    }

    // Set selected example as given in the URI fragment
    final UriFragmentUtility urifu = new UriFragmentUtility();
    urifu.addListener(
        new FragmentChangedListener() {
          private static final long serialVersionUID = -6588416218607827834L;

          public void fragmentChanged(FragmentChangedEvent source) {
            String fragment = source.getUriFragmentUtility().getFragment();
            if (fragment != null) {
              // Handle redirection
              while (redirects.containsKey(fragment)) fragment = redirects.get(fragment);

              menu.setValue(fragment);

              // Open the tree nodes leading to the example
              for (Object parent = menu.getParent(fragment);
                  parent != null;
                  parent = menu.getParent(parent)) menu.expandItem(parent);
            }
          }
        });
    mainLayout.addComponent(urifu);

    // Handle menu selection
    menu.addListener(
        new Property.ValueChangeListener() {
          private static final long serialVersionUID = 8236533959795019956L;

          public void valueChange(ValueChangeEvent event) {
            viewpanel.removeAllComponents();

            String selection = (String) event.getProperty().getValue();

            // Find the example
            CaptionedExampleItem exampleItem = exampleitems.get(selection);
            if (selection != null && exampleItem == null)
              main.showNotification("Invalid item " + selection);
            else if (exampleItem != null) {
              if (exampleItem.getClass().isAssignableFrom(ExampleCtgr.class)) {
                if (menu.hasChildren(exampleItem.getExampleId())) {
                  menu.select((String) menu.getChildren(exampleItem.getExampleId()).toArray()[0]);
                }
              } else { // A leaf
                BookExample example = (BookExample) exampleItem;

                // Load unless already loaded
                WebApplicationContext ctx = (WebApplicationContext) getContext();
                example.loadExample(ctx.getBaseDirectory());

                if (example.getDescription() != null) {
                  Label descLabel = new Label(example.getDescription(), Label.CONTENT_XHTML);
                  descLabel.addStyleName("example-description");
                  viewpanel.addComponent(descLabel);
                }

                // The actual example component
                viewpanel.addComponent(example.createInstance());

                // Java sources on the left, CSS on the right
                HorizontalLayout horizontalOrder = new HorizontalLayout();
                horizontalOrder.addStyleName("sourcecontainer");
                horizontalOrder.setSpacing(true);
                horizontalOrder.setMargin(true);

                Panel bookRefs = null;
                Panel forumLinks = null;
                Panel kbRefs = null;

                List<SourceFragment> fragments = example.getSourceFragments();
                if (fragments != null) {
                  // Java Sources are laid out vertically
                  VerticalLayout verticalListings = new VerticalLayout();
                  verticalListings.setSizeUndefined();
                  verticalListings.setSpacing(true);
                  horizontalOrder.addComponent(verticalListings);

                  // Find the widest source fragment
                  int widestIndex = 0;
                  int widestWidth = 0;
                  for (int fragmentNum = 0; fragmentNum < fragments.size(); fragmentNum++)
                    if (fragments.get(fragmentNum).getSrcWidth() > widestWidth) {
                      widestIndex = fragmentNum;
                      widestWidth = fragments.get(fragmentNum).getSrcWidth();
                    }
                  System.out.println("Widest listing: " + widestIndex + " which is " + widestWidth);

                  for (int fragmentNum = 0; fragmentNum < fragments.size(); fragmentNum++) {
                    SourceFragment fragment = fragments.get(fragmentNum);

                    // Have caption only in the beginning of the listings
                    String listingCaption = fragmentNum == 0 ? "Source Code" : "";

                    String srcurl =
                        "http://dev.vaadin.com/browser/doc/book-examples/trunk/src"
                            + fragment.getSrcName();
                    SourceListing listing = new SourceListing(listingCaption, srcurl, fragment);
                    verticalListings.addComponent(listing);

                    // Use the width of the widest listing for all listings
                    if (fragmentNum == widestIndex) listing.setWidth(Sizeable.SIZE_UNDEFINED, 0);
                    else listing.setWidth("100%");

                    if (!fragment.getBookRefs().isEmpty()) {
                      bookRefs = new Panel("Book References");
                      bookRefs.setSizeUndefined();
                      for (Iterator<String> iter = fragment.getBookRefs().iterator();
                          iter.hasNext(); ) {
                        String ref = iter.next();
                        int hashPos = ref.indexOf('#');
                        String refFragment = "";
                        if (hashPos != -1) {
                          refFragment = "#" + ref.replace('#', '.');
                          ref = ref.substring(0, hashPos);
                        }
                        String bookUrl =
                            "http://vaadin.com/book/-/page/" + ref + ".html" + refFragment;
                        Link link = new Link(bookUrl, new ExternalResource(bookUrl));
                        link.setTargetName("_new");
                        bookRefs.addComponent(link);
                      }
                    }

                    if (!fragment.getForumLinks().isEmpty()) {
                      forumLinks = new Panel("Forum Messages");
                      forumLinks.setSizeUndefined();
                      for (Iterator<String> iter = fragment.getForumLinks().iterator();
                          iter.hasNext(); ) {
                        String url = iter.next();
                        Link link = new Link(url, new ExternalResource(url));
                        link.setTargetName("_new");
                        forumLinks.addComponent(link);
                      }
                    }

                    if (!fragment.getKbRefs().isEmpty()) {
                      kbRefs = new Panel("Pro Account Knowledge Base Articles");
                      kbRefs.setSizeUndefined();
                      for (Iterator<SourceFragment.Ref> iter = fragment.getKbRefs().iterator();
                          iter.hasNext(); ) {
                        SourceFragment.Ref ref = iter.next();
                        String url = "http://vaadin.com/knowledge-base#" + ref.ref;
                        Link link = new Link(ref.caption, new ExternalResource(url));
                        link.setTargetName("_new");
                        forumLinks.addComponent(link);
                      }
                    }
                  }
                }

                // Show associated CSS
                if (example.getCssFragments() != null && example.getCssFragments().size() > 0) {
                  SourceFragment csscode = example.getCssFragments().get(0);
                  String srcurl =
                      "http://dev.vaadin.com/browser/doc/book-examples/trunk/WebContent/VAADIN/themes/book-examples/styles.css";
                  horizontalOrder.addComponent(new SourceListing("CSS Code", srcurl, csscode));
                }

                if (horizontalOrder.getComponentIterator().hasNext())
                  viewpanel.addComponent(horizontalOrder);
                if (bookRefs != null) viewpanel.addComponent(bookRefs);
                if (forumLinks != null) viewpanel.addComponent(forumLinks);
                if (kbRefs != null) viewpanel.addComponent(kbRefs);

                urifu.setFragment(example.getExampleId());
              }
            }
          }
        });

    Tree.ItemStyleGenerator itemStyleGenerator =
        new Tree.ItemStyleGenerator() {
          private static final long serialVersionUID = -3231268865512947125L;

          public String getStyle(Object itemId) {
            // Chapter title items do not contain a period
            if (!((String) itemId).contains(".")) return "chaptertitle";
            return null;
          }
        };
    menu.setItemStyleGenerator(itemStyleGenerator);
  }
  protected void addProcessImage() {
    ProcessDefinitionEntity processDefinitionEntity =
        (ProcessDefinitionEntity)
            ((RepositoryServiceImpl) repositoryService)
                .getDeployedProcessDefinition(processDefinition.getId());

    // Only show when graphical notation is defined
    if (processDefinitionEntity != null) {

      boolean didDrawImage = false;

      if (ExplorerApp.get().isUseJavascriptDiagram()) {
        try {

          final InputStream definitionStream =
              repositoryService.getResourceAsStream(
                  processDefinition.getDeploymentId(), processDefinition.getResourceName());
          XMLInputFactory xif = XMLInputFactory.newInstance();
          XMLStreamReader xtr = xif.createXMLStreamReader(definitionStream);
          BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);

          if (bpmnModel.getFlowLocationMap().size() > 0) {

            int maxX = 0;
            int maxY = 0;
            for (String key : bpmnModel.getLocationMap().keySet()) {
              GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(key);
              double elementX = graphicInfo.getX() + graphicInfo.getWidth();
              if (maxX < elementX) {
                maxX = (int) elementX;
              }
              double elementY = graphicInfo.getY() + graphicInfo.getHeight();
              if (maxY < elementY) {
                maxY = (int) elementY;
              }
            }

            Panel imagePanel = new Panel(); // using panel for scrollbars
            imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
            imagePanel.setWidth(100, UNITS_PERCENTAGE);
            imagePanel.setHeight(100, UNITS_PERCENTAGE);
            URL explorerURL = ExplorerApp.get().getURL();
            URL url =
                new URL(
                    explorerURL.getProtocol(),
                    explorerURL.getHost(),
                    explorerURL.getPort(),
                    explorerURL.getPath().replace("/ui", "")
                        + "diagram-viewer/index.html?processDefinitionId="
                        + processDefinition.getId()
                        + "&processInstanceId="
                        + processInstance.getId());
            Embedded browserPanel = new Embedded("", new ExternalResource(url));
            browserPanel.setType(Embedded.TYPE_BROWSER);
            browserPanel.setWidth(maxX + 350 + "px");
            browserPanel.setHeight(maxY + 220 + "px");

            HorizontalLayout panelLayoutT = new HorizontalLayout();
            panelLayoutT.setSizeUndefined();
            imagePanel.setContent(panelLayoutT);
            imagePanel.addComponent(browserPanel);

            panelLayout.addComponent(imagePanel);

            didDrawImage = true;
          }

        } catch (Exception e) {
          LOGGER.error("Error loading process diagram component", e);
        }
      }

      if (didDrawImage == false && processDefinitionEntity.isGraphicalNotationDefined()) {

        StreamResource diagram =
            new ProcessDefinitionImageStreamResourceBuilder()
                .buildStreamResource(processInstance, repositoryService, runtimeService);

        if (diagram != null) {
          Label header = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
          header.addStyleName(ExplorerLayout.STYLE_H3);
          header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
          header.addStyleName(ExplorerLayout.STYLE_NO_LINE);
          panelLayout.addComponent(header);

          Embedded embedded = new Embedded(null, diagram);
          embedded.setType(Embedded.TYPE_IMAGE);
          embedded.setSizeUndefined();

          Panel imagePanel = new Panel(); // using panel for scrollbars
          imagePanel.setScrollable(true);
          imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
          imagePanel.setWidth(100, UNITS_PERCENTAGE);
          imagePanel.setHeight(100, UNITS_PERCENTAGE);

          HorizontalLayout panelLayoutT = new HorizontalLayout();
          panelLayoutT.setSizeUndefined();
          imagePanel.setContent(panelLayoutT);
          imagePanel.addComponent(embedded);

          panelLayout.addComponent(imagePanel);
        }
      }
    }
  }
  @Override
  protected void init(VaadinRequest request) {
    CssLayout rootLayout = new CssLayout();
    rootLayout.setSizeFull();
    setContent(rootLayout);

    TabSheet tabs = new TabSheet();
    tabs.setSizeFull();
    rootLayout.addComponent(tabs);

    VerticalLayout mapContent = new VerticalLayout();
    mapContent.setSizeFull();
    tabs.addTab(mapContent, "The map map");
    tabs.addTab(new Label("An another tab"), "The other tab");

    googleMap = new GoogleMap(null, null, null);
    googleMap.setCenter(new LatLon(60.440963, 22.25122));
    googleMap.setZoom(10);
    googleMap.setSizeFull();
    kakolaMarker.setAnimationEnabled(false);
    googleMap.addMarker(kakolaMarker);
    googleMap.addMarker(
        "DRAGGABLE: Paavo Nurmi Stadion",
        new LatLon(60.442423, 22.26044),
        true,
        "VAADIN/1377279006_stadium.png");
    googleMap.addMarker(
        "NOT DRAGGABLE: Iso-Heikkilä", new LatLon(60.450403, 22.230399), false, null);
    googleMap.setMinZoom(4);
    googleMap.setMaxZoom(16);

    kakolaInfoWindow.setWidth("400px");
    kakolaInfoWindow.setHeight("500px");

    mapContent.addComponent(googleMap);
    mapContent.setExpandRatio(googleMap, 1.0f);

    Panel console = new Panel();
    console.setHeight("100px");
    final CssLayout consoleLayout = new CssLayout();
    console.setContent(consoleLayout);
    mapContent.addComponent(console);

    HorizontalLayout buttonLayoutRow1 = new HorizontalLayout();
    buttonLayoutRow1.setHeight("26px");
    mapContent.addComponent(buttonLayoutRow1);

    HorizontalLayout buttonLayoutRow2 = new HorizontalLayout();
    buttonLayoutRow2.setHeight("26px");
    mapContent.addComponent(buttonLayoutRow2);

    OpenInfoWindowOnMarkerClickListener infoWindowOpener =
        new OpenInfoWindowOnMarkerClickListener(googleMap, kakolaMarker, kakolaInfoWindow);
    googleMap.addMarkerClickListener(infoWindowOpener);

    googleMap.addMarkerClickListener(
        new MarkerClickListener() {
          @Override
          public void markerClicked(GoogleMapMarker clickedMarker) {
            Label consoleEntry =
                new Label(
                    "Marker \""
                        + clickedMarker.getCaption()
                        + "\" at ("
                        + clickedMarker.getPosition().getLat()
                        + ", "
                        + clickedMarker.getPosition().getLon()
                        + ") clicked.");
            consoleLayout.addComponent(consoleEntry, 0);
          }
        });

    googleMap.addMapMoveListener(
        new MapMoveListener() {
          @Override
          public void mapMoved(int zoomLevel, LatLon center, LatLon boundsNE, LatLon boundsSW) {
            Label consoleEntry =
                new Label(
                    "Map moved to ("
                        + center.getLat()
                        + ", "
                        + center.getLon()
                        + "), zoom "
                        + zoomLevel
                        + ", boundsNE: ("
                        + boundsNE.getLat()
                        + ", "
                        + boundsNE.getLon()
                        + "), boundsSW: ("
                        + boundsSW.getLat()
                        + ", "
                        + boundsSW.getLon()
                        + ")");
            consoleLayout.addComponent(consoleEntry, 0);
          }
        });

    googleMap.addMapClickListener(
        new MapClickListener() {
          @Override
          public void mapClicked(LatLon position) {
            Label consoleEntry =
                new Label("Map click to (" + position.getLat() + ", " + position.getLon() + ")");
            consoleLayout.addComponent(consoleEntry, 0);
          }
        });

    googleMap.addMarkerDragListener(
        new MarkerDragListener() {
          @Override
          public void markerDragged(GoogleMapMarker draggedMarker, LatLon oldPosition) {
            Label consoleEntry =
                new Label(
                    "Marker \""
                        + draggedMarker.getCaption()
                        + "\" dragged from ("
                        + oldPosition.getLat()
                        + ", "
                        + oldPosition.getLon()
                        + ") to ("
                        + draggedMarker.getPosition().getLat()
                        + ", "
                        + draggedMarker.getPosition().getLon()
                        + ")");
            consoleLayout.addComponent(consoleEntry, 0);
          }
        });

    googleMap.addInfoWindowClosedListener(
        new InfoWindowClosedListener() {

          @Override
          public void infoWindowClosed(GoogleMapInfoWindow window) {
            Label consoleEntry = new Label("InfoWindow \"" + window.getContent() + "\" closed");
            consoleLayout.addComponent(consoleEntry, 0);
          }
        });

    Button moveCenterButton =
        new Button(
            "Move over Luonnonmaa (60.447737, 21.991668), zoom 12",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.setCenter(new LatLon(60.447737, 21.991668));
                googleMap.setZoom(12);
              }
            });
    buttonLayoutRow1.addComponent(moveCenterButton);

    Button limitCenterButton =
        new Button(
            "Limit center between (60.619324, 22.712753), (60.373484, 21.945083)",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.setCenterBoundLimits(
                    new LatLon(60.619324, 22.712753), new LatLon(60.373484, 21.945083));
                event.getButton().setEnabled(false);
              }
            });
    buttonLayoutRow1.addComponent(limitCenterButton);

    Button limitVisibleAreaButton =
        new Button(
            "Limit visible area between (60.494439, 22.397835), (60.373484, 21.945083)",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.setVisibleAreaBoundLimits(
                    new LatLon(60.494439, 22.397835), new LatLon(60.420632, 22.138626));
                event.getButton().setEnabled(false);
              }
            });
    buttonLayoutRow1.addComponent(limitVisibleAreaButton);

    Button zoomToBoundsButton =
        new Button(
            "Zoom to bounds",
            new Button.ClickListener() {

              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.fitToBounds(
                    new LatLon(60.45685853323144, 22.320034754486073),
                    new LatLon(60.4482979242303, 22.27887893936156));
              }
            });
    buttonLayoutRow1.addComponent(zoomToBoundsButton);
    Button addPolyOverlayButton =
        new Button(
            "Add overlay over Luonnonmaa",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                ArrayList<LatLon> points = new ArrayList<LatLon>();
                points.add(new LatLon(60.484715, 21.923706));
                points.add(new LatLon(60.446636, 21.941387));
                points.add(new LatLon(60.422496, 21.99546));
                points.add(new LatLon(60.427326, 22.06464));
                points.add(new LatLon(60.446467, 22.064297));

                GoogleMapPolygon overlay =
                    new GoogleMapPolygon(points, "#ae1f1f", 0.8, "#194915", 0.5, 3);
                googleMap.addPolygonOverlay(overlay);
                event.getButton().setEnabled(false);
              }
            });
    buttonLayoutRow2.addComponent(addPolyOverlayButton);

    Button addPolyLineButton =
        new Button(
            "Draw line from Turku to Raisio",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                ArrayList<LatLon> points = new ArrayList<LatLon>();
                points.add(new LatLon(60.448118, 22.253738));
                points.add(new LatLon(60.455144, 22.24198));
                points.add(new LatLon(60.460222, 22.211939));
                points.add(new LatLon(60.488224, 22.174602));
                points.add(new LatLon(60.486025, 22.169195));

                GoogleMapPolyline overlay = new GoogleMapPolyline(points, "#d31717", 0.8, 10);
                googleMap.addPolyline(overlay);
                event.getButton().setEnabled(false);
              }
            });
    buttonLayoutRow2.addComponent(addPolyLineButton);
    Button addPolyLineButton2 =
        new Button(
            "Draw line from Turku to Raisio2",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                ArrayList<LatLon> points2 = new ArrayList<LatLon>();
                points2.add(new LatLon(60.448118, 22.253738));
                points2.add(new LatLon(60.486025, 22.169195));
                GoogleMapPolyline overlay2 = new GoogleMapPolyline(points2, "#d31717", 0.8, 10);
                googleMap.addPolyline(overlay2);
                event.getButton().setEnabled(false);
              }
            });
    buttonLayoutRow2.addComponent(addPolyLineButton2);
    Button changeToTerrainButton =
        new Button(
            "Change to terrain map",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.setMapType(GoogleMap.MapType.Terrain);
                event.getButton().setEnabled(false);
              }
            });
    buttonLayoutRow2.addComponent(changeToTerrainButton);

    Button changeControls =
        new Button(
            "Remove street view control",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.removeControl(GoogleMapControl.StreetView);
                event.getButton().setEnabled(false);
              }
            });
    buttonLayoutRow2.addComponent(changeControls);

    Button addInfoWindowButton =
        new Button(
            "Add InfoWindow to Kakola marker",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.openInfoWindow(kakolaInfoWindow);
              }
            });
    buttonLayoutRow2.addComponent(addInfoWindowButton);

    Button moveMarkerButton =
        new Button(
            "Move kakola marker",
            new Button.ClickListener() {

              @Override
              public void buttonClick(ClickEvent event) {
                kakolaMarker.setPosition(new LatLon(60.3, 22.242415));
                googleMap.addMarker(kakolaMarker);
              }
            });
    buttonLayoutRow2.addComponent(moveMarkerButton);

    Button addKmlLayerButton =
        new Button(
            "Add KML layer",
            new Button.ClickListener() {

              @Override
              public void buttonClick(ClickEvent event) {
                googleMap.addKmlLayer(
                    new GoogleMapKmlLayer(
                        "http://maps.google.it/maps/"
                            + "ms?authuser=0&ie=UTF8&hl=it&oe=UTF8&msa=0&"
                            + "output=kml&msid=212897908682884215672.0004ecbac547d2d635ff5"));
              }
            });
    buttonLayoutRow2.addComponent(addKmlLayerButton);

    Button clearMarkersButton =
        new Button(
            "Remove all markers",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent clickEvent) {
                googleMap.clearMarkers();
              }
            });
    buttonLayoutRow2.addComponent(clearMarkersButton);
  }
Exemple #21
0
  @SuppressWarnings({"deprecation", "serial"})
  private void updateComponents(final User user) {
    if (container != null) {
      container.removeAllComponents();
    }
    container = new Panel();
    root = new Panel();
    root.setStyle(Reindeer.PANEL_LIGHT);
    container.setHeight("100%");
    container.setStyle(Reindeer.PANEL_LIGHT);
    setCompositionRoot(container);

    // Create the Form
    newExpForm = new Form();
    newExpForm.setCaption("New Experiment");
    newExpForm.setWriteThrough(false); // we want explicit 'apply'
    newExpForm.setInvalidCommitted(false); // no invalid values in data model
    // Determines which properties are shown, and in which order:
    expNameField = new TextField("Experiment Name:");
    expNameField.setStyle(Reindeer.TEXTFIELD_SMALL);
    expNameField.setRequired(true);
    expNameField.setRequiredError("EXPERIMENT NAME CAN NOT BE EMPTY!");
    expNameField.setWidth("350px");
    expNameField.setMaxLength(70);

    speciesField = new TextField("Species:");
    speciesField.setStyle(Reindeer.TEXTFIELD_SMALL);
    speciesField.setRequired(true);
    speciesField.setRequiredError("EXPERIMENT SPECIES CAN NOT BE EMPTY!");
    speciesField.setWidth("350px");
    speciesField.setMaxLength(70);

    sampleTypeField = new TextField("Sample Type:");
    sampleTypeField.setStyle(Reindeer.TEXTFIELD_SMALL);
    sampleTypeField.setRequired(true);
    sampleTypeField.setRequiredError("EXPERIMENT SAMPLE TYPE CAN NOT BE EMPTY!");
    sampleTypeField.setWidth("350px");
    sampleTypeField.setMaxLength(70);

    sampleProcessingField = new TextField("Sample Processing:");
    sampleProcessingField.setStyle(Reindeer.TEXTFIELD_SMALL);
    sampleProcessingField.setRequired(true);
    sampleProcessingField.setRequiredError("EXPERIMENT SAMPLE PROCESSING CAN NOT BE EMPTY!");
    sampleProcessingField.setWidth("350px");
    sampleProcessingField.setMaxLength(70);

    instrumentTypeField = new TextField("Instrument Type:");
    instrumentTypeField.setStyle(Reindeer.TEXTFIELD_SMALL);
    instrumentTypeField.setRequired(true);
    instrumentTypeField.setRequiredError("EXPERIMENT INSTURMENT TYPE CAN NOT BE EMPTY!");
    instrumentTypeField.setWidth("350px");
    instrumentTypeField.setMaxLength(70);

    fragModeField = new TextField("Frag Mode:");
    fragModeField.setStyle(Reindeer.TEXTFIELD_SMALL);
    fragModeField.setRequired(true);
    fragModeField.setRequiredError("EXPERIMENT FRAG MODE CAN NOT BE EMPTY!");
    fragModeField.setWidth("350px");
    fragModeField.setMaxLength(70);

    UploadedByNameField = new TextField("Uploaded By:");
    UploadedByNameField.setStyle(Reindeer.TEXTFIELD_SMALL);
    UploadedByNameField.setRequired(true);
    UploadedByNameField.setRequiredError("EXPERIMENT UPLOADED BY CAN NOT BE EMPTY!");
    UploadedByNameField.setValue(user.getUsername());
    UploadedByNameField.setEnabled(false);
    UploadedByNameField.setWidth("350px");
    UploadedByNameField.setMaxLength(70);

    emailField = new TextField("Email:");
    emailField.setStyle(Reindeer.TEXTFIELD_SMALL);
    emailField.setRequired(true);
    emailField.setValue(user.getEmail());
    emailField.setEnabled(false);
    emailField.setRequiredError("EXPERIMENT EMAIL CAN NOT BE EMPTY!");
    emailField.setWidth("350px");
    emailField.setMaxLength(70);

    descriptionField = new TextArea("Description:");
    descriptionField.setStyle(Reindeer.TEXTFIELD_SMALL);
    descriptionField.setRequired(true);
    descriptionField.setRequiredError("EXPERIMENT Description CAN NOT BE EMPTY!");
    descriptionField.setWidth("350px");
    descriptionField.setMaxLength(950);

    publicationLinkField = new TextField("Publication Link:");
    publicationLinkField.setStyle(Reindeer.TEXTFIELD_SMALL);
    publicationLinkField.setWidth("350px");
    publicationLinkField.setMaxLength(300);

    newExpForm.addField(Integer.valueOf(1), expNameField);
    newExpForm.addField(Integer.valueOf(2), descriptionField);

    newExpForm.addField(Integer.valueOf(3), speciesField);
    newExpForm.addField(Integer.valueOf(4), sampleTypeField);
    newExpForm.addField(Integer.valueOf(5), sampleProcessingField);
    newExpForm.addField(Integer.valueOf(6), instrumentTypeField);
    newExpForm.addField(Integer.valueOf(7), fragModeField);
    newExpForm.addField(Integer.valueOf(8), UploadedByNameField);
    newExpForm.addField(Integer.valueOf(9), emailField);
    newExpForm.addField(Integer.valueOf(10), publicationLinkField);

    // Add form to layout
    container.addComponent(newExpForm);

    Panel p = new Panel();
    Label l =
        new Label(
            "<h4 style='color:blue'>Or Update Existing Experiments !</h4><h4 style='color:blue'>For New Experiment Please Leave Experiment ID Blank!</h4><h4 style='color:blue'><strong style='color:red'>* </strong> For New Experiment Please Remember to Upload Protein file first!</h4>");
    l.setContentMode(Label.CONTENT_XHTML);
    p.addComponent(l);
    container.addComponent(p);

    // Create the Form
    Form existExpForm = new Form();
    existExpForm.setCaption("Exist Experiments");
    expList = eh.getExperiments(null);
    List<String> strExpList = new ArrayList<String>();
    for (ExperimentBean exp : expList.values()) {
      if (user.getEmail().equalsIgnoreCase("*****@*****.**")
          || exp.getEmail().equalsIgnoreCase(user.getEmail())) {
        String str = exp.getExpId() + "	" + exp.getName() + "	( " + exp.getUploadedByName() + " )";
        strExpList.add(str);
      }
    }
    select = new Select("Experiment ID", strExpList);
    select.setImmediate(true);
    select.addListener(
        new Property.ValueChangeListener() {
          @Override
          public void valueChange(ValueChangeEvent event) {
            Object o = select.getValue();
            if (o != null) {
              String str = select.getValue().toString();
              String[] strArr = str.split("\t");
              int id = (Integer.valueOf(strArr[0]));
              ExperimentBean expDet = expList.get(id);
              if (expDetails != null) {
                expDetails.removeAllComponents();

                if (expDet.getProteinsNumber() == 0) {
                  Label l = new Label("<h4 style='color:red'>1) Protein File is Missing</h4>");
                  l.setContentMode(Label.CONTENT_XHTML);
                  expDetails.addComponent(l);
                } else {
                  Label l = new Label("<h4 style='color:blue'>1) Protein File is Uploaded</h4>");
                  l.setContentMode(Label.CONTENT_XHTML);
                  expDetails.addComponent(l);
                }
                if (expDet.getFractionsNumber() == 0) {
                  Label l = new Label("<h4 style='color:red'>2) Fraction File is Missing</h4>");
                  l.setContentMode(Label.CONTENT_XHTML);
                  expDetails.addComponent(l);
                } else {
                  Label l = new Label("<h4 style='color:blue'>2) Fraction File Uploaded</h4>");
                  l.setContentMode(Label.CONTENT_XHTML);
                  expDetails.addComponent(l);
                }
                //                        if (expDet.getFractionRange() == 0) {
                //                            Label l = new Label("<h4 style='color:red'>3) Fraction
                // Range File is Missing</h4>");
                //                            l.setContentMode(Label.CONTENT_XHTML);
                //                            expDetails.addComponent(l);
                //                        } else {
                //                            Label l = new Label("<h4 style='color:blue'>3)
                // Fraction Range File Uploaded</h4>");
                //                            l.setContentMode(Label.CONTENT_XHTML);
                //                            expDetails.addComponent(l);
                //                        }
                if (expDet.getPeptidesNumber() == 0) {
                  Label l = new Label("<h4 style='color:red'>3) Peptides File is Missing</h4>");
                  l.setContentMode(Label.CONTENT_XHTML);
                  expDetails.addComponent(l);
                } else {
                  Label l = new Label("<h4 style='color:blue'>3) Peptides File Uploaded</h4>");
                  l.setContentMode(Label.CONTENT_XHTML);
                  expDetails.addComponent(l);
                }
              }
            } else {
              expDetails.removeAllComponents();
              Label labelDetails =
                  new Label(
                      "<h4 style='color:red;'>Please Select Experiment To Show the Details.</h4>");
              labelDetails.setContentMode(Label.CONTENT_XHTML);
              expDetails.addComponent(labelDetails);
            }
          }
        });
    select.setWidth("60%");
    existExpForm.addField(Integer.valueOf(1), select);

    // Add form to layout
    VerticalLayout vlo = new VerticalLayout();

    if (hslo != null) {
      vlo.removeComponent(hslo);
    }
    hslo = new HorizontalLayout();
    hslo.setSizeFull();
    hslo.addComponent(existExpForm);
    vlo.addComponent(hslo);
    if (removeExperimentLayout != null) {
      hslo.removeComponent(removeExperimentLayout);
    }
    removeExperimentLayout = this.getRemoveForm(user.getEmail());
    hslo.addComponent(removeExperimentLayout);
    hslo.setComponentAlignment(removeExperimentForm, Alignment.MIDDLE_CENTER);
    vlo.addComponent(hslo);
    container.addComponent(vlo);

    // Create the Upload component.

    upload = new Upload(null, this);
    upload.setStyleName("small");
    upload.setVisible(true);
    upload.setHeight("30px");
    upload.setButtonCaption("ADD / EDIT EXPERIMENT !");

    // *****************************************************
    upload.addListener(
        new Upload.StartedListener() {
          @SuppressWarnings("static-access")
          @Override
          public void uploadStarted(StartedEvent event) {
            try {

              Thread.currentThread().sleep(1000);
              Thread t =
                  new Thread(
                      new Runnable() {
                        @Override
                        public void run() {
                          pi.setVisible(true);
                        }
                      });
              t.start();
              t.join();
            } catch (InterruptedException e) {
            }

            mainTabs.setReadOnly(true);
            subTabs.setReadOnly(true);
          }
        });

    upload.addListener(
        new Upload.FinishedListener() {
          @Override
          public void uploadFinished(FinishedEvent event) {
            pi.setVisible(false);
            mainTabs.setReadOnly(false);
            subTabs.setReadOnly(false);
            file = new File(event.getFilename());
          }
        });

    // ***********************************

    upload.addListener((Upload.SucceededListener) this);
    upload.addListener((Upload.FailedListener) this);
    if (helpNote != null) {
      vlo.removeComponent(helpNote);
    }
    Label label =
        new Label(
            "<h4 style='color:red;'>Please upload proteins file first</h4><h4 style='color:red;'>Please upload proteins files in (.txt) format.</h4><h4 style='color:red;'>Upload fraction range file after upload protein fraction file.</h4><h4 style='color:red;'>Upload fraction range file in (.xlsx) format.</h4>");
    label.setContentMode(Label.CONTENT_XHTML);
    helpNote = help.getHelpNote(label);
    helpNote.setMargin(false, true, true, true);

    vlo.addComponent(upload);
    vlo.addComponent(pi);
    vlo.addComponent(helpNote);
    vlo.setComponentAlignment(helpNote, Alignment.MIDDLE_RIGHT);

    expDetails = new Panel("Experiment Details");
    Label labelDetails =
        new Label("<h4 style='color:red;'>Please Select Experiment To Show the Details.</h4>");
    labelDetails.setContentMode(Label.CONTENT_XHTML);
    expDetails.addComponent(labelDetails);

    vlo.addComponent(expDetails);
    root.addComponent(vlo);
    container.addComponent(root);
  }