use of com.intellij.ide.todo.TodoFilter in project intellij-community by JetBrains.
the class TodoConfigurable method areFiltersModified.
protected boolean areFiltersModified() {
TodoConfiguration todoConfiguration = TodoConfiguration.getInstance();
TodoFilter[] initialFilters = todoConfiguration.getTodoFilters();
if (initialFilters.length != myFilters.size()) {
return true;
}
for (TodoFilter initialFilter : initialFilters) {
if (!myFilters.contains(initialFilter)) {
return true;
}
}
return false;
}
use of com.intellij.ide.todo.TodoFilter in project intellij-community by JetBrains.
the class TodoConfigurable method reset.
@Override
public void reset() {
// Patterns
myPatterns.clear();
TodoConfiguration todoConfiguration = TodoConfiguration.getInstance();
TodoPattern[] patterns = getTodoPatternsToDisplay(todoConfiguration);
for (TodoPattern pattern : patterns) {
myPatterns.add(pattern.clone());
}
myPatternsModel.fireTableDataChanged();
// Filters
myFilters.clear();
TodoFilter[] filters = todoConfiguration.getTodoFilters();
for (TodoFilter filter : filters) {
myFilters.add(filter.clone());
}
myFiltersModel.fireTableDataChanged();
}
use of com.intellij.ide.todo.TodoFilter in project intellij-community by JetBrains.
the class TodoConfigurable method editSelectedPattern.
private void editSelectedPattern() {
stopEditing();
int selectedIndex = myPatternsTable.getSelectedRow();
if (selectedIndex < 0 || selectedIndex >= myPatternsModel.getRowCount()) {
return;
}
TodoPattern sourcePattern = myPatterns.get(selectedIndex);
TodoPattern pattern = sourcePattern.clone();
PatternDialog dialog = new PatternDialog(myPanel, pattern);
dialog.setTitle(IdeBundle.message("title.edit.todo.pattern"));
if (!dialog.showAndGet()) {
return;
}
myPatterns.set(selectedIndex, pattern);
myPatternsModel.fireTableRowsUpdated(selectedIndex, selectedIndex);
myPatternsTable.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
// Update model with patterns
for (int i = 0; i < myFilters.size(); i++) {
TodoFilter filter = myFilters.get(i);
if (filter.contains(sourcePattern)) {
filter.removeTodoPattern(sourcePattern);
filter.addTodoPattern(pattern);
myFiltersModel.fireTableRowsUpdated(i, i);
}
}
}
use of com.intellij.ide.todo.TodoFilter in project intellij-community by JetBrains.
the class TodoConfigurable method createComponent.
@Override
public JComponent createComponent() {
myPatternsTable = new JBTable(myPatternsModel);
myPatternsTable.getEmptyText().setText(IdeBundle.message("text.todo.no.patterns"));
TableColumn typeColumn = myPatternsTable.getColumnModel().getColumn(0);
int width = myPatternsTable.getFontMetrics(myPatternsTable.getFont()).stringWidth(myPatternsTable.getColumnName(0)) + 10;
typeColumn.setPreferredWidth(width);
typeColumn.setMaxWidth(width);
typeColumn.setMinWidth(width);
typeColumn.setCellRenderer(new IconTableCellRenderer<Icon>() {
@Nullable
@Override
protected Icon getIcon(@NotNull Icon value, JTable table, int row) {
return value;
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean focus, int row, int column) {
super.getTableCellRendererComponent(table, value, selected, focus, row, column);
setText("");
return this;
}
@Override
protected boolean isCenterAlignment() {
return true;
}
});
// Column "Case Sensitive"
TableColumn todoCaseSensitiveColumn = myPatternsTable.getColumnModel().getColumn(1);
width = myPatternsTable.getFontMetrics(myPatternsTable.getFont()).stringWidth(myPatternsTable.getColumnName(1)) + 10;
todoCaseSensitiveColumn.setPreferredWidth(width);
todoCaseSensitiveColumn.setMaxWidth(width);
todoCaseSensitiveColumn.setMinWidth(width);
todoCaseSensitiveColumn.setCellRenderer(new BooleanTableCellRenderer());
todoCaseSensitiveColumn.setCellEditor(new BooleanTableCellEditor());
// Column "Pattern"
TodoPatternTableCellRenderer todoPatternRenderer = new TodoPatternTableCellRenderer(myPatterns);
TableColumn patternColumn = myPatternsTable.getColumnModel().getColumn(2);
patternColumn.setCellRenderer(todoPatternRenderer);
JPanel patternsPanel = new JPanel(new BorderLayout());
patternsPanel.setBorder(IdeBorderFactory.createTitledBorder(IdeBundle.message("label.todo.patterns"), false));
patternsPanel.add(ToolbarDecorator.createDecorator(myPatternsTable).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
stopEditing();
TodoPattern pattern = new TodoPattern(TodoAttributesUtil.createDefault());
PatternDialog dialog = new PatternDialog(myPanel, pattern);
if (!dialog.showAndGet()) {
return;
}
myPatterns.add(pattern);
int index = myPatterns.size() - 1;
myPatternsModel.fireTableRowsInserted(index, index);
myPatternsTable.getSelectionModel().setSelectionInterval(index, index);
myPatternsTable.scrollRectToVisible(myPatternsTable.getCellRect(index, 0, true));
}
}).setEditAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
editSelectedPattern();
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
stopEditing();
int selectedIndex = myPatternsTable.getSelectedRow();
if (selectedIndex < 0 || selectedIndex >= myPatternsModel.getRowCount()) {
return;
}
TodoPattern patternToBeRemoved = myPatterns.get(selectedIndex);
TableUtil.removeSelectedItems(myPatternsTable);
for (int i = 0; i < myFilters.size(); i++) {
TodoFilter filter = myFilters.get(i);
if (filter.contains(patternToBeRemoved)) {
filter.removeTodoPattern(patternToBeRemoved);
myFiltersModel.fireTableRowsUpdated(i, i);
}
}
}
}).disableUpDownActions().createPanel(), BorderLayout.CENTER);
// double click in "Patterns" table should also start editing of selected pattern
new DoubleClickListener() {
@Override
protected boolean onDoubleClick(MouseEvent e) {
editSelectedPattern();
return true;
}
}.installOn(myPatternsTable);
// Panel with filters
myFiltersTable = new JBTable(myFiltersModel);
myFiltersTable.getEmptyText().setText(IdeBundle.message("text.todo.no.filters"));
// Column "Name"
TableColumn nameColumn = myFiltersTable.getColumnModel().getColumn(0);
width = myPatternsTable.getColumnModel().getColumn(0).getPreferredWidth() + /*typeColumn*/
myPatternsTable.getColumnModel().getColumn(1).getPreferredWidth();
nameColumn.setPreferredWidth(width);
nameColumn.setMaxWidth(width);
nameColumn.setMinWidth(width);
nameColumn.setCellRenderer(new MyFilterNameTableCellRenderer());
JPanel filtersPanel = new JPanel(new BorderLayout());
filtersPanel.setBorder(IdeBorderFactory.createTitledBorder(IdeBundle.message("label.todo.filters"), false));
filtersPanel.add(ToolbarDecorator.createDecorator(myFiltersTable).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
stopEditing();
TodoFilter filter = new TodoFilter();
FilterDialog dialog = new FilterDialog(myPanel, filter, -1, myFilters, myPatterns);
if (dialog.showAndGet()) {
myFilters.add(filter);
int index = myFilters.size() - 1;
myFiltersModel.fireTableRowsInserted(index, index);
myFiltersTable.getSelectionModel().setSelectionInterval(index, index);
myFiltersTable.scrollRectToVisible(myFiltersTable.getCellRect(index, 0, true));
}
}
}).setEditAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
editSelectedFilter();
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
stopEditing();
TableUtil.removeSelectedItems(myFiltersTable);
}
}).disableUpDownActions().createPanel());
new DoubleClickListener() {
@Override
protected boolean onDoubleClick(MouseEvent e) {
editSelectedFilter();
return true;
}
}.installOn(myFiltersTable);
myPanel = FormBuilder.createFormBuilder().addComponentFillVertically(patternsPanel, 0).addComponentFillVertically(filtersPanel, 0).getPanel();
return myPanel;
}
use of com.intellij.ide.todo.TodoFilter in project intellij-community by JetBrains.
the class TodoConfigurable method editSelectedFilter.
private void editSelectedFilter() {
stopEditing();
int selectedIndex = myFiltersTable.getSelectedRow();
if (selectedIndex < 0 || selectedIndex >= myFiltersModel.getRowCount()) {
return;
}
TodoFilter sourceFilter = myFilters.get(selectedIndex);
TodoFilter filter = sourceFilter.clone();
FilterDialog dialog = new FilterDialog(myPanel, filter, selectedIndex, myFilters, myPatterns);
dialog.setTitle(IdeBundle.message("title.edit.todo.filter"));
dialog.show();
int exitCode = dialog.getExitCode();
if (DialogWrapper.OK_EXIT_CODE == exitCode) {
myFilters.set(selectedIndex, filter);
myFiltersModel.fireTableRowsUpdated(selectedIndex, selectedIndex);
myFiltersTable.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
}
}
Aggregations