Search in sources :

Example 6 with ToolbarDecorator

use of com.intellij.ui.ToolbarDecorator in project azure-tools-for-java by Microsoft.

the class SettingPanel method createUIComponents.

private void createUIComponents() {
    containerSettingPanel = new ContainerSettingPanel(project);
    // create table of Web App on Linux
    final DefaultTableModel tableModel = new DefaultTableModel() {

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    tableModel.addColumn(TABLE_HEAD_WEB_APP_NAME);
    tableModel.addColumn(TABLE_HEAD_RESOURCE_GROUP);
    webAppTable = new JBTable(tableModel);
    webAppTable.getEmptyText().setText(TABLE_LOADING_MESSAGE);
    webAppTable.setRowSelectionAllowed(true);
    webAppTable.setDragEnabled(false);
    webAppTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    webAppTable.getSelectionModel().addListSelectionListener(event -> {
        final int index = webAppTable.getSelectedRow();
        if (cachedWebAppList != null && index >= 0 && index < cachedWebAppList.size()) {
            textSelectedAppName.setText(cachedWebAppList.get(webAppTable.getSelectedRow()).name());
        }
    });
    btnRefresh = new AnActionButton("Refresh", AllIcons.Actions.Refresh) {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            btnRefresh.setEnabled(false);
            webAppTable.getEmptyText().setText(TABLE_LOADING_MESSAGE);
            final DefaultTableModel model = (DefaultTableModel) webAppTable.getModel();
            model.getDataVector().clear();
            model.fireTableDataChanged();
            textSelectedAppName.setText("");
            webAppOnLinuxDeployPresenter.onRefreshList();
        }
    };
    final ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(webAppTable).addExtraActions(btnRefresh).setToolbarPosition(ActionToolbarPosition.TOP);
    pnlWebAppOnLinuxTable = tableToolbarDecorator.createPanel();
}
Also used : ContainerSettingPanel(com.microsoft.azure.toolkit.intellij.webapp.docker.ContainerSettingPanel) DefaultTableModel(javax.swing.table.DefaultTableModel) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) JBTable(com.intellij.ui.table.JBTable) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnActionButton(com.intellij.ui.AnActionButton)

Example 7 with ToolbarDecorator

use of com.intellij.ui.ToolbarDecorator in project azure-tools-for-java by Microsoft.

the class ContainerRegistryPropertyView method createUIComponents.

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

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    repoModel.addColumn(REPOSITORY);
    tblRepo = new JBTable(repoModel);
    tblRepo.getEmptyText().setText(TABLE_LOADING_MESSAGE);
    tblRepo.setRowSelectionAllowed(true);
    tblRepo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tblRepo.setStriped(true);
    tblRepo.getSelectionModel().addListSelectionListener(event -> {
        if (event.getValueIsAdjusting()) {
            return;
        }
        int selectedRow = tblRepo.getSelectedRow();
        if (selectedRow < 0 || selectedRow >= tblRepo.getRowCount()) {
            return;
        }
        String selectedRepo = (String) tblRepo.getModel().getValueAt(selectedRow, 0);
        if (Utils.isEmptyString(selectedRepo) || Comparing.equal(selectedRepo, currentRepo)) {
            return;
        }
        currentRepo = selectedRepo;
        disableWidgets(false, true);
        tblTag.getEmptyText().setText(TABLE_LOADING_MESSAGE);
        containerPropertyPresenter.onListTags(subscriptionId, registryId, currentRepo, true);
    });
    btnRepoRefresh = new AnActionButton(REFRESH, AllIcons.Actions.Refresh) {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            disableWidgets(true, true);
            tblTag.getEmptyText().setText(TABLE_EMPTY_MESSAGE);
            containerPropertyPresenter.onRefreshRepositories(subscriptionId, registryId, true);
        }
    };
    btnRepoPrevious = new AnActionButton(PREVIOUS_PAGE, AllIcons.Actions.MoveUp) {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            disableWidgets(true, true);
            tblTag.getEmptyText().setText(TABLE_EMPTY_MESSAGE);
            containerPropertyPresenter.onListRepositories(subscriptionId, registryId, false);
        }
    };
    btnRepoNext = new AnActionButton(NEXT_PAGE, AllIcons.Actions.MoveDown) {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            disableWidgets(true, true);
            tblTag.getEmptyText().setText(TABLE_EMPTY_MESSAGE);
            containerPropertyPresenter.onListRepositories(subscriptionId, registryId, true);
        }
    };
    ToolbarDecorator repoDecorator = ToolbarDecorator.createDecorator(tblRepo).addExtraActions(btnRepoRefresh).addExtraAction(btnRepoPrevious).addExtraAction(btnRepoNext).setToolbarPosition(ActionToolbarPosition.BOTTOM).setToolbarBorder(JBUI.Borders.empty());
    pnlRepoTable = repoDecorator.createPanel();
    DefaultTableModel tagModel = new DefaultTableModel() {

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    tagModel.addColumn(TAG);
    tblTag = new JBTable(tagModel);
    tblTag.getEmptyText().setText(TABLE_EMPTY_MESSAGE);
    tblTag.setRowSelectionAllowed(true);
    tblTag.setStriped(true);
    tblTag.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tblTag.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
                int rowIndex = tblTag.getSelectedRow();
                if (rowIndex < 0 || rowIndex >= tblTag.getRowCount()) {
                    return;
                }
                currentTag = (String) tblTag.getModel().getValueAt(rowIndex, 0);
                menu.show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });
    btnTagRefresh = new AnActionButton(REFRESH, AllIcons.Actions.Refresh) {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            if (Utils.isEmptyString(currentRepo)) {
                return;
            }
            disableWidgets(false, true);
            containerPropertyPresenter.onListTags(subscriptionId, registryId, currentRepo, true);
        }
    };
    btnTagPrevious = new AnActionButton(PREVIOUS_PAGE, AllIcons.Actions.MoveUp) {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            if (Utils.isEmptyString(currentRepo)) {
                return;
            }
            disableWidgets(false, true);
            containerPropertyPresenter.onListTags(subscriptionId, registryId, currentRepo, false);
        }
    };
    btnTagNext = new AnActionButton(NEXT_PAGE, AllIcons.Actions.MoveDown) {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            if (Utils.isEmptyString(currentRepo)) {
                return;
            }
            disableWidgets(false, true);
            containerPropertyPresenter.onListTags(subscriptionId, registryId, currentRepo, true);
        }
    };
    ToolbarDecorator tagDecorator = ToolbarDecorator.createDecorator(tblTag).addExtraActions(btnTagRefresh).addExtraAction(btnTagPrevious).addExtraAction(btnTagNext).setToolbarPosition(ActionToolbarPosition.BOTTOM).setToolbarBorder(JBUI.Borders.empty());
    pnlTagTable = tagDecorator.createPanel();
}
Also used : MouseEvent(java.awt.event.MouseEvent) DefaultTableModel(javax.swing.table.DefaultTableModel) MouseAdapter(java.awt.event.MouseAdapter) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) JBTable(com.intellij.ui.table.JBTable) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnActionButton(com.intellij.ui.AnActionButton)

Example 8 with ToolbarDecorator

use of com.intellij.ui.ToolbarDecorator in project android by JetBrains.

the class CreateXmlResourceSubdirPanel method setupDirectoriesPanel.

protected void setupDirectoriesPanel() {
    final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myDirectoriesList);
    decorator.setEditAction(null);
    decorator.disableUpDownActions();
    decorator.setAddAction(button -> doAddNewDirectory());
    decorator.setRemoveAction(button -> doDeleteDirectory());
    final AnActionButton selectAll = new AnActionButton("Select All", null, PlatformIcons.SELECT_ALL_ICON) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            doSelectAllDirs();
        }
    };
    decorator.addExtraAction(selectAll);
    final AnActionButton unselectAll = new AnActionButton("Unselect All", null, PlatformIcons.UNSELECT_ALL_ICON) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            doUnselectAllDirs();
        }
    };
    decorator.addExtraAction(unselectAll);
    myDirectoriesPanel.add(decorator.createPanel());
    updateDirectories(true, myParent.getResourceDirectory());
}
Also used : ToolbarDecorator(com.intellij.ui.ToolbarDecorator) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnActionButton(com.intellij.ui.AnActionButton)

Example 9 with ToolbarDecorator

use of com.intellij.ui.ToolbarDecorator in project intellij-plugins by JetBrains.

the class FilesToPackageForm method initTableButtons.

private void initTableButtons() {
    ToolbarDecorator d = ToolbarDecorator.createDecorator(myFilesToPackageTable);
    d.setAddAction(new AnActionButtonRunnable() {

        public void run(AnActionButton button) {
            final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, true, false, true);
            final VirtualFile[] files = FileChooser.chooseFiles(descriptor, myProject, null);
            final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
            for (final VirtualFile file : files) {
                final VirtualFile sourceRoot = fileIndex.getSourceRootForFile(file);
                String relativePath = sourceRoot == null ? null : sourceRoot.equals(file) ? "." : VfsUtilCore.getRelativePath(file, sourceRoot, '/');
                myFilesToPackage.add(new FilePathAndPathInPackage(file.getPath(), StringUtil.notNullize(relativePath, file.getName())));
            }
            if (files.length > 0) {
                fireDataChanged();
                IdeFocusManager.getInstance(myProject).requestFocus(myFilesToPackageTable, true);
                final int rowCount = myFilesToPackageTable.getRowCount();
                myFilesToPackageTable.setRowSelectionInterval(rowCount - files.length, rowCount - 1);
            }
        }
    });
    d.setRemoveAction(new AnActionButtonRunnable() {

        public void run(AnActionButton anActionButton) {
            TableUtil.stopEditing(myFilesToPackageTable);
            final int[] selectedRows = myFilesToPackageTable.getSelectedRows();
            Arrays.sort(selectedRows);
            for (int i = selectedRows.length - 1; i >= 0; i--) {
                myFilesToPackage.remove(selectedRows[i]);
            }
            fireDataChanged();
        }
    });
    myMainPanel.add(d.createPanel(), BorderLayout.CENTER);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilePathAndPathInPackage(com.intellij.lang.javascript.flex.projectStructure.model.AirPackagingOptions.FilePathAndPathInPackage) AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) AnActionButton(com.intellij.ui.AnActionButton)

Example 10 with ToolbarDecorator

use of com.intellij.ui.ToolbarDecorator in project intellij-community by JetBrains.

the class ProjectSettingsPanel method getMainComponent.

public JComponent getMainComponent() {
    final LabeledComponent<JComboBox> component = new LabeledComponent<>();
    component.setText("Default &project copyright:");
    component.setLabelLocation(BorderLayout.WEST);
    component.setComponent(myProfilesComboBox);
    ElementProducer<ScopeSetting> producer = new ElementProducer<ScopeSetting>() {

        @Override
        public ScopeSetting createElement() {
            return new ScopeSetting(CustomScopesProviderEx.getAllScope(), myProfilesModel.getAllProfiles().values().iterator().next());
        }

        @Override
        public boolean canCreateElement() {
            return !myProfilesModel.getAllProfiles().isEmpty();
        }
    };
    ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myScopeMappingTable, producer);
    return JBUI.Panels.simplePanel(0, 10).addToTop(component).addToCenter(decorator.createPanel()).addToBottom(myScopesLink);
}
Also used : ToolbarDecorator(com.intellij.ui.ToolbarDecorator) LabeledComponent(com.intellij.openapi.ui.LabeledComponent)

Aggregations

ToolbarDecorator (com.intellij.ui.ToolbarDecorator)20 AnActionButton (com.intellij.ui.AnActionButton)15 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)9 AnActionButtonRunnable (com.intellij.ui.AnActionButtonRunnable)9 JBTable (com.intellij.ui.table.JBTable)8 DefaultTableModel (javax.swing.table.DefaultTableModel)6 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)3 List (java.util.List)3 ApplicationManager (com.intellij.openapi.application.ApplicationManager)2 CustomLineBorder (com.intellij.ui.border.CustomLineBorder)2 Tree (com.intellij.ui.treeStructure.Tree)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 TableColumn (javax.swing.table.TableColumn)2 CloudLineBreakpointType (com.google.cloud.tools.intellij.debugger.CloudLineBreakpointType)1 CommonBundle (com.intellij.CommonBundle)1 CodeInsightBundle (com.intellij.codeInsight.CodeInsightBundle)1 HintManager (com.intellij.codeInsight.hint.HintManager)1