mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EditTaskDialog
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.tasks.actions.EditTaskDialog">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="4" 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>
|
||||
<xy x="20" y="20" width="500" height="195"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="5590b" class="com.intellij.ui.components.JBLabel" binding="myBranchLabel">
|
||||
<constraints>
|
||||
<grid row="1" 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="4ef0b"/>
|
||||
<text value="Associated &branch"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="16cf7">
|
||||
<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="4ef0b" class="com.intellij.openapi.ui.ComboBox" binding="myBranch">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="e70a4" class="com.intellij.ui.components.JBLabel" binding="myChangelistLabel">
|
||||
<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>
|
||||
<labelFor value="9ab51"/>
|
||||
<text value="Associated change&list"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="9ab51" class="com.intellij.openapi.ui.ComboBox" binding="myChangelist">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="bb96d" 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="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="573e5"/>
|
||||
<text value="&Summary"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="573e5" class="javax.swing.JTextField" binding="mySummary">
|
||||
<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"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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 com.intellij.tasks.actions;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.VcsTaskHandler;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vcs.changes.LocalChangeList;
|
||||
import com.intellij.tasks.BranchInfo;
|
||||
import com.intellij.tasks.ChangeListInfo;
|
||||
import com.intellij.tasks.TaskManager;
|
||||
import com.intellij.tasks.impl.LocalTaskImpl;
|
||||
import com.intellij.ui.CollectionComboBoxModel;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public class EditTaskDialog extends DialogWrapper {
|
||||
|
||||
private final LocalTaskImpl myTask;
|
||||
|
||||
private JPanel myPanel;
|
||||
private JTextField mySummary;
|
||||
private JBLabel myBranchLabel;
|
||||
private ComboBox myBranch;
|
||||
private JBLabel myChangelistLabel;
|
||||
private ComboBox myChangelist;
|
||||
|
||||
public static void editTask(LocalTaskImpl task, Project project) {
|
||||
new EditTaskDialog(project, task).show();
|
||||
}
|
||||
|
||||
protected EditTaskDialog(Project project, LocalTaskImpl task) {
|
||||
super(project);
|
||||
myTask = task;
|
||||
setTitle("Edit Task " + task.getId());
|
||||
|
||||
// mySummary.putClientProperty(DialogWrapperPeer.HAVE_INITIAL_SELECTION, "");
|
||||
mySummary.setText(task.getSummary());
|
||||
|
||||
AbstractVcs vcs = TaskManager.getManager(project).getActiveVcs();
|
||||
if (vcs == null) {
|
||||
myBranchLabel.setVisible(false);
|
||||
myBranch.setVisible(false);
|
||||
myChangelistLabel.setVisible(false);
|
||||
myChangelist.setVisible(false);
|
||||
}
|
||||
else {
|
||||
ChangeListManager changeListManager = ChangeListManager.getInstance(project);
|
||||
List<LocalChangeList> changeLists = changeListManager.getChangeLists();
|
||||
myChangelist.setModel(new CollectionComboBoxModel<LocalChangeList>(changeLists));
|
||||
final List<ChangeListInfo> lists = task.getChangeLists();
|
||||
if (!lists.isEmpty()) {
|
||||
LocalChangeList list = changeListManager.getChangeList(lists.get(0).id);
|
||||
myChangelist.setSelectedItem(list);
|
||||
}
|
||||
|
||||
VcsTaskHandler[] handlers = VcsTaskHandler.getAllHandlers(project);
|
||||
if (handlers.length == 0) {
|
||||
myBranchLabel.setVisible(false);
|
||||
myBranch.setVisible(false);
|
||||
}
|
||||
else {
|
||||
VcsTaskHandler.TaskInfo[] tasks = handlers[0].getAllExistingTasks();
|
||||
myBranch.setModel(new DefaultComboBoxModel(tasks));
|
||||
final List<BranchInfo> branches = task.getBranches();
|
||||
if (!branches.isEmpty()) {
|
||||
VcsTaskHandler.TaskInfo info = ContainerUtil.find(tasks, new Condition<VcsTaskHandler.TaskInfo>() {
|
||||
@Override
|
||||
public boolean value(VcsTaskHandler.TaskInfo info) {
|
||||
return branches.get(0).name.equals(info.getName());
|
||||
}
|
||||
});
|
||||
myBranch.setSelectedItem(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doOKAction() {
|
||||
myTask.setSummary(mySummary.getText());
|
||||
if (myChangelist.isVisible()) {
|
||||
List<ChangeListInfo> changeLists = myTask.getChangeLists();
|
||||
changeLists.clear();
|
||||
ChangeListInfo item = (ChangeListInfo)myChangelist.getSelectedItem();
|
||||
if (item != null) {
|
||||
changeLists.add(item);
|
||||
}
|
||||
}
|
||||
if (myBranch.isVisible()) {
|
||||
// todo
|
||||
}
|
||||
close(OK_EXIT_CODE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return mySummary;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
return myPanel;
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -149,6 +150,12 @@ public class SwitchTaskAction extends BaseTaskAction {
|
||||
manager.activateTask(task, !shiftPressed.get());
|
||||
}
|
||||
});
|
||||
group.add(new AnAction("&Edit") {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
EditTaskDialog.editTask(task, project);
|
||||
}
|
||||
});
|
||||
}
|
||||
final AnAction remove = new AnAction("&Remove") {
|
||||
@Override
|
||||
@@ -161,6 +168,7 @@ public class SwitchTaskAction extends BaseTaskAction {
|
||||
}
|
||||
}
|
||||
};
|
||||
remove.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)), null);
|
||||
group.add(remove);
|
||||
|
||||
return group;
|
||||
|
||||
Reference in New Issue
Block a user