Esempio n. 1
0
    public Component generateCell(Table source, final Object itemId, Object columnId) {

      Property<?> prop = source.getItem(itemId).getItemProperty(JobLogContainer.ERROR_MESSAGE);
      if (prop != null && prop.getType() != null && prop.getType().equals(String.class)) {

        String errorMessage = (String) prop.getValue();

        if (errorMessage != null) {

          Button link = new Button();
          link.setIcon(new ThemeResource("../admin/crystal/agt_update_critical.png"));
          link.setStyleName(BaseTheme.BUTTON_LINK);
          link.setDescription("Show job error message");

          link.addClickListener(
              new Button.ClickListener() {

                public void buttonClick(ClickEvent event) {

                  select(itemId);
                  view.showErrorOutput(itemId);
                }
              });

          return link;
        }
      }

      return null;
    }
  @SuppressWarnings("unchecked")
  @Override
  public void setup(VaadinRequest request) {

    final Table items = new Table("Items - double-click to edit");
    items.setSelectable(true);
    items.addContainerProperty("name", String.class, "");
    items.addContainerProperty("birthday", Date.class, "");

    final TableFieldFactory fieldFactory = new ItemFieldFactory();
    items.setTableFieldFactory(fieldFactory);

    Calendar cal = Calendar.getInstance();
    cal.set(2010, 7, 12, 12, 7, 54);

    for (String name : names) {
      items.addItem(name);
      items.getItem(name).getItemProperty("name").setValue(name);
      items
          .getItem(name)
          .getItemProperty("birthday")
          .setValue(new FormattedDate(cal.getTime().getTime()));
    }

    items.addItemClickListener(
        new ItemClickEvent.ItemClickListener() {

          @Override
          public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
              selectionEvent = event;
              items.setEditable(true);
            } else if (items.isEditable()) {
              items.setEditable(false);
            }
          }
        });

    addComponent(items);
  }
  private TestExerExerciseData getCurrentExercise() {

    TestExerExerciseData newData =
        new TestExerExerciseData(
            questionText.getValue(),
            Integer.parseInt(eventStartYear.getValue()),
            Integer.parseInt(eventEndYear.getValue()),
            Integer.parseInt(eventResolution.getValue()));

    for (int i = 0;
        i < maxEvents && !eventTable.getItem(i).getItemProperty("Tapahtuma").getValue().equals("");
        i++) {
      try {
        newData.setAnswer(
            Integer.parseInt((String) eventTable.getItem(i).getItemProperty("Vuosi").getValue()));
        newData.setEvent((String) eventTable.getItem(i).getItemProperty("Tapahtuma").getValue());
      } catch (NumberFormatException nfe) {
        if (!eventTable.getItem(i).getItemProperty("Vuosi").getValue().equals("")) {
          Notification.show(
              "WARNING: "
                  + (String) eventTable.getItem(i).getItemProperty("Vuosi").getValue()
                  + " isn't an integer value. Event '"
                  + (String) eventTable.getItem(i).getItemProperty("Tapahtuma").getValue()
                  + "' wasn't saved!");
        }
      }
    }

    return newData;
  }
Esempio n. 4
0
    public Component generateCell(Table source, final Object itemId, Object columnId) {

      Property<?> prop = source.getItem(itemId).getItemProperty(columnId);
      if (prop != null && prop.getType() != null && prop.getType().equals(Integer.class)) {

        Integer wallClockTime = (Integer) prop.getValue();

        Label label = new Label(StringUtils.formatMinutes(wallClockTime));

        return label;
      }
      return null;
    }
    @Override
    public List<List<String>> getSummary(String page, Object object) {
      List<List<String>> list = null;
      if (page.equals("viewOrganization.jsp")) {
        if (!(object instanceof Unit)) {
          return null;
        }

        Unit unit = (Unit) object;
        Person currentUser = UserView.getCurrentUser().getExpenditurePerson();
        if (!(unit.isResponsible(currentUser)
            || unit.getObserversSet().contains(currentUser)
            || UserView.getCurrentUser().hasRoleType(RoleType.MANAGER))) {
          return null;
        }

        list = new ArrayList<List<String>>();
        list.add(new ArrayList<String>());
        list.add(new ArrayList<String>());

        ReportViewerComponent projectSummary;
        Project project = getProjectFromID(unit.getExternalId());
        if (project != null) {
          String projectCode = project.getProjectCode();
          System.out.println(projectCode);

          projectSummary =
              new ReportViewerComponent(
                  "SELECT V.\"Orçamento\", V.\"Máximo Financiável\" AS \"Máx. Financiável\", V.\"Receita\", V.\"Transf. Parceiros\", V.\"Despesa\", V.\"Adiantamentos por Justificar\", V.\"Cabimentos por Executar\", V.\"Saldo Tesouraria\", V.\"Saldo Orçamental\" FROM V_RESPROJPROF V WHERE V.\"NºProj\"='"
                      + projectCode
                      + "'",
                  new NoBehaviourCustomTableFormatter());

          Table t = projectSummary.getTable();

          if (t.getItemIds().size() > 0) {
            for (Object a : t.getItemIds()) {
              Item item = t.getItem(a);

              for (Object column : item.getItemPropertyIds()) {
                String itemString =
                    ReportType.formatCurrency(item.getItemProperty(column).toString());
                list.get(0).add(t.getColumnHeader(column));
                list.get(1).add(itemString);
              }
            }
          }
        }
      }
      return list;
    }
  @Override
  public void buttonClick(ClickEvent event) {
    if (event.getButton().equals(btnCrearUsuario)) {
      Usuario object = new Usuario();
      object.setUsuario(txtUsuario.getValue().toString());
      object.setNombres(txtNombres.getValue().toString());
      object.setApePat(txtApellidoPaterno.getValue().toString());
      object.setApeMat(txtApellidoMaterno.getValue().toString());

      object.setRol((Rol) cmbRol.getValue());
      object.setCargo(
          txtCargo.getValue() != null ? txtCargo.getValue().toString() : StringUtils.EMPTY);
      object.setDescCargo(
          txtCargoDescripcion.getValue() != null
              ? txtCargoDescripcion.getValue().toString()
              : StringUtils.EMPTY);
      object.setOficina((Dependencia) cmbOficina.getValue());
      object.setPolicia((Policia) cmbPolicia.getValue());

      if (flagNuevoUsuario) {
        String randomPassword = RandomUtil.createWord(8);
        object.setClave(randomPassword);
        usuarioService.crear(object);
      } else {
        object.setClave(clave);
        Item item = tblUsuarios.getItem(tblUsuarios.getValue());
        object.setId((Long) item.getItemProperty("id").getValue());
        usuarioService.actualizar(object);
      }
      refrescar();
    } else if (event.getButton().equals(btnEliminarUsuario)) {
      ConfirmDialog.show(
          getApplication().getMainWindow(),
          "¿Seguro de Eliminar el Registro?",
          new ConfirmDialog.Listener() {
            private static final long serialVersionUID = 1L;

            public void onClose(ConfirmDialog dialog) {
              if (dialog.isConfirmed()) {
                Item item = tblUsuarios.getItem(tblUsuarios.getValue());
                usuarioService.eliminarXId((Long) item.getItemProperty("id").getValue());
                refrescar();
              }
            }
          });
    } else if (event.getButton().equals(btnAgregarPolicia)) {
      cargarWindowRegistroPolicia();
    }
  }
Esempio n. 7
0
 private void cachingForTriples(Table table, String endpoint) {
   Model model = ModelFactory.createDefaultModel();
   List<String> resources = null;
   FileWriter fstream = null;
   try {
     fstream = new FileWriter("/home/mofeed/TrialStart/zicozico.nt");
   } catch (IOException e1) {
     // TODO Auto-generated catch block
     e1.printStackTrace();
   }
   BufferedWriter out = new BufferedWriter(fstream);
   try {
     for (Object id : table.getItemIds()) {
       Item item = table.getItem(id);
       Property sourceURI = item.getItemProperty("sourceURI"); // vaadin property not jena
       Resource resource = model.createResource();
       try {
         String sparqlQuery = "select distinct * where { <" + sourceURI.getValue() + "> ?p  ?o .}";
         Query query = QueryFactory.create(sparqlQuery);
         QueryExecution qexec = QueryExecutionFactory.sparqlService(endpoint, query);
         com.hp.hpl.jena.query.ResultSet results = qexec.execSelect();
         com.hp.hpl.jena.query.QuerySolution binding = null;
         while (results.hasNext()) {
           binding = results.next();
           String property = binding.getResource("?p").toString();
           String value;
           if (binding.get("?o").isResource()) value = binding.getResource("?o").toString();
           else value = binding.getLiteral("?o").toString();
           com.hp.hpl.jena.rdf.model.Property pt = ResourceFactory.createProperty(property);
           // resource.addProperty(pt, value);
           model.add(resource, pt, value);
         }
         qexec.close();
         model.write(out, null, "TURTLE");
       } catch (Exception e) {
         Notification.show(e.toString());
       }
       // model.add(s, p, o);
       // Property destinationURI = item.getItemProperty("destinationURI");
       // out.write(sourceURI.getValue()+"\n");
     }
     /*out.flush();
     fstream.flush();*/
     out.close();
   } catch (Exception e) { // Catch exception if any
     System.err.println("Error: " + e.getMessage());
   }
 }
  public TableEditorWindow(final Table table, final Object value, Object... dates) {

    for (Object o : dates) dates2.add(o);
    VerticalLayout content = new VerticalLayout();
    Object[] columns = table.getVisibleColumns();
    String[] headers = table.getColumnHeaders();
    int n = columns.length;

    for (int i = 0; i < n; ++i) {
      HorizontalLayout lay = new HorizontalLayout();
      Label l = new Label(headers[i]);
      lay.addComponent(l);
      Component field = dates2.contains(columns[i]) ? new DateField() : new TextField();

      lay.addComponent(field);
      map.put(columns[i], field);
      content.addComponent(lay);
      lay.setComponentAlignment(l, Alignment.MIDDLE_LEFT);
      lay.setComponentAlignment(field, Alignment.MIDDLE_RIGHT);
    }

    if (value != null) {
      Item item = table.getItem(value);
      for (Object o : columns) {
        Object val = item.getItemProperty(o).getValue();
        if (dates2.contains(o)) {
          ((DateField) map.get(o)).setValue((Date) val);
        } else {
          ((TextField) map.get(o)).setValue(val.toString());
        }
      }
    }

    save = new Button("Записать");
    content.addComponent(save);
    save.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(Button.ClickEvent clickEvent) {
            if (actionPerformed()) close();
          }
        });

    setContent(content);
  }