/* * * Perforce/JBuilder Opentool * Copyright (C) 2001 David Freels * * 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.text.SimpleDateFormat; import java.util.Date; import java.util.Vector; import java.awt.Dimension; import java.awt.Font; import java.awt.Frame; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.SwingUtilities; import com.borland.primetime.ide.Browser; import com.dafreels.opentools.Main; import com.dafreels.opentools.MessageWriter; import com.dafreels.opentools.properties.PerforceGroup; import com.dafreels.vcs.command.Command; import com.dafreels.vcs.command.CommandTool; import com.dafreels.vcs.command.MessageFormatter; import com.dafreels.vcs.util.ActionImages; /** * Title: * Description: * Copyright: Copyright (c) 2001 * Company: DF Systems * @author David Freels * @version 1.0 * @version 1.1 Mark Ackerman - Fixed stretching of dialog. Added Popup menu. */ public final class SubmitDialog extends JDialog implements ActionListener { public static final String ENTER_DESC_HERE= "<enter description here>"; private static String[] TOGGLE_BUTTON_TEXT = { "Deselect All Files", "Select All Files" }; JPanel infoPanel = new JPanel(); GridBagLayout gridBagLayout1 = new GridBagLayout(); GridBagLayout tableLayout = new GridBagLayout(); GridLayout buttonLayout = new GridLayout(); GridBagLayout gridBagLayout2 = new GridBagLayout(); GridBagLayout gridBagLayout3 = new GridBagLayout(); GridBagLayout gridBagLayout4 = new GridBagLayout(); JPanel buttonPanel = new JPanel(); JPanel descriptionPanel = new JPanel(); JPanel filesPanel = new JPanel(); JButton submit = new JButton("Submit"); JButton cancel = new JButton("Cancel"); JScrollPane descSP = new JScrollPane(); JTextArea descTA = new JTextArea() { public Dimension getPreferredScrollableViewportSize() { Dimension d = super.getPreferredScrollableViewportSize(); d.height = 400; return d; } }; JScrollPane filesSP = new JScrollPane(); JLabel fileLabel = new JLabel("Files:"); JLabel descLabel = new JLabel("Description:"); JLabel changeLabel = new JLabel("Change:"); JLabel dateLabel = new JLabel("Date:"); JLabel clientLabel = new JLabel("Client:"); JLabel userLabel = new JLabel("User:"); JLabel statusLabel = new JLabel("Status:"); JTextField changeTF = new JTextField(); JTextField dateTF = new JTextField(); JTextField clientTF = new JTextField(); JTextField userTF = new JTextField(); JTextField statusTF = new JTextField(); JButton toggleSelectionButton = new JButton(); JCheckBox reopenCB = new JCheckBox(); private boolean _submitVal = false; private FileModel _dtm = new FileModel(); private final static String newLine = System.getProperty("line.separator"); JPanel tablePanel = new JPanel(); JTable fileTable = new JTable() { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.height = getRowCount()*getRowHeight()+10; return d; } /* public Dimension getPreferredScrollableViewportSize() { Dimension d = super.getPreferredScrollableViewportSize(); d.height = 400; return d; } public int getColumnCount() { return 0; } */ }; JPopupMenu _fileTablePopup; public SubmitDialog(Frame frame, String title, boolean modal) { super(frame, title, modal); this.adjustDialog(); try { jbInit(); //pack(); } catch(Exception ex) { ex.printStackTrace(); } } private void adjustDialog() { //Set the size of the dialog this.setSize(550,600); //Position variables double x = 0; double y = 0; double width = 0; double height = 0; //Get the position variables from the parent if(this.getParent() != null) { width = this.getParent().getWidth() + this.getParent().getLocation().getX(); height = this.getParent().getHeight(); // - this.getParent().getLocation().getY(); } else //Make up the position variables { width = this.getToolkit().getDefaultToolkit().getScreenSize().getWidth(); height = this.getToolkit().getDefaultToolkit().getScreenSize().getHeight(); } x = (width / 2) + (this.getSize().getWidth() / 2); y = (height / 2) + (this.getSize().getHeight() / 2); this.setLocation((int)x, (int)y); setLocationRelativeTo(this.getParent()); } public SubmitDialog() { this(null, "", false); } public void showSubmit(String changeNumber, Vector files, String description) { Vector columns = new Vector(); columns.add("submit"); columns.add(""); if ( description == null ) { descTA.setText(ENTER_DESC_HERE); descTA.selectAll(); } else { descTA.setText(description); } //descTA.select(0, 24); //Reset the values in the form SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); dateTF.setText(sdf.format(new Date())); if ( changeNumber != null ) { changeTF.setText(changeNumber); statusTF.setText("pending"); } else { changeTF.setText("new"); statusTF.setText("new"); } clientTF.setText(PerforceGroup.CLIENTSPEC.getValue(Browser.getActiveBrowser().getActiveProject())); userTF.setText(PerforceGroup.USERNAME.getValue(Browser.getActiveBrowser().getActiveProject())); if(files == null) { _submitVal = false; this.setModal(false); return; } _dtm.setDataVector(files, columns); tablePanel.doLayout(); fileTable.doLayout(); filesSP.doLayout(); //Resize the checkbox column fileTable.getColumnModel().getColumn(0).setMinWidth(15); fileTable.getColumnModel().getColumn(0).setMaxWidth(15); setModal(true); SwingUtilities.invokeLater(new Runnable() { public void run() { descTA.requestFocus(); if ( ENTER_DESC_HERE.equals(descTA.getText())) { descTA.selectAll(); } } }); setVisible(true); } public boolean getReopenFiles() { return reopenCB.isSelected(); } public Vector getFiles() { //Get the data from the table Vector files = _dtm.getDataVector(); //Count backwards, as Vector shifts data as it is removed for(int i = files.size() - 1; i >= 0; i--) { if(! ((Boolean)((Vector)files.elementAt(i)).elementAt(0)).booleanValue()) { files.removeElementAt(i); } } return files; } public String getDescription() { int lines = descTA.getLineCount(); String change = descTA.getText(); StringBuffer changeList = new StringBuffer(); //Parse the description and make sure it is tabbed for(int i = 0; i < lines; i++) { if(change.indexOf("\n") != -1) { changeList.append("\t"+change.substring(0,change.indexOf("\n"))+newLine); change = change.substring(change.indexOf("\n") + 1); } else if(change.indexOf("\r\n") != -1) { changeList.append("\t"+change.substring(0,change.indexOf("\r\n"))+newLine); change = change.substring(change.indexOf("\r\n") + 1); } else { changeList.append("\t"+change+newLine); } } return changeList.toString(); } /** * get the change number * @return the change Number */ public String getChangeNumber() { return changeTF.getText(); } /** * get the change list status * @return the change list status */ public String getStatus() { return statusTF.getText(); } public boolean getState() { return _submitVal; } void jbInit() throws Exception { infoPanel.setLayout(gridBagLayout4); this.getContentPane().setLayout(gridBagLayout1); Font f = descLabel.getFont(); descLabel.setFont(new Font(f.getName(), Font.BOLD, f.getSize())); descriptionPanel.setLayout(gridBagLayout2); filesPanel.setLayout(gridBagLayout3); buttonPanel.setLayout(buttonLayout); submit.setActionCommand("submit"); submit.addActionListener(this); cancel.setActionCommand("cancel"); cancel.addActionListener(this); buttonLayout.setRows(3); buttonLayout.setColumns(1); buttonLayout.setHgap(5); buttonLayout.setVgap(5); descSP.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); descSP.setMaximumSize(new Dimension(400, 70)); descTA.setLineWrap(true); descTA.setWrapStyleWord(true); descTA.setToolTipText("Comments about the ChangeList. Required"); filesSP.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); filesSP.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); filesSP.setAutoscrolls(true); filesSP.setMaximumSize(new Dimension(1000, 1000)); changeTF.setEditable(false); changeTF.setBorder(null); changeTF.setToolTipText("The change number. 'new' on a new changelist."); dateTF.setEditable(false); dateTF.setBorder(null); dateTF.setToolTipText("The date this specification was last modified."); clientTF.setEditable(false); clientTF.setBorder(null); clientTF.setToolTipText("The client on which this changelist was created"); userTF.setEditable(false); userTF.setBorder(null); userTF.setToolTipText("The user who created this changelist"); statusTF.setEditable(false); statusTF.setBorder(null); statusTF.setToolTipText("Either 'pending' or 'submitted'"); fileTable.setShowHorizontalLines(false); fileTable.setShowVerticalLines(false); fileTable.setPreferredSize(new Dimension(1000, 1000)); fileTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); fileTable.setCellSelectionEnabled(true); fileTable.setColumnSelectionAllowed(true); fileTable.setPreferredScrollableViewportSize(new Dimension(1000, 1000)); fileTable.setEditingColumn(0); fileTable.setModel(_dtm); fileTable.setRowSelectionAllowed(true); fileTable.sizeColumnsToFit(1); tablePanel.setLayout(tableLayout); toggleSelectionButton.setText(TOGGLE_BUTTON_TEXT[0]); reopenCB.setText("Reopen"); getContentPane().add(descriptionPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0,0)); descriptionPanel.add(descLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); descriptionPanel.add(descSP, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0 ,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); descSP.getViewport().add(descTA, null); getContentPane().add(filesPanel, new GridBagConstraints(0, 2, 3, 1, 1.0, 2.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); filesPanel.add(filesSP, new GridBagConstraints(0, 1, 2, 1, 1.0, 2.0 ,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); filesPanel.add(fileLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); filesPanel.add(toggleSelectionButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); tablePanel.add(fileTable, new GridBagConstraints(0, 0, 1, 1, 1.0, 2.0 ,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); filesSP.getViewport().add(tablePanel, null); getContentPane().add(infoPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0 ,GridBagConstraints.SOUTHEAST, GridBagConstraints.HORIZONTAL, new Insets(3, 4, 3, 4), 0,0));//548, 218)); infoPanel.add(dateLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0)); infoPanel.add(clientLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0)); infoPanel.add(userLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0)); infoPanel.add(statusLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0)); infoPanel.add(changeLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0)); infoPanel.add(changeTF, new GridBagConstraints(2, 0, 4, 1, 1.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 170, 0)); infoPanel.add(dateTF, new GridBagConstraints(2, 1, 1, 1, 1.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 170, 0)); infoPanel.add(clientTF, new GridBagConstraints(2, 2, 1, 1, 1.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 170, 0)); infoPanel.add(userTF, new GridBagConstraints(2, 3, 1, 1, 1.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 170, 0)); infoPanel.add(statusTF, new GridBagConstraints(2, 4, 1, 1, 1.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 170, 0)); getContentPane().add(buttonPanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(10, 5, 0, 5), 3, 4)); buttonPanel.add(submit); buttonPanel.add(cancel); buttonPanel.add(reopenCB); fileTable.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent e) { if ( e.isPopupTrigger() || SwingUtilities.isRightMouseButton(e)) { int row = fileTable.rowAtPoint(e.getPoint()); if ( row == -1 ) { return; } fileTable.getSelectionModel().addSelectionInterval(row, row); if ( _fileTablePopup == null ) { buildFileTablePopup(); } _fileTablePopup.show(fileTable, e.getX(), e.getY()); } } }); toggleSelectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Boolean bool; boolean select = toggleSelectionButton.getText().equals(TOGGLE_BUTTON_TEXT[1]); for (int i = 0; i < fileTable.getRowCount();i++ ) { bool = new Boolean(select); fileTable.setValueAt(bool, i, 0); } fileTable.repaint(); toggleSelectionButton.setText(select?TOGGLE_BUTTON_TEXT[0]:TOGGLE_BUTTON_TEXT[1]); } }); } private void buildFileTablePopup() { if ( _fileTablePopup != null ) { return; } _fileTablePopup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem("Diff Against Depot", ActionImages.P4_DIFF); menuItem.setActionCommand("diff"); menuItem.addActionListener(this); _fileTablePopup.add(menuItem); } public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("cancel")) { _submitVal = false; this.setVisible(false); this.setModal(false); } else if(e.getActionCommand().equals("submit")) { _submitVal = true; this.setVisible(false); this.setModal(false); } else if ("diff".equals(e.getActionCommand())) { diff(); } } private void diff() { int[] rows = fileTable.getSelectedRows(); if ( rows == null || rows.length == 0 ) { return; } for (int i = 0; i < rows.length; i++ ) { String file = (String)fileTable.getValueAt(rows[i], 1); diffFile(file); } } private void diffFile(String file) { // really should let the DiffAction handle this // but I'm in a hurry right now StringBuffer sb = new StringBuffer("diff -f "); sb.append(file); //Run the command CommandTool.runCommand(new Command(sb.toString()), Main.m_props); //Output the p4 messages MessageWriter.outputErrorMessages(MessageFormatter.getInstance()); MessageWriter.outputMessages(MessageFormatter.getInstance()); } }
# | 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/SubmitDialog.java | |||||
#6 | 2994 | Mark E. Ackerman |
changed for version 1.0.7. Added display of submitted changelists, redo sync, updated icons, misc bug fixes and improvements. |
||
#5 | 1873 | Mark E. Ackerman | Version 1.0 build. | ||
#4 | 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 |
||
#3 | 1445 | David Freels | Refreshing source tree. | ||
#2 | 1429 | David Freels | New packaging and bug fixes. | ||
#1 | 940 | David Freels | Initial revision | ||
//guest/david_freels/p4ot/src/com/dafreels/opentools/actions/ui/SubmitDialog.java | |||||
#1 | 934 | David Freels | Initial revision |