1 19 20 package org.netbeans.modules.websvc.design.view.widget; 21 22 import java.awt.Color ; 23 import java.awt.GradientPaint ; 24 import java.awt.Graphics2D ; 25 import java.awt.Paint ; 26 import java.awt.Rectangle ; 27 import javax.swing.Action ; 28 import org.netbeans.api.visual.action.ActionFactory; 29 import org.netbeans.api.visual.layout.LayoutFactory; 30 import org.netbeans.api.visual.widget.LabelWidget; 31 import org.netbeans.api.visual.widget.Scene; 32 import org.netbeans.api.visual.widget.Widget; 33 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlOperation; 34 import org.netbeans.modules.websvc.design.view.DesignViewPopupProvider; 35 36 40 public class OperationContentWidget extends Widget{ 41 42 private static final Color FILL_COLOR_DARK = new Color (255,255,102); 43 private static final Color FILL_COLOR_LIGHT = new Color (255,255,204); 44 private static final Color BORDER_COLOR = new Color (153,204,255); 45 46 private LabelWidget label; 47 private OperationWidget operationWidget; 48 private static final String MORE_INFO = "Add documentation here"; 49 50 private static final int radius = 10; 51 56 public OperationContentWidget(Scene scene, WsdlOperation operation) { 57 super(scene); 58 setLayout(LayoutFactory.createVerticalLayout(LayoutFactory.SerialAlignment.LEFT_TOP, radius)); 59 operationWidget = new OperationWidget(scene,operation); 60 addChild(operationWidget); 61 label = new LabelWidget(scene,MORE_INFO); 62 addChild(label); 63 getActions().addAction(ActionFactory.createMoveAction()); 64 getActions().addAction(ActionFactory.createPopupMenuAction( 65 new DesignViewPopupProvider(new Action []{}))); 66 } 67 68 protected Rectangle calculateClientArea() { 69 Rectangle opBounds = operationWidget.getBounds(); 70 Rectangle labelBounds = label.getBounds(); 71 return new Rectangle ( 72 opBounds.x - radius, opBounds.y - radius, opBounds.width>=labelBounds.width ? opBounds.width + 2*radius : 75 labelBounds.width + 2*radius, opBounds.height + labelBounds.height + 3*radius ); 78 } 79 80 protected void paintWidget() { 81 Rectangle bounds = getBounds(); 82 Graphics2D g = getGraphics(); 83 Paint oldPaint = g.getPaint(); 84 g.setPaint(new GradientPaint (bounds.x, bounds.y, FILL_COLOR_DARK, 85 bounds.x, bounds.y + bounds.height, FILL_COLOR_LIGHT)); 86 g.fillRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, radius, radius); 87 g.setPaint(BORDER_COLOR); 88 g.drawRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, radius, radius); 89 g.setPaint(oldPaint); 90 } 91 92 } 93 | Popular Tags |