use of org.jetbrains.jps.android.model.impl.AndroidImportableProperty in project android by JetBrains.
the class AndroidFacetEditorTab method apply.
@Override
public void apply() throws ConfigurationException {
if (!isModified())
return;
String absGenPathR = myRGenPathField.getText().trim();
String absGenPathAidl = myAidlGenPathField.getText().trim();
boolean runApt = false;
boolean runIdl = false;
if (absGenPathR == null || absGenPathR.length() == 0 || absGenPathAidl == null || absGenPathAidl.length() == 0) {
throw new ConfigurationException("Please specify source root for autogenerated files");
} else {
String relativeGenPathR = getAndCheckRelativePath(absGenPathR, false);
String newAptDestDir = '/' + relativeGenPathR;
if (!newAptDestDir.equals(myConfiguration.getState().GEN_FOLDER_RELATIVE_PATH_APT)) {
runApt = true;
}
myConfiguration.getState().GEN_FOLDER_RELATIVE_PATH_APT = newAptDestDir;
String relativeGenPathAidl = getAndCheckRelativePath(absGenPathAidl, false);
String newIdlDestDir = '/' + relativeGenPathAidl;
if (!newIdlDestDir.equals(myConfiguration.getState().GEN_FOLDER_RELATIVE_PATH_AIDL)) {
runIdl = true;
}
myConfiguration.getState().GEN_FOLDER_RELATIVE_PATH_AIDL = newIdlDestDir;
}
String absManifestPath = myManifestFileField.getText().trim();
if (absManifestPath.length() == 0) {
throw new ConfigurationException("Manifest file not specified");
}
String manifestRelPath = getAndCheckRelativePath(absManifestPath, true);
if (!SdkConstants.FN_ANDROID_MANIFEST_XML.equals(AndroidUtils.getSimpleNameByRelativePath(manifestRelPath))) {
throw new ConfigurationException("Manifest file must have name AndroidManifest.xml");
}
myConfiguration.getState().MANIFEST_FILE_RELATIVE_PATH = '/' + manifestRelPath;
String absResPath = myResFolderField.getText().trim();
if (absResPath.length() == 0) {
throw new ConfigurationException("Resources folder not specified");
}
myConfiguration.getState().RES_FOLDER_RELATIVE_PATH = '/' + getAndCheckRelativePath(absResPath, false);
String absAssetsPath = myAssetsFolderField.getText().trim();
myConfiguration.getState().ASSETS_FOLDER_RELATIVE_PATH = absAssetsPath.length() > 0 ? '/' + getAndCheckRelativePath(absAssetsPath, false) : "";
String absApkPath = (String) myApkPathCombo.getComboBox().getEditor().getItem();
if (absApkPath.length() == 0) {
myConfiguration.getState().APK_PATH = "";
} else {
myConfiguration.getState().APK_PATH = '/' + getAndCheckRelativePath(absApkPath, false);
}
String absLibsPath = myNativeLibsFolder.getText().trim();
myConfiguration.getState().LIBS_FOLDER_RELATIVE_PATH = absLibsPath.length() > 0 ? '/' + getAndCheckRelativePath(absLibsPath, false) : "";
myConfiguration.getState().CUSTOM_DEBUG_KEYSTORE_PATH = getSelectedCustomKeystorePath();
myConfiguration.getState().PROJECT_TYPE = myIsLibraryProjectCheckbox.isSelected() ? PROJECT_TYPE_LIBRARY : PROJECT_TYPE_APP;
myConfiguration.getState().RUN_PROCESS_RESOURCES_MAVEN_TASK = myRunProcessResourcesRadio.isSelected();
myConfiguration.getState().ENABLE_MANIFEST_MERGING = myEnableManifestMerging.isSelected();
myConfiguration.getState().ENABLE_PRE_DEXING = myPreDexEnabledCheckBox.isSelected();
myConfiguration.getState().ENABLE_MULTI_DEX = myEnableMultiDexCheckBox.isSelected();
myConfiguration.getState().MAIN_DEX_LIST = myMainDexList.getText().trim();
myConfiguration.getState().MINIMAL_MAIN_DEX = myMinimalMainDexCheckBox.isSelected();
myConfiguration.getState().PACK_TEST_CODE = myIncludeTestCodeAndCheckBox.isSelected();
myConfiguration.getState().ENABLE_SOURCES_AUTOGENERATION = myEnableSourcesAutogenerationCheckBox.isSelected();
myConfiguration.setIncludeAssetsFromLibraries(myIncludeAssetsFromLibraries.isSelected());
if (AndroidMavenUtil.isMavenizedModule(myContext.getModule())) {
final Set<AndroidImportableProperty> notImportedProperties = myConfiguration.getState().myNotImportedProperties;
notImportedProperties.clear();
for (int i = 0; i < myImportedOptionsList.getItemsCount(); i++) {
final AndroidImportableProperty property = (AndroidImportableProperty) myImportedOptionsList.getItemAt(i);
if (!myImportedOptionsList.isItemSelected(i)) {
notImportedProperties.add(property);
}
}
}
myConfiguration.getState().RUN_PROGUARD = myRunProguardCheckBox.isSelected();
myConfiguration.getState().myProGuardCfgFiles = myProGuardConfigFilesPanel.getUrls();
boolean useCustomAptSrc = myUseCustomSourceDirectoryRadio.isSelected();
myConfiguration.getState().USE_CUSTOM_APK_RESOURCE_FOLDER = useCustomAptSrc;
myConfiguration.getState().USE_CUSTOM_MANIFEST_PACKAGE = myUseCustomManifestPackage.isSelected();
myConfiguration.getState().CUSTOM_MANIFEST_PACKAGE = myCustomManifestPackageField.getText().trim();
myConfiguration.getState().ADDITIONAL_PACKAGING_COMMAND_LINE_PARAMETERS = myAdditionalPackagingCommandLineParametersField.getText().trim();
String absAptSourcePath = myCustomAptSourceDirField.getText().trim();
if (useCustomAptSrc) {
if (absAptSourcePath.length() == 0) {
throw new ConfigurationException("Resources folder not specified");
}
myConfiguration.getState().CUSTOM_APK_RESOURCE_FOLDER = '/' + getAndCheckRelativePath(absAptSourcePath, false);
} else {
String relPath = toRelativePath(absAptSourcePath);
myConfiguration.getState().CUSTOM_APK_RESOURCE_FOLDER = relPath != null ? '/' + relPath : "";
}
myConfiguration.getState().UPDATE_PROPERTY_FILES = (String) myUpdateProjectPropertiesCombo.getSelectedItem();
String absProguardLogsPath = myProguardLogsDirectoryField.getText().trim();
myConfiguration.getState().PROGUARD_LOGS_FOLDER_RELATIVE_PATH = absProguardLogsPath.length() > 0 ? '/' + getAndCheckRelativePath(absProguardLogsPath, false) : "";
if (runApt || runIdl) {
final Module module = myContext.getModule();
if (runApt) {
AndroidCompileUtil.generate(module, AndroidAutogeneratorMode.AAPT);
}
if (runIdl) {
AndroidCompileUtil.generate(module, AndroidAutogeneratorMode.AIDL);
}
}
}
use of org.jetbrains.jps.android.model.impl.AndroidImportableProperty in project android by JetBrains.
the class AndroidFacetEditorTab method resetOptions.
private void resetOptions(AndroidFacetConfiguration configuration) {
String aptGenPath = configuration.getState().GEN_FOLDER_RELATIVE_PATH_APT;
String aptAbspath = aptGenPath.length() > 0 ? toAbsolutePath(aptGenPath) : "";
myRGenPathField.setText(aptAbspath != null ? aptAbspath : "");
String aidlGenPath = configuration.getState().GEN_FOLDER_RELATIVE_PATH_AIDL;
String aidlAbsPath = aidlGenPath.length() > 0 ? toAbsolutePath(aidlGenPath) : "";
myAidlGenPathField.setText(aidlAbsPath != null ? aidlAbsPath : "");
String manifestPath = configuration.getState().MANIFEST_FILE_RELATIVE_PATH;
String manifestAbsPath = manifestPath.length() > 0 ? toAbsolutePath(manifestPath) : "";
myManifestFileField.setText(manifestAbsPath != null ? manifestAbsPath : "");
String resPath = configuration.getState().RES_FOLDER_RELATIVE_PATH;
String resAbsPath = resPath.length() > 0 ? toAbsolutePath(resPath) : "";
myResFolderField.setText(resAbsPath != null ? resAbsPath : "");
String assetsPath = configuration.getState().ASSETS_FOLDER_RELATIVE_PATH;
String assetsAbsPath = assetsPath.length() > 0 ? toAbsolutePath(assetsPath) : "";
myAssetsFolderField.setText(assetsAbsPath != null ? assetsAbsPath : "");
String libsPath = configuration.getState().LIBS_FOLDER_RELATIVE_PATH;
String libsAbsPath = libsPath.length() > 0 ? toAbsolutePath(libsPath) : "";
myNativeLibsFolder.setText(libsAbsPath != null ? libsAbsPath : "");
myCustomDebugKeystoreField.setText(FileUtil.toSystemDependentName(VfsUtil.urlToPath(configuration.getState().CUSTOM_DEBUG_KEYSTORE_PATH)));
final boolean runProguard = configuration.getState().RUN_PROGUARD;
myRunProguardCheckBox.setSelected(runProguard);
myProGuardConfigFilesPanel.setUrls(configuration.getState().myProGuardCfgFiles);
myEnableMultiDexCheckBox.setSelected(configuration.getState().ENABLE_MULTI_DEX);
myMainDexList.setText(configuration.getState().MAIN_DEX_LIST);
myMinimalMainDexCheckBox.setSelected(configuration.getState().MINIMAL_MAIN_DEX);
myUseCustomSourceDirectoryRadio.setSelected(configuration.getState().USE_CUSTOM_APK_RESOURCE_FOLDER);
myUseAptResDirectoryFromPathRadio.setSelected(!configuration.getState().USE_CUSTOM_APK_RESOURCE_FOLDER);
String aptSourcePath = configuration.getState().CUSTOM_APK_RESOURCE_FOLDER;
String aptSourceAbsPath = aptSourcePath.length() > 0 ? toAbsolutePath(aptSourcePath) : "";
myCustomAptSourceDirField.setText(aptSourceAbsPath != null ? aptSourceAbsPath : "");
myCustomAptSourceDirField.setEnabled(configuration.getState().USE_CUSTOM_APK_RESOURCE_FOLDER);
String apkPath = configuration.getState().APK_PATH;
String apkAbsPath = apkPath.length() > 0 ? toAbsolutePath(apkPath) : "";
myApkPathCombo.getComboBox().getEditor().setItem(apkAbsPath != null ? apkAbsPath : "");
boolean mavenizedModule = AndroidMavenUtil.isMavenizedModule(myContext.getModule());
myRunProcessResourcesRadio.setVisible(mavenizedModule);
myRunProcessResourcesRadio.setSelected(myConfiguration.getState().RUN_PROCESS_RESOURCES_MAVEN_TASK);
myCompileResourcesByIdeRadio.setVisible(mavenizedModule);
myCompileResourcesByIdeRadio.setSelected(!myConfiguration.getState().RUN_PROCESS_RESOURCES_MAVEN_TASK);
myEnableManifestMerging.setSelected(myConfiguration.getState().ENABLE_MANIFEST_MERGING);
myPreDexEnabledCheckBox.setSelected(myConfiguration.getState().ENABLE_PRE_DEXING);
myIncludeTestCodeAndCheckBox.setSelected(myConfiguration.getState().PACK_TEST_CODE);
myIncludeAssetsFromLibraries.setSelected(myConfiguration.isIncludeAssetsFromLibraries());
myUseCustomManifestPackage.setSelected(myConfiguration.getState().USE_CUSTOM_MANIFEST_PACKAGE);
myCustomManifestPackageField.setEnabled(myConfiguration.getState().USE_CUSTOM_MANIFEST_PACKAGE);
myCustomManifestPackageField.setText(myConfiguration.getState().CUSTOM_MANIFEST_PACKAGE);
myAdditionalPackagingCommandLineParametersField.setText(myConfiguration.getState().ADDITIONAL_PACKAGING_COMMAND_LINE_PARAMETERS);
String proguardLogsPath = configuration.getState().PROGUARD_LOGS_FOLDER_RELATIVE_PATH;
String proguardLogsAbsPath = proguardLogsPath.length() > 0 ? toAbsolutePath(proguardLogsPath) : "";
myProguardLogsDirectoryField.setText(proguardLogsAbsPath != null ? proguardLogsAbsPath : "");
myUpdateProjectPropertiesCombo.setSelectedItem(myConfiguration.getState().UPDATE_PROPERTY_FILES);
myEnableSourcesAutogenerationCheckBox.setSelected(myConfiguration.getState().ENABLE_SOURCES_AUTOGENERATION);
updateAutogenerationPanels();
final int mavenTabIndex = myTabbedPane.indexOfTab(MAVEN_TAB_TITLE);
if (mavenTabIndex >= 0) {
myTabbedPane.removeTabAt(mavenTabIndex);
}
if (mavenizedModule) {
myTabbedPane.insertTab(MAVEN_TAB_TITLE, null, myMavenTabComponent, null, 2);
for (int i = 0; i < myImportedOptionsList.getItemsCount(); i++) {
final AndroidImportableProperty property = (AndroidImportableProperty) myImportedOptionsList.getItemAt(i);
myImportedOptionsList.setItemSelected(property, configuration.isImportedProperty(property));
}
}
updateLibAndAppSpecificFields();
}
Aggregations