コード例 #1
0
ファイル: Controller.java プロジェクト: onyxbits/ScenePainter
  @Override
  public void valueChanged(TreeSelectionEvent e) {
    if (e.getSource() == colors && !locked) {
      TreeSelectionModel tsm = colors.getSelectionModel();
      TreePath tp[] = tsm.getSelectionPaths();
      if (tp == null) return;
      Vector<ClassedItem> tmp = new Vector<ClassedItem>();
      for (TreePath element : tp) {
        try {
          Object[] path = element.getPath();
          ClassedItem ci = new ClassedItem(path[1].toString(), path[2].toString());
          tmp.add(ci);
        } catch (Exception exp) {
          // User did not select a leafnode
        }
      }

      if (sceneElement instanceof NenyaImageSceneElement) {
        ((NenyaImageSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0]));
      }
      if (sceneElement instanceof NenyaTileSceneElement) {
        ((NenyaTileSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0]));
      }
      if (sceneElement instanceof NenyaComponentSceneElement) {
        ((NenyaComponentSceneElement) sceneElement)
            .getComponents()[itemList.getSelectedIndex()].setColorList(
                tmp.toArray(new ClassedItem[0]));
      }

      submitElement(sceneElement, null);
    } else {
      super.valueChanged(e);
    }
  }
コード例 #2
0
  public void uninstallUI(JComponent c) {
    HelpModel helpmodel = searchnav.getModel();

    searchnav.removeComponentListener(this);
    searchnav.removePropertyChangeListener(this);
    TreeSelectionModel tsm = tree.getSelectionModel();
    tsm.removeTreeSelectionListener(this);
    searchnav.setLayout(null);
    searchnav.removeAll();

    if (helpmodel != null) {
      helpmodel.removeHelpModelListener(this);
    }
    searchnav = null;
  }
コード例 #3
0
ファイル: ContentTree.java プロジェクト: 2870597860/Oxframe
  public ContentTree(MapCanvas map) {
    super();

    map.getLayerContext().addEventListener(this);

    root = new RootNode();
    treeModel = new DefaultTreeModel(root);
    TreeSelectionModel treeSelectionModel = new DefaultTreeSelectionModel();
    treeSelectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    setSelectionModel(treeSelectionModel);
    setModel(treeModel);
    setEditable(true);
    setShowsRootHandles(false);
    setCellRenderer(new ContentTreeRenderer());
    setCellEditor(new ContentTreeEditor(this));
  }
コード例 #4
0
    public static Image createImage(final JTree tree) {
      final TreeSelectionModel model = tree.getSelectionModel();
      final TreePath[] paths = model.getSelectionPaths();

      int count = 0;
      final List<ChangesBrowserNode> nodes = new ArrayList<ChangesBrowserNode>();
      for (final TreePath path : paths) {
        final ChangesBrowserNode node = (ChangesBrowserNode) path.getLastPathComponent();
        if (!node.isLeaf()) {
          nodes.add(node);
          count += node.getCount();
        }
      }

      for (TreePath path : paths) {
        final ChangesBrowserNode element = (ChangesBrowserNode) path.getLastPathComponent();
        boolean child = false;
        for (final ChangesBrowserNode node : nodes) {
          if (node.isNodeChild(element)) {
            child = true;
            break;
          }
        }

        if (!child) {
          if (element.isLeaf()) count++;
        } else if (!element.isLeaf()) {
          count -= element.getCount();
        }
      }

      final JLabel label = new JLabel(VcsBundle.message("changes.view.dnd.label", count));
      label.setOpaque(true);
      label.setForeground(tree.getForeground());
      label.setBackground(tree.getBackground());
      label.setFont(tree.getFont());
      label.setSize(label.getPreferredSize());
      final BufferedImage image =
          new BufferedImage(label.getWidth(), label.getHeight(), BufferedImage.TYPE_INT_ARGB);

      Graphics2D g2 = (Graphics2D) image.getGraphics();
      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
      label.paint(g2);
      g2.dispose();

      return image;
    }
コード例 #5
0
  private void selectionChanged(boolean _addedPath) {
    TreeSelectionModel selectionModel = myTree.getSelectionModel();
    IContainerTreeNode parentTreeNode;
    IContainerTreeNode selectedTreeNode;
    int childIndex;
    if (_addedPath) {
      TreePath selectionPath = selectionModel.getSelectionPath();
      if (selectionPath == null) {
        selectedTreeNode = null;
        parentTreeNode = null;
        childIndex = -1;
      } else {
        selectedTreeNode = (IContainerTreeNode) selectionPath.getLastPathComponent();
        parentTreeNode = (IContainerTreeNode) selectedTreeNode.getParent();
        if (parentTreeNode != null) {
          childIndex = parentTreeNode.getIndex(selectedTreeNode);
        } else {
          childIndex = -1;
        }
      }
    } else {
      selectedTreeNode = null;
      parentTreeNode = null;
      childIndex = -1;
    }

    myContext.setSelectedContainer(selectedTreeNode);
    if (parentTreeNode == null) {
      // MODIFIED
      myContext.setSelection(myTree, null);
    } else {
      if (parentTreeNode instanceof IFIDPlaylistWrapper) {
        FIDPlaylist playlist = ((IFIDPlaylistWrapper) parentTreeNode).getPlaylist();
        childIndex = ((FIDPlaylistTreeNode) selectedTreeNode).getPlaylistIndex();
        // MODIFIED
        myContext.setSelection(
            myTree, new ContainerSelection(myContext, playlist, new int[] {childIndex}));
      } else {
        // MODIFIED
        myContext.setSelection(
            myTree, new ContainerSelection(myContext, parentTreeNode, new int[] {childIndex}));
      }
    }
  }
コード例 #6
0
    /**
     * selects object geo in the list of GeoElements
     *
     * @param addToSelection false => clear old selection
     */
    public void setSelected(ArrayList<GeoElement> geos, boolean addToSelection) {
      TreePath tp = null;

      TreeSelectionModel lsm = getSelectionModel();
      if (geos == null || geos.size() == 0) {
        lsm.clearSelection();
        selectFirstElement();
      } else {
        // make sure geos are in list, this is needed when MAX_OBJECTS_IN_TREE was
        // exceeded in setViewActive(true)
        //				for (int i=0; i < geos.size(); i++) {
        //					GeoElement geo = (GeoElement) geos.get(i);
        //					add(geo);
        //				}

        if (!addToSelection) lsm.clearSelection();

        // get paths for all geos
        ArrayList<TreePath> paths = new ArrayList<TreePath>();
        for (int i = 0; i < geos.size(); i++) {
          TreePath result = getGeoPath((GeoElement) geos.get(i));
          if (result != null) {
            tp = result;
            expandPath(result);
            paths.add(result);
          }
        }

        // select geo paths
        TreePath[] selPaths = new TreePath[paths.size()];
        for (int i = 0; i < selPaths.length; i++) {
          selPaths[i] = paths.get(i);
        }
        lsm.addSelectionPaths(selPaths);

        if (tp != null && geos.size() == 1) {
          scrollPathToVisible(tp);
        }
      }
    }
コード例 #7
0
  /**
   * Selects the collection of figures.
   *
   * @param l The collection of objects to select.
   * @param clear Pass <code>true</code> to clear the selection <code>false</code> otherwise.
   */
  void setSelectedFigures(List<ROIShape> l, boolean clear) {
    Iterator<ROIShape> i = l.iterator();
    TreeSelectionModel tsm = objectsTable.getTreeSelectionModel();
    ROIFigure figure = null;
    ROIShape shape;
    if (clear) tsm.clearSelection();
    objectsTable.removeTreeSelectionListener(treeSelectionListener);

    try {
      while (i.hasNext()) {
        shape = i.next();
        figure = shape.getFigure();
        objectsTable.selectROIShape(figure.getROIShape());
      }
      objectsTable.repaint();
      if (figure != null) objectsTable.scrollToROIShape(figure.getROIShape());
    } catch (Exception e) {
      MeasurementAgent.getRegistry().getLogger().info(this, "Figure selection " + e);
    }

    objectsTable.addTreeSelectionListener(treeSelectionListener);
  }
コード例 #8
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();
  }
コード例 #9
0
  public void actionPerformed(ActionEvent e) {

    // Spawn thread to handle the results and loading...

    if (e.getSource() == openAsComboBox) {
      String selection = (String) openAsComboBox.getSelectedItem();
      if ("Raw images".equals(selection)) {
        imageWidthTextField.setEnabled(true);
        imageHeightTextField.setEnabled(true);
        bitsAllocatedTextField.setEnabled(true);
        bitsStoredTextField.setEnabled(true);
        fileOffsetTextField.setEnabled(true);
        numImagesTextField.setEnabled(true);
        imageWidthLabel.setEnabled(true);
        imageHeightLabel.setEnabled(true);
        bitsAllocatedLabel.setEnabled(true);
        bitsStoredLabel.setEnabled(true);
        fileOffsetLabel.setEnabled(true);
        numImagesLabel.setEnabled(true);
      } else {
        imageWidthTextField.setEnabled(false);
        imageHeightTextField.setEnabled(false);
        bitsAllocatedTextField.setEnabled(false);
        bitsStoredTextField.setEnabled(false);
        fileOffsetTextField.setEnabled(false);
        numImagesTextField.setEnabled(false);
        imageWidthLabel.setEnabled(false);
        imageHeightLabel.setEnabled(false);
        bitsAllocatedLabel.setEnabled(false);
        bitsStoredLabel.setEnabled(false);
        fileOffsetLabel.setEnabled(false);
        numImagesLabel.setEnabled(false);
      }
    } else if ("open".equals(e.getActionCommand())) {
      if (e.getSource() == openArchiveButton) {
        TreeSelectionModel tsm = treeTable.getTreeSelectionModel();
        TreePath[] selectPaths = tsm.getSelectionPaths();
        StudyListTreeTableModel slttm = (StudyListTreeTableModel) treeTable.getTreeTableModel();

        // If it's a local archive, we don't need to do a move;
        // otherwise we execute a move thread and once that's
        // complete, invoke the openDialogArchive thread.

        if (!localSelectionModel.isSelectionEmpty()) {
          OpenDialogArchiveThread odat =
              new OpenDialogArchiveThread(
                  slttm.computeSeries(selectPaths), false); // openStudyCheckBox.isSelected());
          odat.start();
        } else {
          ImageServerNodeDescription isnd =
              (ImageServerNodeDescription) networkList.getSelectedValue();
          OpenDialogArchiveMoveThread odamt =
              ((isnd.getSupportedMoveScope() == Scope.SERIES)
                      || (isnd.getSupportedMoveScope() == Scope.INSTANCE))
                  ? new OpenDialogArchiveMoveThread(
                      isnd,
                      slttm.computeSeries(selectPaths),
                      false,
                      transferOnlyCheckBox.isSelected())
                  : // openStudyCheckBox.isSelected());
                  new OpenDialogArchiveMoveThread(
                      isnd,
                      slttm.computeStudies(selectPaths),
                      false,
                      transferOnlyCheckBox.isSelected()); // openStudyCheckBox.isSelected());
          odamt.start();
        }
      } else {
        TreeSelectionModel tsm = dirTreeTable.getTreeSelectionModel();
        TreePath[] selectPaths = tsm.getSelectionPaths();
        File[] selectedFiles = new File[selectPaths.length];
        for (int loop = 0; loop < selectPaths.length; loop++)
          selectedFiles[loop] = ((FileNode) (selectPaths[loop].getLastPathComponent())).getFile();

        // Ultimately need to make this part dependent or specific to
        // a given image reader...

        ArrayList<Integer> paramList = new ArrayList<Integer>();
        if (imageWidthTextField.isEnabled())
          paramList.add(Integer.parseInt(imageWidthTextField.getText()));
        if (imageHeightTextField.isEnabled())
          paramList.add(Integer.parseInt(imageHeightTextField.getText()));
        if (bitsAllocatedTextField.isEnabled())
          paramList.add(Integer.parseInt(bitsAllocatedTextField.getText()));
        if (bitsStoredTextField.isEnabled())
          paramList.add(Integer.parseInt(bitsStoredTextField.getText()));
        if (fileOffsetTextField.isEnabled())
          paramList.add(Integer.parseInt(fileOffsetTextField.getText()));
        if (numImagesTextField.isEnabled())
          paramList.add(Integer.parseInt(numImagesTextField.getText()));
        OpenDialogFileThread odft =
            new OpenDialogFileThread(
                selectedFiles,
                (String) openAsComboBox.getSelectedItem(),
                recurseCheckBox.isSelected(),
                false,
                paramList); // openStudyCheckBox.isSelected());
        odft.start();
      }

      if (closeOnOpenCheckBox.isSelected()) doClose();

    } else if ("search".equals(e.getActionCommand())) {

      if ((networkList.isSelectionEmpty()) && (localList.isSelectionEmpty())) return;

      try {

        String patientID = patientIDField.getText();
        String modality = modalityField.getText();
        Date startDate = startDatePicker.getDate();
        Date endDate = endDatePicker.getDate();
        ImageServerFindDescription isfd = new ImageServerFindDescription(patientID);

        if (startDate != null) isfd.setStartDate(startDate);
        if (endDate != null) isfd.setEndDate(endDate);
        isfd.setModality(modality);
        isfd.setResultScope(Scope.SERIES);
        String s = (String) localList.getSelectedValue();
        boolean isLocal = ((s != null) && ("local archive".equalsIgnoreCase(s)));
        if (!isLocal) {
          isfd.setNodeDescription((ImageServerNodeDescription) networkList.getSelectedValue());
          Boolean b =
              (Boolean)
                  ApplicationContext.getContext()
                      .getProperty(ApplicationContext.USE_XML_COMPRESSION);
          if ((b != null) && (b.booleanValue())) isfd.setCompression(Compression.GZIP);
        }
        treeTable.setEnabled(false);
        treeTable.setVisible(
            false); // Hack because the cleared treetable doesn't update the display correctly and
                    // has leftovers
        studyList.clear();
        searchButton.setEnabled(false);
        clearFieldButton.setEnabled(false);
        OpenDialogFindThread odft =
            new OpenDialogFindThread(
                isfd, treeTable, searchButton, clearFieldButton, resultsLabel, isLocal);
        odft.start();

      } catch (Exception exc) {
        exc.printStackTrace();
      }

    } else if ("refreshNetwork".equals(e.getActionCommand())) {
      boolean networkStatus = ImageViewerClientNode.getInstance().connect();
      if (networkStatus) {
        List<ImageServerNodeDescription> nodes =
            ImageViewerClientNode.getInstance().getQueryableNodes();
        if (nodes != null) networkList.setListData(nodes.toArray());
      }
    } else if ("clear".equals(e.getActionCommand())) {
      clearFields();
    } else if ("close".equals(e.getActionCommand())) {
      doClose();
    }
  }
コード例 #10
0
    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);
    }
コード例 #11
0
  /** 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));
  }
コード例 #12
0
 private @Nullable String selectionMode(JTree tree) {
   TreeSelectionModel model = tree.getSelectionModel();
   return SELECTION_MODES.get(model.getSelectionMode());
 }