@SuppressWarnings("UseJBColor") // Colors are used for the graphics generator, not the plugin UI
  public RasterAssetSetStep(
      TemplateWizardState state,
      @Nullable Project project,
      @Nullable Module module,
      @Nullable Icon sidePanelIcon,
      UpdateListener updateListener,
      @Nullable VirtualFile invocationTarget) {
    super(state, project, module, sidePanelIcon, updateListener, invocationTarget);

    // Speed the scrolling of myScrollPane
    myScrollPane.getVerticalScrollBar().setUnitIncrement(16);

    register(ATTR_TEXT, myText);
    register(ATTR_SCALING, myCropRadioButton, Scaling.CROP);
    register(ATTR_SCALING, myCenterRadioButton, Scaling.CENTER);
    register(ATTR_SHAPE, myCircleRadioButton, GraphicGenerator.Shape.CIRCLE);
    register(ATTR_SHAPE, myNoneRadioButton, GraphicGenerator.Shape.NONE);
    register(ATTR_SHAPE, mySquareRadioButton, GraphicGenerator.Shape.SQUARE);
    register(ATTR_SHAPE, myVerticalRadioButton, GraphicGenerator.Shape.VRECT);
    register(ATTR_SHAPE, myHorizontalRadioButton, GraphicGenerator.Shape.HRECT);
    register(ATTR_DOGEAR, myDogEarEffectCheckBox);
    register(ATTR_PADDING, myPaddingSlider);
    register(ATTR_TRIM, myTrimBlankSpace);
    register(ATTR_FONT, myFontFamily);
    register(ATTR_SOURCE_TYPE, myImageRadioButton, AssetStudioAssetGenerator.SourceType.IMAGE);
    register(ATTR_SOURCE_TYPE, myClipartRadioButton, AssetStudioAssetGenerator.SourceType.CLIPART);
    register(ATTR_SOURCE_TYPE, myTextRadioButton, AssetStudioAssetGenerator.SourceType.TEXT);
    register(ATTR_FOREGROUND_COLOR, myForegroundColor);
    register(ATTR_BACKGROUND_COLOR, myBackgroundColor);
    register(ATTR_ASSET_TYPE, myAssetTypeComboBox);
    register(ATTR_ASSET_THEME, myChooseThemeComboBox);
    register(ATTR_ASSET_NAME, myResourceNameField);

    myImageFile.addBrowseFolderListener(
        null, null, null, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());
    myForegroundColor.setSelectedColor(Color.BLUE);
    myBackgroundColor.setSelectedColor(Color.WHITE);

    for (String font :
        GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()) {
      myFontFamily.addItem(new ComboBoxItem(font, font, 1, 1));
      if (font.equals(myTemplateState.get(ATTR_FONT))) {
        myFontFamily.setSelectedIndex(myFontFamily.getItemCount() - 1);
      }
    }

    myChooseClipart.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            displayClipartDialog();
          }
        });

    populateComboBox(myAssetTypeComboBox, AssetType.class);
    populateComboBox(myChooseThemeComboBox, ActionBarIconGenerator.Theme.class);
  }
 public void finalizeAssetType(AssetType type) {
   mySelectedAssetType = type;
   myTemplateState.put(ATTR_ASSET_TYPE, type.name());
   for (int i = 0; i < myAssetTypeComboBox.getItemCount(); ++i) {
     if (((ComboBoxItem) myAssetTypeComboBox.getItemAt(i)).id.equals(type.name())) {
       myAssetTypeComboBox.setSelectedIndex(i);
       break;
     }
   }
   hide(myAssetTypeComboBox, myAssetTypeLabel);
   update();
 }
  @Override
  public void deriveValues() {
    super.deriveValues();

    myTemplateState.put(ATTR_ICON_RESOURCE, myTemplateState.getString(ATTR_ASSET_NAME));

    // Source Radio button
    if (myImageRadioButton.isSelected()) {
      hide(
          myChooseClipart,
          myChooseClipartLabel,
          myText,
          myTextLabel,
          myFontFamily,
          myFontFamilyLabel,
          myForegroundColor,
          myForegroundColorLabel);
      show(myImageFile, myImageFileLabel, myBackgroundColor, myBackgroundColorLabel);
    } else if (myClipartRadioButton.isSelected()) {
      hide(myText, myTextLabel, myFontFamily, myFontFamilyLabel, myImageFile, myImageFileLabel);
      show(
          myChooseClipart,
          myChooseClipartLabel,
          myBackgroundColor,
          myBackgroundColorLabel,
          myForegroundColor,
          myForegroundColorLabel);
    } else if (myTextRadioButton.isSelected()) {
      hide(myChooseClipart, myChooseClipartLabel, myImageFile, myImageFileLabel);
      show(
          myText,
          myTextLabel,
          myFontFamily,
          myFontFamilyLabel,
          myBackgroundColor,
          myBackgroundColorLabel,
          myForegroundColor,
          myForegroundColorLabel);
      myFontFamily.setSelectedItem(myTemplateState.getString(ATTR_FONT));
    }

    // Asset Type Combo Box
    if (myTemplateState.get(ATTR_ASSET_TYPE) != null) {
      final AssetType selectedAssetType =
          AssetType.valueOf(myTemplateState.getString(ATTR_ASSET_TYPE));
      mySelectedAssetType = selectedAssetType;
      if (selectedAssetType != null) {
        switch (selectedAssetType) {
          case LAUNCHER:
            hide(myChooseThemeComboBox, myChooseThemeLabel, myVersionPanel, myDogEarEffectCheckBox);
            show(
                myForegroundScalingLabel,
                myScalingPanel,
                myShapeLabel,
                myShapePanel,
                myResourceNameLabel,
                myResourceNameField,
                myXXXHdpiPreview,
                myXXXHDPILabel,
                myScrollPane);
            if (!myTemplateState.myModified.contains(ATTR_ASSET_NAME)) {
              myTemplateState.put(ATTR_ASSET_NAME, "icon");
            }
            // Dog-ear effect
            if (mySquareRadioButton.isSelected()
                || myVerticalRadioButton.isSelected()
                || myHorizontalRadioButton.isSelected()) {
              show(myDogEarEffectCheckBox);
            }
            break;
          case ACTIONBAR:
            show(myResourceNameField, myResourceNameLabel);
            show(myChooseThemeComboBox, myChooseThemeLabel, myScrollPane);
            hide(
                myForegroundScalingLabel,
                myScalingPanel,
                myShapeLabel,
                myShapePanel,
                myBackgroundColorLabel,
                myBackgroundColor,
                myVersionPanel,
                myXXXHdpiPreview,
                myXXXHDPILabel,
                myDogEarEffectCheckBox);
            break;
          case NOTIFICATION:
            show(myResourceNameField, myResourceNameLabel, myVersionPanel);
            hide(
                myChooseThemeComboBox,
                myChooseThemeLabel,
                myForegroundColor,
                myForegroundColorLabel);
            hide(
                myForegroundScalingLabel,
                myScalingPanel,
                myShapeLabel,
                myShapePanel,
                myBackgroundColorLabel,
                myBackgroundColor,
                myScrollPane,
                myDogEarEffectCheckBox);
            break;
        }

        if (!myTemplateState.myModified.contains(ATTR_ASSET_NAME)) {
          updateDerivedValue(
              ATTR_ASSET_NAME,
              myResourceNameField,
              new Callable<String>() {
                @Override
                public String call() throws Exception {
                  return computeResourceName();
                }
              });
        }
      }
    }

    // Theme chooser
    if (myChooseThemeComboBox.isVisible() && myTemplateState.hasAttr(ATTR_ASSET_THEME)) {
      if (ActionBarIconGenerator.Theme.valueOf(myTemplateState.getString(ATTR_ASSET_THEME))
          .equals(ActionBarIconGenerator.Theme.CUSTOM)) {
        show(myForegroundColor, myForegroundColorLabel);
      } else {
        hide(myForegroundColor, myForegroundColorLabel);
      }
    }
  }