Java Code Examples for org.netbeans.swing.outline.Outline#setModel()

The following examples show how to use org.netbeans.swing.outline.Outline#setModel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OutlineNavigatorTest.java    From jlibs with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked"})
public static void main(String[] args) throws Exception{
    String url = JOptionPane.showInputDialog("File/URL", "http://schemas.xmlsoap.org/wsdl/");
    if(url==null)
        return;
    XSModel model = new XSParser().parse(url);
    MyNamespaceSupport nsSupport = XSUtil.createNamespaceSupport(model);

    Navigator navigator1 = new FilteredTreeNavigator(new XSNavigator(), new XSDisplayFilter());
    Navigator navigator = new PathNavigator(navigator1);
    XSPathDiplayFilter filter = new XSPathDiplayFilter(navigator1);
    navigator = new FilteredTreeNavigator(navigator, filter);
    TreeModel treeModel = new NavigatorTreeModel(new Path(model), navigator);
    RowModel rowModel = new DefaultRowModel(new DefaultColumn("Detail", String.class, new XSDisplayValueVisitor(nsSupport))/*, new ClassColumn()*/);
    
    OutlineNavigatorTest test = new OutlineNavigatorTest("Navigator Test");
    Outline outline = test.getOutline();
    outline.setShowGrid(false);
    outline.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14));
    outline.setModel(DefaultOutlineModel.createOutlineModel(treeModel, rowModel));
    outline.getColumnModel().getColumn(1).setMinWidth(150);

    DefaultRenderDataProvider dataProvider = new DefaultRenderDataProvider();
    dataProvider.setDisplayNameVisitor(new XSDisplayNameVisitor(nsSupport, filter));
    dataProvider.setForegroundVisitor(new XSColorVisitor(filter));
    dataProvider.setFontStyleVisitor(new XSFontStyleVisitor(filter));
    outline.setRenderDataProvider(dataProvider);
    
    test.setVisible(true);
}
 
Example 2
Source File: ResamplingDialog.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private JPanel createAdvancedMethodDefinitionPanel() {
    final TableLayout tableLayoutMethodDefinition = new TableLayout(1);
    tableLayoutMethodDefinition.setTableAnchor(TableLayout.Anchor.NORTHWEST);
    tableLayoutMethodDefinition.setTableFill(TableLayout.Fill.HORIZONTAL);
    tableLayoutMethodDefinition.setTableWeightX(1.0);
    tableLayoutMethodDefinition.setTablePadding(4, 4);
    JPanel panel = new JPanel(tableLayoutMethodDefinition);
    if(ioParametersPanel.getSourceProductSelectorList().get(0).getSelectedProduct() != null) {
        BandsTreeModel myModel = new BandsTreeModel(ioParametersPanel.getSourceProductSelectorList().get(0).getSelectedProduct());

        bandResamplingPresets = new BandResamplingPreset[myModel.getTotalRows()];
        for(int i = 0 ; i < myModel.getTotalRows() ; i++) {
            bandResamplingPresets[i] = new BandResamplingPreset(myModel.getRows()[i], (String) (parameterSupport.getParameterMap().get("downsamplingMethod")) , (String) (parameterSupport.getParameterMap().get("upsamplingMethod")));
        }

        resamplingRowModel = new ResamplingRowModel(bandResamplingPresets, myModel);

        mdl = DefaultOutlineModel.createOutlineModel(
                myModel, resamplingRowModel, true, "Bands");

        outline1 = new Outline();
        outline1.setRootVisible(false);
        outline1.setModel(mdl);

        ResamplingUtils.setUpUpsamplingColumn(outline1,outline1.getColumnModel().getColumn(1), (String) parameterSupport.getParameterMap().get("upsamplingMethod"));
        ResamplingUtils.setUpDownsamplingColumn(outline1,outline1.getColumnModel().getColumn(2), (String) parameterSupport.getParameterMap().get("downsamplingMethod"));
        JScrollPane tableContainer = new JScrollPane(outline1);
        panel.add(tableContainer);

        panel.setVisible(false);
    }
    return panel;
}
 
Example 3
Source File: OptionsChooserPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Returns outline view for displaying options for export/import. */
private Outline getOutline(TreeModel treeModel) {
    Outline outline = new Outline();
    outline.setModel(DefaultOutlineModel.createOutlineModel(
            treeModel,
            new OptionsRowModel(),
            true,
            NbBundle.getMessage(OptionsChooserPanel.class, "OptionsChooserPanel.outline.header.tree")));
    treeDataProvider = new OptionsTreeDataProvider();
    outline.setRenderDataProvider(treeDataProvider);
    //outline.setRootVisible(false);
    outline.getTableHeader().setReorderingAllowed(false);
    outline.setColumnHidingAllowed(false);
    // a11y
    outline.getAccessibleContext().setAccessibleName(NbBundle.getMessage(OptionsChooserPanel.class, "OptionsChooserPanel.outline.AN"));
    outline.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(OptionsChooserPanel.class, "OptionsChooserPanel.outline.AD"));
    lblHint.setLabelFor(outline);

    final Outline out = outline;
    outline.addKeyListener(new java.awt.event.KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == KeyEvent.VK_SPACE) {
                int[] rows = out.getSelectedRows();
                for (int row : rows) {
                    if (row >= 0) {
                        Object node = out.getValueAt(row, 0);
                        Boolean isSelected = treeDataProvider.isSelected(node);
                        if(isSelected == null) { // node is Category or Root and is partially selected
                            treeDataProvider.setSelected(node, Boolean.FALSE);
                        } else if (treeDataProvider.isCheckEnabled(node)) {
                            treeDataProvider.setSelected(node, !isSelected);
                        }
                    }
                }
            }
        }
    });

    return outline;
}
 
Example 4
Source File: ResamplingDialog.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private void reactToSourceProductChange(Product product) {
    referenceBandNameBoxPanel.reactToSourceProductChange(product);
    targetWidthAndHeightPanel.reactToSourceProductChange(product);
    targetResolutionPanel.reactToSourceProductChange(product);
    if (product != null) {
        referenceBandButton.setEnabled(product.getBandNames().length > 0);

        final ProductNodeGroup<Band> productBands = product.getBandGroup();
        final ProductNodeGroup<TiePointGrid> productTiePointGrids = product.getTiePointGridGroup();
        double xOffset = Double.NaN;
        double yOffset = Double.NaN;
        if (productBands.getNodeCount() > 0) {
            xOffset = productBands.get(0).getImageToModelTransform().getTranslateX();
            yOffset = productBands.get(0).getImageToModelTransform().getTranslateY();
        } else if (productTiePointGrids.getNodeCount() > 0) {
            xOffset = productTiePointGrids.get(0).getImageToModelTransform().getTranslateX();
            yOffset = productTiePointGrids.get(0).getImageToModelTransform().getTranslateY();
        }
        boolean allowToSetWidthAndHeight = true;
        if (!Double.isNaN(xOffset) && !Double.isNaN(yOffset)) {
            allowToSetWidthAndHeight = allOffsetsAreEqual(productBands, xOffset, yOffset) &&
                    allOffsetsAreEqual(productTiePointGrids, xOffset, yOffset);
        }
        widthAndHeightButton.setEnabled(allowToSetWidthAndHeight);
        final GeoCoding sceneGeoCoding = product.getSceneGeoCoding();
        resolutionButton.setEnabled(sceneGeoCoding instanceof CrsGeoCoding &&
                ResampleUtils.allGridsAlignAtUpperLeftPixel(product));
    }
    if (referenceBandButton.isEnabled()) {
        referenceBandButton.setSelected(true);
        referenceBandNameBoxPanel.setEnabled(true);
    } else if (widthAndHeightButton.isEnabled()) {
        widthAndHeightButton.setSelected(true);
    } else if (resolutionButton.isEnabled()) {
        resolutionButton.setSelected(true);
    }

    if(product != null) {
        advancedMethodDefinitionPanel.removeAll();
        BandsTreeModel myModel = new BandsTreeModel(product);

        bandResamplingPresets = new BandResamplingPreset[myModel.getTotalRows()];
        for(int i = 0 ; i < myModel.getTotalRows() ; i++) {
            bandResamplingPresets[i] = new BandResamplingPreset(myModel.getRows()[i], (String) (parameterSupport.getParameterMap().get("downsamplingMethod")),(String) (parameterSupport.getParameterMap().get("upsamplingMethod")));
        }

        resamplingRowModel = new ResamplingRowModel(bandResamplingPresets, myModel);
        //Create the Outline's model, consisting of the TreeModel and the RowModel
        mdl = DefaultOutlineModel.createOutlineModel(
                myModel, resamplingRowModel, true, "Products");

        Outline outline1 = new Outline();
        outline1.setRootVisible(false);
        outline1.setModel(mdl);

        ResamplingUtils.setUpUpsamplingColumn(outline1,outline1.getColumnModel().getColumn(1), (String)  parameterSupport.getParameterMap().get("upsamplingMethod"));
        ResamplingUtils.setUpDownsamplingColumn(outline1,outline1.getColumnModel().getColumn(2), (String) parameterSupport.getParameterMap().get("downsamplingMethod"));

        JScrollPane tableContainer = new JScrollPane(outline1);
        advancedMethodDefinitionPanel.add(tableContainer);
        advancedMethodDefinitionPanel.revalidate();
        advancedMethodDefinitionPanel.setVisible(advancedMethodCheckBox.isSelected());
    }
}