private void createGUI() {
    setTitle(WINDOW_TITLE);
    setPreferredSize(new Dimension(800, 600));
    setMinimumSize(new Dimension(300, 120));

    setLayout(new BorderLayout());

    final JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));

    final Font labelFont = UIManager.getFont("Label.font");
    final Font boldFont = labelFont.deriveFont(Font.BOLD, labelFont.getSize2D() * 1.2f);

    final JPanel topPanel = new JPanel();
    topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));
    topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    final JLabel nameLabel = new JLabel(object.getName());
    nameLabel.setFont(boldFont);
    topPanel.add(nameLabel);
    topPanel.add(new JLabel(object.getId()));
    add(topPanel, BorderLayout.PAGE_START);

    JScrollPane scrollPane = new JScrollPane(panel);
    add(scrollPane, BorderLayout.CENTER);

    propertyPanels = new ArrayList<PropertyEditorFrame.PropertyInputPanel>();

    int position = 0;
    for (PropertyDefinition<?> propDef : object.getType().getPropertyDefinitions().values()) {
      boolean isUpdatable =
          (propDef.getUpdatability() == Updatability.READWRITE)
              || (propDef.getUpdatability() == Updatability.WHENCHECKEDOUT
                  && object
                      .getAllowableActions()
                      .getAllowableActions()
                      .contains(Action.CAN_CHECK_IN));

      if (isUpdatable) {
        PropertyInputPanel propertyPanel =
            new PropertyInputPanel(propDef, object.getPropertyValue(propDef.getId()), position++);

        propertyPanels.add(propertyPanel);
        panel.add(propertyPanel);
      }
    }

    JButton updateButton = new JButton("Update");
    updateButton.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    updateButton.setDefaultCapable(true);
    updateButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            if (doUpdate()) {
              dispose();
            }
          }
        });

    add(updateButton, BorderLayout.PAGE_END);

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    pack();
    setLocationRelativeTo(null);
    setVisible(true);
  }
示例#2
0
  public void objectLoaded(ClientModelEvent event) {
    CmisObject object = getClientModel().getCurrentObject();

    if (object == null) {
      nameField.setText("");
      idField.setText("");
      typeField.setText("");
      basetypeField.setText("");
      versionLabelField.setText("");
      pwcField.setText("");
      paths.removeAll();
      contentUrlField.setText("");
      allowableActionsList.removeAll();
      refreshButton.setEnabled(false);
      checkButton.setEnabled(false);
      scriptPanel.setVisible(false);
    } else {
      try {
        nameField.setText(object.getName());
        idField.setText(object.getId());
        typeField.setText(object.getType().getId());
        basetypeField.setText(object.getBaseTypeId().toString());
        if (object instanceof Document) {
          Document doc = (Document) object;

          try {
            versionLabelField.setText(doc.getVersionLabel());
          } catch (Exception e) {
            versionLabelField.setText("???");
          }

          if (doc.isVersionSeriesCheckedOut() == null) {
            pwcField.setText("");
          } else if (doc.isVersionSeriesCheckedOut().booleanValue()) {
            pwcField.setText(doc.getVersionSeriesCheckedOutId());
          } else {
            pwcField.setText("(not checked out)");
          }
        } else {
          pwcField.setText("");
          versionLabelField.setText("");
        }

        if (object instanceof FileableCmisObject) {
          if (object instanceof Folder) {
            paths.setList(Collections.singletonList(((Folder) object).getPath()));
          } else {
            paths.setList(Collections.singletonList(""));
            final FileableCmisObject pathObject = (FileableCmisObject) object;
            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    try {
                      List<String> pathsList = pathObject.getPaths();
                      if ((pathsList == null) || (pathsList.size() == 0)) {
                        paths.setList(Collections.singletonList("(unfiled)"));
                      } else {
                        paths.setList(pathsList);
                      }
                    } catch (Exception e) {
                      paths.setList(Collections.singletonList("(???)"));
                      // ClientHelper.showError(null, e);
                    }
                    ObjectPanel.this.revalidate();
                  }
                });
          }
        } else {
          paths.setList(Collections.singletonList("(not filable)"));
        }

        String docUrl = getDocumentURL(object, getClientModel().getClientSession().getSession());
        if (docUrl != null) {
          contentUrlField.setText(docUrl);
        } else {
          contentUrlField.setText("(not available)");
        }

        if (object.getAllowableActions() != null) {
          allowableActionsList.setList(object.getAllowableActions().getAllowableActions());
        } else {
          allowableActionsList.setList(Collections.singletonList("(missing)"));
        }

        refreshButton.setEnabled(true);
        checkButton.setEnabled(true);

        if (object instanceof Document) {
          String name = object.getName().toLowerCase(Locale.ENGLISH);
          int x = name.lastIndexOf('.');
          if ((x > -1) && (scriptExtensions.contains(name.substring(x + 1)))) {
            scriptPanel.setVisible(true);
            scriptOutput.setVisible(false);
          } else {
            scriptPanel.setVisible(false);
          }
        }
      } catch (Exception e) {
        ClientHelper.showError(this, e);
      }
    }

    revalidate();
  }