Search in sources :

Example 1 with DynamicWizard

use of com.android.tools.idea.wizard.dynamic.DynamicWizard in project android by JetBrains.

the class ActivityGalleryStep method createGallery.

private JComponent createGallery() {
    myGallery = new ASGallery<>();
    Dimension thumbnailSize = DEFAULT_GALLERY_THUMBNAIL_SIZE;
    myGallery.setThumbnailSize(thumbnailSize);
    myGallery.setMinimumSize(new Dimension(thumbnailSize.width * 2 + 1, thumbnailSize.height));
    myGallery.setLabelProvider(new Function<Optional<TemplateEntry>, String>() {

        @Override
        public String apply(Optional<TemplateEntry> template) {
            if (template.isPresent()) {
                return template.get().getTitle();
            } else {
                return "Add No Activity";
            }
        }
    });
    myGallery.setDefaultAction(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            DynamicWizard wizard = getWizard();
            assert wizard != null;
            wizard.doNextAction();
        }
    });
    myGallery.setImageProvider(new Function<Optional<TemplateEntry>, Image>() {

        @Override
        public Image apply(Optional<TemplateEntry> input) {
            return input.isPresent() ? input.get().getImage() : null;
        }
    });
    myGallery.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            saveState(myGallery);
        }
    });
    myGallery.setName("Templates Gallery");
    AccessibleContext accessibleContext = myGallery.getAccessibleContext();
    if (accessibleContext != null) {
        accessibleContext.setAccessibleDescription(getStepTitle());
    }
    JPanel panel = new JPanel(new JBCardLayout());
    panel.add("only card", new JBScrollPane(myGallery));
    return panel;
}
Also used : Optional(java.util.Optional) AccessibleContext(javax.accessibility.AccessibleContext) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener) DynamicWizard(com.android.tools.idea.wizard.dynamic.DynamicWizard) JBCardLayout(com.intellij.ui.JBCardLayout) JBScrollPane(com.intellij.ui.components.JBScrollPane)

Example 2 with DynamicWizard

use of com.android.tools.idea.wizard.dynamic.DynamicWizard in project android by JetBrains.

the class InstallComponentsPath method createComponentTree.

private ComponentTreeNode createComponentTree(@NotNull FirstRunWizardMode reason, @NotNull ScopedStateStore stateStore, boolean createAvd) {
    List<ComponentTreeNode> components = Lists.newArrayList();
    components.add(new AndroidSdk(stateStore, myInstallUpdates));
    DynamicWizard wizard = getWizard();
    ProgressWindow progressWindow = new ProgressWindow(false, false, null);
    if (wizard != null) {
        Disposer.register(wizard.getDisposable(), progressWindow);
    }
    com.android.repository.api.ProgressIndicator progress = new RepoProgressIndicatorAdapter(progressWindow);
    RepoManager sdkManager = myLocalHandler.getSdkManager(new StudioLoggerProgressIndicator(getClass()));
    sdkManager.loadSynchronously(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, progress, new StudioDownloader(progressWindow), StudioSettingsController.getInstance());
    Map<String, RemotePackage> remotePackages = sdkManager.getPackages().getRemotePackages();
    ComponentTreeNode platforms = Platform.createSubtree(stateStore, remotePackages, myInstallUpdates);
    if (platforms != null) {
        components.add(platforms);
    }
    if (Haxm.canRun() && reason == FirstRunWizardMode.NEW_INSTALL) {
        Haxm.HaxmInstallationIntention haxmInstallationIntention = myInstallUpdates ? Haxm.HaxmInstallationIntention.INSTALL_WITH_UPDATES : Haxm.HaxmInstallationIntention.INSTALL_WITHOUT_UPDATES;
        components.add(new Haxm(haxmInstallationIntention, stateStore, FirstRunWizard.KEY_CUSTOM_INSTALL));
    }
    if (createAvd) {
        components.add(new AndroidVirtualDevice(stateStore, remotePackages, myInstallUpdates, myFileOp));
    }
    return new ComponentCategory("Root", "Root node that is not supposed to appear in the UI", components);
}
Also used : StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) DynamicWizard(com.android.tools.idea.wizard.dynamic.DynamicWizard) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) RepoManager(com.android.repository.api.RepoManager) RepoProgressIndicatorAdapter(com.android.tools.idea.sdk.progress.RepoProgressIndicatorAdapter) ProgressWindow(com.intellij.openapi.progress.util.ProgressWindow) RemotePackage(com.android.repository.api.RemotePackage)

Example 3 with DynamicWizard

use of com.android.tools.idea.wizard.dynamic.DynamicWizard in project android by JetBrains.

the class FirstRunWizardHost method setupWizard.

private void setupWizard() {
    DynamicWizard wizard = new FirstRunWizard(this, myMode);
    wizard.init();
    add(wizard.getContentPane(), BorderLayout.CENTER);
}
Also used : DynamicWizard(com.android.tools.idea.wizard.dynamic.DynamicWizard)

Example 4 with DynamicWizard

use of com.android.tools.idea.wizard.dynamic.DynamicWizard in project android by JetBrains.

the class ChooseModuleTypeStep method createGallery.

private JPanel createGallery() {
    Dimension thumbnailSize = DEFAULT_GALLERY_THUMBNAIL_SIZE;
    myFormFactorGallery = new ASGallery<ModuleTemplate>(JBList.createDefaultListModel(), new Function<ModuleTemplate, Image>() {

        @Override
        public Image apply(ModuleTemplate input) {
            return IconUtil.toImage(input.getIcon());
        }
    }, new Function<ModuleTemplate, String>() {

        @Override
        public String apply(@Nullable ModuleTemplate input) {
            return input == null ? "<none>" : input.getName();
        }
    }, thumbnailSize, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            DynamicWizard wizard = getWizard();
            assert wizard != null;
            getWizard().doNextAction();
        }
    }) {

        @Override
        public Dimension getPreferredScrollableViewportSize() {
            Dimension preferred = getPreferredSize();
            int heightInsets = getInsets().top + getInsets().bottom;
            // Don't want to show an exact number of rows, since then it's not obvious there's another row available.
            return new Dimension(preferred.width, (int) (computeCellSize().height * 2.2) + heightInsets);
        }
    };
    myFormFactorGallery.setMinimumSize(new Dimension(thumbnailSize.width * 2 + 1, thumbnailSize.height));
    myFormFactorGallery.setBorder(BorderFactory.createLineBorder(JBColor.border()));
    AccessibleContext accessibleContext = myFormFactorGallery.getAccessibleContext();
    if (accessibleContext != null) {
        accessibleContext.setAccessibleDescription(getStepTitle());
    }
    JPanel panel = new JPanel(new JBCardLayout());
    panel.add("only card", new JBScrollPane(myFormFactorGallery));
    return panel;
}
Also used : AccessibleContext(javax.accessibility.AccessibleContext) ModuleTemplate(com.android.tools.idea.npw.ModuleTemplate) ActionEvent(java.awt.event.ActionEvent) Function(com.google.common.base.Function) DynamicWizard(com.android.tools.idea.wizard.dynamic.DynamicWizard) JBCardLayout(com.intellij.ui.JBCardLayout) Nullable(org.jetbrains.annotations.Nullable) JBScrollPane(com.intellij.ui.components.JBScrollPane)

Example 5 with DynamicWizard

use of com.android.tools.idea.wizard.dynamic.DynamicWizard in project android by JetBrains.

the class SdkUpdaterConfigPanel method setUpSingleSdkChooser.

private void setUpSingleSdkChooser() {
    myEditSdkLink.setHyperlinkText("Edit");
    myEditSdkLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            final DynamicWizardHost host = new DialogWrapperHost(null);
            DynamicWizard wizard = new DynamicWizard(null, null, "SDK Setup", host) {

                @Override
                public void init() {
                    DownloadingComponentsStep progressStep = new DownloadingComponentsStep(myHost.getDisposable(), myHost);
                    String sdkPath = mySdkLocationTextField.getText();
                    File location;
                    if (StringUtil.isEmpty(sdkPath)) {
                        location = FirstRunWizardDefaults.getInitialSdkLocation(FirstRunWizardMode.MISSING_SDK);
                    } else {
                        location = new File(sdkPath);
                    }
                    InstallComponentsPath path = new InstallComponentsPath(FirstRunWizardMode.MISSING_SDK, location, progressStep, false);
                    progressStep.setInstallComponentsPath(path);
                    addPath(path);
                    addPath(new SingleStepPath(progressStep));
                    super.init();
                }

                @Override
                public void performFinishingActions() {
                    File sdkLocation = IdeSdks.getInstance().getAndroidSdkPath();
                    if (sdkLocation == null) {
                        return;
                    }
                    String stateSdkLocationPath = myState.get(WizardConstants.KEY_SDK_INSTALL_LOCATION);
                    assert stateSdkLocationPath != null;
                    File stateSdkLocation = new File(stateSdkLocationPath);
                    if (!FileUtil.filesEqual(sdkLocation, stateSdkLocation)) {
                        setAndroidSdkLocation(stateSdkLocation);
                        sdkLocation = stateSdkLocation;
                    }
                    mySelectedSdkLocation.setValue(sdkLocation);
                }

                @NotNull
                @Override
                protected String getProgressTitle() {
                    return "Setting up SDK...";
                }

                @Override
                protected String getWizardActionDescription() {
                    return "Setting up SDK...";
                }
            };
            wizard.init();
            wizard.show();
        }
    });
    mySdkLocationTextField.setEditable(false);
}
Also used : DynamicWizard(com.android.tools.idea.wizard.dynamic.DynamicWizard) SingleStepPath(com.android.tools.idea.wizard.dynamic.SingleStepPath) HyperlinkEvent(javax.swing.event.HyperlinkEvent) InstallComponentsPath(com.android.tools.idea.welcome.wizard.InstallComponentsPath) DialogWrapperHost(com.android.tools.idea.wizard.dynamic.DialogWrapperHost) DynamicWizardHost(com.android.tools.idea.wizard.dynamic.DynamicWizardHost) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter)

Aggregations

DynamicWizard (com.android.tools.idea.wizard.dynamic.DynamicWizard)5 JBCardLayout (com.intellij.ui.JBCardLayout)2 JBScrollPane (com.intellij.ui.components.JBScrollPane)2 ActionEvent (java.awt.event.ActionEvent)2 AccessibleContext (javax.accessibility.AccessibleContext)2 RemotePackage (com.android.repository.api.RemotePackage)1 RepoManager (com.android.repository.api.RepoManager)1 ModuleTemplate (com.android.tools.idea.npw.ModuleTemplate)1 StudioDownloader (com.android.tools.idea.sdk.StudioDownloader)1 RepoProgressIndicatorAdapter (com.android.tools.idea.sdk.progress.RepoProgressIndicatorAdapter)1 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)1 InstallComponentsPath (com.android.tools.idea.welcome.wizard.InstallComponentsPath)1 DialogWrapperHost (com.android.tools.idea.wizard.dynamic.DialogWrapperHost)1 DynamicWizardHost (com.android.tools.idea.wizard.dynamic.DynamicWizardHost)1 SingleStepPath (com.android.tools.idea.wizard.dynamic.SingleStepPath)1 Function (com.google.common.base.Function)1 ProgressWindow (com.intellij.openapi.progress.util.ProgressWindow)1 HyperlinkAdapter (com.intellij.ui.HyperlinkAdapter)1 File (java.io.File)1 Optional (java.util.Optional)1