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.ui;
034:
035: import org.libresource.so6.core.WsConnection;
036: import org.libresource.so6.core.exec.FindConflict;
037: import org.libresource.so6.core.interfaces.ConflictViewer;
038: import org.libresource.so6.core.ui.util.Wizard;
039: import org.libresource.so6.core.ui.util.WizardComponent;
040:
041: import java.awt.BorderLayout;
042: import java.awt.Color;
043: import java.awt.event.MouseEvent;
044: import java.awt.event.MouseListener;
045:
046: import java.io.File;
047:
048: import java.util.ArrayList;
049:
050: import javax.swing.AbstractListModel;
051: import javax.swing.JLabel;
052: import javax.swing.JList;
053: import javax.swing.JPanel;
054: import javax.swing.JScrollPane;
055:
056: /**
057: * @author smack
058: */
059: public class ConflictView extends JPanel implements WizardComponent,
060: MouseListener {
061: private JList list;
062: private ArrayList listData;
063: private LocalListModel listModel;
064: private WsConnection wsc;
065: private Wizard wizard;
066: private String wscPath;
067: private JLabel title;
068: private ConflictViewer conflictViewer;
069:
070: public ConflictView(String wscPath) throws Exception {
071: super (new BorderLayout());
072: this .wscPath = wscPath;
073: listModel = new LocalListModel();
074: list = new JList(listModel);
075: title = new JLabel("Files in conflict");
076: add(new JScrollPane(list), BorderLayout.CENTER);
077: add(title, BorderLayout.NORTH);
078: list.addMouseListener(this );
079: listData = new ArrayList();
080: wsc = new WsConnection(wscPath);
081: listData.addAll(FindConflict.searchConflict(wscPath));
082: }
083:
084: public void search() throws Exception {
085: listData.clear();
086: listData.addAll(FindConflict.searchConflict(wscPath));
087: listModel.update();
088: }
089:
090: public void setConflictViewer(ConflictViewer conflictViewer) {
091: this .conflictViewer = conflictViewer;
092: }
093:
094: public void setStyle(Color back, Color forground) {
095: list.setBackground(forground);
096: title.setBackground(back);
097: setBackground(back);
098: }
099:
100: public void mouseClicked(MouseEvent e) {
101: if ((e.getClickCount() == 2) && (list.getSelectedIndex() != -1)) {
102: try {
103: conflictViewer.showConflictEditor(wsc.getPath()
104: + File.separator
105: + ((FindConflict.ConflictFile) list
106: .getSelectedValue()).getPath());
107: } catch (Exception e1) {
108: e1.printStackTrace();
109: }
110: }
111: }
112:
113: public void mouseEntered(MouseEvent e) {
114: }
115:
116: public void mouseExited(MouseEvent e) {
117: }
118:
119: public void mousePressed(MouseEvent e) {
120: }
121:
122: public void mouseReleased(MouseEvent e) {
123: }
124:
125: public void setWizard(Wizard wizard) {
126: this .wizard = wizard;
127: }
128:
129: public Wizard getWizard() {
130: return wizard;
131: }
132:
133: public class LocalListModel extends AbstractListModel {
134: public void update() {
135: fireContentsChanged(this , 0, getSize());
136: }
137:
138: public Object getElementAt(int index) {
139: return listData.get(index);
140: }
141:
142: public int getSize() {
143: return listData.size();
144: }
145: }
146: }
|