[groovy] remove unused TableWithButtons form

GitOrigin-RevId: 6d3e7730c122e263521ea0cf43565cac88325f1b
This commit is contained in:
Daniil Ovchinnikov
2019-06-16 07:46:44 +03:00
committed by intellij-monorepo-bot
parent 4dd42d26d8
commit cb4db2d304
2 changed files with 0 additions and 201 deletions
@@ -1,73 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.groovy.refactoring.changeSignature.TableWithButtons">
<grid id="27dc6" binding="myPanel" default-binding="true" layout-manager="GridLayoutManager" row-count="1" 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="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="62945" layout-manager="GridLayoutManager" row-count="5" 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>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="f238f" class="javax.swing.JButton" binding="myAddButton" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&amp;Add"/>
</properties>
</component>
<component id="b1e3d" class="javax.swing.JButton" binding="myRemoveButton" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="R&amp;emove"/>
</properties>
</component>
<component id="8d490" class="javax.swing.JButton" binding="myMoveUpButton" default-binding="true">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Move &amp;Up"/>
</properties>
</component>
<component id="da3fc" class="javax.swing.JButton" binding="myMoveDownButton" default-binding="true">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Move &amp;Down"/>
</properties>
</component>
<vspacer id="6a705">
<constraints>
<grid row="4" 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>
</children>
</grid>
<scrollpane class="com.intellij.ui.components.JBScrollPane" id="7781a">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="14778" class="com.intellij.ui.table.JBTable" binding="myTable" custom-create="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
</children>
</grid>
</form>
@@ -1,128 +0,0 @@
/*
* Copyright 2000-2017 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 org.jetbrains.plugins.groovy.refactoring.changeSignature;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.ui.RowEditableTableModel;
import com.intellij.ui.table.JBTable;
import javax.swing.*;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* @author Maxim.Medvedev
*/
public abstract class TableWithButtons {
public TableWithButtons(RowEditableTableModel model) {
myModel = model;
myAddButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int selectedColumn = myTable.getSelectedColumn();
if (selectedColumn < 0) selectedColumn = 0;
myModel.addRow();
myTable.setRowSelectionInterval(myModel.getRowCount() - 1, myModel.getRowCount() - 1);
myTable.setColumnSelectionInterval(selectedColumn, selectedColumn);
innerUpdate();
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myTable, true));
}
});
myRemoveButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int selectedRow = myTable.getSelectedRow();
int selectedColumn = myTable.getSelectedColumn();
myModel.removeRow(myTable.getSelectedRow());
if (selectedRow == myModel.getRowCount()) selectedRow--;
if (myModel.getRowCount() == 0) return;
myTable.setRowSelectionInterval(selectedRow, selectedRow);
myTable.setColumnSelectionInterval(selectedColumn, selectedColumn);
innerUpdate();
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myTable, true));
}
});
myMoveUpButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final int selectedRow = myTable.getSelectedRow();
int selectedColumn = myTable.getSelectedColumn();
myModel.exchangeRows(selectedRow, selectedRow - 1);
myTable.setRowSelectionInterval(selectedRow - 1, selectedRow - 1);
myTable.setColumnSelectionInterval(selectedColumn, selectedColumn);
innerUpdate();
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myTable, true));
}
});
myMoveDownButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final int selectedRow = myTable.getSelectedRow();
int selectedColumn = myTable.getSelectedColumn();
myModel.exchangeRows(selectedRow, selectedRow + 1);
myTable.setRowSelectionInterval(selectedRow + 1, selectedRow + 1);
myTable.setColumnSelectionInterval(selectedColumn, selectedColumn);
innerUpdate();
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myTable, true));
}
});
myModel.addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
innerUpdate();
}
});
}
private final RowEditableTableModel myModel;
private JPanel myPanel;
private JButton myAddButton;
private JButton myRemoveButton;
private JButton myMoveUpButton;
private JButton myMoveDownButton;
private JBTable myTable;
private void createUIComponents() {
myTable = new JBTable(myModel);
myTable.setPreferredScrollableViewportSize(new Dimension(450, myTable.getRowHeight() * 8));
}
private void innerUpdate() {
final int selectedRow = myTable.getSelectedRow();
final int rowCount = myModel.getRowCount();
myMoveUpButton.setEnabled(selectedRow > 0);
myMoveDownButton.setEnabled(selectedRow + 1 < rowCount && rowCount > 1);
myRemoveButton.setEnabled(rowCount > 0);
update();
}
protected abstract void update();
public JBTable getTable() {
return myTable;
}
public JPanel getPanel() {
return myPanel;
}
}