예제 #1
0
  public void installUI(JComponent c) {
    searchnav = (JHelpSearchNavigator) c;
    HelpModel helpmodel = searchnav.getModel();

    searchnav.setLayout(new BorderLayout());
    searchnav.addPropertyChangeListener(this);
    searchnav.addComponentListener(this);
    if (helpmodel != null) {
      helpmodel.addHelpModelListener(this);
    }

    JLabel search =
        new JLabel(HelpUtilities.getString(HelpUtilities.getLocale(c), "search.findLabel"));
    searchparams = new JTextField("", 20);
    search.setLabelFor(searchparams);
    searchparams.addActionListener(searchAction);

    JPanel box = new JPanel();
    box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
    box.add(search);
    box.add(searchparams);

    searchnav.add("North", box);
    topNode = new DefaultMutableTreeNode();
    lastTOCnode = null;
    tree = new JTree(topNode);
    // public String convertValueToText(Object val
    TreeSelectionModel tsm = tree.getSelectionModel();
    tsm.addTreeSelectionListener(this);
    tree.setShowsRootHandles(false);
    tree.setRootVisible(false);
    sp = new JScrollPane();
    sp.getViewport().add(tree);
    searchnav.add("Center", sp);
    reloadData();
  }
    public ResourcePanel(AndroidFacet facet, ResourceType[] types, boolean system) {
      myTree = new Tree();
      myTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode()));
      myTree.setScrollsOnExpand(true);
      myTree.setRootVisible(false);
      myTree.setShowsRootHandles(true);
      new DoubleClickListener() {
        @Override
        protected boolean onDoubleClick(MouseEvent e) {
          if (!myTreeBuilder.getSelectedElements(ResourceItem.class).isEmpty()) {
            close(OK_EXIT_CODE);
            return true;
          }
          return false;
        }
      }.installOn(myTree);

      ToolTipManager.sharedInstance().registerComponent(myTree);
      TreeUtil.installActions(myTree);

      myManager = facet.getResourceManager(system ? AndroidUtils.SYSTEM_RESOURCE_PACKAGE : null);
      myGroups = new ResourceGroup[types.length];

      for (int i = 0; i < types.length; i++) {
        myGroups[i] = new ResourceGroup(types[i], myManager);
      }

      myTreeBuilder =
          new AbstractTreeBuilder(
              myTree,
              (DefaultTreeModel) myTree.getModel(),
              new TreeContentProvider(myGroups),
              null);
      myTreeBuilder.initRootNode();

      TreeSelectionModel selectionModel = myTree.getSelectionModel();
      selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
      selectionModel.addTreeSelectionListener(ChooseResourceDialog.this);

      myTree.setCellRenderer(new NodeRenderer());
      new TreeSpeedSearch(myTree, TreeSpeedSearch.NODE_DESCRIPTOR_TOSTRING, true);

      myComponent = new JBSplitter(true, 0.8f);
      myComponent.setSplitterProportionKey("android.resource_dialog_splitter");

      myComponent.setFirstComponent(ScrollPaneFactory.createScrollPane(myTree));

      myPreviewPanel = new JPanel(new CardLayout());
      myComponent.setSecondComponent(myPreviewPanel);

      myTextArea = new JTextArea(5, 20);
      myTextArea.setEditable(false);
      myPreviewPanel.add(ScrollPaneFactory.createScrollPane(myTextArea), TEXT);

      myComboTextArea = new JTextArea(5, 20);
      myComboTextArea.setEditable(false);

      myComboBox = new JComboBox();
      myComboBox.setMaximumRowCount(15);
      myComboBox.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              java.util.List<ResourceElement> resources =
                  (java.util.List<ResourceElement>) myComboBox.getClientProperty(COMBO);
              myComboTextArea.setText(
                  getResourceElementValue(resources.get(myComboBox.getSelectedIndex())));
            }
          });

      JPanel comboPanel =
          new JPanel(
              new BorderLayout(0, 1) {
                @Override
                public void layoutContainer(Container target) {
                  super.layoutContainer(target);
                  Rectangle bounds = myComboBox.getBounds();
                  Dimension size = myComboBox.getPreferredSize();
                  size.width += 20;
                  myComboBox.setBounds(
                      (int) bounds.getMaxX() - size.width, bounds.y, size.width, size.height);
                }
              });
      comboPanel.add(ScrollPaneFactory.createScrollPane(myComboTextArea), BorderLayout.CENTER);
      comboPanel.add(myComboBox, BorderLayout.SOUTH);
      myPreviewPanel.add(comboPanel, COMBO);

      myImageComponent = new JLabel();
      myImageComponent.setHorizontalAlignment(SwingConstants.CENTER);
      myImageComponent.setVerticalAlignment(SwingConstants.CENTER);
      myPreviewPanel.add(myImageComponent, IMAGE);

      myNoPreviewComponent = new JLabel("No Preview");
      myNoPreviewComponent.setHorizontalAlignment(SwingConstants.CENTER);
      myNoPreviewComponent.setVerticalAlignment(SwingConstants.CENTER);
      myPreviewPanel.add(myNoPreviewComponent, NONE);
    }
  /** Creates new form NewTestcaseOperationVisualPanel */
  public NewTestcaseOperationVisualPanel(NewTestcaseOperationWizardPanel panel) {
    mPanel = panel;
    initComponents();
    mScrollPanel = new javax.swing.JScrollPane();
    mTree = new javax.swing.JTree();
    mTree
        .getAccessibleContext()
        .setAccessibleName(
            NbBundle.getMessage(
                NewTestcaseWsdlVisualPanel.class, "ACS_OperationTree_A11YName")); // NOI18N
    final TreeSelectionModel selectionModel = mTree.getSelectionModel();
    selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    selectionModel.addTreeSelectionListener(
        new TreeSelectionListener() {
          public void valueChanged(TreeSelectionEvent e) {
            BindingOperation bindingOp = getSelectedBindingOperation();
            try {
              jTextFieldSelectedOperation.setText(
                  bindingOp == null ? "" : getOperationSignature(bindingOp)); // NOI18N
              mPanel.fireChangeEvent(); // Notify that the panel changed
            } catch (Exception ex) {
              NotifyDescriptor d =
                  new NotifyDescriptor.Message(ex.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
              DialogDisplayer.getDefault().notify(d);
              selectionModel.clearSelection();
            }
          }
        });
    mTree.setRootVisible(false);
    mTree.setEditable(false);
    ToolTipManager.sharedInstance().registerComponent(mTree);
    mTree.setCellRenderer(
        new DefaultTreeCellRenderer() {
          @Override
          public Component getTreeCellRendererComponent(
              JTree tree,
              Object value,
              boolean sel,
              boolean expanded,
              boolean leaf,
              int row,
              boolean hasFocus) {
            JLabel label =
                (JLabel)
                    super.getTreeCellRendererComponent(
                        tree, value, sel, expanded, leaf, row, hasFocus);
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
            Object usrObj = node.getUserObject();
            if (usrObj instanceof Port) {
              Port port = (Port) usrObj;
              Binding binding = port.getBinding().get();
              String labelText =
                  port.getName() + " (" + "Binding=\"" + binding.getName() + "\")"; // NOI18N
              label.setText(labelText);

              JbiBindingInfo bi = JbiDefaultComponentInfo.getBindingInfo(port);
              if (bi != null) {
                label.setToolTipText("binding type: " + bi.getBindingType()); // NOI18N
              } else {
                label.setToolTipText(null);
              }
            } else if (usrObj instanceof BindingOperation) {
              label.setText(((BindingOperation) usrObj).getName());
              label.setToolTipText(null);
            }
            return label;
          }
        });

    mScrollPanel.setViewportView(mTree);
    jLabelOperations.setLabelFor(mTree);

    org.jdesktop.layout.GroupLayout jPanel1Layout =
        (org.jdesktop.layout.GroupLayout) jPanel1.getLayout();
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(mScrollPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE));
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(mScrollPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE));
  }