Search in sources :

Example 1 with JBLoadingPanel

use of com.intellij.ui.components.JBLoadingPanel in project android by JetBrains.

the class BasePerspectiveConfigurable method createComponent.

@Override
@NotNull
public JComponent createComponent() {
    JComponent contents = super.createComponent();
    myLoadingPanel = new JBLoadingPanel(new BorderLayout(), this);
    myLoadingPanel.setLoadingText("Syncing Project with Gradle");
    myLoadingPanel.add(contents, BorderLayout.CENTER);
    return myLoadingPanel;
}
Also used : JBLoadingPanel(com.intellij.ui.components.JBLoadingPanel) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with JBLoadingPanel

use of com.intellij.ui.components.JBLoadingPanel in project android by JetBrains.

the class AndroidToolWindowFactory method createToolWindowContent.

@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {
    // In order to use the runner layout ui, the runner infrastructure needs to be initialized.
    // Otherwise it is not possible to for example drag one of the tabs out of the tool window.
    // The object that needs to be created is the content manager of the execution manager for this project.
    ExecutionManager.getInstance(project).getContentManager();
    RunnerLayoutUi layoutUi = RunnerLayoutUi.Factory.getInstance(project).create("Android", TOOL_WINDOW_ID, "Profiling Tools", project);
    toolWindow.setIcon(AndroidIcons.AndroidToolWindow);
    toolWindow.setAvailable(true, null);
    toolWindow.setToHideOnEmptyContent(true);
    toolWindow.setTitle(TOOL_WINDOW_ID);
    DeviceContext deviceContext = new DeviceContext();
    // TODO Remove global handlers. These handlers are global, but are set per project.
    // if there are two projects opened, things go very wrong.
    ClientData.setMethodProfilingHandler(new OpenVmTraceHandler(project));
    Content logcatContent = createLogcatContent(layoutUi, project, deviceContext);
    final AndroidLogcatView logcatView = logcatContent.getUserData(AndroidLogcatView.ANDROID_LOGCAT_VIEW_KEY);
    assert logcatView != null;
    logcatContent.setSearchComponent(logcatView.createSearchComponent());
    layoutUi.addContent(logcatContent, 0, PlaceInGrid.center, false);
    MonitorContentFactory.createMonitorContent(project, deviceContext, layoutUi);
    layoutUi.getOptions().setLeftToolbar(getToolbarActions(project, deviceContext), ActionPlaces.UNKNOWN);
    layoutUi.addListener(new ContentManagerAdapter() {

        @Override
        public void selectionChanged(ContentManagerEvent event) {
            Content selectedContent = event.getContent();
            BaseMonitorView view = selectedContent.getUserData(BaseMonitorView.MONITOR_VIEW_KEY);
            if (view != null && event.getOperation() == ContentManagerEvent.ContentOperation.add) {
                UsageTracker.getInstance().log(AndroidStudioEvent.newBuilder().setCategory(AndroidStudioEvent.EventCategory.PROFILING).setKind(AndroidStudioEvent.EventKind.MONITOR_RUNNING).setMonitorType(view.getMonitorType()));
            }
        }
    }, project);
    final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), project);
    DevicePanel devicePanel = new DevicePanel(project, deviceContext);
    JPanel panel = devicePanel.getComponent();
    panel.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
    loadingPanel.add(panel, BorderLayout.NORTH);
    loadingPanel.add(layoutUi.getComponent(), BorderLayout.CENTER);
    final ContentManager contentManager = toolWindow.getContentManager();
    Content c = contentManager.getFactory().createContent(loadingPanel, "", true);
    // Store references to the logcat & device panel views, so that these views can be retrieved directly from
    // the DDMS tool window. (e.g. to clear logcat before a launch, select a particular device, etc)
    c.putUserData(AndroidLogcatView.ANDROID_LOGCAT_VIEW_KEY, logcatView);
    c.putUserData(DEVICES_PANEL_KEY, devicePanel);
    contentManager.addContent(c);
    ApplicationManager.getApplication().invokeLater(new Runnable() {

        @Override
        public void run() {
            logcatView.activate();
            final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID);
            if (window != null && window.isVisible()) {
                ConsoleView console = logcatView.getLogConsole().getConsole();
                if (console != null) {
                    checkFacetAndSdk(project, console);
                }
            }
        }
    }, project.getDisposed());
    final File adb = AndroidSdkUtils.getAdb(project);
    if (adb == null) {
        return;
    }
    loadingPanel.setLoadingText("Initializing ADB");
    loadingPanel.startLoading();
    ListenableFuture<AndroidDebugBridge> future = AdbService.getInstance().getDebugBridge(adb);
    Futures.addCallback(future, new FutureCallback<AndroidDebugBridge>() {

        @Override
        public void onSuccess(@Nullable AndroidDebugBridge bridge) {
            Logger.getInstance(AndroidToolWindowFactory.class).info("Successfully obtained debug bridge");
            loadingPanel.stopLoading();
        }

        @Override
        public void onFailure(@NotNull Throwable t) {
            loadingPanel.stopLoading();
            // If we cannot connect to ADB in a reasonable amount of time (10 seconds timeout in AdbService), then something is seriously
            // wrong. The only identified reason so far is that some machines have incompatible versions of adb that were already running.
            // e.g. Genymotion, some HTC flashing software, Ubuntu's adb package may all conflict with the version of adb in the SDK.
            Logger.getInstance(AndroidToolWindowFactory.class).info("Unable to obtain debug bridge", t);
            String msg;
            if (t.getMessage() != null) {
                msg = t.getMessage();
            } else {
                msg = String.format("Unable to establish a connection to adb.\n\n" + "Check the Event Log for possible issues.\n" + "This can happen if you have an incompatible version of adb running already.\n" + "Try re-opening %1$s after killing any existing adb daemons.\n\n" + "If this happens repeatedly, please file a bug at http://b.android.com including the following:\n" + "  1. Output of the command: '%2$s devices'\n" + "  2. Your idea.log file (Help | Show Log in Explorer)\n", ApplicationNamesInfo.getInstance().getProductName(), adb.getAbsolutePath());
            }
            Messages.showErrorDialog(msg, "ADB Connection Error");
        }
    }, EdtExecutor.INSTANCE);
}
Also used : ConsoleView(com.intellij.execution.ui.ConsoleView) ContentManager(com.intellij.ui.content.ContentManager) ContentManagerAdapter(com.intellij.ui.content.ContentManagerAdapter) AndroidLogcatView(com.android.tools.idea.logcat.AndroidLogcatView) ToolWindow(com.intellij.openapi.wm.ToolWindow) RunnerLayoutUi(com.intellij.execution.ui.RunnerLayoutUi) DeviceContext(com.android.tools.idea.ddms.DeviceContext) Content(com.intellij.ui.content.Content) DevicePanel(com.android.tools.idea.ddms.DevicePanel) OpenVmTraceHandler(com.android.tools.idea.ddms.OpenVmTraceHandler) JBLoadingPanel(com.intellij.ui.components.JBLoadingPanel) File(java.io.File) ContentManagerEvent(com.intellij.ui.content.ContentManagerEvent) AndroidDebugBridge(com.android.ddmlib.AndroidDebugBridge)

Example 3 with JBLoadingPanel

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

the class ExternalProjectDataSelectorDialog method createCenterPanel.

@Nullable
@Override
protected JComponent createCenterPanel() {
    ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree).addExtraAction(new SelectAllButton()).addExtraAction(new UnselectAllButton()).addExtraAction(new ShowSelectedOnlyButton()).addExtraAction(new SelectRequiredButton()).setToolbarPosition(ActionToolbarPosition.BOTTOM).setToolbarBorder(IdeBorderFactory.createEmptyBorder());
    contentPanel.add(decorator.createPanel());
    loadingPanel = new JBLoadingPanel(new BorderLayout(), getDisposable());
    loadingPanel.add(mainPanel, BorderLayout.CENTER);
    return loadingPanel;
}
Also used : JBLoadingPanel(com.intellij.ui.components.JBLoadingPanel) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with JBLoadingPanel

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

the class DirDiffTableModel method reloadModel.

public void reloadModel(final boolean userForcedRefresh) {
    myUpdating.set(true);
    myTable.getEmptyText().setText(StatusText.DEFAULT_EMPTY_TEXT);
    final JBLoadingPanel loadingPanel = getLoadingPanel();
    loadingPanel.startLoading();
    final ModalityState modalityState = ModalityState.current();
    ApplicationManager.getApplication().executeOnPooledThread(() -> {
        EmptyProgressIndicator indicator = new EmptyProgressIndicator(modalityState);
        ProgressManager.getInstance().executeProcessUnderProgress(() -> {
            try {
                if (myDisposed)
                    return;
                myUpdater = new Updater(loadingPanel, 100);
                myUpdater.start();
                text.set("Loading...");
                myTree = new DTree(null, "", true);
                mySrc.refresh(userForcedRefresh);
                myTrg.refresh(userForcedRefresh);
                scan(mySrc, myTree, true);
                scan(myTrg, myTree, false);
            } catch (final IOException e) {
                LOG.warn(e);
                reportException(VcsBundle.message("refresh.failed.message", StringUtil.decapitalize(e.getLocalizedMessage())));
            } finally {
                if (myTree != null) {
                    myTree.setSource(mySrc);
                    myTree.setTarget(myTrg);
                    myTree.update(mySettings);
                    applySettings();
                }
            }
        }, indicator);
    });
}
Also used : EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) JBLoadingPanel(com.intellij.ui.components.JBLoadingPanel) IOException(java.io.IOException)

Example 5 with JBLoadingPanel

use of com.intellij.ui.components.JBLoadingPanel in project android by JetBrains.

the class EditorFixture method open.

/**
   * Opens up a different file. This will run through the "Open File..." dialog to
   * find and select the given file.
   *
   * @param file the file to open
   * @param tab which tab to open initially, if there are multiple editors
   */
public EditorFixture open(@NotNull final VirtualFile file, @NotNull final Tab tab) {
    execute(new GuiTask() {

        @Override
        protected void executeInEDT() throws Throwable {
            // TODO: Use UI to navigate to the file instead
            Project project = myFrame.getProject();
            FileEditorManager manager = FileEditorManager.getInstance(project);
            if (tab == Tab.EDITOR) {
                manager.openTextEditor(new OpenFileDescriptor(project, file), true);
            } else {
                manager.openFile(file, true);
            }
        }
    });
    selectEditorTab(tab);
    Wait.seconds(5).expecting("file " + quote(file.getPath()) + " to be opened and loaded").until(() -> {
        if (!file.equals(getCurrentFile())) {
            return false;
        }
        FileEditor fileEditor = FileEditorManager.getInstance(myFrame.getProject()).getSelectedEditor(file);
        JComponent editorComponent = fileEditor.getComponent();
        if (editorComponent instanceof JBLoadingPanel) {
            return !((JBLoadingPanel) editorComponent).isLoading();
        }
        return true;
    });
    myFrame.requestFocusIfLost();
    robot.waitForIdle();
    return this;
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) Project(com.intellij.openapi.project.Project) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) FileEditor(com.intellij.openapi.fileEditor.FileEditor) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) JBLoadingPanel(com.intellij.ui.components.JBLoadingPanel)

Aggregations

JBLoadingPanel (com.intellij.ui.components.JBLoadingPanel)8 Nullable (org.jetbrains.annotations.Nullable)3 AndroidDebugBridge (com.android.ddmlib.AndroidDebugBridge)2 File (java.io.File)2 DeviceContext (com.android.tools.idea.ddms.DeviceContext)1 DevicePanel (com.android.tools.idea.ddms.DevicePanel)1 OpenVmTraceHandler (com.android.tools.idea.ddms.OpenVmTraceHandler)1 AndroidLogcatView (com.android.tools.idea.logcat.AndroidLogcatView)1 ConsoleView (com.intellij.execution.ui.ConsoleView)1 RunnerLayoutUi (com.intellij.execution.ui.RunnerLayoutUi)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)1 Project (com.intellij.openapi.project.Project)1 MultiLineLabelUI (com.intellij.openapi.ui.MultiLineLabelUI)1 ToolWindow (com.intellij.openapi.wm.ToolWindow)1 Content (com.intellij.ui.content.Content)1 ContentManager (com.intellij.ui.content.ContentManager)1 ContentManagerAdapter (com.intellij.ui.content.ContentManagerAdapter)1