<vcs name="hg4idea" vcsClass="org.zmlx.hg4idea.HgVcs"/>
<checkoutProvider implementation="org.zmlx.hg4idea.provider.HgCheckoutProvider"/>
<errorHandler implementation="com.intellij.diagnostic.ITNReporter"/>
- <applicationConfigurable implementation="org.zmlx.hg4idea.HgIdeConfigurable"/>
<applicationService serviceInterface="org.zmlx.hg4idea.HgGlobalSettings"
serviceImplementation="org.zmlx.hg4idea.HgGlobalSettings"/>
+++ /dev/null
-// Copyright 2008-2010 Victor Iacoban
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software distributed under
-// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-// either express or implied. See the License for the specific language governing permissions and
-// limitations under the License.
-package org.zmlx.hg4idea;
-
-import com.intellij.openapi.options.ConfigurationException;
-import com.intellij.openapi.options.SearchableConfigurable;
-import org.jetbrains.annotations.Nls;
-import org.zmlx.hg4idea.ui.HgConfigurationIdePanel;
-
-import javax.swing.*;
-
-public class HgIdeConfigurable implements SearchableConfigurable {
-
- private final HgConfigurationIdePanel panel;
-
- public HgIdeConfigurable(HgGlobalSettings globalSettings) {
- panel = new HgConfigurationIdePanel(globalSettings);
- }
-
- @Nls
- public String getDisplayName() {
- return HgVcsMessages.message("hg4idea.mercurial");
- }
-
- public Icon getIcon() {
- return HgVcs.MERCURIAL_ICON;
- }
-
- public String getHelpTopic() {
- return null;
- }
-
- public JComponent createComponent() {
- return panel.getBasePanel();
- }
-
- public boolean isModified() {
- return panel.isModified();
- }
-
- public void apply() throws ConfigurationException {
- panel.validate();
- panel.saveSettings();
- }
-
- public void reset() {
- panel.loadSettings();
- }
-
- public void disposeUIResources() {
- }
-
- public String getId() {
- return "Mercurial";
- }
-
- public Runnable enableSearch(String option) {
- return null;
- }
-}
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SearchableConfigurable;
import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NotNull;
import org.zmlx.hg4idea.ui.HgConfigurationProjectPanel;
import javax.swing.*;
public class HgProjectConfigurable implements SearchableConfigurable {
- private final HgConfigurationProjectPanel hgConfigurationProjectPanel;
+ private final HgConfigurationProjectPanel myPanel;
public HgProjectConfigurable(HgProjectSettings projectSettings) {
- hgConfigurationProjectPanel = new HgConfigurationProjectPanel(projectSettings);
+ myPanel = new HgConfigurationProjectPanel(projectSettings);
}
@Nls
}
public JComponent createComponent() {
- return hgConfigurationProjectPanel.getPanel();
+ return myPanel.getPanel();
}
public boolean isModified() {
- return hgConfigurationProjectPanel.isModified();
+ return myPanel.isModified();
}
public void apply() throws ConfigurationException {
- hgConfigurationProjectPanel.saveSettings();
+ myPanel.validate();
+ myPanel.saveSettings();
}
public void reset() {
- hgConfigurationProjectPanel.loadSettings();
+ myPanel.loadSettings();
}
public void disposeUIResources() {
}
+ @NotNull
public String getId() {
return "Mercurial.Project";
}
name = "hg4idea.settings",
storages = @Storage(id = "hg4idea.settings", file = "$PROJECT_FILE$")
)
-public class HgProjectSettings implements PersistentStateComponent<HgProjectSettings> {
+public class HgProjectSettings implements PersistentStateComponent<HgProjectSettings.State> {
- private boolean checkIncoming = true;
- private boolean checkOutgoing = true;
+ private boolean myCheckIncoming = true;
+ private boolean myCheckOutgoing = true;
+ private HgGlobalSettings myGlobalSettings;
+
+ public HgProjectSettings(HgGlobalSettings globalSettings) {
+ myGlobalSettings = globalSettings;
+ }
+
+ public State getState() {
+ return new State(myCheckIncoming, myCheckOutgoing, myGlobalSettings);
+ }
+
+ public void loadState(State state) {
+ myCheckIncoming = state.myCheckIncoming;
+ myCheckOutgoing = state.myCheckOutgoing;
+ myGlobalSettings = state.myGlobalSettings;
+ }
public boolean isCheckIncoming() {
- return checkIncoming;
+ return myCheckIncoming;
}
public void setCheckIncoming(boolean checkIncoming) {
- this.checkIncoming = checkIncoming;
+ this.myCheckIncoming = checkIncoming;
}
public boolean isCheckOutgoing() {
- return checkOutgoing;
+ return myCheckOutgoing;
}
public void setCheckOutgoing(boolean checkOutgoing) {
- this.checkOutgoing = checkOutgoing;
+ this.myCheckOutgoing = checkOutgoing;
}
- public HgProjectSettings getState() {
- return this;
+ public String getHgExecutable() {
+ return myGlobalSettings.getHgExecutable();
}
- public void loadState(HgProjectSettings state) {
- checkIncoming = state.checkIncoming;
- checkOutgoing = state.checkOutgoing;
+ public boolean isAutodetectHg() {
+ return myGlobalSettings.isAutodetectHg();
}
+ public void enableAutodetectHg() {
+ myGlobalSettings.enableAutodetectHg();
+ }
+
+ public void setHgExecutable(String text) {
+ myGlobalSettings.setHgExecutable(text);
+ }
+
+ public static class State {
+ private boolean myCheckIncoming;
+ private boolean myCheckOutgoing;
+ private HgGlobalSettings myGlobalSettings;
+ private State(boolean checkIncoming, boolean checkOutgoing, HgGlobalSettings globalSettings) {
+ myCheckIncoming = checkIncoming;
+ myCheckOutgoing = checkOutgoing;
+ myGlobalSettings = globalSettings;
+ }
+ }
}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.zmlx.hg4idea.ui.HgConfigurationIdePanel">
- <grid id="27dc6" binding="basePanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
- <margin top="0" left="0" bottom="0" right="0"/>
- <constraints>
- <xy x="20" y="20" width="500" height="400"/>
- </constraints>
- <properties/>
- <border type="none"/>
- <children>
- <grid id="1beb4" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
- <margin top="0" left="0" bottom="0" right="0"/>
- <constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties/>
- <border type="etched" title="Path to hg executable"/>
- <children>
- <component id="1491f" class="javax.swing.JRadioButton" binding="autoRadioButton">
- <constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties>
- <selected value="true"/>
- <text value="&Autodetect hg in PATH"/>
- </properties>
- </component>
- <component id="45c9f" class="javax.swing.JRadioButton" binding="selectRadioButton">
- <constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties>
- <enabled value="true"/>
- <text value="&Specify executable path"/>
- </properties>
- </component>
- <component id="42f2c" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="pathSelector" custom-create="true">
- <constraints>
- <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false">
- <minimum-size width="100" height="-1"/>
- </grid>
- </constraints>
- <properties>
- <enabled value="false"/>
- </properties>
- </component>
- </children>
- </grid>
- <vspacer id="c4171">
- <constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
- </constraints>
- </vspacer>
- </children>
- </grid>
- <buttonGroups>
- <group name="hgPathGroup">
- <member id="1491f"/>
- <member id="45c9f"/>
- </group>
- </buttonGroups>
-</form>
+++ /dev/null
-// Copyright 2008-2010 Victor Iacoban
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software distributed under
-// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-// either express or implied. See the License for the specific language governing permissions and
-// limitations under the License.
-package org.zmlx.hg4idea.ui;
-
-import com.intellij.openapi.options.ConfigurationException;
-import com.intellij.openapi.ui.TextFieldWithBrowseButton;
-import org.apache.commons.lang.StringUtils;
-import org.zmlx.hg4idea.HgGlobalSettings;
-import org.zmlx.hg4idea.HgVcsMessages;
-import org.zmlx.hg4idea.command.HgVersionCommand;
-
-import javax.swing.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-public class HgConfigurationIdePanel {
- private JRadioButton autoRadioButton;
- private JRadioButton selectRadioButton;
- private TextFieldWithBrowseButton pathSelector;
- private JPanel basePanel;
-
- private final HgGlobalSettings globalSettings;
-
- public HgConfigurationIdePanel(HgGlobalSettings globalSettings) {
- this.globalSettings = globalSettings;
- loadSettings();
-
- final ActionListener listener = new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- pathSelector.setEnabled(selectRadioButton.isSelected());
- }
- };
-
- selectRadioButton.addActionListener(listener);
- autoRadioButton.addActionListener(listener);
- }
-
- public boolean isModified() {
- if (selectRadioButton.isSelected()) {
- return !pathSelector.getText().equals(globalSettings.getHgExecutable());
- }
- return autoRadioButton.isSelected() != globalSettings.isAutodetectHg();
- }
-
- public JPanel getBasePanel() {
- return basePanel;
- }
-
- public void validate() throws ConfigurationException {
- String hgExecutable;
- if (autoRadioButton.isSelected()) {
- hgExecutable = HgGlobalSettings.getDefaultExecutable();
- } else {
- hgExecutable = pathSelector.getText();
- }
- HgVersionCommand command = new HgVersionCommand();
- if (!command.isValid(hgExecutable)) {
- throw new ConfigurationException(
- HgVcsMessages.message("hg4idea.configuration.executable.error", hgExecutable)
- );
- }
- }
-
- public void saveSettings() {
- if (autoRadioButton.isSelected()) {
- globalSettings.enableAutodetectHg();
- } else {
- globalSettings.setHgExecutable(pathSelector.getText());
- }
- }
-
- public void loadSettings() {
- boolean isAutodetectHg = globalSettings.isAutodetectHg();
- autoRadioButton.setSelected(isAutodetectHg);
- selectRadioButton.setSelected(!isAutodetectHg);
- pathSelector.setEnabled(!isAutodetectHg);
- if (isAutodetectHg) {
- pathSelector.setText(StringUtils.EMPTY);
- } else {
- pathSelector.setText(globalSettings.getHgExecutable());
- }
- }
-
- private void createUIComponents() {
- pathSelector = new HgSetExecutablePathPanel();
- }
-}
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.zmlx.hg4idea.ui.HgConfigurationProjectPanel">
- <grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
<properties/>
<border type="none"/>
<children>
- <vspacer id="4794a">
- <constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
- </constraints>
- </vspacer>
<grid id="8c1f" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<properties/>
<border type="etched" title="Changesets"/>
<children>
- <component id="f7b19" class="javax.swing.JCheckBox" binding="checkIncomingCbx">
+ <component id="f7b19" class="javax.swing.JCheckBox" binding="myCheckIncomingCbx">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<text value="Check for &incoming changesets"/>
</properties>
</component>
- <vspacer id="4088f">
- <constraints>
- <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
- </constraints>
- </vspacer>
- <component id="cebcc" class="javax.swing.JCheckBox" binding="checkOutgoingCbx">
+ <component id="cebcc" class="javax.swing.JCheckBox" binding="myCheckOutgoingCbx">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</component>
</children>
</grid>
+ <grid id="4e3f3" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <margin top="0" left="0" bottom="0" right="0"/>
+ <constraints>
+ <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties/>
+ <border type="etched" title="Path to hg executable"/>
+ <children>
+ <component id="9a1fc" class="javax.swing.JRadioButton" binding="myAutoRadioButton">
+ <constraints>
+ <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
+ <preferred-size width="183" height="23"/>
+ </grid>
+ </constraints>
+ <properties>
+ <selected value="true"/>
+ <text value="&Autodetect hg in PATH"/>
+ </properties>
+ </component>
+ <component id="d14b" class="javax.swing.JRadioButton" binding="mySelectRadioButton">
+ <constraints>
+ <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
+ <preferred-size width="183" height="23"/>
+ </grid>
+ </constraints>
+ <properties>
+ <enabled value="true"/>
+ <text value="&Specify executable path"/>
+ </properties>
+ </component>
+ <component id="83ec6" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myPathSelector" custom-create="true">
+ <constraints>
+ <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false">
+ <minimum-size width="100" height="-1"/>
+ </grid>
+ </constraints>
+ <properties>
+ <enabled value="false"/>
+ </properties>
+ </component>
+ </children>
+ </grid>
+ <vspacer id="4088f">
+ <constraints>
+ <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+ </constraints>
+ </vspacer>
</children>
</grid>
<buttonGroups>
<group name="hgPathGroup">
<member id="e2d67"/>
<member id="9c6c7"/>
+ <member id="9a1fc"/>
+ <member id="d14b"/>
</group>
</buttonGroups>
</form>
// limitations under the License.
package org.zmlx.hg4idea.ui;
+import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.ui.TextFieldWithBrowseButton;
+import org.apache.commons.lang.StringUtils;
+import org.zmlx.hg4idea.HgGlobalSettings;
import org.zmlx.hg4idea.HgProjectSettings;
+import org.zmlx.hg4idea.HgVcsMessages;
+import org.zmlx.hg4idea.command.HgVersionCommand;
import javax.swing.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
public class HgConfigurationProjectPanel {
- private JPanel panel;
- private JCheckBox checkIncomingCbx;
- private JCheckBox checkOutgoingCbx;
- private final HgProjectSettings projectSettings;
+ private final HgProjectSettings myProjectSettings;
+
+ private JPanel myMainPanel;
+ private JCheckBox myCheckIncomingCbx;
+ private JCheckBox myCheckOutgoingCbx;
+ private JRadioButton myAutoRadioButton;
+ private JRadioButton mySelectRadioButton;
+ private TextFieldWithBrowseButton myPathSelector;
public HgConfigurationProjectPanel(HgProjectSettings projectSettings) {
- this.projectSettings = projectSettings;
+ myProjectSettings = projectSettings;
loadSettings();
+
+ final ActionListener listener = new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ myPathSelector.setEnabled(mySelectRadioButton.isSelected());
+ }
+ };
+ mySelectRadioButton.addActionListener(listener);
+ myAutoRadioButton.addActionListener(listener);
}
public boolean isModified() {
- return checkIncomingCbx.isSelected() != projectSettings.isCheckIncoming()
- || checkOutgoingCbx.isSelected() != projectSettings.isCheckOutgoing();
+ boolean executableModified = mySelectRadioButton.isSelected()
+ ? !myPathSelector.getText().equals(myProjectSettings.getHgExecutable())
+ : myAutoRadioButton.isSelected() != myProjectSettings.isAutodetectHg();
+ return executableModified || myCheckIncomingCbx.isSelected() != myProjectSettings.isCheckIncoming()
+ || myCheckOutgoingCbx.isSelected() != myProjectSettings.isCheckOutgoing();
}
public void saveSettings() {
- projectSettings.setCheckIncoming(checkIncomingCbx.isSelected());
- projectSettings.setCheckOutgoing(checkOutgoingCbx.isSelected());
+ myProjectSettings.setCheckIncoming(myCheckIncomingCbx.isSelected());
+ myProjectSettings.setCheckOutgoing(myCheckOutgoingCbx.isSelected());
+
+ if (myAutoRadioButton.isSelected()) {
+ myProjectSettings.enableAutodetectHg();
+ } else {
+ myProjectSettings.setHgExecutable(myPathSelector.getText());
+ }
}
public void loadSettings() {
- checkIncomingCbx.setSelected(projectSettings.isCheckIncoming());
- checkOutgoingCbx.setSelected(projectSettings.isCheckOutgoing());
+ myCheckIncomingCbx.setSelected(myProjectSettings.isCheckIncoming());
+ myCheckOutgoingCbx.setSelected(myProjectSettings.isCheckOutgoing());
+
+ boolean isAutodetectHg = myProjectSettings.isAutodetectHg();
+ myAutoRadioButton.setSelected(isAutodetectHg);
+ mySelectRadioButton.setSelected(!isAutodetectHg);
+ myPathSelector.setEnabled(!isAutodetectHg);
+ if (isAutodetectHg) {
+ myPathSelector.setText(StringUtils.EMPTY);
+ } else {
+ myPathSelector.setText(myProjectSettings.getHgExecutable());
+ }
}
public JPanel getPanel() {
- return panel;
+ return myMainPanel;
+ }
+
+ public void validate() throws ConfigurationException {
+ String hgExecutable;
+ if (myAutoRadioButton.isSelected()) {
+ hgExecutable = HgGlobalSettings.getDefaultExecutable();
+ } else {
+ hgExecutable = myPathSelector.getText();
+ }
+ HgVersionCommand command = new HgVersionCommand();
+ if (!command.isValid(hgExecutable)) {
+ throw new ConfigurationException(
+ HgVcsMessages.message("hg4idea.configuration.executable.error", hgExecutable)
+ );
+ }
+ }
+
+ private void createUIComponents() {
+ myPathSelector = new HgSetExecutablePathPanel();
}
}