package com.perforce.p4simulink.ui; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import java.util.Vector; import javax.swing.JComboBox; import javax.swing.JTextArea; import com.perforce.p4java.core.IChangelist; import com.perforce.p4java.server.IOptionsServer; /** * Copyright (C) 2014 Perforce Software. All rights reserved. * * Please see LICENSE.txt in top-level folder of this distribution. */ public class P4ChangelistSelector extends P4Pane implements ActionListener { private IOptionsServer server; private JComboBox<String> changelists; private JTextArea description; /** * Builds a new combo box (drop-down) for picking a changelist out of a list * * @param changelists * list of changelist IDs as a vector of strings * @param currentChangelist * the currently-selected/used changelist (null or string) */ public P4ChangelistSelector(Vector<String> changelists, String currentChangelist, IOptionsServer server) { // add the ability for the user to select a new changelist changelists = changelists != null ? changelists : new Vector<String>(); changelists.insertElementAt("New", 0); this.changelists = new JComboBox<>(changelists); description = new JTextArea(""); description.setColumns(50); description.setRows(10); // if there's a current changelist, pick out the index so we can select // it int index = currentChangelist != null ? changelists .indexOf(currentChangelist) : 0; this.changelists.setSelectedIndex(index); this.server = server; // grab the description from the selected changelist refreshDescription(); // if the changelists selector gets updated to a new value, update the // description field this.changelists.addActionListener(this); } public void actionPerformed(ActionEvent e) { refreshDescription(); } public void refreshDescription() { String descriptionString = ""; String changelistId = (String) changelists.getSelectedItem(); if (changelistId != null && !changelistId.equalsIgnoreCase("New")) { try { IChangelist changelist = server.getChangelist(Integer .parseInt(changelistId)); descriptionString = changelist.getDescription(); } catch (Exception e) { descriptionString = ""; } } description.setText(descriptionString); } /** * Returns a label and the defined combo box * * @return array of objects that can be added to a JOptionPane */ public Object[] getFields() { List<Object> fields = new ArrayList<>(); fields.add("Changelist ID: "); fields.add(changelists); fields.add("Description:"); fields.add(description); return fields.toArray(); } /** * Returns the selected changelist. * * @return selected changelist ID as a string */ public String getChangelistId() { return (String) this.changelists.getSelectedItem(); } public boolean selectedNew() { return ((String) this.changelists.getSelectedItem()) .equalsIgnoreCase("New"); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 11943 | Paul Allen | Remove unused classes. | ||
#1 | 11898 | Paul Allen |
Populate -o //guest/perforce_software/p4sl/main/... //guest/paul_allen/p4sl/.... |
||
//guest/perforce_software/p4sl/main/src/main/java/com/perforce/p4simulink/ui/P4ChangelistSelector.java | |||||
#4 | 11672 | Paul Allen |
Tidy up formatting and imports. No functional change. |
||
#3 | 11659 | Paul Allen |
Performance improvements, continued: improved performance of getFileState() by replacing the client haveList call with a direct server command. Also improved isLatest by removing fstat calls and replacing with simpler calls to diff and sync. Transferred from p4://perforce.perforce.com:1666@983506 |
||
#2 | 11657 | Paul Allen |
Additional changes from Scania meeting: * Current changelist pane: added description * Started investigation into performance Transferred from p4://perforce.perforce.com:1666@980859 |
||
#1 | 11656 | Paul Allen |
Additional functionality from Scania meeting, including current changelist selector (still needs descriptions added) as well as .p4ignore editor. Transferred from p4://perforce.perforce.com:1666@978388 |