001: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012: // POSSIBILITY OF SUCH DAMAGE.
013: //
014: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015: package com.metaboss.applications.designstudio;
016:
017: import java.awt.BorderLayout;
018: import java.awt.Dimension;
019: import java.awt.Toolkit;
020: import java.awt.datatransfer.Clipboard;
021: import java.awt.datatransfer.StringSelection;
022: import java.awt.event.ActionEvent;
023: import java.util.ArrayList;
024:
025: import javax.swing.JEditorPane;
026: import javax.swing.JPanel;
027: import javax.swing.JScrollPane;
028: import javax.swing.JToolBar;
029:
030: /* Base Log Output Panel */
031:
032: public class BaseLogPanel extends JPanel {
033: // UI
034: protected JEditorPane mInformationPane = new JEditorPane();
035: protected JToolBar mToolBar = null;
036: // actions
037: protected CopyToClipBoardAction mCopyToClipBoardAction = new CopyToClipBoardAction();
038: protected ClearAction mClearAction = new ClearAction();
039:
040: public BaseLogPanel() {
041: super (new BorderLayout());
042:
043: setLayout(new BorderLayout());
044:
045: mInformationPane.setEditable(false);
046: mInformationPane.setContentType("text/plain");
047:
048: mToolBar = new JToolBar() {
049: public Dimension getMinimumSize() {
050: Dimension lResult = super .getMinimumSize();
051: lResult.height = 1;
052: return lResult;
053: }
054: };
055:
056: mToolBar.setBorder(null);
057: mToolBar.setOrientation(JToolBar.VERTICAL);
058: mToolBar.setRollover(true);
059:
060: fillChildControls();
061: }
062:
063: public void setVisible(boolean aFlag) {
064: super .setVisible(aFlag);
065: if (aFlag)
066: Application.fillActions(getActions(), mToolBar, null, null);
067: }
068:
069: protected void fillChildControls() {
070: add(mToolBar, BorderLayout.WEST);
071: add(new JScrollPane(mInformationPane));
072: }
073:
074: // get Actions list
075: protected Object[] getActions() {
076: ArrayList lList = new ArrayList();
077: fillActions(lList);
078: return lList.toArray();
079: }
080:
081: protected void fillActions(ArrayList pList) {
082: pList.add(mCopyToClipBoardAction);
083: pList.add(mClearAction);
084: }
085:
086: protected void copyToClipboard() {
087: String lContent = mInformationPane.getText();
088: Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
089: cb.setContents(new StringSelection(lContent), null);
090: }
091:
092: protected void clearContent() {
093: mInformationPane.setText("");
094: }
095:
096: /* Actions */
097:
098: public class CopyToClipBoardAction extends BaseAction {
099: public CopyToClipBoardAction() {
100: super (
101: "Copy",
102: "Copy contents of the log to clipboard (Eg. for e-mailing to MetaBoss Support)",
103: Application.COPYTOCLIP_ICON);
104: }
105:
106: public void actionPerformed(ActionEvent arg0) {
107: copyToClipboard();
108: }
109: }
110:
111: public class ClearAction extends BaseAction {
112: public ClearAction() {
113: super ("Clear", Application.CLEAR_ICON);
114: }
115:
116: public void actionPerformed(ActionEvent arg0) {
117: clearContent();
118: }
119: }
120: }
|