Java Code Examples for org.netbeans.swing.outline.OutlineModel

The following examples show how to use org.netbeans.swing.outline.OutlineModel. These examples are extracted from open source projects. 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 Project: netbeans   Source File: OutlineView.java    License: Apache License 2.0 6 votes vote down vote up
public OutlineViewOutline(final OutlineModel mdl, PropertiesRowModel rowModel) {
    super(mdl);
    this.rowModel = rowModel;
    setSelectVisibleColumnsLabel(NbBundle.getMessage(OutlineView.class, "CTL_ColumnsSelector")); //NOI18N
    
    // fix for #198694
    // default action map for JTable defines these shortcuts
    // but we use our own mechanism for handling them
    // following lines disable default L&F handling (if it is
    // defined on Ctrl-c, Ctrl-v and Ctrl-x)
    removeDefaultCutCopyPaste(getInputMap(WHEN_FOCUSED));
    removeDefaultCutCopyPaste(getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
    
    KeyStroke ctrlSpace;
    if (Utilities.isMac()) {
        ctrlSpace = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, KeyEvent.META_MASK, false);
    } else {
        ctrlSpace = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, KeyEvent.CTRL_DOWN_MASK, false);
    }
    Object ctrlSpaceActionBind = getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).get(ctrlSpace);
    if (ctrlSpaceActionBind != null) {
        getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(ctrlSpace, "invokeCustomEditor"); //NOI18N
        Action invokeCustomEditorAction = new InvokeCustomEditorAction(ctrlSpaceActionBind);
        getActionMap().put("invokeCustomEditor", invokeCustomEditorAction);
    }
}
 
Example 2
Source Project: netbeans   Source File: OutlineOperator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Gets the rowspan of siblings which are above irTreePath in the tree. Only
 * expanded paths are taken into account.
 *
 * @param irTreePath
 * @return
 */
protected int getPrecedingSiblingsRowSpan(TreePath irTreePath) {
    OutlineModel lrModel = getOutline().getOutlineModel();

    if (irTreePath.getParentPath() == null) {
        return 0 + getVisibleRootModifier();
    }

    Object lrLast = irTreePath.getLastPathComponent();
    TreePath lrParent = irTreePath.getParentPath();
    int lnRowSpan = 0;

    int lnIndex = lrModel.getIndexOfChild(lrParent.getLastPathComponent(), lrLast);

    for (int i = lnIndex - 1; i >= 0; i--) {
        Object lrSibling = lrModel.getChild(lrParent.getLastPathComponent(), i);
        lnRowSpan += getRowSpanOfLastElement(lrParent.pathByAddingChild(lrSibling));
    }

    return lnRowSpan;
}
 
Example 3
Source Project: netbeans   Source File: OutlineOperator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Gets the total rowspan of the last element of irTreePath.
 *
 * @param irTreePath
 * @return
 */
protected int getRowSpanOfLastElement(TreePath irTreePath) {
    OutlineModel lrModel = getOutline().getOutlineModel();

    if (!isExpanded(irTreePath)) {
        return 1;
    }

    Object lrLast = irTreePath.getLastPathComponent();
    int lnRowspan = 1; //1 for the current node
    int lnChildCount = lrModel.getChildCount(lrLast);

    for (int i = 0; i < lnChildCount; i++) {
        Object lnChild = lrModel.getChild(lrLast, i);

        TreePath lrTempPath = irTreePath.pathByAddingChild(lnChild);
        lnRowspan += getRowSpanOfLastElement(lrTempPath);
    }

    return lnRowspan;
}
 
Example 4
Source Project: netbeans   Source File: SelectEventsPanel.java    License: 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 5
Source Project: netbeans   Source File: OutlineView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * This method allows plugging own OutlineModel to the OutlineView.
 * You can override it and create different model in the subclass.
 */
protected OutlineModel createOutlineModel(NodeTreeModel treeModel, RowModel rowModel, String label) {
    if (label == null) {
        label = NbBundle.getMessage(OutlineView.class, "NodeOutlineModel_NodesColumnLabel"); // NOI18N
    }
    return new NodeOutlineModel(treeModel, rowModel, false, label);
}
 
Example 6
Source Project: netbeans   Source File: OutlineView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get name of the column that contains outline nodes, or null if it is
 * not available.
 */
private String getNodesColumnName() {
    OutlineModel outlineModel = getOutlineModel();
    if (outlineModel != null && outlineModel.getColumnCount() > 0) {
        return outlineModel.getColumnName(0);
    }
    return null;
}
 
Example 7
Source Project: netbeans   Source File: TestWebServiceMethodDlg.java    License: 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 8
Source Project: netbeans   Source File: OutlineTable.java    License: 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 9
Source Project: netbeans   Source File: DelegatingCellRenderer.java    License: Apache License 2.0 5 votes vote down vote up
static final Node getNodeAt(Outline outline, int rowInUI) {
    Node result = null;
    OutlineModel om = (OutlineModel) outline.getModel();
    int row = outline.convertRowIndexToModel(rowInUI);
    TreePath path = om.getLayout().getPathForRow(row);
    if (path != null) {
        result = Visualizer.findNode(path.getLastPathComponent());
    }
    return result;
}
 
Example 10
Source Project: netbeans   Source File: TestWebServiceMethodDlg.java    License: 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 11
Source Project: NBANDROID-V2   Source File: PackageTreeTableView.java    License: Apache License 2.0 4 votes vote down vote up
public PackageTreeTableView(OutlineModel mdl) {
    super(mdl);
}