/** Performs the update. */
  private boolean doUpdate() {
    try {
      setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

      Map<String, Object> properties = new HashMap<String, Object>();
      for (PropertyInputPanel propertyPanel : propertyPanels) {
        if (propertyPanel.includeInUpdate()) {
          properties.put(propertyPanel.getId(), propertyPanel.getValue());
        }
      }

      if (properties.isEmpty()) {
        return false;
      }

      ObjectId newId = object.updateProperties(properties, false);

      if ((newId != null) && newId.getId().equals(model.getCurrentObject().getId())) {
        try {
          model.reloadObject();
          model.reloadFolder();
        } catch (Exception ex) {
          ClientHelper.showError(null, ex);
        }
      }

      return true;
    } catch (Exception ex) {
      ClientHelper.showError(this, ex);
      return false;
    } finally {
      setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }
  }
Exemplo n.º 2
0
  private void showLoginForm() {
    loginDialog.showDialog();
    if (!loginDialog.isCanceled()) {
      ClientSession clientSession = loginDialog.getClientSession();

      model.setClientSession(clientSession);

      try {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

        model.loadFolder(clientSession.getStartFolderId(), false);
        model.loadObject(clientSession.getStartFolderId());

        toolbarButton[BUTTON_REPOSITORY_INFO].setEnabled(true);
        toolbarButton[BUTTON_TYPES].setEnabled(true);
        toolbarButton[BUTTON_QUERY].setEnabled(model.supportsQuery());
        toolbarButton[BUTTON_CHANGELOG].setEnabled(model.supportsChangeLog());
        toolbarButton[BUTTON_CONSOLE].setEnabled(true);
        toolbarButton[BUTTON_TCK].setEnabled(true);
        toolbarButton[BUTTON_CREATE].setEnabled(true);

        itemMenuItem.setEnabled(model.supportsItems());
        relationshipMenuItem.setEnabled(model.supportsRelationships());
        policyMenuItem.setEnabled(model.supportsPolicies());

        String user = clientSession.getSessionParameters().get(SessionParameter.USER);
        if (user != null) {
          user = "******" + user + ")";
        } else {
          user = "";
        }

        setTitle(
            WINDOW_TITLE + user + " - " + clientSession.getSession().getRepositoryInfo().getName());
      } catch (Exception ex) {
        toolbarButton[BUTTON_REPOSITORY_INFO].setEnabled(false);
        toolbarButton[BUTTON_TYPES].setEnabled(false);
        toolbarButton[BUTTON_QUERY].setEnabled(false);
        toolbarButton[BUTTON_CHANGELOG].setEnabled(false);
        toolbarButton[BUTTON_CONSOLE].setEnabled(false);
        toolbarButton[BUTTON_TCK].setEnabled(false);
        toolbarButton[BUTTON_CREATE].setEnabled(false);

        ClientHelper.showError(null, ex);

        setTitle(WINDOW_TITLE);
      } finally {
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      }
    }
  }
    public Object getValue() {
      Object result = null;

      if (getStatus() == StatusFlag.Update) {
        try {
          if (propDef.getCardinality() == Cardinality.SINGLE) {
            result = ((PropertyValue) valueComponents.get(0)).getPropertyValue();
          } else {
            List<Object> list = new ArrayList<Object>();
            for (JComponent comp : valueComponents) {
              list.add(((PropertyValue) comp).getPropertyValue());
            }
            result = list;
          }
        } catch (Exception ex) {
          ClientHelper.showError(this, ex);
        }
      }

      return result;
    }