Search in sources :

Example 16 with DefaultTableModel

use of javax.swing.table.DefaultTableModel in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method cleanTable.

private void cleanTable() {
    DefaultTableModel dm = (DefaultTableModel) table.getModel();
    dm.getDataVector().removeAllElements();
    webAppWebAppDetailsMap.clear();
    dm.fireTableDataChanged();
}
Also used : DefaultTableModel(javax.swing.table.DefaultTableModel)

Example 17 with DefaultTableModel

use of javax.swing.table.DefaultTableModel in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method createUIComponents.

private void createUIComponents() {
    DefaultTableModel tableModel = new DefaultTableModel() {

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    tableModel.addColumn("Name");
    tableModel.addColumn("JDK");
    tableModel.addColumn("Web container");
    tableModel.addColumn("Resource group");
    table = new JBTable(tableModel);
    table.setRowSelectionAllowed(true);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent event) {
            if (event.getValueIsAdjusting())
                return;
            //System.out.println("row : " + table.getValueAt(table.getSelectedRow(), 0).toString());
            fillAppServiceDetails();
        }
    });
    AnActionButton refreshAction = new AnActionButton("Refresh", AllIcons.Actions.Refresh) {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            refreshAppServices();
        }
    };
    ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(table).setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            createAppService();
        }
    }).setRemoveAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            deleteAppService();
        }
    }).setRemoveActionUpdater(new AnActionButtonUpdater() {

        @Override
        public boolean isEnabled(AnActionEvent e) {
            return table.getSelectedRow() != -1;
        }
    }).disableUpDownActions().addExtraActions(refreshAction);
    panelTable = tableToolbarDecorator.createPanel();
}
Also used : AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) AnActionButtonUpdater(com.intellij.ui.AnActionButtonUpdater) DefaultTableModel(javax.swing.table.DefaultTableModel) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) JBTable(com.intellij.ui.table.JBTable) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnActionButton(com.intellij.ui.AnActionButton) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 18 with DefaultTableModel

use of javax.swing.table.DefaultTableModel in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method editAppService.

private void editAppService() {
    int selectedRow = table.getSelectedRow();
    if (selectedRow >= 0) {
        DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
        String appServiceName = (String) tableModel.getValueAt(selectedRow, 0);
        WebAppDetails wad = webAppWebAppDetailsMap.get(appServiceName);
        AppServiceChangeSettingsDialog d = AppServiceChangeSettingsDialog.go(wad, project);
        if (d == null) {
            // something went wrong - report an error!
            return;
        }
        WebApp wa = d.getWebApp();
        doFillTable();
        selectTableRowWithWebAppName(wa.name());
    }
//fillAppServiceDetails();
}
Also used : WebAppDetails(com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails) DefaultTableModel(javax.swing.table.DefaultTableModel) WebApp(com.microsoft.azure.management.appservice.WebApp)

Example 19 with DefaultTableModel

use of javax.swing.table.DefaultTableModel in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method fillAppServiceDetails.

private void fillAppServiceDetails() {
    DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
    int selectedRow = table.getSelectedRow();
    if (selectedRow >= 0) {
        String appServiceName = (String) tableModel.getValueAt(selectedRow, 0);
        WebAppDetails wad = webAppWebAppDetailsMap.get(appServiceName);
        SubscriptionDetail sd = wad.subscriptionDetail;
        AppServicePlan asp = wad.appServicePlan;
        StringBuilder sb = new StringBuilder();
        sb.append("<div style=\"margin: 7px 7px 7px 7px;\">");
        sb.append(String.format("App Service Name:&nbsp;<b>%s</b><br/>", appServiceName));
        sb.append(String.format("Subscription Name:&nbsp;<b>%s</b>;&nbsp;ID:&nbsp;<b>%s</b><br/>", sd.getSubscriptionName(), sd.getSubscriptionId()));
        String aspName = asp == null ? "N/A" : asp.name();
        String aspPricingTier = asp == null ? "N/A" : asp.pricingTier().toString();
        sb.append(String.format("App Service Plan Name:&nbsp;<b>%s</b>;&nbsp;Pricing Tier:&nbsp;<b>%s</b><br/>", aspName, aspPricingTier));
        String link = buildSiteLink(wad.webApp, null);
        sb.append(String.format("Link:&nbsp;<a href=\"%s\">%s</a>", link, link));
        sb.append("</div>");
        editorPaneAppServiceDetails.setText(sb.toString());
    }
//        listWebAppDetails.setModel(listModel);
}
Also used : WebAppDetails(com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails) DefaultTableModel(javax.swing.table.DefaultTableModel) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) AppServicePlan(com.microsoft.azure.management.appservice.AppServicePlan)

Example 20 with DefaultTableModel

use of javax.swing.table.DefaultTableModel in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method doValidate.

@Nullable
@Override
protected ValidationInfo doValidate() {
    int selectedRow = table.getSelectedRow();
    if (selectedRow < 0) {
        return new ValidationInfo("Please select an App Service to deploy to", table);
    }
    DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
    WebAppDetails wad = webAppWebAppDetailsMap.get(tableModel.getValueAt(selectedRow, 0));
    if (wad.webApp.javaVersion() == JavaVersion.OFF) {
        return new ValidationInfo("Please select java based App Service", table);
    }
    return super.doValidate();
}
Also used : WebAppDetails(com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails) ValidationInfo(com.intellij.openapi.ui.ValidationInfo) DefaultTableModel(javax.swing.table.DefaultTableModel) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

DefaultTableModel (javax.swing.table.DefaultTableModel)119 Vector (java.util.Vector)12 JTable (javax.swing.JTable)12 JBTable (com.intellij.ui.table.JBTable)10 Dimension (java.awt.Dimension)9 JScrollPane (javax.swing.JScrollPane)9 TableColumn (javax.swing.table.TableColumn)9 ActionEvent (java.awt.event.ActionEvent)7 JButton (javax.swing.JButton)7 JPanel (javax.swing.JPanel)7 ListSelectionEvent (javax.swing.event.ListSelectionEvent)7 ListSelectionListener (javax.swing.event.ListSelectionListener)7 WebAppDetails (com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails)6 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)5 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 DockerHost (com.microsoft.azure.docker.model.DockerHost)5 EditableDockerHost (com.microsoft.azure.docker.model.EditableDockerHost)5 Color (java.awt.Color)5 ActionListener (java.awt.event.ActionListener)5