1 19 20 25 26 package org.netbeans.modules.css.actions; 27 28 import org.netbeans.modules.css.visual.model.CssMetaModel; 29 import java.awt.Component ; 30 import java.awt.Dimension ; 31 import java.awt.event.ActionEvent ; 32 import java.awt.event.ActionListener ; 33 import javax.swing.ImageIcon ; 34 import javax.swing.JPanel ; 35 import javax.swing.JToggleButton ; 36 import org.openide.nodes.Node; 37 import org.openide.util.HelpCtx; 38 import org.openide.util.NbBundle; 39 import org.openide.util.actions.CookieAction; 40 41 46 public class CssStyleBuilderViewAction extends CookieAction { 47 48 51 private static final Class [] REQUIRED_COOKIES = new Class [] { 52 53 }; 54 55 56 public HelpCtx getHelpCtx() { 57 return HelpCtx.DEFAULT_HELP; 58 } 59 60 63 public String getName() { 64 return NbBundle.getMessage(CssStyleBuilderViewAction.class, "STYLE_BUILDER_VIEW_ACTION"); 65 } 66 67 70 protected int mode() { 71 return MODE_EXACTLY_ONE; 72 } 73 74 protected Class [] cookieClasses() { 75 return REQUIRED_COOKIES; 76 } 77 78 81 protected void performAction(Node[] activatedNodes) { 82 } 84 85 public Component getToolbarPresenter() { 86 Component viewToggle = new ToolbarPresenter(); 87 return viewToggle; 88 } 89 90 private static class ToolbarPresenter extends JPanel { 91 private String imgName = "/org/netbeans/modules/css/resources/style_builder_view_toolbar.png"; 92 private ImageIcon imgIcon = new ImageIcon (CssStyleBuilderViewAction.class.getResource(imgName)); 93 private JToggleButton viewToggle = new JToggleButton (null,imgIcon); 94 private static final int FIXED_WIDTH = 30; 95 96 ToolbarPresenter() { 97 initComponents(); 98 } 99 100 private void initComponents() { 101 viewToggle.setToolTipText(NbBundle.getMessage(CssStyleBuilderViewAction.class, "VIEW_STYLE_BUILDER_TOOLTIP")); 102 viewToggle.setSelected(true); 103 viewToggle.setFocusable(false); 104 viewToggle.setPreferredSize(new Dimension (25,20)); 105 viewToggle.addActionListener(new ActionListener () { 106 public void actionPerformed(ActionEvent evt) { 107 CssMetaModel.getInstance().setStyleBuilderVisibility(viewToggle.isSelected()); 108 } 109 }); 110 viewToggle.setRolloverEnabled(true); 111 add(viewToggle); 112 } 113 114 public java.awt.Dimension getMinimumSize() { 115 return new java.awt.Dimension (FIXED_WIDTH, getPreferredSize().height); 116 } 117 118 public java.awt.Dimension getMaximumSize() { 119 return new java.awt.Dimension (FIXED_WIDTH, getPreferredSize().height); 120 } 121 } 122 } 123 | Popular Tags |