Search in sources :

Example 6 with AsyncProcessIcon

use of com.intellij.util.ui.AsyncProcessIcon in project android by JetBrains.

the class ApkViewPanel method createUIComponents.

private void createUIComponents() {
    myNameAsyncIcon = new AsyncProcessIcon("aapt xmltree manifest");
    mySizeAsyncIcon = new AsyncProcessIcon("estimating apk size");
    myTreeModel = new DefaultTreeModel(new LoadingNode());
    myTree = new Tree(myTreeModel);
    myTree.setShowsRootHandles(true);
    // show root node only when showing LoadingNode
    myTree.setRootVisible(true);
    myTree.setPaintBusy(true);
    TreeSpeedSearch treeSpeedSearch = new TreeSpeedSearch(myTree, path -> {
        ApkEntry e = ApkEntry.fromNode(path.getLastPathComponent());
        if (e == null) {
            return null;
        }
        return e.getPath();
    }, true);
    // Provides the percentage of the node size to the total size of the APK
    PercentRenderer.PercentProvider percentProvider = (jTree, value, row) -> {
        ApkEntry entry = ApkEntry.fromNode(value);
        ApkEntry rootEntry = ApkEntry.fromNode(jTree.getModel().getRoot());
        if (entry == null || rootEntry == null) {
            return 0;
        } else if (!entry.isCompressedSizeKnown() || !rootEntry.isCompressedSizeKnown()) {
            return 0;
        } else {
            return (double) entry.getCompressedSize() / rootEntry.getCompressedSize();
        }
    };
    ColumnTreeBuilder builder = new ColumnTreeBuilder(myTree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("File").setPreferredWidth(600).setHeaderAlignment(SwingConstants.LEADING).setRenderer(new NameRenderer(treeSpeedSearch))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Raw File Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(false))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Download Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(true))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("% of Total Download size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.LEADING).setRenderer(new PercentRenderer(percentProvider)));
    myColumnTreePane = (JScrollPane) builder.build();
    myTree.addTreeSelectionListener(this);
}
Also used : AllIcons(com.intellij.icons.AllIcons) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SdkConstants(com.android.SdkConstants) VirtualFile(com.intellij.openapi.vfs.VirtualFile) AnimatedIcon(com.intellij.util.ui.AnimatedIcon) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) EdtExecutor(com.android.tools.idea.ddms.EdtExecutor) TreeSelectionListener(javax.swing.event.TreeSelectionListener) AsyncProcessIcon(com.intellij.util.ui.AsyncProcessIcon) Disposer(com.intellij.openapi.util.Disposer) Tree(com.intellij.ui.treeStructure.Tree) ColumnTreeBuilder(com.android.tools.adtui.common.ColumnTreeBuilder) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) AndroidBundle(org.jetbrains.android.util.AndroidBundle) DecimalFormat(java.text.DecimalFormat) com.intellij.ui(com.intellij.ui) FutureCallback(com.google.common.util.concurrent.FutureCallback) SearchUtil(com.intellij.ide.ui.search.SearchUtil) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Nullable(org.jetbrains.annotations.Nullable) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) AndroidIcons(icons.AndroidIcons) Function(com.intellij.util.Function) NotNull(org.jetbrains.annotations.NotNull) javax.swing(javax.swing) AsyncProcessIcon(com.intellij.util.ui.AsyncProcessIcon) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) ColumnTreeBuilder(com.android.tools.adtui.common.ColumnTreeBuilder) Tree(com.intellij.ui.treeStructure.Tree)

Example 7 with AsyncProcessIcon

use of com.intellij.util.ui.AsyncProcessIcon in project android by JetBrains.

the class UpdateSitesPanel method createUIComponents.

private void createUIComponents() {
    mySourcesLoadingIcon = new AsyncProcessIcon("Loading...");
    mySourcesTableModel = new SourcesTableModel(new Runnable() {

        @Override
        public void run() {
            UIUtil.invokeAndWaitIfNeeded(new Runnable() {

                @Override
                public void run() {
                    mySourcesLoadingPanel.setVisible(true);
                }
            });
        }
    }, new Runnable() {

        @Override
        public void run() {
            UIUtil.invokeAndWaitIfNeeded(new Runnable() {

                @Override
                public void run() {
                    mySourcesLoadingPanel.setVisible(false);
                }
            });
        }
    });
    myUpdateSitesTable = new TableView<SourcesTableModel.Row>(mySourcesTableModel);
    ToolbarDecorator userDefinedDecorator = ToolbarDecorator.createDecorator(myUpdateSitesTable);
    mySourcesPanel = addExtraActions(userDefinedDecorator).createPanel();
    SdkUpdaterConfigPanel.setTableProperties(myUpdateSitesTable, null);
}
Also used : AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) AsyncProcessIcon(com.intellij.util.ui.AsyncProcessIcon) ToolbarDecorator(com.intellij.ui.ToolbarDecorator)

Example 8 with AsyncProcessIcon

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

the class DartGeneratorPeer method startLoadingTemplates.

private void startLoadingTemplates() {
    myLoadingTemplatesPanel.setVisible(true);
    myLoadingTemplatesPanel.setPreferredSize(myLoadedTemplatesPanel.getPreferredSize());
    myLoadedTemplatesPanel.setVisible(false);
    // until loaded
    myCreateSampleProjectCheckBox.setSelected(false);
    final AsyncProcessIcon asyncProcessIcon = new AsyncProcessIcon("Dart project templates loading");
    // defaults are ok: row = 0, column = 0
    myLoadingTemplatesPanel.add(asyncProcessIcon, new GridConstraints());
    asyncProcessIcon.resume();
    ApplicationManager.getApplication().executeOnPooledThread(() -> {
        final String sdkPath = mySdkPathComboWithBrowse.getComboBox().getEditor().getItem().toString().trim();
        DartProjectTemplate.loadTemplatesAsync(sdkPath, templates -> {
            asyncProcessIcon.suspend();
            Disposer.dispose(asyncProcessIcon);
            onTemplatesLoaded(templates);
        });
    });
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints) AsyncProcessIcon(com.intellij.util.ui.AsyncProcessIcon)

Example 9 with AsyncProcessIcon

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

the class ProgressStripeIcon method generateIcon.

@NotNull
public static AsyncProcessIcon generateIcon(@NotNull JComponent component) {
    List<Icon> result = ContainerUtil.newArrayList();
    if (UIUtil.isUnderAquaBasedLookAndFeel() && !UIUtil.isUnderDarcula()) {
        for (int i = 0; i < 2 * JBUI.scale(GradientIcon.GRADIENT); i += JBUI.scale(TRANSLATE)) {
            result.add(new GradientIcon(component, i));
        }
    } else {
        for (int i = 0; i < JBUI.scale(StripeIcon.WIDTH); i += JBUI.scale(TRANSLATE)) {
            result.add(new StripeIcon(component, i));
        }
        result = ContainerUtil.reverse(result);
    }
    Icon passive = result.get(0);
    AsyncProcessIcon icon = new AsyncProcessIcon("ProgressWithStripes", result.toArray(new Icon[result.size()]), passive) {

        @Override
        public Dimension getPreferredSize() {
            return new Dimension(component.getWidth(), passive.getIconHeight());
        }
    };
    component.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            super.componentResized(e);
            icon.revalidate();
        }
    });
    return icon;
}
Also used : AsyncProcessIcon(com.intellij.util.ui.AsyncProcessIcon) AsyncProcessIcon(com.intellij.util.ui.AsyncProcessIcon) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with AsyncProcessIcon

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

the class DesignerEditorPanel method createProgressPanel.

private void createProgressPanel() {
    myProgressIcon = new AsyncProcessIcon("Designer progress");
    myProgressMessage = new JLabel();
    JPanel progressBlock = new JPanel();
    progressBlock.add(myProgressIcon);
    progressBlock.add(myProgressMessage);
    progressBlock.setBorder(IdeBorderFactory.createRoundedBorder());
    myProgressPanel = new JPanel(new GridBagLayout());
    myProgressPanel.add(progressBlock, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    myProgressPanel.setOpaque(false);
}
Also used : AsyncProcessIcon(com.intellij.util.ui.AsyncProcessIcon)

Aggregations

AsyncProcessIcon (com.intellij.util.ui.AsyncProcessIcon)16 NotNull (org.jetbrains.annotations.NotNull)3 AllIcons (com.intellij.icons.AllIcons)2 Disposer (com.intellij.openapi.util.Disposer)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 com.intellij.ui (com.intellij.ui)2 TreeTableView (com.intellij.ui.dualView.TreeTableView)2 ListTreeTableModelOnColumns (com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns)2 TreeColumnInfo (com.intellij.ui.treeStructure.treetable.TreeColumnInfo)2 ColumnInfo (com.intellij.util.ui.ColumnInfo)2 List (java.util.List)2 javax.swing (javax.swing)2 Nullable (org.jetbrains.annotations.Nullable)2 SdkConstants (com.android.SdkConstants)1 ColumnTreeBuilder (com.android.tools.adtui.common.ColumnTreeBuilder)1 EdtExecutor (com.android.tools.idea.ddms.EdtExecutor)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 TargetElementUtil (com.intellij.codeInsight.TargetElementUtil)1