KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > design > view > widget > OperationContentWidget


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.design.view.widget;
21
22 import java.awt.Color JavaDoc;
23 import java.awt.GradientPaint JavaDoc;
24 import java.awt.Graphics2D JavaDoc;
25 import java.awt.Paint JavaDoc;
26 import java.awt.Rectangle JavaDoc;
27 import javax.swing.Action JavaDoc;
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 /**
37  *
38  * @author Ajit Bhate
39  */

40 public class OperationContentWidget extends Widget{
41     
42     private static final Color JavaDoc FILL_COLOR_DARK = new Color JavaDoc(255,255,102);
43     private static final Color JavaDoc FILL_COLOR_LIGHT = new Color JavaDoc(255,255,204);
44     private static final Color JavaDoc BORDER_COLOR = new Color JavaDoc(153,204,255);
45
46     private LabelWidget label;
47     private OperationWidget operationWidget;
48     private static final String JavaDoc MORE_INFO = "Add documentation here";
49     
50     private static final int radius = 10;
51     /**
52      * Creates a new instance of OperationWidget
53      * @param scene
54      * @param operation
55      */

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 JavaDoc[]{})));
66     }
67     
68     protected Rectangle JavaDoc calculateClientArea() {
69         Rectangle JavaDoc opBounds = operationWidget.getBounds();
70         Rectangle JavaDoc labelBounds = label.getBounds();
71         return new Rectangle JavaDoc(
72                 opBounds.x - radius, // x
73
opBounds.y - radius,// y
74
opBounds.width>=labelBounds.width ? opBounds.width + 2*radius :
75                     labelBounds.width + 2*radius, //width
76
opBounds.height + labelBounds.height + 3*radius //height
77
);
78     }
79     
80     protected void paintWidget() {
81         Rectangle JavaDoc bounds = getBounds();
82         Graphics2D JavaDoc g = getGraphics();
83         Paint JavaDoc oldPaint = g.getPaint();
84         g.setPaint(new GradientPaint JavaDoc(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