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);
}
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);
}
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);
});
});
}
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;
}
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);
}
Aggregations