001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource.so6.core.engine.log.monitoring;
034:
035: import org.libresource.so6.core.engine.log.MessageWriter;
036:
037: import java.awt.Color;
038: import java.awt.Dimension;
039:
040: import javax.swing.BorderFactory;
041: import javax.swing.Box;
042: import javax.swing.BoxLayout;
043: import javax.swing.JLabel;
044: import javax.swing.JPanel;
045: import javax.swing.JProgressBar;
046: import javax.swing.border.TitledBorder;
047:
048: /**
049: * @author smack
050: */
051: public class XMLProgressView extends JPanel implements MessageWriter {
052: private JProgressBar localBar;
053: private JProgressBar globalBar;
054: private JLabel localText;
055: private JLabel globalText;
056: private TitledBorder localBorder;
057: private TitledBorder globalBorder;
058: private TreeContext context;
059: private JPanel lineLocal;
060: private JPanel lineGlobal;
061: private JPanel localView;
062: private JPanel globalView;
063:
064: public XMLProgressView(XMLLogHandler xmlLogHandler) {
065: context = xmlLogHandler.getContext();
066: xmlLogHandler.addMessageListener(this );
067:
068: //
069: localBar = context.getLocalProgressBar();
070: globalBar = context.getGlobalProgressBar();
071:
072: //
073: localText = new JLabel("local");
074: localText.setMaximumSize(new Dimension(500, 500));
075: localText.setMinimumSize(new Dimension(5, 5));
076: globalText = new JLabel("global");
077: globalText.setMaximumSize(new Dimension(500, 500));
078: globalText.setMinimumSize(new Dimension(5, 5));
079:
080: //
081: lineLocal = new JPanel();
082:
083: BoxLayout layoutLineLocal = new BoxLayout(lineLocal,
084: BoxLayout.X_AXIS);
085: lineLocal.setLayout(layoutLineLocal);
086: lineLocal.add(localText);
087: lineLocal.add(Box.createHorizontalGlue());
088: lineGlobal = new JPanel();
089:
090: BoxLayout layoutLineGlobal = new BoxLayout(lineGlobal,
091: BoxLayout.X_AXIS);
092: lineGlobal.setLayout(layoutLineGlobal);
093: lineGlobal.add(globalText);
094: lineGlobal.add(Box.createHorizontalGlue());
095:
096: //
097: localBorder = BorderFactory.createTitledBorder("Local action");
098: globalBorder = BorderFactory
099: .createTitledBorder("Global action");
100:
101: //
102: localView = new JPanel();
103:
104: BoxLayout layoutLocal = new BoxLayout(localView,
105: BoxLayout.Y_AXIS);
106: localView.setLayout(layoutLocal);
107: localView.setBorder(localBorder);
108: localView.add(lineLocal);
109: localView.add(localBar);
110:
111: //
112: globalView = new JPanel();
113:
114: BoxLayout layoutGlobal = new BoxLayout(globalView,
115: BoxLayout.Y_AXIS);
116: globalView.setLayout(layoutGlobal);
117: globalView.setBorder(globalBorder);
118: globalView.add(lineGlobal);
119: globalView.add(globalBar);
120:
121: //
122: //setBorder(new EmptyBorder(5, 5, 5, 5));
123: BoxLayout layout = new BoxLayout(this , BoxLayout.Y_AXIS);
124: setLayout(layout);
125: add(localView);
126: add(globalView);
127:
128: //
129: setMaximumSize(new Dimension(200, 200));
130: setMinimumSize(new Dimension(200, 200));
131: }
132:
133: public void setBackground(Color color) {
134: if (localText != null) {
135: localText.setBackground(color);
136: }
137:
138: if (globalText != null) {
139: globalText.setBackground(color);
140: }
141:
142: if (localView != null) {
143: localView.setBackground(color);
144: }
145:
146: if (globalView != null) {
147: globalView.setBackground(color);
148: }
149:
150: if (lineLocal != null) {
151: lineLocal.setBackground(color);
152: }
153:
154: if (lineGlobal != null) {
155: lineGlobal.setBackground(color);
156: }
157: }
158:
159: public void printMessage(boolean global, String message) {
160: if (global) {
161: globalText.setText(message);
162: } else {
163: localText.setText(message);
164: }
165: }
166:
167: public void setStyle(Color back, Color forground) {
168: setBackground(back);
169: lineLocal.setBackground(back);
170: lineGlobal.setBackground(back);
171: localView.setBackground(back);
172: globalView.setBackground(back);
173: }
174: }
|