use of com.intellij.util.ui.ListTableModel in project azure-tools-for-java by Microsoft.
the class ActivityLogToolWindowFactory method createToolWindowContent.
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {
this.project = project;
table = new TableView<DeploymentTableItem>(new ListTableModel<DeploymentTableItem>(DESC, PROGRESS, STATUS, START_TIME));
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
// add mouse listener for links in table
table.addMouseListener(createTableMouseListener());
toolWindow.getComponent().add(new JBScrollPane(table));
registerDeploymentListener();
}
use of com.intellij.util.ui.ListTableModel in project intellij-community by JetBrains.
the class EnvVariablesTable method createListModel.
@Override
protected ListTableModel createListModel() {
final ColumnInfo name = new ElementsColumnInfoBase<EnvironmentVariable>("Name") {
@Override
public String valueOf(EnvironmentVariable environmentVariable) {
return environmentVariable.getName();
}
@Override
public boolean isCellEditable(EnvironmentVariable environmentVariable) {
return environmentVariable.getNameIsWriteable();
}
@Override
public void setValue(EnvironmentVariable environmentVariable, String s) {
if (s.equals(valueOf(environmentVariable))) {
return;
}
environmentVariable.setName(s);
setModified();
}
@Override
protected String getDescription(EnvironmentVariable environmentVariable) {
return environmentVariable.getDescription();
}
};
final ColumnInfo value = new ElementsColumnInfoBase<EnvironmentVariable>("Value") {
@Override
public String valueOf(EnvironmentVariable environmentVariable) {
return environmentVariable.getValue();
}
@Override
public boolean isCellEditable(EnvironmentVariable environmentVariable) {
return !environmentVariable.getIsPredefined();
}
@Override
public void setValue(EnvironmentVariable environmentVariable, String s) {
if (s.equals(valueOf(environmentVariable))) {
return;
}
environmentVariable.setValue(s);
setModified();
}
@Nullable
@Override
protected String getDescription(EnvironmentVariable environmentVariable) {
return environmentVariable.getDescription();
}
@Nullable
@Override
public TableCellEditor getEditor(EnvironmentVariable variable) {
StringWithNewLinesCellEditor editor = new StringWithNewLinesCellEditor();
editor.setClickCountToStart(1);
return editor;
}
};
return new ListTableModel((new ColumnInfo[] { name, value }));
}
use of com.intellij.util.ui.ListTableModel in project intellij-community by JetBrains.
the class TableToolbarDecorator method createDefaultTableActions.
private void createDefaultTableActions(@Nullable final ElementProducer<?> producer) {
final JTable table = myTable;
final EditableModel tableModel = (EditableModel) table.getModel();
myAddAction = new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
TableUtil.stopEditing(table);
final int rowCount = table.getRowCount();
if (tableModel instanceof ListTableModel && producer != null) {
//noinspection unchecked
((ListTableModel) tableModel).addRow(producer.createElement());
} else {
tableModel.addRow();
}
if (rowCount == table.getRowCount())
return;
final int index = table.getModel().getRowCount() - 1;
table.setRowSelectionInterval(index, index);
table.setColumnSelectionInterval(0, 0);
table.editCellAt(index, 0);
TableUtil.updateScroller(table);
//noinspection SSBasedInspection
SwingUtilities.invokeLater(() -> {
final Component editorComponent = table.getEditorComponent();
if (editorComponent != null) {
final Rectangle bounds = editorComponent.getBounds();
table.scrollRectToVisible(bounds);
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(editorComponent, true);
});
}
});
}
};
myRemoveAction = new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
if (TableUtil.doRemoveSelectedItems(table, tableModel, null)) {
updateButtons();
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(table, true);
});
TableUtil.updateScroller(table);
}
}
};
class MoveRunnable implements AnActionButtonRunnable {
final int delta;
MoveRunnable(int delta) {
this.delta = delta;
}
@Override
public void run(AnActionButton button) {
int row = table.getEditingRow();
int col = table.getEditingColumn();
TableUtil.stopEditing(table);
int[] idx = table.getSelectedRows();
Arrays.sort(idx);
if (delta > 0) {
idx = ArrayUtil.reverseArray(idx);
}
if (idx.length == 0)
return;
if (idx[0] + delta < 0)
return;
if (idx[idx.length - 1] + delta > table.getModel().getRowCount())
return;
for (int i = 0; i < idx.length; i++) {
tableModel.exchangeRows(idx[i], idx[i] + delta);
idx[i] += delta;
}
TableUtil.selectRows(table, idx);
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(table, true);
});
if (row > 0 && col != -1) {
table.editCellAt(row - 1, col);
}
}
}
myUpAction = new MoveRunnable(-1);
myDownAction = new MoveRunnable(1);
}
use of com.intellij.util.ui.ListTableModel in project intellij-community by JetBrains.
the class DualView method createFlatComponent.
private Component createFlatComponent(DualViewColumnInfo[] columns) {
ArrayList<ColumnInfo> shownColumns = new ArrayList<>();
for (DualViewColumnInfo column : columns) {
if (column.shouldBeShownIsTheTable()) {
shownColumns.add(column);
}
}
ListTableModel flatModel = new ListTableModel(shownColumns.toArray(new ColumnInfo[shownColumns.size()]));
//noinspection unchecked
myFlatView = new TableView(flatModel) {
public TableCellRenderer getCellRenderer(int row, int column) {
return createWrappedRenderer(super.getCellRenderer(row, column));
}
@NotNull
@Override
public Component prepareRenderer(@NotNull TableCellRenderer renderer, int row, int column) {
final Component c = super.prepareRenderer(renderer, row, column);
if (c instanceof JComponent && !myFlatView.getCellSelectionEnabled()) {
((JComponent) c).setBorder(null);
}
return c;
}
@Override
public void doLayout() {
try {
mySuppressStore = true;
super.doLayout();
} finally {
mySuppressStore = false;
}
}
@Override
public void updateColumnSizes() {
// suppress automatic layout, use stored values instead
}
};
myFlatView.setCellSelectionEnabled(false);
myFlatView.setColumnSelectionAllowed(false);
myFlatView.setRowSelectionAllowed(true);
refreshFlatModel();
JPanel result = new JPanel(new BorderLayout());
result.add(ScrollPaneFactory.createScrollPane(myFlatView), BorderLayout.CENTER);
return result;
}
use of com.intellij.util.ui.ListTableModel in project intellij-community by JetBrains.
the class PathMappingTable method createListModel.
@Override
protected ListTableModel createListModel() {
ColumnInfo local = new ElementsColumnInfoBase<PathMappingSettings.PathMapping>("Local path") {
@Override
public String valueOf(PathMappingSettings.PathMapping pathMapping) {
return pathMapping.getLocalRoot();
}
@Override
public boolean isCellEditable(PathMappingSettings.PathMapping pathMapping) {
return canDeleteElement(pathMapping);
}
@Override
public void setValue(PathMappingSettings.PathMapping pathMapping, String s) {
if (s.equals(valueOf(pathMapping))) {
return;
}
pathMapping.setLocalRoot(s);
setModified();
}
@Override
protected String getDescription(PathMappingSettings.PathMapping pathMapping) {
return valueOf(pathMapping);
}
};
ColumnInfo remote = new ElementsColumnInfoBase<PathMappingSettings.PathMapping>("Remote path") {
@Override
public String valueOf(PathMappingSettings.PathMapping pathMapping) {
return pathMapping.getRemoteRoot();
}
@Override
public boolean isCellEditable(PathMappingSettings.PathMapping pathMapping) {
return canDeleteElement(pathMapping);
}
@Override
public void setValue(PathMappingSettings.PathMapping pathMapping, String s) {
if (s.equals(valueOf(pathMapping))) {
return;
}
pathMapping.setRemoteRoot(s);
setModified();
}
@Override
protected String getDescription(PathMappingSettings.PathMapping pathMapping) {
return valueOf(pathMapping);
}
};
return new ListTableModel((new ColumnInfo[] { local, remote }));
}
Aggregations