/* * * 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.properties; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.SwingConstants; import com.borland.primetime.help.HelpTopic; import com.borland.primetime.ide.Browser; import com.borland.primetime.properties.PropertyPage; import com.borland.primetime.vfs.Url; import com.borland.primetime.vfs.ui.UrlChooser; import com.dafreels.opentools.Main; /** * Title: * Description: * Copyright: Copyright (c) 2001 * Company: DF Systems * @author David Freels * @version 1.0 */ public class PerforcePage extends PropertyPage implements ActionListener { JLabel _clientSpecLabel = new JLabel(); JLabel _executeLabel = new JLabel(); JLabel _portLabel = new JLabel(); JTextField _clientSpecTF = new JTextField(15); JTextField _executeTF = new JTextField(15); JTextField _portTF = new JTextField(15); JButton _locateButton = new JButton(); GridBagLayout gridBagLayout1 = new GridBagLayout(); JLabel _userLabel = new JLabel(); JTextField _userTF = new JTextField(); JLabel debugLabel = new JLabel(); JCheckBox _debugCB = new JCheckBox(); JComboBox _debugDD = new JComboBox(); JLabel _showOutputLabel = new JLabel(); JCheckBox _showOutputCB = new JCheckBox(); JLabel _addToSourceLabel = new JLabel(); JCheckBox _addToSourceCB = new JCheckBox(); JLabel _versionLabel = new JLabel(); JLabel _debugDDLabel = new JLabel(); JCheckBox _askForChangelistCB = new JCheckBox(); JLabel _askForChangelistLabel = new JLabel(); JCheckBox _addToToolBarCB = new JCheckBox(); JLabel _addToToolBarLabel = new JLabel(); JLabel _passwdLabel = new JLabel(); JPasswordField _jPasswordField = new JPasswordField(); public PerforcePage() { super(); try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } public void writeProperties() { PerforceGroup.CLIENTSPEC.setValue(Browser.getActiveBrowser(). getActiveProject(), _clientSpecTF.getText()); PerforceGroup.P4EXECUTABLE.setValue(Browser.getActiveBrowser(). getActiveProject(), _executeTF.getText()); PerforceGroup.PORT.setValue(Browser.getActiveBrowser().getActiveProject(), _portTF.getText()); PerforceGroup.USERNAME.setValue(Browser.getActiveBrowser().getActiveProject(), _userTF.getText()); PerforceGroup.PASSWORD.setValue(Browser.getActiveBrowser().getActiveProject(), new String(_jPasswordField.getPassword())); PerforceGroup.DEBUG.setValue(Browser.getActiveBrowser().getActiveProject(), "" + _debugCB.isSelected()); PerforceGroup.DEBUGLEVEL.setValue(Browser.getActiveBrowser(). getActiveProject(), (String) _debugDD.getSelectedItem()); PerforceGroup.SHOWOUTPUT.setValue(Browser.getActiveBrowser(). getActiveProject(), "" + _showOutputCB.isSelected()); PerforceGroup.ADDTOSOURCETAB.setValue(Browser.getActiveBrowser(). getActiveProject(), "" + _addToSourceCB.isSelected()); PerforceGroup.ASKFORCHANGELIST.setValue(Browser.getActiveBrowser(). getActiveProject(), "" + _askForChangelistCB.isSelected()); PerforceGroup.ADDTOTOOLBAR.setValue(Browser.getActiveBrowser(). getActiveProject(), "" + _addToToolBarCB.isSelected()); } public HelpTopic getHelpTopic() { return null; } public void readProperties() { _clientSpecTF.setText(PerforceGroup.CLIENTSPEC.getValue(Browser. getActiveBrowser().getActiveProject())); _executeTF.setText(PerforceGroup.P4EXECUTABLE.getValue(Browser. getActiveBrowser().getActiveProject())); _portTF.setText(PerforceGroup.PORT.getValue(Browser.getActiveBrowser(). getActiveProject())); _userTF.setText(PerforceGroup.USERNAME.getValue(Browser.getActiveBrowser(). getActiveProject())); _jPasswordField.setText(PerforceGroup.PASSWORD.getValue(Browser.getActiveBrowser(). getActiveProject())); _debugCB.setSelected(PerforceGroup.DEBUG.getValue(Browser.getActiveBrowser(). getActiveProject()) != null && PerforceGroup.DEBUG.getValue(Browser.getActiveBrowser(). getActiveProject()).equalsIgnoreCase("true")); _debugDD.setSelectedItem(PerforceGroup.DEBUGLEVEL.getValue(Browser. getActiveBrowser().getActiveProject())); _showOutputCB.setSelected("true".equalsIgnoreCase(PerforceGroup.SHOWOUTPUT. getValue(Browser.getActiveBrowser().getActiveProject()))); _addToSourceCB.setSelected("true".equalsIgnoreCase(PerforceGroup. ADDTOSOURCETAB.getValue(Browser.getActiveBrowser().getActiveProject()))); _askForChangelistCB.setSelected("true".equalsIgnoreCase(PerforceGroup. ASKFORCHANGELIST.getValue(Browser.getActiveBrowser().getActiveProject()))); _addToToolBarCB.setSelected("true".equalsIgnoreCase(PerforceGroup. ADDTOTOOLBAR.getValue(Browser.getActiveBrowser().getActiveProject()))); _debugDD.setEnabled(_debugCB.isSelected()); } private void jbInit() throws Exception { _debugDD.addItem("1"); _debugDD.addItem("2"); _debugDD.addItem("3"); _debugDD.addItem("4"); _debugDD.addItem("5"); _debugDD.addItem("6"); _debugDD.addItem("7"); _clientSpecLabel.setHorizontalAlignment(SwingConstants.RIGHT); _clientSpecLabel.setHorizontalTextPosition(SwingConstants.RIGHT); _clientSpecLabel.setText("ClientSpec: "); _showOutputLabel.setText("Show P4 Output: "); _showOutputLabel.setHorizontalAlignment(SwingConstants.TRAILING); _executeLabel.setHorizontalAlignment(SwingConstants.TRAILING); _executeLabel.setText("Location of P4 Executable:"); _portLabel.setHorizontalAlignment(SwingConstants.TRAILING); _portLabel.setText("Server:Port: "); _locateButton.setText("..."); _locateButton.addActionListener(this); _debugDDLabel.setText("Level: "); _locateButton.setActionCommand("locate"); _versionLabel.setText("Perforce Open Tool Version " + Main.getOpenToolInfo("VERSION")); _addToSourceLabel.setText("Add to Source Tab"); _addToToolBarLabel.setText("Add to Toolbar"); _addToToolBarCB.setToolTipText( "<html>Adds the Perforce actions to<br>JBuilder's toolbar.</html>"); _askForChangelistLabel.setText("Ask to specify ChangeList during edits"); _executeTF.setToolTipText( "<html>The location in the filesystem of the p4.exe application<html>"); _clientSpecTF.setToolTipText("<html>The name of the client workspace<html>"); _portTF.setToolTipText("<html>The server and port in the form <font=+0 color=blue>servername:port</font></html>"); _userTF.setToolTipText("<html>The Perforce Login Name<html>"); _showOutputCB.setToolTipText( "<html>Select to always display the output of the p4 command<br>" + "even if the command completed successfully.<br>Sync Preview always displays it's output</html>"); _askForChangelistCB.setToolTipText( "<html>Select to get to choose the Changelist<br>" + "to add an edit or locked file to.<br> If left un-checked, files will get added<br>" + "to the Default ChangeList</html>"); _debugCB.setToolTipText("<html>Select to turn on p4.exe debug</html>"); _debugDD.setToolTipText("<html>Select the p4.exe debug level</html>"); setLayout(gridBagLayout1); _userLabel.setText("User Name: "); debugLabel.setText("Debug:"); Insets insets5555 = new Insets(5, 5, 5, 5); Insets insets5550 = new Insets(5, 5, 5, 5); _passwdLabel.setPreferredSize(new Dimension(56, 15)); _passwdLabel.setText("Password: "); add(_executeLabel, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 15, 0)); add(_executeTF, new GridBagConstraints(2, 0, 3, 1, 1.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 30, 0)); add(_locateButton, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 15, 0)); add(_clientSpecLabel, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 15, 0)); add(_clientSpecTF, new GridBagConstraints(2, 1, 3, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 30, 0)); add(_portLabel, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 15, 0)); add(_portTF, new GridBagConstraints(2, 2, 3, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 30, 0)); add(_userLabel, new GridBagConstraints(0, 3, 2, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); add(_userTF, new GridBagConstraints(2, 3, 3, 1, 1.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 30, 0)); add(_showOutputLabel, new GridBagConstraints(0, 5, 2, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); add(_showOutputCB, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(_askForChangelistLabel, new GridBagConstraints(0, 6, 2, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); add(_askForChangelistCB, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); /* add(_addToSourceLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, insets5555, 0, 0)); add(_addToSourceCB, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, insets5550, 0, 0)); */ add(debugLabel, new GridBagConstraints(0, 7, 2, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); add(_debugCB, new GridBagConstraints(2, 7, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(_debugDDLabel, new GridBagConstraints(3, 7, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(_debugDD, new GridBagConstraints(4, 7, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); add(_addToToolBarLabel, new GridBagConstraints(0, 8, 2, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); add(_addToToolBarCB, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); add(_versionLabel, new GridBagConstraints(2, 9, 5, 1, 0.0, 1.0 ,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); this.add(_passwdLabel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 4), 0, 0)); this.add(_jPasswordField, new GridBagConstraints(2, 4, 3, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 113, 0)); _debugCB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { _debugDD.setEnabled(_debugCB.isSelected()); } }); } public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("locate")) { Url url = UrlChooser.promptForUrl(Browser.getActiveBrowser(), null); if (url != null) { _executeTF.setText(url.getFileObject().getAbsolutePath()); } } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 4123 | David Freels | Fixed bug and added the ability to set password. | ||
#1 | 4090 | David Freels |
Fixed bug where paths with spaces would not work. Also checked in new code or JBuilderX. |