This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 97153
Collapse All | Expand All

(-)web/css/src/org/netbeans/modules/css/resources/mf-layer.xml (-1 / +31 lines)
Lines 21-26 Link Here
21
<filesystem>
21
<filesystem>
22
    
22
    
23
    <folder name="Actions">
23
    <folder name="Actions">
24
        <folder name="Other">
25
            <file name="org-netbeans-modules-css-test-ShowStyleBuilderDialog.instance"/>
26
        </folder>
24
        <folder name="Window">
27
        <folder name="Window">
25
            <file name="org-netbeans-modules-css-visual-ui-StyleBuilderAction.instance"/>
28
            <file name="org-netbeans-modules-css-visual-ui-StyleBuilderAction.instance"/>
26
            <file name="org-netbeans-modules-css-visual-ui-preview-CssPreviewAction.instance"/>
29
            <file name="org-netbeans-modules-css-visual-ui-preview-CssPreviewAction.instance"/>
Lines 28-33 Link Here
28
    </folder>
31
    </folder>
29
32
30
    <folder name="Menu">
33
    <folder name="Menu">
34
        <folder name="Tools">
35
            <attr name="org-netbeans-modules-css-test-ShowStyleBuilderDialog.shadow/DerbyDatabaseAction.instance" boolvalue="true"/>
36
            <attr name="org-netbeans-modules-css-test-ShowStyleBuilderDialog.shadow/org-netbeans-modules-css-test-separatorAfter.instance" boolvalue="true"/>
37
            <attr name="org-netbeans-modules-css-test-separatorAfter.instance/DerbyDatabaseAction.instance" boolvalue="true"/>
38
            <file name="org-netbeans-modules-css-test-ShowStyleBuilderDialog.shadow">
39
                <attr name="originalFile" stringvalue="Actions/Other/org-netbeans-modules-css-test-ShowStyleBuilderDialog.instance"/>
40
            </file>
41
            <file name="org-netbeans-modules-css-test-separatorAfter.instance">
42
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
43
            </file>
44
        </folder>
31
        <folder name="Window">
45
        <folder name="Window">
32
            <folder name="Other">
46
            <folder name="Other">
33
                <attr name="position" intvalue="1700"/>
47
                <attr name="position" intvalue="1700"/>
Lines 93-98 Link Here
93
        <folder name="text">
107
        <folder name="text">
94
            <folder name="x-css">
108
            <folder name="x-css">
95
                <folder name="Actions">
109
                <folder name="Actions">
110
                    <file name="org-netbeans-modules-css-test-ShowStyleBuilderDialog.shadow">
111
                        <attr name="originalFile" stringvalue="Actions/Other/org-netbeans-modules-css-test-ShowStyleBuilderDialog.instance"/>
112
                        <attr name="position" intvalue="0"/>
113
                    </file>
114
                    <file name="org-netbeans-modules-css-test-separatorAfter.instance">
115
                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
116
                        <attr name="position" intvalue="50"/>
117
                    </file>
96
                    <file name="org-openide-actions-OpenAction.instance">
118
                    <file name="org-openide-actions-OpenAction.instance">
97
                        <attr name="position" intvalue="100"/>
119
                        <attr name="position" intvalue="100"/>
98
                    </file>
120
                    </file>
Lines 179-185 Link Here
179
                    <file name="format">
201
                    <file name="format">
180
                        <attr name="position" intvalue="4800"/>
202
                        <attr name="position" intvalue="4800"/>
181
                    </file>
203
                    </file>
182
                    </folder>
204
                        <file name="org-netbeans-modules-css-test-ShowStyleBuilderDialog.shadow">
205
                        <attr name="originalFile" stringvalue="Actions/Other/org-netbeans-modules-css-test-ShowStyleBuilderDialog.instance"/>
206
                        <attr name="position" intvalue="4000"/>
207
                    </file>
208
                    <file name="org-netbeans-modules-css-test-separatorAfter.instance">
209
                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
210
                        <attr name="position" intvalue="4050"/>
211
                    </file>
212
                </folder>
183
                <folder name="Toolbars">
213
                <folder name="Toolbars">
184
                    <folder name="Default">
214
                    <folder name="Default">
185
                        <file name="create-rule">
215
                        <file name="create-rule">
(-)web/css/src/org/netbeans/modules/css/test/Bundle.properties (+1 lines)
Added Link Here
1
CTL_ShowStyleBuilderDialog=Show Style Builder Dialog
(-)web/css/src/org/netbeans/modules/css/test/ShowStyleBuilderDialog.java (+50 lines)
Added Link Here
1
package org.netbeans.modules.css.test;
2
3
import org.openide.cookies.EditorCookie;
4
import org.openide.nodes.Node;
5
import org.openide.util.HelpCtx;
6
import org.openide.util.NbBundle;
7
import org.openide.util.actions.CookieAction;
8
9
public final class ShowStyleBuilderDialog extends CookieAction {
10
    
11
    protected void performAction(Node[] activatedNodes) {
12
        EditorCookie editorCookie = (EditorCookie) activatedNodes[0].getLookup().lookup(EditorCookie.class);
13
        java.awt.EventQueue.invokeLater(new Runnable() {
14
            public void run() {
15
                StyleBuilderDialog dialog = new StyleBuilderDialog(new javax.swing.JFrame(), true);
16
                dialog.setVisible(true);
17
            }
18
        });
19
    }
20
    
21
    protected int mode() {
22
        return CookieAction.MODE_EXACTLY_ONE;
23
    }
24
    
25
    public String getName() {
26
        return NbBundle.getMessage(ShowStyleBuilderDialog.class, "CTL_ShowStyleBuilderDialog");
27
    }
28
    
29
    protected Class[] cookieClasses() {
30
        return new Class[] {
31
            EditorCookie.class
32
        };
33
    }
34
    
35
    protected void initialize() {
36
        super.initialize();
37
        // see org.openide.util.actions.SystemAction.iconResource() javadoc for more details
38
        putValue("noIconInMenu", Boolean.TRUE);
39
    }
40
    
41
    public HelpCtx getHelpCtx() {
42
        return HelpCtx.DEFAULT_HELP;
43
    }
44
    
45
    protected boolean asynchronous() {
46
        return false;
47
    }
48
    
49
}
50
(-)web/css/src/org/netbeans/modules/css/test/StyleBuilderDialog.form (+69 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
3
<Form version="1.3" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
4
  <Properties>
5
    <Property name="defaultCloseOperation" type="int" value="2"/>
6
  </Properties>
7
  <SyntheticProperties>
8
    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
9
  </SyntheticProperties>
10
  <AuxValues>
11
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
12
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
13
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
14
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
15
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
16
    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
17
    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
18
    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
19
  </AuxValues>
20
21
  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
22
  <SubComponents>
23
    <Container class="javax.swing.JPanel" name="jPanel1">
24
      <Constraints>
25
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
26
          <BorderConstraints direction="Last"/>
27
        </Constraint>
28
      </Constraints>
29
30
      <Layout>
31
        <DimensionLayout dim="0">
32
          <Group type="103" groupAlignment="0" attributes="0">
33
              <Group type="102" alignment="1" attributes="0">
34
                  <EmptySpace max="-2" attributes="0"/>
35
                  <Component id="jScrollPane1" pref="376" max="32767" attributes="0"/>
36
                  <EmptySpace max="-2" attributes="0"/>
37
              </Group>
38
          </Group>
39
        </DimensionLayout>
40
        <DimensionLayout dim="1">
41
          <Group type="103" groupAlignment="0" attributes="0">
42
              <Group type="102" alignment="0" attributes="0">
43
                  <EmptySpace max="-2" attributes="0"/>
44
                  <Component id="jScrollPane1" pref="276" max="32767" attributes="0"/>
45
                  <EmptySpace max="-2" attributes="0"/>
46
              </Group>
47
          </Group>
48
        </DimensionLayout>
49
      </Layout>
50
      <SubComponents>
51
        <Container class="javax.swing.JScrollPane" name="jScrollPane1">
52
          <AuxValues>
53
            <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
54
          </AuxValues>
55
56
          <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
57
          <SubComponents>
58
            <Component class="javax.swing.JTextArea" name="jTextArea1">
59
              <Properties>
60
                <Property name="columns" type="int" value="20"/>
61
                <Property name="rows" type="int" value="5"/>
62
              </Properties>
63
            </Component>
64
          </SubComponents>
65
        </Container>
66
      </SubComponents>
67
    </Container>
68
  </SubComponents>
69
</Form>
(-)web/css/src/org/netbeans/modules/css/test/StyleBuilderDialog.java (+137 lines)
Added Link Here
1
/*
2
 * StyleBuilderDialog.java
3
 *
4
 * Created on August 17, 2007, 2:18 PM
5
 */
6
7
package org.netbeans.modules.css.test;
8
9
import java.awt.BorderLayout;
10
import java.awt.Dimension;
11
import java.beans.PropertyChangeEvent;
12
import java.beans.PropertyChangeListener;
13
import java.io.ByteArrayInputStream;
14
import java.util.ArrayList;
15
import java.util.List;
16
import org.netbeans.modules.css.model.CssModel;
17
import org.netbeans.modules.css.model.CssRule;
18
import org.netbeans.modules.css.model.CssRuleItem;
19
import org.netbeans.modules.css.visual.api.CssRuleContext;
20
import org.netbeans.modules.css.visual.api.StyleBuilderPanel;
21
import org.netbeans.modules.css.visual.ui.preview.CssPreviewGenerator;
22
import org.netbeans.modules.css.visual.ui.preview.CssPreviewPanel;
23
import org.openide.util.Exceptions;
24
25
/**
26
 *
27
 * @author  marek
28
 */
29
public class StyleBuilderDialog extends javax.swing.JDialog {
30
31
    private CssPreviewPanel previewPanel = new CssPreviewPanel();
32
    
33
    /** Creates new form StyleBuilderDialog */
34
    public StyleBuilderDialog(java.awt.Frame parent, boolean modal) {
35
        super(parent, modal);
36
37
        initComponents();
38
        
39
        String testingRule = " h1 { color: red; }";
40
        CssModel model = CssModel.get(new ByteArrayInputStream(testingRule.getBytes()));
41
        CssRule rule = model.rules().get(0);
42
        final CssRuleContext context = new CssRuleContext(rule, model, null, null);
43
        
44
        updateRulesListUI(context);
45
        updatePreview(context);
46
        
47
        rule.ruleContent().addPropertyChangeListener(new PropertyChangeListener() {
48
49
            public void propertyChange(PropertyChangeEvent evt) {
50
                updateRulesListUI(context);
51
                updatePreview(context);
52
            }
53
        });
54
55
        
56
57
        StyleBuilderPanel panel = StyleBuilderPanel.createInstance();
58
        panel.setContent(context);
59
60
        previewPanel.setMinimumSize(new Dimension(300,300));
61
        
62
        getContentPane().add(panel, BorderLayout.CENTER);
63
        getContentPane().add(previewPanel, BorderLayout.EAST);
64
        
65
        pack();
66
    }
67
68
    private void updateRulesListUI(CssRuleContext context) {
69
        StringBuffer sb = new StringBuffer();
70
        for (CssRuleItem i : context.selectedRule().ruleContent().ruleItems()) {
71
            sb.append(i.toString());
72
            sb.append('\n');
73
        }
74
        jTextArea1.setText(sb.toString());
75
    }
76
    
77
    private void updatePreview(CssRuleContext context) {
78
        try {
79
            String htmlCode = CssPreviewGenerator.getPreviewCode(context).toString();
80
            previewPanel.panel().setDocument(new java.io.ByteArrayInputStream(htmlCode.getBytes()), null);
81
        } catch (Exception ex) {
82
            Exceptions.printStackTrace(ex);
83
        }
84
    }
85
86
    /** This method is called from within the constructor to
87
     * initialize the form.
88
     * WARNING: Do NOT modify this code. The content of this method is
89
     * always regenerated by the Form Editor.
90
     */
91
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
92
    private void initComponents() {
93
94
        jPanel1 = new javax.swing.JPanel();
95
        jScrollPane1 = new javax.swing.JScrollPane();
96
        jTextArea1 = new javax.swing.JTextArea();
97
98
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
99
100
        jTextArea1.setColumns(20);
101
        jTextArea1.setRows(5);
102
        jScrollPane1.setViewportView(jTextArea1);
103
104
        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
105
        jPanel1.setLayout(jPanel1Layout);
106
        jPanel1Layout.setHorizontalGroup(
107
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
108
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
109
                .addContainerGap()
110
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
111
                .addContainerGap())
112
        );
113
        jPanel1Layout.setVerticalGroup(
114
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
115
            .add(jPanel1Layout.createSequentialGroup()
116
                .addContainerGap()
117
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE)
118
                .addContainerGap())
119
        );
120
121
        getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_END);
122
123
        pack();
124
    }// </editor-fold>//GEN-END:initComponents
125
126
    /**
127
     * @param args the command line arguments
128
     */
129
    public static void main(String[] args) {
130
    }
131
132
    // Variables declaration - do not modify//GEN-BEGIN:variables
133
    private javax.swing.JPanel jPanel1;
134
    private javax.swing.JScrollPane jScrollPane1;
135
    private javax.swing.JTextArea jTextArea1;
136
    // End of variables declaration//GEN-END:variables
137
}

Return to bug 97153