mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -77,7 +77,7 @@ public class TodoCheckinHandler extends CheckinHandler {
|
||||
|
||||
@Override
|
||||
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
|
||||
final JCheckBox checkBox = new JCheckBox(VcsBundle.message("before.checkin.new.todo.check", ""));
|
||||
JCheckBox checkBox = new JCheckBox(VcsBundle.message("before.checkin.new.todo.check", ""));
|
||||
return new RefreshableOnComponent() {
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
@@ -88,16 +88,13 @@ public class TodoCheckinHandler extends CheckinHandler {
|
||||
myTodoFilter = TodoConfiguration.getInstance().getTodoFilter(myConfiguration.myTodoPanelSettings.todoFilterName);
|
||||
}
|
||||
|
||||
final Consumer<TodoFilter> consumer = new Consumer<TodoFilter>() {
|
||||
@Override
|
||||
public void consume(TodoFilter todoFilter) {
|
||||
myTodoFilter = todoFilter;
|
||||
final String name = todoFilter == null ? null : todoFilter.getName();
|
||||
myConfiguration.myTodoPanelSettings.todoFilterName = name;
|
||||
setFilterText(name);
|
||||
}
|
||||
Consumer<TodoFilter> consumer = todoFilter -> {
|
||||
myTodoFilter = todoFilter;
|
||||
String name = todoFilter == null ? null : todoFilter.getName();
|
||||
myConfiguration.myTodoPanelSettings.todoFilterName = name;
|
||||
setFilterText(name);
|
||||
};
|
||||
final LinkLabel linkLabel = new LinkLabel("Configure", null);
|
||||
LinkLabel linkLabel = new LinkLabel("Configure", null);
|
||||
linkLabel.setListener(new LinkListener() {
|
||||
@Override
|
||||
public void linkSelected(LinkLabel aSource, Object aLinkData) {
|
||||
@@ -112,7 +109,7 @@ public class TodoCheckinHandler extends CheckinHandler {
|
||||
return panel;
|
||||
}
|
||||
|
||||
private void setFilterText(final String filterName) {
|
||||
private void setFilterText(String filterName) {
|
||||
if (filterName == null) {
|
||||
checkBox.setText(VcsBundle.message("before.checkin.new.todo.check", IdeBundle.message("action.todo.show.all")));
|
||||
} else {
|
||||
@@ -140,7 +137,7 @@ public class TodoCheckinHandler extends CheckinHandler {
|
||||
public ReturnResult beforeCheckin(@Nullable CommitExecutor executor, PairConsumer<Object, Object> additionalDataConsumer) {
|
||||
if (! myConfiguration.CHECK_NEW_TODO) return ReturnResult.COMMIT;
|
||||
if (DumbService.getInstance(myProject).isDumb()) {
|
||||
final String todoName = VcsBundle.message("before.checkin.new.todo.check.title");
|
||||
String todoName = VcsBundle.message("before.checkin.new.todo.check.title");
|
||||
if (Messages.showOkCancelDialog(myProject,
|
||||
todoName +
|
||||
" can't be performed while " + ApplicationNamesInfo.getInstance().getFullProductName() + " updates the indices in background.\n" +
|
||||
@@ -151,11 +148,11 @@ public class TodoCheckinHandler extends CheckinHandler {
|
||||
}
|
||||
return ReturnResult.COMMIT;
|
||||
}
|
||||
final Collection<Change> changes = myCheckinProjectPanel.getSelectedChanges();
|
||||
final TodoCheckinHandlerWorker worker = new TodoCheckinHandlerWorker(myProject, changes, myTodoFilter, true);
|
||||
Collection<Change> changes = myCheckinProjectPanel.getSelectedChanges();
|
||||
TodoCheckinHandlerWorker worker = new TodoCheckinHandlerWorker(myProject, changes, myTodoFilter, true);
|
||||
|
||||
final Ref<Boolean> completed = Ref.create(Boolean.FALSE);
|
||||
ProgressManager.getInstance().run(new Task.Modal(myProject, "Looking for new and edited TODO items...", true) {
|
||||
Ref<Boolean> completed = Ref.create(Boolean.FALSE);
|
||||
ProgressManager.getInstance().run(new Task.Modal(myProject, "Looking for New and Edited TODO Items...", true) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
indicator.setIndeterminate(true);
|
||||
@@ -173,13 +170,13 @@ public class TodoCheckinHandler extends CheckinHandler {
|
||||
return showResults(worker, executor);
|
||||
}
|
||||
|
||||
private ReturnResult showResults(final TodoCheckinHandlerWorker worker, CommitExecutor executor) {
|
||||
private ReturnResult showResults(TodoCheckinHandlerWorker worker, CommitExecutor executor) {
|
||||
String commitButtonText = executor != null ? executor.getActionText() : myCheckinProjectPanel.getCommitActionName();
|
||||
commitButtonText = StringUtil.trimEnd(commitButtonText, "...");
|
||||
|
||||
final String text = createMessage(worker);
|
||||
final String[] buttons;
|
||||
final boolean thereAreTodoFound = worker.getAddedOrEditedTodos().size() + worker.getInChangedTodos().size() > 0;
|
||||
String text = createMessage(worker);
|
||||
String[] buttons;
|
||||
boolean thereAreTodoFound = worker.getAddedOrEditedTodos().size() + worker.getInChangedTodos().size() > 0;
|
||||
int commitOption;
|
||||
if (thereAreTodoFound) {
|
||||
buttons = new String[]{VcsBundle.message("todo.in.new.review.button"), commitButtonText, CommonBundle.getCancelButtonText()};
|
||||
@@ -189,7 +186,7 @@ public class TodoCheckinHandler extends CheckinHandler {
|
||||
buttons = new String[]{commitButtonText, CommonBundle.getCancelButtonText()};
|
||||
commitOption = 0;
|
||||
}
|
||||
final int answer = Messages.showDialog(myProject, text, "TODO", null, buttons, 0, 1, UIUtil.getWarningIcon());
|
||||
int answer = Messages.showDialog(myProject, text, "TODO", null, buttons, 0, 1, UIUtil.getWarningIcon());
|
||||
if (thereAreTodoFound && answer == Messages.OK) {
|
||||
showTodo(worker);
|
||||
return ReturnResult.CLOSE_WINDOW;
|
||||
@@ -200,8 +197,8 @@ public class TodoCheckinHandler extends CheckinHandler {
|
||||
return ReturnResult.CANCEL;
|
||||
}
|
||||
|
||||
private void showTodo(final TodoCheckinHandlerWorker worker) {
|
||||
final String title = "For commit (" + DateFormatUtil.formatDateTime(System.currentTimeMillis()) + ")";
|
||||
private void showTodo(TodoCheckinHandlerWorker worker) {
|
||||
String title = "For commit (" + DateFormatUtil.formatDateTime(System.currentTimeMillis()) + ")";
|
||||
ServiceManager.getService(myProject, TodoView.class).addCustomTodoView(new TodoTreeBuilderFactory() {
|
||||
@Override
|
||||
public TodoTreeBuilder createTreeBuilder(JTree tree, DefaultTreeModel treeModel, Project project) {
|
||||
@@ -209,33 +206,27 @@ public class TodoCheckinHandler extends CheckinHandler {
|
||||
}
|
||||
}, title, new TodoPanelSettings(myConfiguration.myTodoPanelSettings));
|
||||
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final ToolWindowManager manager = ToolWindowManager.getInstance(myProject);
|
||||
if (manager != null) {
|
||||
final ToolWindow window = manager.getToolWindow("TODO");
|
||||
if (window != null) {
|
||||
window.show(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final ContentManager cm = window.getContentManager();
|
||||
final Content[] contents = cm.getContents();
|
||||
if (contents.length > 0) {
|
||||
cm.setSelectedContent(contents[contents.length - 1], true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
ToolWindowManager manager = ToolWindowManager.getInstance(myProject);
|
||||
if (manager != null) {
|
||||
ToolWindow window = manager.getToolWindow("TODO");
|
||||
if (window != null) {
|
||||
window.show(() -> {
|
||||
ContentManager cm = window.getContentManager();
|
||||
Content[] contents = cm.getContents();
|
||||
if (contents.length > 0) {
|
||||
cm.setSelectedContent(contents[contents.length - 1], true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, ModalityState.NON_MODAL, myProject.getDisposed());
|
||||
}
|
||||
|
||||
private static String createMessage(TodoCheckinHandlerWorker worker) {
|
||||
final int added = worker.getAddedOrEditedTodos().size();
|
||||
final int changed = worker.getInChangedTodos().size();
|
||||
final int skipped = worker.getSkipped().size();
|
||||
int added = worker.getAddedOrEditedTodos().size();
|
||||
int changed = worker.getInChangedTodos().size();
|
||||
int skipped = worker.getSkipped().size();
|
||||
if (added == 0 && changed == 0) {
|
||||
return VcsBundle.message("todo.handler.only.skipped", skipped);
|
||||
} else if (changed == 0) {
|
||||
|
||||
Reference in New Issue
Block a user