use of com.intellij.openapi.options.ConfigurationException in project android by JetBrains.
the class AndroidRenameHandler method performApplicationPackageRenaming.
private static void performApplicationPackageRenaming(@NotNull Project project, @NotNull Editor editor, @NotNull DataContext context) {
PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(context);
if (!(element instanceof XmlAttributeValue)) {
return;
}
final Module module = ModuleUtilCore.findModuleForPsiElement(element);
if (module == null) {
return;
}
RenameDialog.showRenameDialog(context, new RenameDialog(project, element, null, editor) {
@NotNull
@Override
protected String getLabelText() {
return "Rename Android application package of module '" + module.getName() + "' to:";
}
@Override
protected void canRun() throws ConfigurationException {
final String name = getNewName();
if (name.length() == 0) {
throw new ConfigurationException(AndroidBundle.message("specify.package.name.error"));
}
if (!AndroidUtils.isValidAndroidPackageName(name)) {
throw new ConfigurationException(AndroidBundle.message("not.valid.package.name.error", name));
}
if (!AndroidCommonUtils.contains2Identifiers(name)) {
throw new ConfigurationException(AndroidBundle.message("package.name.must.contain.2.ids.error"));
}
super.canRun();
}
});
}
use of com.intellij.openapi.options.ConfigurationException 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 com.intellij.openapi.options.ConfigurationException in project android by JetBrains.
the class AdtImportBuilder method commit.
@Nullable
@Override
public List<Module> commit(Project project, @Nullable ModifiableModuleModel model, ModulesProvider modulesProvider, @Nullable ModifiableArtifactModel artifactModel) {
File destDir = getBaseDirPath(project);
try {
if (!destDir.exists()) {
boolean ok = destDir.mkdirs();
if (!ok) {
throw new IOException("Could not create destination directory");
}
}
// Re-read the project here since one of the wizard steps can have modified the importer options,
// and that affects the imported state (for example, if you enable/disable the replace-lib-with-dependency
// options, the set of modules can change)
readProjects();
if (!myImporter.getErrors().isEmpty()) {
return null;
}
myImporter.exportProject(destDir, true);
project.getBaseDir().refresh(false, true);
} catch (IOException e) {
Logger.getInstance(AdtImportBuilder.class).error(e);
return null;
}
try {
NewProjectImportGradleSyncListener syncListener = new NewProjectImportGradleSyncListener() {
@Override
public void syncSucceeded(@NotNull Project project) {
ApplicationManager.getApplication().invokeLater(() -> {
activateProjectView(project);
openSummary(project);
});
}
@Override
public void syncFailed(@NotNull Project project, @NotNull String errorMessage) {
ApplicationManager.getApplication().invokeLater(() -> {
createTopLevelProjectAndOpen(project);
openSummary(project);
});
}
};
GradleProjectImporter importer = GradleProjectImporter.getInstance();
if (myCreateProject) {
GradleProjectImporter.Request request = new GradleProjectImporter.Request().setProject(project);
importer.importProject(project.getName(), destDir, request, syncListener);
} else {
GradleSyncInvoker.getInstance().requestProjectSyncAndSourceGeneration(project, syncListener);
}
} catch (ConfigurationException e) {
Messages.showErrorDialog(project, e.getMessage(), e.getTitle());
} catch (Throwable e) {
Messages.showErrorDialog(project, e.getMessage(), "ADT Project Import");
}
return Collections.emptyList();
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.
the class FlexTestUtils method modifyConfigs.
public static void modifyConfigs(Project project, final Consumer<FlexProjectConfigurationEditor> modifier) {
Module[] modules = ModuleManager.getInstance(project).getModules();
final FlexProjectConfigurationEditor editor = createConfigEditor(modules);
try {
modifier.consume(editor);
editor.commit();
} catch (ConfigurationException ex) {
throw new RuntimeException(ex);
} finally {
Disposer.dispose(editor);
}
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.
the class FlexMoveClassDialog method canRun.
@Override
protected void canRun() throws ConfigurationException {
final NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(JavaScriptSupportLoader.JAVASCRIPT.getLanguage());
if (myFileLocal) {
final String className = myClassNameField.getText();
if (StringUtil.isEmpty(className)) {
throw new ConfigurationException(FlexBundle.message("element.name.empty", JSBundle.message(JSNamedElementKind.kind(myElements.iterator().next()).humanReadableKey())));
}
if (!namesValidator.isIdentifier(className, myProject)) {
throw new ConfigurationException(FlexBundle.message("invalid.element.name", StringUtil.decapitalize(JSBundle.message(JSNamedElementKind.kind(myElements.iterator().next()).humanReadableKey())), className));
}
}
final String packageName = myTargetPackageField.getText();
for (final String s : StringUtil.split(packageName, ".")) {
if (!namesValidator.isIdentifier(s, myProject)) {
throw new ConfigurationException(JSBundle.message("invalid.package", packageName));
}
}
}
Aggregations