Search in sources :

Example 26 with DefaultTableModel

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);
            }
        }
    });
}
Also used : BlobItem(com.microsoft.tooling.msservices.model.storage.BlobItem) Task(com.intellij.openapi.progress.Task) BlobDirectory(com.microsoft.tooling.msservices.model.storage.BlobDirectory) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) BlobFile(com.microsoft.tooling.msservices.model.storage.BlobFile) DefaultTableModel(javax.swing.table.DefaultTableModel) SimpleDateFormat(java.text.SimpleDateFormat)

Example 27 with DefaultTableModel

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;
}
Also used : DefaultTableModel(javax.swing.table.DefaultTableModel) JTableHeader(javax.swing.table.JTableHeader)

Example 28 with DefaultTableModel

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");
    }
}
Also used : AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) DefaultTableModel(javax.swing.table.DefaultTableModel) SubscriptionManager(com.microsoft.azuretools.authmanage.SubscriptionManager)

Example 29 with DefaultTableModel

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DefaultTableModel(javax.swing.table.DefaultTableModel) JBTable(com.intellij.ui.table.JBTable) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) JBLabel(com.intellij.ui.components.JBLabel) List(java.util.List)

Example 30 with DefaultTableModel

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DefaultTableModel(javax.swing.table.DefaultTableModel) JBTable(com.intellij.ui.table.JBTable) JBLabel(com.intellij.ui.components.JBLabel) List(java.util.List)

Aggregations

DefaultTableModel (javax.swing.table.DefaultTableModel)139 JTable (javax.swing.JTable)18 Dimension (java.awt.Dimension)14 Vector (java.util.Vector)14 JScrollPane (javax.swing.JScrollPane)14 TableColumn (javax.swing.table.TableColumn)12 JBTable (com.intellij.ui.table.JBTable)10 Point (java.awt.Point)10 ActionEvent (java.awt.event.ActionEvent)9 JPanel (javax.swing.JPanel)9 ListSelectionEvent (javax.swing.event.ListSelectionEvent)9 ListSelectionListener (javax.swing.event.ListSelectionListener)9 JButton (javax.swing.JButton)8 ActionListener (java.awt.event.ActionListener)7 WebAppDetails (com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails)6 Color (java.awt.Color)6 ArrayList (java.util.ArrayList)6 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)5 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5