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.StateMonitoring;
036:
037: import java.awt.Color;
038: import java.awt.Dimension;
039:
040: import java.util.Observable;
041: import java.util.Observer;
042:
043: import javax.swing.BorderFactory;
044: import javax.swing.Box;
045: import javax.swing.BoxLayout;
046: import javax.swing.JLabel;
047: import javax.swing.JPanel;
048: import javax.swing.JProgressBar;
049: import javax.swing.border.TitledBorder;
050:
051: /**
052: * @author smack
053: */
054: public class ProgressView extends JPanel implements Observer {
055: private JProgressBar localBar;
056: private JProgressBar globalBar;
057: private JLabel localText;
058: private JLabel globalText;
059: private TitledBorder localBorder;
060: private TitledBorder globalBorder;
061: private JPanel lineLocal;
062: private JPanel lineGlobal;
063: private JPanel localView;
064: private JPanel globalView;
065:
066: public ProgressView() {
067: localBar = StateMonitoring.getInstance().getContext()
068: .getLocalProgressBar();
069: globalBar = StateMonitoring.getInstance().getContext()
070: .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: StateMonitoring.getInstance().addObserver(this );
134: }
135:
136: public void setBackground(Color color) {
137: if (localText != null) {
138: localText.setBackground(color);
139: }
140:
141: if (globalText != null) {
142: globalText.setBackground(color);
143: }
144:
145: if (localView != null) {
146: localView.setBackground(color);
147: }
148:
149: if (globalView != null) {
150: globalView.setBackground(color);
151: }
152:
153: if (lineLocal != null) {
154: lineLocal.setBackground(color);
155: }
156:
157: if (lineGlobal != null) {
158: lineGlobal.setBackground(color);
159: }
160: }
161:
162: public void setStyle(Color back, Color forground) {
163: setBackground(back);
164: lineLocal.setBackground(back);
165: lineGlobal.setBackground(back);
166: localView.setBackground(back);
167: globalView.setBackground(back);
168: }
169:
170: public void update(Observable arg0, Object arg1) {
171: globalText.setText(StateMonitoring.getInstance()
172: .getCurrentGlobalMessage());
173: localText.setText(StateMonitoring.getInstance()
174: .getCurrentLocalMessage());
175: }
176: }
|