{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Sample Attributes Shortcut Panel Implementation","description":"Accelerate E&P application development and protect your innovation by consuming our Data and Domain APIs / Platform APIs.","lang":"en-US","meta":[{"name":"robots","content":"noindex"}],"llmstxt":{"hide":false}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"sample-attributes-shortcut-panel-implementation","__idx":0},"children":["Sample Attributes Shortcut Panel Implementation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In this implementation, we provide an attributes shortcut panel for a triangle mesh layer. This panel only contains a button for the selection of a line color."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"extending-abstractvisualattributesshortcutpanel","__idx":1},"children":["Extending AbstractVisualAttributesShortcutPanel"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following panel class was created using the Netbeans Matisse editor, then customized to extend com.interactive.intviewerapi.editors.AbstractVisualAttributesShortcutPanel."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["TRIANGLEMESHLAYERATTRIBUTESSHORTCUTPANEL.JAVA"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"package com.interactive.intviewer.tmesh.editor.shortcut;\nimport com.interactive.intviewerapi.events.PropertyProviderEvent;\nimport com.interactive.intviewerapi.editors.AbstractVisualAttributesShortcutPanel;\nimport com.interactive.intviewer.util.gui.LineColorButton;\nimport com.interactive.intviewerapi.layers.ITriangleMeshLayer;\nimport com.interactive.intviewerapi.layers.NamedProps;\nimport java.awt.Color;\npublic class TriangleMeshLayerAttributesShortcutPanel extends AbstractVisualAttributesShortcutPanel {\n    public TriangleMeshLayerAttributesShortcutPanel(ITriangleMeshLayer tmeshLayer) {\n        super(tmeshLayer);\n        initComponents();\n        initGUI();\n        this.setReady(true);\n    }\n    /** \n     * WARNING: Do NOT modify this code. The content of this method is\n     * always regenerated by the Form Editor.\n     */\n    @SuppressWarnings(\"unchecked\")\n    // <editor-fold defaultstate=\"collapsed\" desc=\"Generated Code\">                          \n    private void initComponents() {\n        jLabel1 = new javax.swing.JLabel();\n        colorBtn = new LineColorButton(\"\", Color.black);\n        jLabel1.setText(org.openide.util.NbBundle.getMessage(TriangleMeshLayerAttributesShortcutPanel.class, \"TriangleMeshLayerAttributesShortcutPanel.jLabel1.text\")); // NOI18N\n        colorBtn.setText(org.openide.util.NbBundle.getMessage(TriangleMeshLayerAttributesShortcutPanel.class, \"TriangleMeshLayerAttributesShortcutPanel.colorBtn.text\")); // NOI18N\n        colorBtn.addPropertyChangeListener(new java.beans.PropertyChangeListener() {\n            public void propertyChange(java.beans.PropertyChangeEvent evt) {\n                colorBtnPropertyChange(evt);\n            }\n        });\n        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);\n        this.setLayout(layout);\n        layout.setHorizontalGroup(\n            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)\n            .addGroup(layout.createSequentialGroup()\n                .addContainerGap()\n                .addComponent(jLabel1)\n                .addGap(27, 27, 27)\n                .addComponent(colorBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)\n                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))\n        );\n        layout.setVerticalGroup(\n            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)\n            .addGroup(layout.createSequentialGroup()\n                .addGap(12, 12, 12)\n                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)\n                    .addComponent(colorBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)\n                    .addComponent(jLabel1))\n                .addContainerGap(24, Short.MAX_VALUE))\n        );\n    }// </editor-fold>                        \n    private void colorBtnPropertyChange(java.beans.PropertyChangeEvent evt) {                                        \n        // TODO add your handling code here:\n        if (!isReady()) {\n            return;\n        }\n        if (this.getVisual() == null) {\n            return;\n        }\n        if (evt.getSource() == colorBtn && evt.getPropertyName().equals(LineColorButton.COLOR_PROPERTY)) {\n            Color c = ((LineColorButton) colorBtn).getSelectedColor();\n            NamedProps prop = new NamedProps();\n            prop.putProperty(ITriangleMeshLayer.LINE_COLOR, c);\n            getVisual().setProperties(prop, this);\n        }\n    }                                       \n    // Variables declaration - do not modify                     \n    private javax.swing.JButton colorBtn;\n    private javax.swing.JLabel jLabel1;\n    // End of variables declaration                   \n    private void initGUI() {\n        Color c = getVisual().getProperties().getProperty(ITriangleMeshLayer.LINE_COLOR);\n        ((LineColorButton) colorBtn).setSelectedColor(c);\n    }\n    @Override\n    protected void processEvent(PropertyProviderEvent e) {\n        this.setReady(false);\n        initGUI();\n        this.setReady(true);\n    }\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"extending-abstractvisualattributesshortcuteditor","__idx":2},"children":["Extending AbstractVisualAttributesShortcutEditor"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following editor class does a lazy-instantiation of the panel created earlier."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["TRIANGLEMESHLAYERATTRIBUTESSHORTCUTEDITOR.JAVA"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"package com.interactive.intviewer.tmesh.editor.shortcut;\nimport com.interactive.intviewerapi.editors.AbstractVisualAttributesShortcutEditor;\nimport com.interactive.intviewerapi.layers.ILayer2D;\nimport com.interactive.intviewerapi.layers.IVisual;\nimport com.interactive.intviewerapi.layers.ITriangleMeshLayer;\nimport javax.swing.JComponent;\npublic class TriangleMeshLayerAttributesShortcutEditor extends AbstractVisualAttributesShortcutEditor {\n    private TriangleMeshLayerAttributesShortcutPanel panel;\n    public TriangleMeshLayerAttributesShortcutEditor(ILayer2D layer) {\n        super(layer);\n    }\n    @Override\n    public JComponent getComponent() {\n          if (panel == null) {\n            panel = new TriangleMeshLayerAttributesShortcutPanel((ITriangleMeshLayer) this.getVisual());\n        }\n        return panel;\n    }\n    @Override\n    public void dispose() {\n        super.dispose();\n        if (panel != null) {\n            panel.dispose();\n            panel = null;\n        }\n    }\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"implementing-iattributesshortcutadapter","__idx":3},"children":["Implementing IAttributesShortcutAdapter"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following adapter class verifies that the object is a xsection triangle mesh layer, and vends the editor created earlier."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["XSECTIONTRIANGLEMESHLAYERSHORTCUTADAPTER.JAVA"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"package com.interactive.intviewer.tmesh.editor.shortcut;\nimport com.interactive.intviewer.tmesh.layer2d.XSectionTriangleMeshLayer;\nimport com.interactive.intviewerapi.editors.IAttributesShortcutAdapter;\nimport com.interactive.intviewerapi.editors.IAttributesShortcutProvider;\nimport com.interactive.intviewerapi.editors.IAttributesShortcutProvider.IAttributesShortcutEditor;\npublic class XSectionTriangleMeshLayerShortcutAdapter implements IAttributesShortcutAdapter {\n    @Override\n    public Class<?> getSupportedClass() {\n        return XSectionTriangleMeshLayer.class;\n    }\n    @Override\n    public boolean canProcess(Object o) {\n        return (o instanceof XSectionTriangleMeshLayer);\n    }\n    @Override\n    public IAttributesShortcutProvider getProvider(Object o) {\n        if (o instanceof XSectionTriangleMeshLayer) {\n            return new TriangleMeshShortcutProvider((XSectionTriangleMeshLayer) o);\n        } else {\n            return null;\n        }\n    }\n    class TriangleMeshShortcutProvider implements IAttributesShortcutProvider {\n        private XSectionTriangleMeshLayer layer;\n        public TriangleMeshShortcutProvider(XSectionTriangleMeshLayer tmeshLayer) {\n            layer = tmeshLayer;\n        }\n        @Override\n        public IAttributesShortcutEditor[] getEditors() {\n            return new IAttributesShortcutEditor[]{new TriangleMeshLayerAttributesShortcutEditor(layer)};\n        }\n    }\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Important:"]}," In the getSupportedClass method, indicate the implementation class, not the interface. To get the implementation class of a layer, use layer.getClass()."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"registering-the-adapter","__idx":4},"children":["Registering the adapter"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following layer registration adds the adapter created earlier to the INTViewer desktop."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["LAYER.XML"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"xml","header":{"controls":{"copy":{}}},"source":"    <folder name=\"ShortcutEditors\">\n        <folder name=\"AttributesShortcut\">\n            <file name=\"com-interactive-intviewer-tmesh-editor-shortcut-XSectionTriangleMeshLayerShortcutAdapter.instance\"/>\n        </folder>\n    </folder>\n","lang":"xml"},"children":[]}]},"headings":[{"value":"Sample Attributes Shortcut Panel Implementation","id":"sample-attributes-shortcut-panel-implementation","depth":1},{"value":"Extending AbstractVisualAttributesShortcutPanel","id":"extending-abstractvisualattributesshortcutpanel","depth":3},{"value":"Extending AbstractVisualAttributesShortcutEditor","id":"extending-abstractvisualattributesshortcuteditor","depth":3},{"value":"Implementing IAttributesShortcutAdapter","id":"implementing-iattributesshortcutadapter","depth":3},{"value":"Registering the adapter","id":"registering-the-adapter","depth":3}],"frontmatter":{"title":"Sample Attributes Shortcut Panel Implementation","pageId":"intviewer-apis-for-dialogs-and-editors/working-with-attribute-and-window-shortcut-panels/sample-attributes-shortcut-panel-implementation","seo":{"title":"Sample Attributes Shortcut Panel Implementation"}},"lastModified":"2026-10-22T14:32:05.575Z","pagePropGetterError":{"message":"","name":""}},"slug":"/solutions/intviewer/intviewer-apis-for-dialogs-and-editors/working-with-attribute-and-window-shortcut-panels/sample-attributes-shortcut-panel-implementation","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}