From 105781fff4db5fb24bb8b718ed9c84d464cd2755 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 14 Mar 2014 15:17:02 +0100 Subject: [PATCH] git edit global message --- plugins/git4idea/src/META-INF/plugin.xml | 1 + .../actions/GitEditGlobalMessageAction.java | 56 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 plugins/git4idea/src/git4idea/actions/GitEditGlobalMessageAction.java diff --git a/plugins/git4idea/src/META-INF/plugin.xml b/plugins/git4idea/src/META-INF/plugin.xml index a81039083c16..1b3621bec47a 100644 --- a/plugins/git4idea/src/META-INF/plugin.xml +++ b/plugins/git4idea/src/META-INF/plugin.xml @@ -65,6 +65,7 @@ + diff --git a/plugins/git4idea/src/git4idea/actions/GitEditGlobalMessageAction.java b/plugins/git4idea/src/git4idea/actions/GitEditGlobalMessageAction.java new file mode 100644 index 000000000000..459386ede58c --- /dev/null +++ b/plugins/git4idea/src/git4idea/actions/GitEditGlobalMessageAction.java @@ -0,0 +1,56 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * 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 git4idea.actions; + +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.project.DumbAwareAction; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.vcs.impl.VcsGlobalMessage; +import com.intellij.openapi.vcs.impl.VcsGlobalMessageManager; +import com.intellij.util.SystemProperties; + +/** + * @author Konstantin Bulenkov + */ +public class GitEditGlobalMessageAction extends DumbAwareAction { + @Override + public void actionPerformed(AnActionEvent e) { + final Project project = e.getProject(); + assert project != null; + final VcsGlobalMessageManager messageManager = VcsGlobalMessageManager.getInstance(project); + VcsGlobalMessage message = messageManager.getState(); + + final String result = Messages.showMultilineInputDialog(project, "Enter a broadcast message. The message will appear in the Commit dialog for everyone who works with '" + project.getName() +"' project.
To remove the broadcast message just remove its content.", "Edit Global Message", message == null ? "" : message.message, null, null); + if (result != null) { + if (message == null) { + message = new VcsGlobalMessage(); + messageManager.loadState(message); + } + message.message = result; + message.author = SystemProperties.getUserName(); + message.when = System.currentTimeMillis(); + ApplicationManager.getApplication().saveAll(); + } + + } + + @Override + public void update(AnActionEvent e) { + e.getPresentation().setEnabledAndVisible(ApplicationManager.getApplication().isInternal() && e.getProject() != null); + } +}