org.netbeans.swing.outline.DefaultOutlineModel Java Examples

The following examples show how to use org.netbeans.swing.outline.DefaultOutlineModel. 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: XSDOutlinePanel.java    From jlibs with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked"})
public void setXSModel(XSModel model, MyNamespaceSupport nsSupport){
    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()*/);

    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);
}
 
Example #2
Source File: SelectEventsPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void setData(String[] names, boolean[] logging) {
    int n = names.length;
    for (int i = 0; i < n; i++) {
        Event e = new Event(names[i], logging[i]);
        events.add(e);
    }
    OutlineModel om = DefaultOutlineModel.createOutlineModel(new EventsTreeModel(events), new EventsRowModel(events));
    table.setModel(om);
    ((Outline) table).setRenderDataProvider(new EventsDataProvider(events));
    table.setShowHorizontalLines(false);
    table.setTableHeader(null);
    ((Outline) table).setRootVisible(false);
}
 
Example #3
Source File: TestWebServiceMethodDlg.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Outline loadResultTreeTable(JavaMethod inMethod, Object inResultObject) throws WebServiceReflectionException {
    if(null == inMethod) {
        return null;
    }
    JavaType currentType = inMethod.getReturnType();
    String typeName = currentType.getRealName();
    TypeNodeData data = ReflectionHelper.createTypeData(typeName, inResultObject);

    DefaultMutableTreeNode node = NodeHelper.getInstance().createResultNodeFromData(data);

    /**
     * Make sure to create a new result root each time since the user can change the parameters and submit many
     * times.
     */
    this.setResultRootNode(new DefaultMutableTreeNode());
    /**
     *  Add it to the root.
     */
    this.getResultRootNode().add(node);

    DefaultTreeModel treeModel = new DefaultTreeModel(this.getResultRootNode());
    RowModel rowModel = new ResultRowModel();
    OutlineModel outlineModel = DefaultOutlineModel.createOutlineModel(treeModel,
            rowModel, false,NbBundle.getMessage(this.getClass(), 
            "TYPE_COLUMN_NAME"));
    Outline returnOutline = new Outline(outlineModel);
    ResultCellEditor cellEditor = new ResultCellEditor();
    returnOutline.setDefaultEditor(Object.class,cellEditor);
    returnOutline.setRootVisible(false);

    returnOutline.setRenderDataProvider(new TypeDataProvider());

    return returnOutline;
}
 
Example #4
Source File: OutlineTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void setNodesColumnName(String name, String description) {
    OutlineModel m = getOutline().getOutlineModel();
    if (m instanceof DefaultOutlineModel) {
        ((DefaultOutlineModel) m).setNodesColumnLabel(name);
    }
    setPropertyColumnDescription(name, description);
}
 
Example #5
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 #6
Source File: OrderingAttributesTopComponent.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
private void initTable() {
        Outline outline = outlineView1.getOutline();
        outline.setRootVisible(false);
//        outline.setAutoResizeMode(ETable.AUTO_RESIZE_OFF);
//        TableColumnModel columnModel = outline.getColumnModel();
//        ETableColumn column = (ETableColumn) columnModel.getColumn(0);
//        ((ETableColumnModel) columnModel).setColumnHidden(column, true);
        ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel(Bundle.COL_Attribute());
        OrderingAttributeNode.createTableColumns(outlineView1);
        outline.setFullyNonEditable(true);
    }
 
Example #7
Source File: DbPagedTableTopComponent.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
private void initTable() {
        outlineView1.setNodePopupFactory(new TablePopupFactory());
        Outline outline = outlineView1.getOutline();
        outline.setRootVisible(false);
        outline.setCellSelectionEnabled(true);
//        outline.setAutoResizeMode(ETable.AUTO_RESIZE_OFF);
        outline.setAutoResizeMode(ETable.AUTO_RESIZE_ALL_COLUMNS);
        ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel("tid");
        outline.setFullyNonEditable(true);
    }
 
Example #8
Source File: DbTableTopComponent.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
private void initTable() {
        outlineView1.setNodePopupFactory(new TablePopupFactory());
        Outline outline = outlineView1.getOutline();
        outline.setRootVisible(false);
        outline.setCellSelectionEnabled(true);
        outline.setAutoResizeMode(ETable.AUTO_RESIZE_OFF);
//        TableColumnModel columnModel = outline.getColumnModel();
//        ETableColumn column = (ETableColumn) columnModel.getColumn(0);
//        ((ETableColumnModel) columnModel).setColumnHidden(column, true);
        ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel("tid");
        outline.setFullyNonEditable(true);
    }
 
Example #9
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 #10
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 #11
Source File: TestWebServiceMethodDlg.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private Outline loadParameterTreeTable(JavaMethod inMethod) throws WebServiceReflectionException {
    if(null == inMethod) {
        return null;
    }

    List<JavaParameter> parameters = inMethod.getParametersList();
    for (JavaParameter currentParameter : parameters) {
        /**
         * Add all Parameter's to the root tree node.
         */
        JavaType currentType = currentParameter.getType();

        String typeName = currentType.getRealName();
        String typeParamName = currentParameter.getName();

        if (currentParameter.isHolder()) {
            typeName = "javax.xml.ws.Holder<" + typeName + ">"; // NOI18N
        }

        TypeNodeData data = ReflectionHelper.createTypeData(typeName, typeParamName);
        data.setTypeValue(NodeHelper.getInstance().getParameterDefaultValue(data));
        if (currentParameter.isHolder()) {
            if (currentParameter.isIN()) data.setHolderType(TypeNodeData.IN);
            if (currentParameter.isOUT()) data.setHolderType(TypeNodeData.OUT);
            if (currentParameter.isINOUT()) data.setHolderType(TypeNodeData.IN_OUT);
        }

        DefaultMutableTreeNode node = NodeHelper.getInstance().createNodeFromData(data);

        /**
         *  Add it to the root.
         */
        this.getParamterRootNode().add(node);
    }

    DefaultTreeModel treeModel = new DefaultTreeModel(this.getParamterRootNode());
    RowModel rowModel = new TypeRowModel(this.getRuntimeClassLoader());
    OutlineModel outlineModel = DefaultOutlineModel.createOutlineModel(
            treeModel,rowModel, false,NbBundle.getMessage(this.getClass(), 
            "TYPE_COLUMN_NAME"));       // NOI18N
    Outline returnOutline = new Outline(outlineModel);
    TypeCellEditor cellEditor = new TypeCellEditor(getRuntimeClassLoader());
    returnOutline.setDefaultEditor(Object.class,cellEditor);
    returnOutline.setRootVisible(false);
    returnOutline.setRenderDataProvider(new TypeDataProvider());
    /**
     * Fix Bug 5052705.  This setting will cause the cells values to take affect when
     * the focus is lost.  This will remove the requirement of hitting "ENTER" after
     * entering a value in a cell to get the value to take affect.
     */
    returnOutline.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); // NOI18N

    return returnOutline;
}
 
Example #12
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());
    }
}