@Override public JComponent getPreferredFocusedComponent() { if (myNameField.getText().length() == 0) { return myNameField; } else if (myValueField.isVisible()) { return myValueField; } else if (myModuleCombo.isVisible()) { return myModuleCombo; } else { return myFileNameCombo; } }
@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); } } }