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.exec.ui;
034:
035: import org.libresource.so6.core.WsConnection;
036: import org.libresource.so6.core.interfaces.Closer;
037: import org.libresource.so6.core.ui.BasicMenu;
038: import org.libresource.so6.core.ui.BasicProgressView;
039: import org.libresource.so6.core.ui.TextView;
040: import org.libresource.so6.core.ui.util.StyledUI;
041: import org.libresource.so6.core.ui.util.Wizard;
042: import org.libresource.so6.core.ui.util.WizardComponent;
043: import org.libresource.so6.core.ui.util.WizardListener;
044:
045: import java.awt.BorderLayout;
046: import java.awt.Color;
047: import java.awt.Toolkit;
048: import java.awt.event.WindowAdapter;
049: import java.awt.event.WindowEvent;
050:
051: import javax.swing.JFrame;
052: import javax.swing.JPanel;
053:
054: /**
055: * @author smack
056: */
057: public class Compress extends JPanel implements WizardListener,
058: StyledUI {
059: private BasicMenu menuBar;
060:
061: //
062: private BasicProgressView progressView;
063: private TextView reportView;
064:
065: //
066: private boolean jobDone = false;
067:
068: //
069: private Wizard wizard;
070:
071: public Compress(String wscPath) throws Exception {
072: // Make views
073: progressView = new BasicProgressView(wscPath);
074: reportView = new TextView("Report");
075: reportView.setEditable(false);
076:
077: // Make menu
078: menuBar = new BasicMenu();
079: menuBar.setProgressView(progressView);
080:
081: //
082: wizard = new Wizard(this );
083: wizard.setMenuBar(menuBar);
084: wizard.addComponent(progressView);
085: wizard.addComponent(reportView);
086: wizard.renderView(0);
087:
088: //
089: setLayout(new BorderLayout());
090: add(wizard, BorderLayout.CENTER);
091: }
092:
093: public BasicMenu getMenu() {
094: return menuBar;
095: }
096:
097: public WizardComponent getProgressView() {
098: return progressView;
099: }
100:
101: public void doTheJob() {
102: if (!jobDone) {
103: progressView.sendCurrentCompressState();
104: }
105:
106: jobDone = true;
107: progressView.getWizard().renderButtons();
108: }
109:
110: public static void main(String[] args) throws Exception {
111: if (args.length < 1) {
112: System.err.println("Usage: wsPath");
113: System.err.println(" (1) wsPath : path of the file "
114: + WsConnection.SO6_WSC_FILE);
115: System.exit(0);
116: }
117:
118: String wscPath = args[0];
119: Compress compress = new Compress(wscPath);
120: compress.setStyle(Color.white, Color.decode("#eeeeee"));
121:
122: // Make frame
123: JFrame f = new JFrame("Compress the connection : " + wscPath);
124: f.getContentPane().add(compress, BorderLayout.CENTER);
125: f.setSize(400, 215);
126: f.addWindowListener(new WindowAdapter() {
127: public void windowClosing(WindowEvent e) {
128: System.exit(0);
129: }
130: });
131: f.setLocation(((int) Toolkit.getDefaultToolkit()
132: .getScreenSize().getWidth() - f.getWidth()) / 2,
133: ((int) Toolkit.getDefaultToolkit().getScreenSize()
134: .getHeight() - f.getHeight()) / 2);
135: f.setVisible(true);
136: }
137:
138: public boolean setCurrentPosition(int currentHistoryPosition) {
139: // ask comment -> commit <-> report
140: if (currentHistoryPosition == 0) {
141: Thread thread = new Thread(new Runnable() {
142: public void run() {
143: doTheJob();
144: }
145: });
146: thread.setPriority(Thread.NORM_PRIORITY);
147: thread.start();
148: } else {
149: reportView.getWizard().renderButtons();
150: }
151:
152: return true;
153: }
154:
155: public void setStyle(Color back, Color forground) {
156: wizard.setStyle(back, forground);
157: }
158:
159: public void setCloser(Closer closer) {
160: wizard.setCloser(closer);
161: menuBar.setCloser(closer);
162: }
163: }
|