changelist name format moved to task settings

This commit is contained in:
Dmitry Avdeev
2012-03-06 16:10:03 +04:00
parent 263c31ac81
commit a8a2f3cc40
9 changed files with 56 additions and 76 deletions
@@ -157,16 +157,6 @@ public abstract class TaskRepository {
protected boolean myShouldFormatCommitMessage;
protected String myCommitMessageFormat = "{id} {summary}";
protected String myChangelistNameFormat = "{id} {summary}";
@Tag("changelistNameFormat")
public String getChangelistNameFormat() {
return myChangelistNameFormat;
}
public void setChangelistNameFormat(String changelistNameFormat) {
myChangelistNameFormat = changelistNameFormat;
}
private static String trimTrailingSlashes(String url) {
if (url == null) return "";
@@ -145,48 +145,17 @@
</component>
</children>
</grid>
<grid id="3d7e" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="3d7e" 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>
<tabbedpane title="Messages"/>
<tabbedpane title="Commit Message"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="c181a" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<horizontalAlignment value="4"/>
<text value="&amp;Changelist name format:"/>
</properties>
</component>
<vspacer id="d9925">
<constraints>
<grid row="3" 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="8c253" class="javax.swing.JTextField" binding="myChangelistNameFormat">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="c06d8" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<horizontalAlignment value="4"/>
<text value="Commit message format:"/>
</properties>
</component>
<component id="ae3b0" class="javax.swing.JLabel" binding="myComment">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" 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>
<text value="Use..."/>
@@ -194,7 +163,7 @@
</component>
<component id="b2312" class="com.intellij.ui.components.JBCheckBox" binding="myAddCommitMessage">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<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>
<text value="Add commit message"/>
@@ -202,7 +171,7 @@
</component>
<grid id="e7ed6" binding="myEditorPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="2" column="1" row-span="2" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<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="none"/>
@@ -57,7 +57,6 @@ public class BaseRepositoryEditor<T extends BaseRepository> extends TaskReposito
protected JPanel myCustomPanel;
protected JPanel myCustomLabel;
private JTextField myChangelistNameFormat;
private JBCheckBox myAddCommitMessage;
private JLabel myComment;
private JPanel myEditorPanel;
@@ -94,14 +93,12 @@ public class BaseRepositoryEditor<T extends BaseRepository> extends TaskReposito
myUseHTTPAuthentication.setSelected(repository.isUseHttpAuthentication());
myUseHTTPAuthentication.setVisible(repository.getRepositoryType().isSupported(TaskRepositoryType.BASIC_HTTP_AUTHORIZATION));
myChangelistNameFormat.setText(repository.getChangelistNameFormat());
myAddCommitMessage.setSelected(repository.isShouldFormatCommitMessage());
myDocument = EditorFactory.getInstance().createDocument(repository.getCommitMessageFormat());
myEditor = EditorFactory.getInstance().createEditor(myDocument);
myEditorPanel.add(ScrollPaneFactory.createScrollPane(myEditor.getComponent(), SideBorder.NONE), BorderLayout.CENTER);
myComment.setText("Available placeholders: " + repository.getComment());
installListener(myChangelistNameFormat);
installListener(myAddCommitMessage);
myDocument.addDocumentListener(new com.intellij.openapi.editor.event.DocumentAdapter() {
@Override
@@ -185,7 +182,6 @@ public class BaseRepositoryEditor<T extends BaseRepository> extends TaskReposito
myRepository.setUseProxy(myUseProxy.isSelected());
myRepository.setUseHttpAuthentication(myUseHTTPAuthentication.isSelected());
myRepository.setChangelistNameFormat(myChangelistNameFormat.getText());
myRepository.setShouldFormatCommitMessage(myAddCommitMessage.isSelected());
myRepository.setCommitMessageFormat(myDocument.getText());
@@ -46,10 +46,10 @@ public class CreateChangelistAction extends BaseTaskAction {
@Override
public void actionPerformed(AnActionEvent e) {
LocalTask activeTask = getActiveTask(e);
String name = Messages.showInputDialog(getProject(e), "Changelist name:", "Create Changelist", null, TaskUtil.getChangeListName(activeTask), null);
TaskManagerImpl manager = (TaskManagerImpl)getTaskManager(e);
assert manager != null;
String name = Messages.showInputDialog(getProject(e), "Changelist name:", "Create Changelist", null, manager.getChangelistName(activeTask), null);
if (name != null) {
TaskManagerImpl manager = (TaskManagerImpl)getTaskManager(e);
assert manager != null;
manager.createChangeList(activeTask, name);
}
}
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.tasks.config.TaskConfigurable">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="5" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="6" column-count="3" 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="555" height="400"/>
@@ -10,7 +10,7 @@
<children>
<component id="e53da" class="javax.swing.JCheckBox" binding="myUpdateCheckBox" default-binding="true">
<constraints>
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Enable issue &amp;cache"/>
@@ -18,7 +18,7 @@
</component>
<component id="9f69d" class="javax.swing.JFormattedTextField" binding="myHistoryLength">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="50" height="-1"/>
</grid>
</constraints>
@@ -29,22 +29,23 @@
</component>
<component id="b5a6c" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<horizontalAlignment value="4"/>
<labelFor value="9f69d"/>
<text value="Task history &amp;length:"/>
</properties>
</component>
<vspacer id="3f700">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="5" column="1" 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="e4d1f" binding="myCacheSettings" layout-manager="GridLayoutManager" row-count="1" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="8" fill="2" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<clientProperties>
@@ -58,7 +59,8 @@
</constraints>
<properties>
<horizontalAlignment value="4"/>
<text value="Update"/>
<labelFor value="4b4f6"/>
<text value="&amp;Update"/>
</properties>
</component>
<hspacer id="87f9">
@@ -79,10 +81,12 @@
</component>
<component id="1c14" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="issues every"/>
<horizontalAlignment value="4"/>
<labelFor value="fc85e"/>
<text value="issues e&amp;very"/>
</properties>
</component>
<component id="fc85e" class="javax.swing.JTextField" binding="myUpdateInterval">
@@ -108,17 +112,35 @@
</grid>
<hspacer id="ac0b8">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="6f93" class="javax.swing.JCheckBox" binding="mySaveContextOnCommit">
<constraints>
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&amp;Save context on commit"/>
</properties>
</component>
<component id="89ca" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<horizontalAlignment value="4"/>
<labelFor value="ef62"/>
<text value="Changelist name &amp;format:"/>
</properties>
</component>
<component id="ef62" class="javax.swing.JTextField" binding="myChangelistNameFormat">
<constraints>
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
</form>
@@ -44,6 +44,9 @@ public class TaskConfigurable extends BindableConfigurable implements Searchable
@BindControl("saveContextOnCommit")
private JCheckBox mySaveContextOnCommit;
@BindControl("changelistNameFormat")
private JTextField myChangelistNameFormat;
private final Project myProject;
private Configurable[] myConfigurables;
private final NotNullLazyValue<ControlBinder> myControlBinder = new NotNullLazyValue<ControlBinder>() {
@@ -321,7 +321,7 @@ public class TaskManagerImpl extends TaskManager implements ProjectComponent, Pe
if (createChangelist) {
if (changeLists.isEmpty()) {
String name = TaskUtil.getChangeListName(task);
String name = getChangelistName(task);
String comment = TaskUtil.getChangeListComment(this, origin);
createChangeList(task, name, comment);
} else {
@@ -335,6 +335,14 @@ public class TaskManagerImpl extends TaskManager implements ProjectComponent, Pe
}
}
public String getChangelistName(Task task) {
TaskRepository repository = task.getRepository();
if (repository != null) {
return TaskUtil.formatTask(task, myConfig.changelistNameFormat);
}
return task.getSummary();
}
private void saveActiveTask() {
myContextManager.saveContext(myActiveTask);
myActiveTask.setActive(false);
@@ -831,6 +839,7 @@ public class TaskManagerImpl extends TaskManager implements ProjectComponent, Pe
public boolean saveContextOnCommit = true;
public boolean trackContextForNewChangelist = true;
public boolean markAsInProgress = false;
public String changelistNameFormat = "{id} {summary}";
@Tag("servers")
public Element servers = new Element("servers");
@@ -27,15 +27,7 @@ import org.jetbrains.annotations.Nullable;
*/
public class TaskUtil {
public static String getChangeListName(Task task) {
TaskRepository repository = task.getRepository();
if (repository != null) {
return formatTask(task, repository.getChangelistNameFormat());
}
return task.getSummary();
}
private static String formatTask(Task task, String format) {
public static String formatTask(Task task, String format) {
return format.replace("{id}", task.getId()).replace("{number}", task.getNumber())
.replace("{project}", task.getProject()).replace("{summary}", task.getSummary());
}
@@ -22,7 +22,6 @@ import com.intellij.openapi.vcs.changes.LocalChangeList;
import com.intellij.openapi.vcs.changes.committed.MockAbstractVcs;
import com.intellij.openapi.vcs.impl.projectlevelman.AllVcses;
import com.intellij.tasks.impl.LocalTaskImpl;
import com.intellij.tasks.impl.TaskUtil;
import java.util.Collections;
import java.util.List;
@@ -58,7 +57,7 @@ public class TaskVcsTest extends TaskManagerTestCase {
private ChangeListInfo createChangelist(LocalTaskImpl task) {
clearChangeLists();
myManager.createChangeList(task, TaskUtil.getChangeListName(task));
myManager.createChangeList(task, myManager.getChangelistName(task));
List<ChangeListInfo> list = myManager.getOpenChangelists(task);
assertEquals(1, list.size());
ChangeListInfo info = list.get(0);