? web/css/lib Index: web/css/src/org/netbeans/modules/css/resources/mf-layer.xml =================================================================== RCS file: /cvs/web/css/src/org/netbeans/modules/css/resources/mf-layer.xml,v retrieving revision 1.12 diff -u -u -r1.12 mf-layer.xml --- web/css/src/org/netbeans/modules/css/resources/mf-layer.xml 23 Jul 2007 16:16:58 -0000 1.12 +++ web/css/src/org/netbeans/modules/css/resources/mf-layer.xml 17 Aug 2007 16:21:35 -0000 @@ -21,6 +21,9 @@ + + + @@ -28,6 +31,17 @@ + + + + + + + + + + + @@ -93,6 +107,14 @@ + + + + + + + + @@ -179,7 +201,15 @@ - + + + + + + + + + Index: web/css/src/org/netbeans/modules/css/test/Bundle.properties =================================================================== RCS file: web/css/src/org/netbeans/modules/css/test/Bundle.properties diff -N web/css/src/org/netbeans/modules/css/test/Bundle.properties --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ web/css/src/org/netbeans/modules/css/test/Bundle.properties 17 Aug 2007 16:21:35 -0000 @@ -0,0 +1 @@ +CTL_ShowStyleBuilderDialog=Show Style Builder Dialog Index: web/css/src/org/netbeans/modules/css/test/ShowStyleBuilderDialog.java =================================================================== RCS file: web/css/src/org/netbeans/modules/css/test/ShowStyleBuilderDialog.java diff -N web/css/src/org/netbeans/modules/css/test/ShowStyleBuilderDialog.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ web/css/src/org/netbeans/modules/css/test/ShowStyleBuilderDialog.java 17 Aug 2007 16:21:35 -0000 @@ -0,0 +1,50 @@ +package org.netbeans.modules.css.test; + +import org.openide.cookies.EditorCookie; +import org.openide.nodes.Node; +import org.openide.util.HelpCtx; +import org.openide.util.NbBundle; +import org.openide.util.actions.CookieAction; + +public final class ShowStyleBuilderDialog extends CookieAction { + + protected void performAction(Node[] activatedNodes) { + EditorCookie editorCookie = (EditorCookie) activatedNodes[0].getLookup().lookup(EditorCookie.class); + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + StyleBuilderDialog dialog = new StyleBuilderDialog(new javax.swing.JFrame(), true); + dialog.setVisible(true); + } + }); + } + + protected int mode() { + return CookieAction.MODE_EXACTLY_ONE; + } + + public String getName() { + return NbBundle.getMessage(ShowStyleBuilderDialog.class, "CTL_ShowStyleBuilderDialog"); + } + + protected Class[] cookieClasses() { + return new Class[] { + EditorCookie.class + }; + } + + protected void initialize() { + super.initialize(); + // see org.openide.util.actions.SystemAction.iconResource() javadoc for more details + putValue("noIconInMenu", Boolean.TRUE); + } + + public HelpCtx getHelpCtx() { + return HelpCtx.DEFAULT_HELP; + } + + protected boolean asynchronous() { + return false; + } + +} + Index: web/css/src/org/netbeans/modules/css/test/StyleBuilderDialog.form =================================================================== RCS file: web/css/src/org/netbeans/modules/css/test/StyleBuilderDialog.form diff -N web/css/src/org/netbeans/modules/css/test/StyleBuilderDialog.form --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ web/css/src/org/netbeans/modules/css/test/StyleBuilderDialog.form 17 Aug 2007 16:21:36 -0000 @@ -0,0 +1,69 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: web/css/src/org/netbeans/modules/css/test/StyleBuilderDialog.java =================================================================== RCS file: web/css/src/org/netbeans/modules/css/test/StyleBuilderDialog.java diff -N web/css/src/org/netbeans/modules/css/test/StyleBuilderDialog.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ web/css/src/org/netbeans/modules/css/test/StyleBuilderDialog.java 17 Aug 2007 16:21:36 -0000 @@ -0,0 +1,137 @@ +/* + * StyleBuilderDialog.java + * + * Created on August 17, 2007, 2:18 PM + */ + +package org.netbeans.modules.css.test; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.ByteArrayInputStream; +import java.util.ArrayList; +import java.util.List; +import org.netbeans.modules.css.model.CssModel; +import org.netbeans.modules.css.model.CssRule; +import org.netbeans.modules.css.model.CssRuleItem; +import org.netbeans.modules.css.visual.api.CssRuleContext; +import org.netbeans.modules.css.visual.api.StyleBuilderPanel; +import org.netbeans.modules.css.visual.ui.preview.CssPreviewGenerator; +import org.netbeans.modules.css.visual.ui.preview.CssPreviewPanel; +import org.openide.util.Exceptions; + +/** + * + * @author marek + */ +public class StyleBuilderDialog extends javax.swing.JDialog { + + private CssPreviewPanel previewPanel = new CssPreviewPanel(); + + /** Creates new form StyleBuilderDialog */ + public StyleBuilderDialog(java.awt.Frame parent, boolean modal) { + super(parent, modal); + + initComponents(); + + String testingRule = " h1 { color: red; }"; + CssModel model = CssModel.get(new ByteArrayInputStream(testingRule.getBytes())); + CssRule rule = model.rules().get(0); + final CssRuleContext context = new CssRuleContext(rule, model, null, null); + + updateRulesListUI(context); + updatePreview(context); + + rule.ruleContent().addPropertyChangeListener(new PropertyChangeListener() { + + public void propertyChange(PropertyChangeEvent evt) { + updateRulesListUI(context); + updatePreview(context); + } + }); + + + + StyleBuilderPanel panel = StyleBuilderPanel.createInstance(); + panel.setContent(context); + + previewPanel.setMinimumSize(new Dimension(300,300)); + + getContentPane().add(panel, BorderLayout.CENTER); + getContentPane().add(previewPanel, BorderLayout.EAST); + + pack(); + } + + private void updateRulesListUI(CssRuleContext context) { + StringBuffer sb = new StringBuffer(); + for (CssRuleItem i : context.selectedRule().ruleContent().ruleItems()) { + sb.append(i.toString()); + sb.append('\n'); + } + jTextArea1.setText(sb.toString()); + } + + private void updatePreview(CssRuleContext context) { + try { + String htmlCode = CssPreviewGenerator.getPreviewCode(context).toString(); + previewPanel.panel().setDocument(new java.io.ByteArrayInputStream(htmlCode.getBytes()), null); + } catch (Exception ex) { + Exceptions.printStackTrace(ex); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jTextArea1 = new javax.swing.JTextArea(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + jTextArea1.setColumns(20); + jTextArea1.setRows(5); + jScrollPane1.setViewportView(jTextArea1); + + org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup() + .addContainerGap() + .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE) + .addContainerGap()) + ); + + getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_END); + + pack(); + }// //GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea jTextArea1; + // End of variables declaration//GEN-END:variables +}