001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.modules.bpel.design;
021:
022: import java.awt.Component;
023: import java.awt.Dimension;
024: import java.awt.Graphics;
025: import java.awt.Graphics2D;
026: import java.awt.RenderingHints;
027: import java.io.IOException;
028: import java.net.MalformedURLException;
029: import java.net.URL;
030: import javax.swing.JEditorPane;
031: import javax.swing.JPanel;
032: import javax.swing.JScrollPane;
033: import javax.swing.border.EmptyBorder;
034: import javax.swing.text.html.HTMLEditorKit;
035: import org.openide.util.NbBundle;
036:
037: public class ErrorPanel extends JEditorPane {
038:
039: private DesignView designView;
040: private boolean installed = false;
041: private static final long serialVersionUID = 1;
042:
043: // private Timer timer;
044:
045: public ErrorPanel(DesignView designView) {
046: this .designView = designView;
047: // this.timer = new Timer(3000, this);
048:
049: // setEditorKitForContentType("text/html",new HTMLEditorKit()); // NOI18N
050: setEditable(false);
051: setPreferredSize(new Dimension(200, 200));
052: setBorder(new EmptyBorder(20, 20, 20, 20));
053: setContentType("text/html"); // NOI18N
054: setBackground(designView.getBackground());
055: setText(NbBundle.getMessage(ErrorPanel.class,
056: "LBL_ErrorPanel_Content"));
057: // try {
058: // setPage(ERROR_MESSAGE);
059: //
060: // } catch (IOException e) {};
061: }
062:
063: public boolean isInstalled() {
064: return installed;
065: }
066:
067: public void install() {
068: if (!installed) {
069: Component c = getDesignView().getParent();
070:
071: if (c != null) {
072: JScrollPane scrollPane = (JScrollPane) c.getParent();
073: scrollPane.setViewportView(this );
074: }
075:
076: installed = true;
077: // timer.start();
078: }
079:
080: // updateErrorMessage();
081: }
082:
083: // public void updateErrorMessage() {
084: // if (!isInstalled()) return;
085: //
086: // boolean verifyNamespace = false;
087: //
088: // if (designView.getBPELModel().getState() != BpelModel.State.VALID) {
089: // AnotherVersionBpelProcess avp = designView.getBPELModel()
090: // .getAnotherVersionProcess();
091: //
092: // if (avp != null) {
093: // String currentNS = avp.getNamespaceUri();
094: // if (currentNS == null) {
095: // verifyNamespace = true;
096: // } else {
097: // verifyNamespace = !currentNS.equals(BpelEntity
098: // .BUSINESS_PROCESS_NS_URI);
099: // }
100: // }
101: // }
102: //
103: // try {
104: // setPage((verifyNamespace) ? ERROR_MESSAGE_2 : ERROR_MESSAGE_1);
105: // } catch (IOException e) {};
106: // }
107:
108: public void uninstall() {
109: if (!installed)
110: return;
111:
112: JScrollPane scrollPane = (JScrollPane) getParent().getParent();
113: scrollPane.setViewportView(getDesignView());
114:
115: // timer.stop();
116: installed = false;
117: }
118:
119: public DesignView getDesignView() {
120: return designView;
121: }
122:
123: protected void paintComponent(Graphics g) {
124: Graphics2D g2 = (Graphics2D) g.create();
125: g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
126: RenderingHints.VALUE_ANTIALIAS_ON);
127: g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
128: RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
129: super .paintComponent(g2);
130: }
131:
132: // public void actionPerformed(ActionEvent e) {
133: // updateErrorMessage();
134: // }
135:
136: // private static URL ERROR_MESSAGE; // NOI18N
137:
138: static {
139: // try {
140: // ERROR_MESSAGE = new URL("nbresloc:/org/netbeans/modules/bpel/design/resources/errormessage.html"); // NOI18N
141: // ERROR_MESSAGE = NbBundle.getMessage(ErrorPanel.class, "LBL_ErrorPanel_Content");// NOI18N
142: // } catch (MalformedURLException e) {}
143: }
144:
145: // private static URL ERROR_MESSAGE_1 = ErrorPanel.class
146: // .getResource("resources/errormessage1.html"); // NOI18N
147: //
148: // private static URL ERROR_MESSAGE_2 = ErrorPanel.class
149: // .getResource("resources/errormessage2.html"); // NOI18N
150: }
|