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