mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup CVS root configuration and IDEA-33904
This commit is contained in:
@@ -87,7 +87,7 @@ operation.name.edit.configurations=Edit Configurations
|
||||
dialog.title.cvs.roots=CVS Roots
|
||||
action.name.add=Add
|
||||
action.name.remove=Remove
|
||||
action.name.copy=Copy
|
||||
action.name.copy=Duplicate CVS Root
|
||||
configure.root.field.name.user=User
|
||||
configure.root.field.name.host=Host
|
||||
configure.root.field.name.repository=Repository
|
||||
|
||||
+20
-35
@@ -39,7 +39,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.InputException;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.util.BooleanValueHolder;
|
||||
import com.intellij.util.ThreeState;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -55,9 +54,8 @@ import java.awt.event.ActionListener;
|
||||
public class Cvs2SettingsEditPanel {
|
||||
|
||||
private JPanel myPanel;
|
||||
private final BooleanValueHolder myIsInUpdating = new BooleanValueHolder(false);
|
||||
private final CvsRootAsStringConfigurationPanel myCvsRootConfigurationPanelView
|
||||
= new CvsRootAsStringConfigurationPanel(myIsInUpdating);
|
||||
private final Ref<Boolean> myIsUpdating = new Ref<Boolean>();
|
||||
private final CvsRootAsStringConfigurationPanel myCvsRootConfigurationPanelView;
|
||||
private JPanel myCvsRootConfigurationPanel;
|
||||
|
||||
private final DateOrRevisionOrTagSettings myDateOrRevisionOrTagSettings;
|
||||
@@ -76,7 +74,7 @@ public class Cvs2SettingsEditPanel {
|
||||
@NonNls private static final String NON_EMPTY_PROXY_SETTINGS = "NON-EMPTY-PROXY-SETTINGS";
|
||||
private final Project myProject;
|
||||
|
||||
public Cvs2SettingsEditPanel(Project project) {
|
||||
public Cvs2SettingsEditPanel(Project project, boolean readOnly) {
|
||||
myProject = project;
|
||||
myDateOrRevisionOrTagSettings = new DateOrRevisionOrTagSettings(new TagsProviderOnEnvironment() {
|
||||
@Override
|
||||
@@ -87,6 +85,7 @@ public class Cvs2SettingsEditPanel {
|
||||
}, project);
|
||||
myPanel.setSize(myPanel.getPreferredSize());
|
||||
myCvsRootConfigurationPanel.setLayout(new BorderLayout());
|
||||
myCvsRootConfigurationPanelView = new CvsRootAsStringConfigurationPanel(readOnly, myIsUpdating);
|
||||
myCvsRootConfigurationPanel.add(myCvsRootConfigurationPanelView.getPanel(), BorderLayout.CENTER);
|
||||
|
||||
myConnectionSettingsPanel.setLayout(new CardLayout());
|
||||
@@ -97,7 +96,6 @@ public class Cvs2SettingsEditPanel {
|
||||
myConnectionSettingsPanel.add(new JPanel(), CvsMethod.PSERVER_METHOD.getDisplayName());
|
||||
myConnectionSettingsPanel.add(mySshConnectionSettingsEditor.getPanel(), CvsMethod.SSH_METHOD.getDisplayName());
|
||||
myConnectionSettingsPanel.add(myLocalConnectionSettingsPanel.getPanel(), CvsMethod.LOCAL_METHOD.getDisplayName());
|
||||
|
||||
myConnectionSettingsPanel.add(new JPanel(), EMPTY);
|
||||
|
||||
myDateOrRevisionOrTagSettingsPanel.setLayout(new BorderLayout(4, 2));
|
||||
@@ -119,11 +117,11 @@ public class Cvs2SettingsEditPanel {
|
||||
});
|
||||
|
||||
myProxySettingsPanel.setLayout(new CardLayout());
|
||||
|
||||
myProxySettingsNonEmptyPanel = new ProxySettingsPanel();
|
||||
|
||||
myProxySettingsPanel.add(myProxySettingsNonEmptyPanel.getPanel(), NON_EMPTY_PROXY_SETTINGS);
|
||||
myProxySettingsPanel.add(new JPanel(), EMPTY);
|
||||
|
||||
if (readOnly) setEnabled(myDateOrRevisionOrTagSettingsPanel, false);
|
||||
}
|
||||
|
||||
public void addCvsRootChangeListener(CvsRootChangeListener cvsRootChangeListener) {
|
||||
@@ -132,7 +130,7 @@ public class Cvs2SettingsEditPanel {
|
||||
|
||||
public void updateFrom(final CvsRootConfiguration configuration) {
|
||||
setEnabled(true);
|
||||
myIsInUpdating.setValue(true);
|
||||
myIsUpdating.set(Boolean.TRUE);
|
||||
try {
|
||||
myCvsRootConfigurationPanelView.updateFrom(configuration);
|
||||
myExtConnectionSettingsEditor.updateFrom(configuration.EXT_CONFIGURATION, configuration.SSH_FOR_EXT_CONFIGURATION);
|
||||
@@ -142,7 +140,7 @@ public class Cvs2SettingsEditPanel {
|
||||
myProxySettingsNonEmptyPanel.updateFrom(configuration.PROXY_SETTINGS);
|
||||
}
|
||||
finally {
|
||||
myIsInUpdating.setValue(false);
|
||||
myIsUpdating.set(null);
|
||||
}
|
||||
setExtPanelEnabling();
|
||||
}
|
||||
@@ -150,7 +148,7 @@ public class Cvs2SettingsEditPanel {
|
||||
public boolean saveTo(CvsRootConfiguration configuration) {
|
||||
try {
|
||||
myCvsRootConfigurationPanelView.saveTo(configuration);
|
||||
CvsApplicationLevelConfiguration globalCvsSettings = CvsApplicationLevelConfiguration.getInstance();
|
||||
final CvsApplicationLevelConfiguration globalCvsSettings = CvsApplicationLevelConfiguration.getInstance();
|
||||
|
||||
if (!myExtConnectionSettingsEditor.equalsTo(configuration.EXT_CONFIGURATION, configuration.SSH_FOR_EXT_CONFIGURATION)) {
|
||||
myExtConnectionSettingsEditor.saveTo(configuration.EXT_CONFIGURATION, configuration.SSH_FOR_EXT_CONFIGURATION);
|
||||
@@ -181,7 +179,7 @@ public class Cvs2SettingsEditPanel {
|
||||
}
|
||||
|
||||
private void testConfiguration() {
|
||||
CvsRootConfiguration newConfiguration = createConfigurationWithCurrentSettings();
|
||||
final CvsRootConfiguration newConfiguration = createConfigurationWithCurrentSettings();
|
||||
if (newConfiguration == null) return;
|
||||
testConnection(newConfiguration, myPanel, myProject);
|
||||
updateFrom(newConfiguration);
|
||||
@@ -189,7 +187,7 @@ public class Cvs2SettingsEditPanel {
|
||||
|
||||
@Nullable
|
||||
private CvsRootConfiguration createConfigurationWithCurrentSettings() {
|
||||
CvsRootConfiguration newConfiguration =
|
||||
final CvsRootConfiguration newConfiguration =
|
||||
CvsApplicationLevelConfiguration.createNewConfiguration(CvsApplicationLevelConfiguration.getInstance());
|
||||
if (!saveTo(newConfiguration)) return null;
|
||||
return newConfiguration;
|
||||
@@ -204,10 +202,10 @@ public class Cvs2SettingsEditPanel {
|
||||
indicator.setText2(CvsBundle.message("message.current.global.timeout.setting",
|
||||
CvsApplicationLevelConfiguration.getInstance().TIMEOUT));
|
||||
try {
|
||||
final ThreeState checkResult = LoginPerformer.checkLoginWorker(loginWorker, true);
|
||||
if (ThreeState.NO.equals(checkResult)) {
|
||||
final ThreeState result = LoginPerformer.checkLoginWorker(loginWorker, true);
|
||||
if (ThreeState.NO == result) {
|
||||
showConnectionFailedMessage(component, CvsBundle.message("test.connection.login.failed.text"));
|
||||
} else if (ThreeState.UNSURE.equals(checkResult)) {
|
||||
} else if (ThreeState.UNSURE == result) {
|
||||
showConnectionFailedMessage(component, CvsBundle.message("error.message.authentication.canceled"));
|
||||
} else {
|
||||
success.set(Boolean.TRUE);
|
||||
@@ -260,13 +258,11 @@ public class Cvs2SettingsEditPanel {
|
||||
|
||||
private void setExtPanelEnabling() {
|
||||
try {
|
||||
CvsRootData currentRootData = CvsRootDataBuilder.createSettingsOn(myCvsRootConfigurationPanelView.getCvsRoot(), true);
|
||||
String settingsPanelName = getSettingsPanelName(currentRootData);
|
||||
final CvsRootData currentRootData = CvsRootDataBuilder.createSettingsOn(myCvsRootConfigurationPanelView.getCvsRoot(), true);
|
||||
final String settingsPanelName = getSettingsPanelName(currentRootData);
|
||||
((CardLayout)myConnectionSettingsPanel.getLayout()).show(myConnectionSettingsPanel, settingsPanelName);
|
||||
|
||||
((CardLayout)myProxySettingsPanel.getLayout()).show(myProxySettingsPanel, getProxyPanelName(currentRootData));
|
||||
|
||||
|
||||
if (currentRootData.CONTAINS_PROXY_INFO) {
|
||||
myProxySettingsNonEmptyPanel.updateFrom(currentRootData);
|
||||
myProxySettingsNonEmptyPanel.disablePanel();
|
||||
@@ -274,11 +270,9 @@ public class Cvs2SettingsEditPanel {
|
||||
else {
|
||||
myProxySettingsNonEmptyPanel.enablePanel();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Throwable ignored) {
|
||||
((CardLayout)myConnectionSettingsPanel.getLayout()).show(myConnectionSettingsPanel, EMPTY);
|
||||
|
||||
((CardLayout)myProxySettingsPanel.getLayout()).show(myProxySettingsPanel, EMPTY);
|
||||
|
||||
}
|
||||
@@ -292,7 +286,7 @@ public class Cvs2SettingsEditPanel {
|
||||
}
|
||||
|
||||
private static String getSettingsPanelName(CvsRootData cvsRootData) {
|
||||
CvsMethod method = cvsRootData.METHOD;
|
||||
final CvsMethod method = cvsRootData.METHOD;
|
||||
if (method == null) {
|
||||
return EMPTY;
|
||||
}
|
||||
@@ -305,7 +299,7 @@ public class Cvs2SettingsEditPanel {
|
||||
component.setEnabled(enabled);
|
||||
|
||||
if (component instanceof Container) {
|
||||
Container container = (Container)component;
|
||||
final Container container = (Container)component;
|
||||
for (int i = 0; i < container.getComponentCount(); i++) {
|
||||
setEnabled(container.getComponent(i), enabled);
|
||||
}
|
||||
@@ -313,12 +307,8 @@ public class Cvs2SettingsEditPanel {
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
clearAllTextFields();
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
private void clearAllTextFields() {
|
||||
clearAllTextFieldsIn(myPanel);
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
private static void clearAllTextFieldsIn(Component component) {
|
||||
@@ -327,7 +317,7 @@ public class Cvs2SettingsEditPanel {
|
||||
return;
|
||||
}
|
||||
if (component instanceof Container) {
|
||||
Container container = (Container)component;
|
||||
final Container container = (Container)component;
|
||||
for (int i = 0; i < container.getComponentCount(); i++) {
|
||||
clearAllTextFieldsIn(container.getComponent(i));
|
||||
}
|
||||
@@ -337,9 +327,4 @@ public class Cvs2SettingsEditPanel {
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return myCvsRootConfigurationPanelView.getPreferredFocusedComponent();
|
||||
}
|
||||
|
||||
public void setReadOnly() {
|
||||
myCvsRootConfigurationPanelView.setReadOnly();
|
||||
setEnabled(myDateOrRevisionOrTagSettingsPanel, false);
|
||||
}
|
||||
}
|
||||
|
||||
+57
-124
@@ -16,7 +16,6 @@
|
||||
package com.intellij.cvsSupport2.config.ui;
|
||||
|
||||
import com.intellij.CvsBundle;
|
||||
import com.intellij.cvsSupport2.CvsActionPlaces;
|
||||
import com.intellij.cvsSupport2.config.CvsApplicationLevelConfiguration;
|
||||
import com.intellij.cvsSupport2.config.CvsRootConfiguration;
|
||||
import com.intellij.cvsSupport2.ui.CvsRootChangeListener;
|
||||
@@ -26,7 +25,9 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.ui.AnActionButtonRunnable;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -45,19 +46,20 @@ import java.util.List;
|
||||
* author: lesya
|
||||
*/
|
||||
public class CvsConfigurationsListEditor extends DialogWrapper implements DataProvider{
|
||||
private final BorderLayout myCenterPanelLayout = new BorderLayout();
|
||||
private final JPanel myCenterPanel = new JPanel(myCenterPanelLayout);
|
||||
private final JList myList = new JBList();
|
||||
private final DefaultListModel myModel = new DefaultListModel();
|
||||
private CvsRootConfiguration mySelection;
|
||||
|
||||
private final Cvs2SettingsEditPanel myCvs2SettingsEditPanel;
|
||||
@NonNls private static final String SAMPLE_CVSROOT = ":pserver:user@host/server/home/user/cvs";
|
||||
private boolean myIsReadOnly = false;
|
||||
|
||||
public CvsConfigurationsListEditor(List<CvsRootConfiguration> configs, Project project) {
|
||||
this(configs, project, false);
|
||||
}
|
||||
|
||||
public CvsConfigurationsListEditor(List<CvsRootConfiguration> configs, Project project, boolean readOnly) {
|
||||
super(true);
|
||||
myCvs2SettingsEditPanel = new Cvs2SettingsEditPanel(project);
|
||||
myCvs2SettingsEditPanel = new Cvs2SettingsEditPanel(project, readOnly);
|
||||
setTitle(CvsBundle.message("operation.name.edit.configurations"));
|
||||
myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
selectNone();
|
||||
@@ -77,18 +79,19 @@ public class CvsConfigurationsListEditor extends DialogWrapper implements DataPr
|
||||
if (!configs.isEmpty()) {
|
||||
myList.setSelectedIndex(0);
|
||||
}
|
||||
if (readOnly) {
|
||||
myList.setEnabled(false);
|
||||
}
|
||||
init();
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CvsRootConfiguration reconfigureCvsRoot(String root, Project project){
|
||||
CvsApplicationLevelConfiguration configuration = CvsApplicationLevelConfiguration.getInstance();
|
||||
CvsRootConfiguration selectedConfig = configuration.getConfigurationForCvsRoot(root);
|
||||
ArrayList<CvsRootConfiguration> modifiableList = new ArrayList<CvsRootConfiguration>(configuration.CONFIGURATIONS);
|
||||
CvsConfigurationsListEditor editor = new CvsConfigurationsListEditor(modifiableList, project);
|
||||
final CvsApplicationLevelConfiguration configuration = CvsApplicationLevelConfiguration.getInstance();
|
||||
final CvsRootConfiguration selectedConfig = configuration.getConfigurationForCvsRoot(root);
|
||||
final ArrayList<CvsRootConfiguration> modifiableList = new ArrayList<CvsRootConfiguration>(configuration.CONFIGURATIONS);
|
||||
final CvsConfigurationsListEditor editor = new CvsConfigurationsListEditor(modifiableList, project, true);
|
||||
editor.select(selectedConfig);
|
||||
editor.setReadOnly();
|
||||
editor.show();
|
||||
if (editor.isOK()){
|
||||
configuration.CONFIGURATIONS = modifiableList;
|
||||
@@ -98,15 +101,9 @@ public class CvsConfigurationsListEditor extends DialogWrapper implements DataPr
|
||||
}
|
||||
}
|
||||
|
||||
private void setReadOnly() {
|
||||
myIsReadOnly = true;
|
||||
myList.setEnabled(false);
|
||||
myCvs2SettingsEditPanel.setReadOnly();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Action[] createLeftSideActions() {
|
||||
AbstractAction globalSettingsAction = new AbstractAction(CvsBundle.message("button.text.global.settings")) {
|
||||
final AbstractAction globalSettingsAction = new AbstractAction(CvsBundle.message("button.text.global.settings")) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new ConfigureCvsGlobalSettingsDialog().show();
|
||||
@@ -122,7 +119,6 @@ public class CvsConfigurationsListEditor extends DialogWrapper implements DataPr
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void fillModel(List<CvsRootConfiguration> configurations) {
|
||||
for (final CvsRootConfiguration configuration : configurations) {
|
||||
myModel.addElement(configuration.getMyCopy());
|
||||
@@ -130,47 +126,51 @@ public class CvsConfigurationsListEditor extends DialogWrapper implements DataPr
|
||||
}
|
||||
|
||||
private JComponent createListPanel() {
|
||||
return ScrollPaneFactory.createScrollPane(myList);
|
||||
}
|
||||
final AnActionButton duplicateButton =
|
||||
new AnActionButton(CvsBundle.message("action.name.copy"), IconLoader.getIcon("/general/copy.png")) {
|
||||
|
||||
private JPanel createActionsPanel() {
|
||||
DefaultActionGroup commonActionGroup = new DefaultActionGroup();
|
||||
commonActionGroup.add(new MyAddAction());
|
||||
commonActionGroup.add(new MyRemoveAction());
|
||||
commonActionGroup.add(new MyCopyAction());
|
||||
@Override
|
||||
public void updateButton(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(getSelectedConfiguration() != null);
|
||||
}
|
||||
|
||||
ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(
|
||||
CvsActionPlaces.CVS_CONFIGURATIONS_TOOLBAR,
|
||||
commonActionGroup, true);
|
||||
|
||||
JPanel actionPanel = new JPanel(new BorderLayout());
|
||||
actionPanel.add(actionToolbar.getComponent(), BorderLayout.WEST);
|
||||
return actionPanel;
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
copySelectedConfiguration();
|
||||
}
|
||||
};
|
||||
duplicateButton.setShortcut(new CustomShortcutSet(
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_D, SystemInfo.isMac ? KeyEvent.META_MASK : KeyEvent.CTRL_MASK)));
|
||||
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myList).setAddAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton anActionButton) {
|
||||
createNewConfiguration();
|
||||
}
|
||||
}).addExtraAction(duplicateButton);
|
||||
return decorator.createPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
myList.setCellRenderer(new CvsListCellRenderer());
|
||||
final BorderLayout layout = new BorderLayout();
|
||||
layout.setHgap(6);
|
||||
|
||||
myCenterPanelLayout.setHgap(6);
|
||||
|
||||
myCenterPanel.add(createActionsPanel(), BorderLayout.NORTH);
|
||||
JComponent listPanel = createListPanel();
|
||||
|
||||
myCenterPanel.add(listPanel, BorderLayout.CENTER);
|
||||
myCenterPanel.add(createCvsConfigurationPanel(), BorderLayout.EAST);
|
||||
myCenterPanel.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH);
|
||||
final JPanel centerPanel = new JPanel(layout);
|
||||
final JComponent listPanel = createListPanel();
|
||||
centerPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
|
||||
centerPanel.add(listPanel, BorderLayout.CENTER);
|
||||
centerPanel.add(createCvsConfigurationPanel(), BorderLayout.EAST);
|
||||
|
||||
myList.setModel(myModel);
|
||||
|
||||
addSelectionListener();
|
||||
|
||||
|
||||
int minWidth = myList.getFontMetrics(myList.getFont()).stringWidth(SAMPLE_CVSROOT) + 40;
|
||||
Dimension minSize = new Dimension(minWidth, myList.getMaximumSize().height);
|
||||
final int minWidth = myList.getFontMetrics(myList.getFont()).stringWidth(SAMPLE_CVSROOT) + 40;
|
||||
final Dimension minSize = new Dimension(minWidth, myList.getMaximumSize().height);
|
||||
listPanel.setMinimumSize(minSize);
|
||||
listPanel.setPreferredSize(minSize);
|
||||
return myCenterPanel;
|
||||
return centerPanel;
|
||||
}
|
||||
|
||||
private JComponent createCvsConfigurationPanel() {
|
||||
@@ -184,9 +184,9 @@ public class CvsConfigurationsListEditor extends DialogWrapper implements DataPr
|
||||
|
||||
private void copySelectedConfiguration() {
|
||||
if (!saveSelectedConfiguration()) return;
|
||||
CvsRootConfiguration newConfig = mySelection.getMyCopy();
|
||||
final CvsRootConfiguration newConfig = mySelection.getMyCopy();
|
||||
myModel.addElement(newConfig);
|
||||
myList.setSelectedValue(newConfig, true);
|
||||
myList.setSelectedIndex(myModel.getSize() - 1);
|
||||
}
|
||||
|
||||
private void editSelectedConfiguration() {
|
||||
@@ -194,20 +194,11 @@ public class CvsConfigurationsListEditor extends DialogWrapper implements DataPr
|
||||
myList.repaint();
|
||||
}
|
||||
|
||||
private void removeSelectedConfiguration() {
|
||||
int oldSelection = myList.getSelectedIndex();
|
||||
myModel.removeElement(mySelection);
|
||||
int size = myList.getModel().getSize();
|
||||
int newSelection = oldSelection < size ? oldSelection : size - 1;
|
||||
if (newSelection >= 0 && newSelection < size) {
|
||||
myList.setSelectedIndex(newSelection);
|
||||
}
|
||||
}
|
||||
|
||||
private void createNewConfiguration() {
|
||||
if (!saveSelectedConfiguration()) return;
|
||||
myList.setSelectedValue(null, false);
|
||||
CvsRootConfiguration newConfig = CvsApplicationLevelConfiguration.createNewConfiguration(CvsApplicationLevelConfiguration.getInstance());
|
||||
final CvsRootConfiguration newConfig =
|
||||
CvsApplicationLevelConfiguration.createNewConfiguration(CvsApplicationLevelConfiguration.getInstance());
|
||||
myModel.addElement(newConfig);
|
||||
myList.setSelectedValue(newConfig, true);
|
||||
}
|
||||
@@ -220,12 +211,12 @@ public class CvsConfigurationsListEditor extends DialogWrapper implements DataPr
|
||||
myList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
int selectedIndex = myList.getSelectedIndex();
|
||||
final int selectedIndex = myList.getSelectedIndex();
|
||||
if (selectedIndex < 0 || selectedIndex >= myModel.getSize()) {
|
||||
selectNone();
|
||||
}
|
||||
else {
|
||||
CvsRootConfiguration newSelection = (CvsRootConfiguration)myModel.getElementAt(selectedIndex);
|
||||
final CvsRootConfiguration newSelection = (CvsRootConfiguration)myModel.getElementAt(selectedIndex);
|
||||
if (newSelection == mySelection) return;
|
||||
if (!select(newSelection)) {
|
||||
myList.setSelectedValue(mySelection, true);
|
||||
@@ -236,24 +227,20 @@ public class CvsConfigurationsListEditor extends DialogWrapper implements DataPr
|
||||
}
|
||||
|
||||
private boolean select(CvsRootConfiguration cvs2Configuration) {
|
||||
if (mySelection != null) {
|
||||
if (!myCvs2SettingsEditPanel.saveTo(mySelection)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (mySelection != null && !myCvs2SettingsEditPanel.saveTo(mySelection)) return false;
|
||||
mySelection = cvs2Configuration;
|
||||
editSelectedConfiguration();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void selectNone() {
|
||||
myCvs2SettingsEditPanel.disable();
|
||||
mySelection = null;
|
||||
myCvs2SettingsEditPanel.disable();
|
||||
}
|
||||
|
||||
public ArrayList<CvsRootConfiguration> getConfigurations() {
|
||||
ArrayList<CvsRootConfiguration> result = new ArrayList<CvsRootConfiguration>();
|
||||
Enumeration each = myModel.elements();
|
||||
public List<CvsRootConfiguration> getConfigurations() {
|
||||
final ArrayList<CvsRootConfiguration> result = new ArrayList<CvsRootConfiguration>();
|
||||
final Enumeration each = myModel.elements();
|
||||
while (each.hasMoreElements()) result.add((CvsRootConfiguration)each.nextElement());
|
||||
return result;
|
||||
}
|
||||
@@ -266,60 +253,6 @@ public class CvsConfigurationsListEditor extends DialogWrapper implements DataPr
|
||||
myList.setSelectedValue(selectedConfiguration, true);
|
||||
}
|
||||
|
||||
private class MyAddAction extends AnAction {
|
||||
public MyAddAction() {
|
||||
super(CvsBundle.message("action.name.add"), null, IconLoader.getIcon("/general/add.png"));
|
||||
registerCustomShortcutSet(CommonShortcuts.INSERT, myList);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(!myIsReadOnly);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
createNewConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
private class MyRemoveAction extends AnAction {
|
||||
public MyRemoveAction() {
|
||||
super(CvsBundle.message("action.name.remove"), null, IconLoader.getIcon("/general/remove.png"));
|
||||
registerCustomShortcutSet(CommonShortcuts.DELETE, myList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(getSelectedConfiguration() != null && !myIsReadOnly);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
removeSelectedConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
private class MyCopyAction extends AnAction {
|
||||
public MyCopyAction() {
|
||||
super(CvsBundle.message("action.name.copy"), null, IconLoader.getIcon("/general/copy.png"));
|
||||
registerCustomShortcutSet(new CustomShortcutSet(
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_C, SystemInfo.isMac ? KeyEvent.META_MASK : KeyEvent.CTRL_MASK)),
|
||||
myList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(getSelectedConfiguration() != null && !myIsReadOnly);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
copySelectedConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNls
|
||||
public Object getData(String dataId) {
|
||||
|
||||
+2
-1
@@ -21,11 +21,12 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="fa331" class="javax.swing.JLabel" binding="myRootLabel">
|
||||
<component id="fa331" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="c77e2"/>
|
||||
<text resource-bundle="com/intellij/cvsSupport2/CvsBundle" key="label.cvs.root.field.label"/>
|
||||
</properties>
|
||||
</component>
|
||||
|
||||
+13
-18
@@ -19,8 +19,8 @@ import com.intellij.cvsSupport2.config.CvsApplicationLevelConfiguration;
|
||||
import com.intellij.cvsSupport2.config.CvsRootConfiguration;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsEdit.ui.EditCvsConfigurationFieldByFieldDialog;
|
||||
import com.intellij.cvsSupport2.ui.CvsRootChangeListener;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.util.BooleanValueHolder;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
@@ -35,14 +35,12 @@ import java.util.Collection;
|
||||
public class CvsRootAsStringConfigurationPanel {
|
||||
private JTextField myCvsRoot;
|
||||
private JButton myEditFieldByFieldButton;
|
||||
private JLabel myRootLabel;
|
||||
private final BooleanValueHolder myIsInUpdating;
|
||||
private final Ref<Boolean> myIsUpdating;
|
||||
private final Collection<CvsRootChangeListener> myCvsRootListeners = new ArrayList<CvsRootChangeListener>();
|
||||
private JPanel myPanel;
|
||||
|
||||
public CvsRootAsStringConfigurationPanel(BooleanValueHolder isInUpdating) {
|
||||
myIsInUpdating = isInUpdating;
|
||||
myRootLabel.setLabelFor(myCvsRoot);
|
||||
public CvsRootAsStringConfigurationPanel(boolean readOnly, Ref<Boolean> isUpdating) {
|
||||
myIsUpdating = isUpdating;
|
||||
myCvsRoot.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
public void textChanged(DocumentEvent event) {
|
||||
@@ -53,20 +51,24 @@ public class CvsRootAsStringConfigurationPanel {
|
||||
myEditFieldByFieldButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
CvsRootConfiguration cvsRootConfiguration = CvsApplicationLevelConfiguration.createNewConfiguration(CvsApplicationLevelConfiguration.getInstance());
|
||||
final CvsRootConfiguration cvsRootConfiguration =
|
||||
CvsApplicationLevelConfiguration.createNewConfiguration(CvsApplicationLevelConfiguration.getInstance());
|
||||
saveTo(cvsRootConfiguration);
|
||||
EditCvsConfigurationFieldByFieldDialog dialog
|
||||
= new EditCvsConfigurationFieldByFieldDialog(myCvsRoot.getText());
|
||||
final EditCvsConfigurationFieldByFieldDialog dialog = new EditCvsConfigurationFieldByFieldDialog(myCvsRoot.getText());
|
||||
dialog.show();
|
||||
if (dialog.isOK()){
|
||||
if (dialog.isOK()) {
|
||||
myCvsRoot.setText(dialog.getConfiguration());
|
||||
}
|
||||
}
|
||||
});
|
||||
if (readOnly) {
|
||||
myCvsRoot.setEditable(false);
|
||||
myEditFieldByFieldButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected void notifyListeners() {
|
||||
if (myIsInUpdating.getValue()) return;
|
||||
if (!myIsUpdating.isNull()) return;
|
||||
for (CvsRootChangeListener cvsRootChangeListener : myCvsRootListeners) {
|
||||
cvsRootChangeListener.onCvsRootChanged();
|
||||
}
|
||||
@@ -83,7 +85,6 @@ public class CvsRootAsStringConfigurationPanel {
|
||||
public void updateFrom(CvsRootConfiguration config) {
|
||||
myCvsRoot.setText(config.CVS_ROOT);
|
||||
myCvsRoot.selectAll();
|
||||
myCvsRoot.requestFocus();
|
||||
}
|
||||
|
||||
public void saveTo(CvsRootConfiguration config) {
|
||||
@@ -97,10 +98,4 @@ public class CvsRootAsStringConfigurationPanel {
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return myCvsRoot;
|
||||
}
|
||||
|
||||
public void setReadOnly() {
|
||||
myCvsRoot.setEditable(false);
|
||||
myEditFieldByFieldButton.setEnabled(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+16
-6
@@ -21,34 +21,44 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
/**
|
||||
* author: lesya
|
||||
*/
|
||||
public class SelectCvsConfigurationDialog extends DialogWrapper {
|
||||
private final SelectCvsConfigurationPanel myPanel;
|
||||
private final ListSelectionListener myListener;
|
||||
|
||||
public SelectCvsConfigurationDialog(Project project) {
|
||||
super(true);
|
||||
myPanel = new SelectCvsConfigurationPanel(project);
|
||||
setOKActionEnabled(myPanel.getSelectedConfiguration() != null);
|
||||
|
||||
myPanel.getObservable().addObserver(new Observer() {
|
||||
public void update(Observable o, Object arg) {
|
||||
myListener = new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
setOKActionEnabled(myPanel.getSelectedConfiguration() != null);
|
||||
}
|
||||
});
|
||||
};
|
||||
myPanel.addListSelectionListener(myListener);
|
||||
setTitle(CvsBundle.message("dialog.title.select.cvs.root.configuration"));
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispose() {
|
||||
myPanel.removeListSelectionListener(myListener);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return (JComponent)myPanel.getJList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
+36
-42
@@ -21,6 +21,7 @@ import com.intellij.cvsSupport2.config.CvsRootConfiguration;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
@@ -30,7 +31,6 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
|
||||
/**
|
||||
* author: lesya
|
||||
@@ -38,74 +38,79 @@ import java.util.Observable;
|
||||
public class SelectCvsConfigurationPanel extends JPanel {
|
||||
private final DefaultListModel myModel = new DefaultListModel();
|
||||
private final JList myList = new JBList(myModel);
|
||||
private CvsRootConfiguration mySelection;
|
||||
private CvsRootConfiguration mySelection = null;
|
||||
private final Project myProject;
|
||||
private final MyObservable myObservable;
|
||||
|
||||
public SelectCvsConfigurationPanel(Project project) {
|
||||
super(new BorderLayout(2, 4));
|
||||
myProject = project;
|
||||
add(createListPanel(), BorderLayout.CENTER);
|
||||
add(ScrollPaneFactory.createScrollPane(myList), BorderLayout.CENTER);
|
||||
add(createButtonPanel(), BorderLayout.EAST);
|
||||
myObservable = new MyObservable();
|
||||
myList.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
mySelection = (CvsRootConfiguration)myList.getSelectedValue();
|
||||
myObservable.setChanged();
|
||||
myObservable.notifyObservers(mySelection);
|
||||
fireSelectionValueChanged(e.getFirstIndex(), e.getLastIndex(), e.getValueIsAdjusting());
|
||||
}
|
||||
});
|
||||
|
||||
myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
||||
fillModel(null);
|
||||
}
|
||||
|
||||
public void addListSelectionListener(ListSelectionListener listener) {
|
||||
listenerList.add(ListSelectionListener.class, listener);
|
||||
}
|
||||
|
||||
public void removeListSelectionListener(ListSelectionListener listener) {
|
||||
listenerList.remove(ListSelectionListener.class, listener);
|
||||
}
|
||||
|
||||
private void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting) {
|
||||
final ListSelectionListener[] listeners = getListeners(ListSelectionListener.class);
|
||||
if( listeners.length == 0) return;
|
||||
final ListSelectionEvent event = new ListSelectionEvent(this, firstIndex, lastIndex, isAdjusting);
|
||||
for (ListSelectionListener listener : listeners) {
|
||||
listener.valueChanged(event);
|
||||
}
|
||||
}
|
||||
|
||||
private Component createButtonPanel() {
|
||||
JPanel result = new JPanel(new BorderLayout());
|
||||
JButton jButton = new JButton(CvsBundle.message("button.text.configure.cvs.roots"));
|
||||
jButton.addActionListener(new ActionListener() {
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
final JButton button = new JButton(CvsBundle.message("button.text.configure.cvs.roots"));
|
||||
button.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
editConfigurations();
|
||||
}
|
||||
});
|
||||
result.add(jButton, BorderLayout.NORTH);
|
||||
return result;
|
||||
}
|
||||
|
||||
private JPanel createListPanel() {
|
||||
JPanel result = new JPanel(new BorderLayout());
|
||||
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myList);
|
||||
result.add(scrollPane, BorderLayout.CENTER);
|
||||
scrollPane.setFocusable(false);
|
||||
return result;
|
||||
panel.add(button, BorderLayout.NORTH);
|
||||
return panel;
|
||||
}
|
||||
|
||||
public void editConfigurations() {
|
||||
final CvsApplicationLevelConfiguration configuration = CvsApplicationLevelConfiguration.getInstance();
|
||||
CvsConfigurationsListEditor cvsConfigurationsListEditor =
|
||||
final CvsConfigurationsListEditor cvsConfigurationsListEditor =
|
||||
new CvsConfigurationsListEditor(new ArrayList<CvsRootConfiguration>(configuration.CONFIGURATIONS), myProject);
|
||||
CvsRootConfiguration selectedConfiguration = getSelectedConfiguration();
|
||||
final CvsRootConfiguration selectedConfiguration = getSelectedConfiguration();
|
||||
if (selectedConfiguration != null) {
|
||||
cvsConfigurationsListEditor.selectConfiguration(selectedConfiguration);
|
||||
}
|
||||
cvsConfigurationsListEditor.show();
|
||||
if (cvsConfigurationsListEditor.isOK()) {
|
||||
configuration.CONFIGURATIONS =
|
||||
new ArrayList<CvsRootConfiguration>(cvsConfigurationsListEditor.getConfigurations());
|
||||
configuration.CONFIGURATIONS = cvsConfigurationsListEditor.getConfigurations();
|
||||
fillModel(cvsConfigurationsListEditor.getSelectedConfiguration());
|
||||
}
|
||||
}
|
||||
|
||||
private void fillModel(Object selectedConfiguration) {
|
||||
Object selection = selectedConfiguration == null ? myList.getSelectedValue() : selectedConfiguration;
|
||||
private void fillModel(@Nullable CvsRootConfiguration configurationToSelect) {
|
||||
final CvsRootConfiguration selection = configurationToSelect == null ? mySelection : configurationToSelect;
|
||||
myModel.removeAllElements();
|
||||
List<CvsRootConfiguration> configurations = CvsApplicationLevelConfiguration.getInstance().CONFIGURATIONS;
|
||||
final List<CvsRootConfiguration> configurations = CvsApplicationLevelConfiguration.getInstance().CONFIGURATIONS;
|
||||
for (CvsRootConfiguration configuration : configurations) {
|
||||
if (configuration.CVS_ROOT.isEmpty()) continue;
|
||||
myModel.addElement(configuration);
|
||||
}
|
||||
myList.setSelectedValue(selection, true);
|
||||
|
||||
if (selection != null) myList.setSelectedValue(selection, true);
|
||||
if (myList.getSelectedIndex() < 0 && myList.getModel().getSize() > 0) {
|
||||
myList.setSelectedIndex(0);
|
||||
}
|
||||
@@ -115,18 +120,7 @@ public class SelectCvsConfigurationPanel extends JPanel {
|
||||
return mySelection;
|
||||
}
|
||||
|
||||
public Observable getObservable() {
|
||||
return myObservable;
|
||||
}
|
||||
|
||||
public Component getJList() {
|
||||
return myList;
|
||||
}
|
||||
|
||||
private static class MyObservable extends Observable {
|
||||
public synchronized void setChanged() {
|
||||
super.setChanged();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-11
@@ -94,7 +94,7 @@ public class DateOrRevisionOrTagSettings {
|
||||
myBranch.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String tagName = TagsHelper.chooseBranch(myTagsProvider, myProject);
|
||||
final String tagName = TagsHelper.chooseBranch(myTagsProvider, myProject);
|
||||
if (tagName != null) myBranch.setText(tagName);
|
||||
}
|
||||
});
|
||||
@@ -137,16 +137,10 @@ public class DateOrRevisionOrTagSettings {
|
||||
}
|
||||
|
||||
private void refreshEnabling() {
|
||||
|
||||
boolean useBranch = myUseBranch.isSelected();
|
||||
boolean useDate = myUseDate.isSelected();
|
||||
|
||||
final boolean useBranch = myUseBranch.isSelected();
|
||||
myBranch.setEnabled(useBranch);
|
||||
myBranch.setEditable(useBranch);
|
||||
|
||||
myDatePicker.setEnabled(useDate);
|
||||
|
||||
myBranch.getButton().setEnabled(useBranch);
|
||||
myDatePicker.setEnabled(myUseDate.isSelected());
|
||||
}
|
||||
|
||||
private void updateDate(String dateString) {
|
||||
@@ -166,12 +160,11 @@ public class DateOrRevisionOrTagSettings {
|
||||
}
|
||||
}
|
||||
|
||||
public JComponent getPanel() {
|
||||
public JPanel getPanel() {
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
public void setHeadCaption(String text){
|
||||
myUseHead.setText(text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+16
-16
@@ -21,54 +21,54 @@ import com.intellij.cvsSupport2.config.ui.SelectCvsConfigurationPanel;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import java.awt.*;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
/**
|
||||
* author: lesya
|
||||
*/
|
||||
public class SelectCVSConfigurationStep extends WizardStep{
|
||||
private final SelectCvsConfigurationPanel mySelectCvsConfigurationPanel;
|
||||
private final Observer myObserver;
|
||||
|
||||
private final ListSelectionListener myListSelectionListener;
|
||||
|
||||
public SelectCVSConfigurationStep(Project project, CvsWizard wizard) {
|
||||
super(CvsBundle.message("dialog.title.select.cvs.configuration"), wizard);
|
||||
mySelectCvsConfigurationPanel = new SelectCvsConfigurationPanel(project);
|
||||
myObserver = new Observer() {
|
||||
public void update(Observable o, Object arg) {
|
||||
getWizard().updateStep();
|
||||
}
|
||||
};
|
||||
mySelectCvsConfigurationPanel.getObservable().addObserver(myObserver);
|
||||
myListSelectionListener = new ListSelectionListener() {
|
||||
@Override public void valueChanged(ListSelectionEvent e) {
|
||||
getWizard().updateStep();
|
||||
}
|
||||
};
|
||||
mySelectCvsConfigurationPanel.addListSelectionListener(myListSelectionListener);
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispose() {
|
||||
mySelectCvsConfigurationPanel.getObservable().deleteObserver(myObserver);
|
||||
mySelectCvsConfigurationPanel.removeListSelectionListener(myListSelectionListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextIsEnabled() {
|
||||
return mySelectCvsConfigurationPanel.getSelectedConfiguration() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createComponent() {
|
||||
JPanel result = new JPanel(new BorderLayout());
|
||||
result.add(mySelectCvsConfigurationPanel, BorderLayout.CENTER);
|
||||
JPanel buttonPanel = new JPanel(new BorderLayout());
|
||||
result.add(buttonPanel, BorderLayout.SOUTH);
|
||||
return result;
|
||||
return mySelectCvsConfigurationPanel;
|
||||
}
|
||||
|
||||
public CvsRootConfiguration getSelectedConfiguration() {
|
||||
return mySelectCvsConfigurationPanel.getSelectedConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getPreferredFocusedComponent() {
|
||||
return mySelectCvsConfigurationPanel.getJList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user