/* * * Perforce/JBuilder Opentool * Copyright (C) 2002 Mark Ackerman * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package com.dafreels.opentools.actions.ui; import java.util.StringTokenizer; import java.util.Vector; import java.awt.Component; import java.awt.Cursor; import java.awt.Dimension; import java.awt.Frame; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; import com.dafreels.opentools.MessageWriter; import com.dafreels.opentools.actions.DescribeAction; import com.dafreels.opentools.actions.DiffAction; import com.dafreels.vcs.command.MessageFormatter; /** * Title: Perforce Open Tool * Description: * Copyright: Copyright (c) 2002 * Company: * @author Mark Ackerman * @version 1.0 */ public class HistoryDialog extends JDialog { private static final String LEAD_IN = "... "; protected static Vector _columnNames = new Vector(4); private JTable _historyTable; private JTextArea _fileName; private JButton _diffRevsButton, _diffButton, _describeButton, _syncButton; private JTextArea _actionsText; private JTextArea _descriptionText; static { _columnNames.add( "Revision" ); _columnNames.add( "File" ); _columnNames.add( "ChangeList" ); _columnNames.add( "Date" ); _columnNames.add( "User" ); _columnNames.add( "Action" ); _columnNames.add( "Description"); } public HistoryDialog(Frame frame, String title, boolean modal) { super(frame, title, modal); buildControls(); } protected void buildControls() { getContentPane().setLayout(new GridBagLayout()); JPanel buttonPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(5,5,5,5); gbc.weightx = 1.0; getContentPane().add(buttonPanel, gbc); _syncButton = new JButton("Sync"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; //gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.NORTH; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(5,5,5,5); buttonPanel.add(_syncButton, gbc); _diffRevsButton = new JButton("Diff Revs"); _diffRevsButton.setEnabled(false); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; //gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.NORTH; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(5,5,5,5); buttonPanel.add(_diffRevsButton, gbc); _diffButton = new JButton("Diff vs Client File"); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 0; //gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.NORTH; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(5,5,5,5); buttonPanel.add(_diffButton, gbc); _describeButton = new JButton("Describe ChangeList"); gbc = new GridBagConstraints(); gbc.gridx = 3; gbc.gridy = 0; //gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.NORTH; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(5,5,5,5); buttonPanel.add(_describeButton, gbc); //Color gray = new Color(200,200,200); JLabel label = new JLabel("File:"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(5,5,0,5); //getContentPane().add(label, gbc); _fileName = new JTextArea(); _fileName.setEditable(false); _fileName.setBackground(null); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 1; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(5,5,5,5); //getContentPane().add(_fileName, gbc); _historyTable = new JTable() { public boolean isCellEditable(int row, int col) { return false; } public Dimension getPreferredScrollableViewportSize() { Dimension d = super.getPreferredScrollableViewportSize(); d.height = getRowHeight() *10; return d; } }; _historyTable.setBackground(null); //_historyTable.setEnabled(false); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(5,5,5,5); gbc.weightx = 1.0; gbc.weighty = 1.0; getContentPane().add(new JScrollPane(_historyTable), gbc); label = new JLabel("Actions:"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; //gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(5,5,5,5); getContentPane().add(label, gbc); _actionsText = new JTextArea () { public Dimension getPreferredScrollableViewportSize() { Dimension d = super.getPreferredScrollableViewportSize(); d.height = 100; return d; } }; gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 3; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(5,5,5,5); gbc.weightx = 1.0; gbc.weighty = .8; getContentPane().add(new JScrollPane(_actionsText), gbc); label = new JLabel("Change Description:"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 4; //gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(5,5,5,5); getContentPane().add(label, gbc); _descriptionText = new JTextArea() { public Dimension getPreferredScrollableViewportSize() { Dimension d = super.getPreferredScrollableViewportSize(); d.height = 100; return d; } }; _descriptionText.setWrapStyleWord(true); _descriptionText.setLineWrap(true); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(5,5,5,5); gbc.weightx = 1.0; gbc.weighty = .8; getContentPane().add(new JScrollPane(_descriptionText), gbc); JPanel panel = new JPanel(new GridBagLayout()); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 6; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.SOUTH; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0,0,0,0); getContentPane().add(panel, gbc); JButton button = new JButton("Close"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.SOUTH; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(5,5,5,5); panel.add(button, gbc); _historyTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if ( e.getClickCount() >= 2 && SwingUtilities.isLeftMouseButton(e)) { int row = _historyTable.rowAtPoint(e.getPoint()); if ( row == -1 ) { return; } Vector changeList = getChangeList(); try { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); new DescribeAction((String)_historyTable.getValueAt(row, 2), changeList); } finally { setCursor(Cursor.getDefaultCursor()); } } } }); _historyTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int rowCnt = _historyTable.getSelectedRowCount(); if (rowCnt == 1 ) { _diffButton.setEnabled(true); _syncButton.setEnabled(true); _describeButton.setEnabled(true); _diffRevsButton.setEnabled(false); } else if ( rowCnt == 2 ) { _diffButton.setEnabled(false); _syncButton.setEnabled(false); _describeButton.setEnabled(false); _diffRevsButton.setEnabled(true); } else { _diffButton.setEnabled(false); _syncButton.setEnabled(false); _describeButton.setEnabled(false); _diffRevsButton.setEnabled(false); } int[] rows = _historyTable.getSelectedRows(); if ( rows.length == 0 ) { _actionsText.setText(""); _descriptionText.setText(""); } else { int lastRow = rows[rows.length-1]; _actionsText.setText((String)_historyTable.getValueAt(lastRow, 5)); _descriptionText.setText((String)_historyTable.getValueAt(lastRow, 6)); } } }); _describeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int row = _historyTable.getSelectedRow(); if ( row < 0 ) { return; } Vector changeList = getChangeList(); try { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); new DescribeAction((String)_historyTable.getValueAt(row, 2), changeList); } finally { setCursor(Cursor.getDefaultCursor()); } } }); _diffButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new DiffAction(true). actionPerformed(com.borland.primetime.ide.Browser.getActiveBrowser()); } }); _diffRevsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if ( _historyTable.getSelectedRowCount() != 2 ) { return; } int[] rows = _historyTable.getSelectedRows(); } }); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); } }); } /** * fill this dialog with the contents of formatter * @param formatter the output from the <code>fstat</code> command */ public void fillForm(String fileName, MessageFormatter formatter) { if ( _fileName != null ) { _fileName.setText(fileName); } String message, arg; StringTokenizer tokenizer; String token; int field; Vector row; Vector table = new Vector(); MessageWriter.outputErrorMessages(MessageFormatter.getInstance()); boolean firstFile = true; while( (message = formatter.getNextMessage()) != null) { System.out.println(message); if ( message.startsWith("//")) { if ( !firstFile ) { HistoryDialog dialog = new HistoryDialog((Frame)getParent(), getTitle(), false); dialog.fillForm(message, formatter); dialog.setVisible(true); break; } firstFile = false; } else if ( message.startsWith(LEAD_IN)) { message = message.substring(4); if ( message.startsWith(LEAD_IN)) { continue; // proly got a ... ... branch into } // format of message s/b: // #7 change 60 edit on 2002/04/08 by mark@Q (text) 'fix so that during a Save' tokenizer = new StringTokenizer(message, " "); field = 0; row = new Vector(7); while (tokenizer.hasMoreTokens() && field <= 10) { token = tokenizer.nextToken(); field++; switch ( field ) { case 1: // revision row.add(token); row.add(fileName); break; case 3: // changelist number row.add(token); break; case 4: // type of change, edit, add, etc - skip row.add(token); break; case 6: // date row.insertElementAt(token,3); break; case 8: // changed by row.insertElementAt(token,4); break; case 10: // description int idx = message.indexOf("'"); if ( idx == -1 ) { continue; } row.add(message.substring(idx+1, message.length()-1)); break; case 2: // word 'change' case 5: // word 'on' - skip case 7: // word 'by' case 9: // (text) break; } } table.add(row); } } DefaultTableModel model = new DefaultTableModel(table, _columnNames) { public boolean isCellEditable(int row, int column) { return false; } }; _historyTable.setModel(model); pack(); setLocation(); } /** * set the dialogs location centered on its parent. If it doesn't * hava a parent then center it on the screen. */ public void setLocation() { Component parent = getParent(); int ix, iy, bx, by; Dimension d = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); Dimension dd = getSize(); if ( parent == null ) { ix = (d.width-dd.width)/2; iy = (d.height-dd.height)/2; } else { Rectangle bounds = parent.getBounds(); Rectangle abounds = getBounds(); ix = bounds.x + (bounds.width - abounds.width)/ 2; iy = bounds.y + (bounds.height - abounds.height)/2; } if(iy < 10) iy = 10; if(ix < 10) ix = 10; bx = ix+dd.width; by = iy+dd.height; // see if the dialog is off the screen. if ( bx > d.width ) { ix -=bx-d.width; } if ( by > d.height ) { iy -= by-d.height; } setLocation(ix,iy); } protected Vector getChangeList() { int rowCnt = _historyTable.getRowCount(); Vector v = new Vector(rowCnt); for (int i = 0; i < rowCnt; i++ ) { v.add(_historyTable.getValueAt(i, 2)); } return v; } public static void main(String[] args) { new HistoryDialog(new JFrame(), "File History", false).setVisible(true); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 5093 | Hari Krishna Dara |
Populating perforce branch. I will be adding p4admin files to it. |
||
#1 | 3839 | Hari Krishna Dara | Populating the integrations part of my guest branch. | ||
//guest/perforce_software/integrations/jbuilder/p4ot/src/com/dafreels/opentools/actions/ui/HistoryDialog.java | |||||
#5 | 2994 | Mark E. Ackerman |
changed for version 1.0.7. Added display of submitted changelists, redo sync, updated icons, misc bug fixes and improvements. |
||
#4 | 1902 | Mark E. Ackerman |
fix for the HistoryDialog (again). Change to the CommandTool to spit out a message when the tool isn't configured. |
||
#3 | 1897 | Mark E. Ackerman |
fix for HistoryDialog not recognizing branches etc. Now notifies the user when starting the opentool if it's not configured. increased the version 1.0.1 |
||
#2 | 1696 | Mark E. Ackerman |
updated developer.txt file. updated version to 0.9.4. Added option to display the Perforce menu on the file tabs, use "-DPerforce.menuOnFileTab=true" in the JBuilder.config file. Added support for multiple files being selected for File history and Status. New perforceot.jar. |
||
#1 | 1640 | Mark E. Ackerman |
added diff action, unlock action, status dialog, file history with detail, fixed stretching of submit dialog. added diff to submit dialog. added icons to the popup menu. added status line message for most actions. added confirm to revert action. added displaying of error messages from p4 command. added About Open tool support. added option on Perforce Page to not display output from p4 command. added version info on the PerforcePage. some other misc fixes and changes. changed version number to 0.9.3 |