use of javax.swing.table.DefaultTableModel in project azure-tools-for-java by Microsoft.
the class BlobExplorerFileEditor method fillGrid.
public void fillGrid() {
setUIState(true);
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Loading blobs...", false) {
@Override
public void run(@NotNull ProgressIndicator progressIndicator) {
try {
progressIndicator.setIndeterminate(true);
if (directoryQueue.peekLast() == null) {
directoryQueue.addLast(StorageClientSDKManager.getManager().getRootDirectory(connectionString, blobContainer));
}
blobItems = StorageClientSDKManager.getManager().getBlobItems(connectionString, directoryQueue.peekLast());
if (!queryTextField.getText().isEmpty()) {
for (int i = blobItems.size() - 1; i >= 0; i--) {
BlobItem blobItem = blobItems.get(i);
if (blobItem instanceof BlobFile && !blobItem.getName().startsWith(queryTextField.getText())) {
blobItems.remove(i);
}
}
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
pathLabel.setText(directoryQueue.peekLast().getPath());
DefaultTableModel model = (DefaultTableModel) blobListTable.getModel();
while (model.getRowCount() > 0) {
model.removeRow(0);
}
for (BlobItem blobItem : blobItems) {
if (blobItem instanceof BlobDirectory) {
model.addRow(new Object[] { UIHelperImpl.loadIcon("storagefolder.png"), blobItem.getName(), "", "", "", blobItem.getUri() });
} else {
BlobFile blobFile = (BlobFile) blobItem;
model.addRow(new String[] { "", blobFile.getName(), UIHelperImpl.readableFileSize(blobFile.getSize()), new SimpleDateFormat().format(blobFile.getLastModified().getTime()), blobFile.getContentType(), blobFile.getUri() });
}
}
setUIState(false);
blobListTable.clearSelection();
}
});
} catch (AzureCmdException ex) {
String msg = "An error occurred while attempting to query blob list." + "\n" + String.format(message("webappExpMsg"), ex.getMessage());
PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, ex);
}
}
});
}
use of javax.swing.table.DefaultTableModel in project druid by alibaba.
the class RowHeaderRenderer method getTableCellRendererComponent.
public Component getTableCellRendererComponent(JTable table, Object obj, boolean isSelected, boolean hasFocus, int row, int col) {
int rowCountNow = refTable.getRowCount() / rowSpan;
((DefaultTableModel) table.getModel()).setRowCount(rowCountNow);
JTableHeader header = refTable.getTableHeader();
this.setOpaque(true);
// 设置为TableHeader的边框类型
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
// 让text居中显示
setHorizontalAlignment(CENTER);
// 设置背景色为TableHeader的背景色
setBackground(header.getBackground());
if (// 当选取单元格时,在row header上设置成选取颜色
isSelect(row)) {
setForeground(Color.white);
setBackground(Color.lightGray);
} else {
setForeground(header.getForeground());
}
setFont(header.getFont());
if (row <= rowCountNow) {
showCol(row);
}
return this;
}
use of javax.swing.table.DefaultTableModel in project azure-tools-for-java by Microsoft.
the class SubscriptionsDialog method refreshSubscriptions.
private void refreshSubscriptions() {
try {
AzureManager manager = AuthMethodManager.getInstance().getAzureManager();
if (manager == null) {
return;
}
final SubscriptionManager subscriptionManager = manager.getSubscriptionManager();
subscriptionManager.cleanSubscriptions();
DefaultTableModel dm = (DefaultTableModel) table.getModel();
dm.getDataVector().removeAllElements();
dm.fireTableDataChanged();
SelectSubscriptionsAction.updateSubscriptionWithProgressDialog(subscriptionManager, project);
//System.out.println("refreshSubscriptions: calling getSubscriptionDetails()");
sdl = subscriptionManager.getSubscriptionDetails();
setSubscriptions();
// to notify subscribers
subscriptionManager.setSubscriptionDetails(sdl);
} catch (Exception ex) {
ex.printStackTrace();
//LOGGER.error("refreshSubscriptions", ex);
ErrorWindow.show(project, ex.getMessage(), "Refresh Subscriptions Error");
}
}
use of javax.swing.table.DefaultTableModel in project intellij-community by JetBrains.
the class JavadocEditor method createComponentImpl.
@Override
public JComponent createComponentImpl() {
final DefaultTableModel tableModel = createModel();
myTable = new JBTable(tableModel);
myTable.setIntercellSpacing(new Dimension(0, 0));
myTable.setDefaultRenderer(TableItem.class, new MyRenderer());
myTable.setShowGrid(false);
myTable.setDragEnabled(false);
myTable.setShowHorizontalLines(false);
myTable.setShowVerticalLines(false);
myTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
JPanel tablePanel = ToolbarDecorator.createDecorator(myTable).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
FileChooserDescriptor myDescriptor = FileChooserDescriptorFactory.createMultipleJavaPathDescriptor();
myDescriptor.setTitle(ProjectBundle.message("module.javadoc.add.path.title"));
myDescriptor.setDescription(ProjectBundle.message("module.javadoc.add.path.prompt"));
VirtualFile[] files = FileChooser.chooseFiles(myDescriptor, myTable, myProject, null);
final MyTableModel tableModel = (MyTableModel) myTable.getModel();
boolean changes = false;
for (final VirtualFile file : files) {
if (file != null) {
tableModel.addTableItem(new TableItem(file));
changes = true;
}
}
if (changes) {
saveData();
TableUtil.selectRows(myTable, new int[] { tableModel.getRowCount() - 1 });
}
}
}).addExtraAction(new DumbAwareActionButton(ProjectBundle.message("module.javadoc.add.url.button"), IconUtil.getAddLinkIcon()) {
@Override
public void actionPerformed(AnActionEvent e) {
VirtualFile[] files = new VirtualFile[] { Util.showSpecifyJavadocUrlDialog(myTable) };
final MyTableModel tableModel = (MyTableModel) myTable.getModel();
boolean changes = false;
for (final VirtualFile file : files) {
if (file != null) {
tableModel.addTableItem(new TableItem(file));
changes = true;
}
}
if (changes) {
saveData();
TableUtil.selectRows(myTable, new int[] { tableModel.getRowCount() - 1 });
}
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final List removedItems = TableUtil.removeSelectedItems(myTable);
if (removedItems.size() > 0) {
saveData();
}
}
}).setButtonComparator("Add", ProjectBundle.message("module.javadoc.add.url.button"), "Remove").createPanel();
final JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.add(tablePanel, BorderLayout.CENTER);
mainPanel.add(new JBLabel(ProjectBundle.message("project.roots.javadoc.tab.description"), UIUtil.ComponentStyle.SMALL, UIUtil.FontColor.BRIGHTER), BorderLayout.NORTH);
return mainPanel;
}
use of javax.swing.table.DefaultTableModel in project intellij-community by JetBrains.
the class AnnotationsEditor method createComponentImpl.
@Override
public JComponent createComponentImpl() {
final DefaultTableModel tableModel = createModel();
myTable = new JBTable(tableModel);
myTable.setIntercellSpacing(new Dimension(0, 0));
myTable.setDefaultRenderer(TableItem.class, new MyRenderer());
myTable.setShowGrid(false);
myTable.setDragEnabled(false);
myTable.setShowHorizontalLines(false);
myTable.setShowVerticalLines(false);
myTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
JPanel tablePanel = ToolbarDecorator.createDecorator(myTable).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
FileChooserDescriptor myDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
myDescriptor.setTitle(ProjectBundle.message("add.external.annotations.path.title"));
myDescriptor.setDescription(ProjectBundle.message("add.external.annotations.path.description"));
VirtualFile[] files = FileChooser.chooseFiles(myDescriptor, myTable, myProject, null);
final MyTableModel tableModel = (MyTableModel) myTable.getModel();
boolean changes = false;
for (final VirtualFile file : files) {
if (file != null) {
tableModel.addTableItem(new TableItem(file));
changes = true;
}
}
if (changes) {
saveData();
TableUtil.selectRows(myTable, new int[] { tableModel.getRowCount() - 1 });
}
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final List removedItems = TableUtil.removeSelectedItems(myTable);
if (removedItems.size() > 0) {
saveData();
}
}
}).createPanel();
final JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.add(tablePanel, BorderLayout.CENTER);
mainPanel.add(new JBLabel(ProjectBundle.message("project.roots.external.annotations.description"), UIUtil.ComponentStyle.SMALL, UIUtil.FontColor.BRIGHTER), BorderLayout.NORTH);
return mainPanel;
}
Aggregations