Пример #1
0
 private static void showTopComponent(int id, Exception exception) {
   String name = "exception" + id;
   TopComponent c = NbComponents.findTopComponentByNameAndClass(name, TopComponent.class);
   if (c == null) {
     c =
         new TopComponent() {
           @Override
           public int getPersistenceType() {
             return TopComponent.PERSISTENCE_NEVER;
           }
         };
     c.setName(name);
     c.setDisplayName(exception.getClass().getSimpleName());
     c.setLayout(new BorderLayout());
     c.add(ExceptionPanel.create(exception), BorderLayout.CENTER);
     c.open();
   }
   c.requestActive();
 }
  public RevisionAnalysisTopComponent(WorkspaceItem<RevisionAnalysisDocument> item) {
    super(item);
    setName(getDocument().getDisplayName());
    setToolTipText(Bundle.HINT_RevisionAnalysisTopComponent());

    toolBarRepresentation = NbComponents.newInnerToolbar();
    toolBarRepresentation.setFloatable(false);
    toolBarRepresentation.add(Box.createRigidArea(new Dimension(5, 0)));
    runButton =
        toolBarRepresentation.add(
            new AbstractAction("", DemetraUiIcon.COMPILE_16) {
              @Override
              public void actionPerformed(ActionEvent e) {
                start();
              }
            });
    runButton.setDisabledIcon(ImageUtilities.createDisabledIcon(runButton.getIcon()));
    runButton.setEnabled(false);

    addPropertyChangeListener(
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(STATE_PROPERTY)) {
              onStateChange();
            }
          }
        });

    toolBarRepresentation.addSeparator();
    itemsLabel = (JLabel) toolBarRepresentation.add(new JLabel("No items"));

    inputList = new JTsList();
    inputList.addPropertyChangeListener(
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            switch (evt.getPropertyName()) {
              case JTsList.COLLECTION_PROPERTY:
                onCollectionChange();
                break;
            }
          }
        });

    toolBarRepresentation.addSeparator();
    JPopupMenu specPopup = new JPopupMenu();
    final JButton specButton =
        (JButton)
            toolBarRepresentation.add(
                DropDownButtonFactory.createDropDownButton(
                    ImageUtilities.loadImageIcon("ec/nbdemetra/sa/blog_16x16.png", false),
                    specPopup));
    specButton.setFocusPainted(false);
    specPopup
        .add(new ec.nbdemetra.ws.ui.SpecSelectionComponent())
        .addPropertyChangeListener(
            new PropertyChangeListener() {
              @Override
              public void propertyChange(PropertyChangeEvent evt) {
                String p = evt.getPropertyName();
                if (p.equals(ec.nbdemetra.ws.ui.SpecSelectionComponent.SPECIFICATION_PROPERTY)
                    && evt.getNewValue() != null) {
                  ISaSpecification spec = (ISaSpecification) evt.getNewValue();
                  curSpec.setSaSpecification(spec);
                  defSpecLabel.setText(spec == null ? "" : spec.toLongString());
                } else if (p.equals(ec.nbdemetra.ws.ui.SpecSelectionComponent.ICON_PROPERTY)
                    && evt.getNewValue() != null) {
                  specButton.setIcon(ImageUtilities.image2Icon((Image) evt.getNewValue()));
                }
              }
            });
    specPopup.addPopupMenuListener(
        new PopupMenuAdapter() {
          @Override
          public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            ((ec.nbdemetra.ws.ui.SpecSelectionComponent)
                    ((JPopupMenu) e.getSource()).getComponent(0))
                .setSpecification((ISaSpecification) curSpec.getSaSpecification());
          }
        });

    raView = new RevisionAnalysisTopComponent.RevisionAnalysisDocumentView();
    raView.setDocument(getDocument().getElement());

    loadingPanel = new LoadingPanel(raView);

    curSpec = getDocument().getElement().getSpecification().clone();

    defSpecLabel = (JLabel) toolBarRepresentation.add(new JLabel());
    defSpecLabel.setText(
        curSpec.getSaSpecification() == null
            ? ""
            : ((ISaSpecification) curSpec.getSaSpecification()).toLongString());

    visualRepresentation =
        NbComponents.newJSplitPane(JSplitPane.VERTICAL_SPLIT, inputList, loadingPanel);
    visualRepresentation.setOneTouchExpandable(true);

    inputList.setTsCollection(getDocument().getElement().getInput());

    setLayout(new BorderLayout());
    add(toolBarRepresentation, BorderLayout.NORTH);
    add(visualRepresentation, BorderLayout.CENTER);

    refreshNode();
  }