use of com.intellij.openapi.ui.ValidationInfo in project android by JetBrains.
the class ScreenRecorderOptionsDialog method validateIntegerMultipleOf.
@Nullable
private static ValidationInfo validateIntegerMultipleOf(JTextField textField, int multiple, String errorMessage) {
String s = getText(textField);
if (s.isEmpty()) {
return null;
}
int x;
try {
x = Integer.parseInt(s);
} catch (NumberFormatException e) {
return new ValidationInfo(errorMessage, textField);
}
return (x % multiple > 0) ? new ValidationInfo("Must be a multiple of " + multiple, textField) : null;
}
use of com.intellij.openapi.ui.ValidationInfo in project android by JetBrains.
the class ConvertHprofDialog method doValidate.
@Nullable
@Override
protected ValidationInfo doValidate() {
String path = myPathTextFieldWithButton.getText().trim();
JTextField textField = myPathTextFieldWithButton.getTextField();
if (path.isEmpty()) {
return new ValidationInfo("Destination should not be empty", textField);
}
File f = new File(path);
if (!f.isAbsolute()) {
return new ValidationInfo("Destination path must be absolute.", textField);
}
if (f.getParentFile() == null || !f.getParentFile().isDirectory()) {
return new ValidationInfo("Invalid path", textField);
}
return null;
}
use of com.intellij.openapi.ui.ValidationInfo in project android by JetBrains.
the class CreateXmlResourcePanelImpl method doValidate.
/**
* @see CreateXmlResourceDialog#doValidate()
*/
@Override
public ValidationInfo doValidate() {
String resourceName = getResourceName();
Module selectedModule = getModule();
VirtualFile resourceDir = getResourceDirectory();
List<String> directoryNames = getDirNames();
String fileName = getFileName();
if (myNameField.isVisible() && resourceName.isEmpty()) {
return new ValidationInfo("specify resource name", myNameField);
} else if (myNameField.isVisible() && !AndroidResourceUtil.isCorrectAndroidResourceName(resourceName)) {
return new ValidationInfo(resourceName + " is not correct resource name", myNameField);
} else if (fileName.isEmpty()) {
return new ValidationInfo("specify file name", myFileNameCombo);
} else if (selectedModule == null) {
return new ValidationInfo("specify module", myModuleCombo);
} else if (resourceDir == null) {
return new ValidationInfo("specify a module with resources", myModuleCombo);
} else if (directoryNames.isEmpty()) {
return new ValidationInfo("choose directories", myDirectoriesPanel);
} else if (resourceName.equals(ResourceHelper.prependResourcePrefix(myModule, null, myFolderType))) {
return new ValidationInfo("specify more than resource prefix", myNameField);
}
return CreateXmlResourceDialog.checkIfResourceAlreadyExists(selectedModule.getProject(), resourceDir, resourceName, myResourceType, directoryNames, fileName);
}
use of com.intellij.openapi.ui.ValidationInfo in project intellij-plugins by JetBrains.
the class AddAdapterSupportDialog method doValidate.
@Override
@Nullable
protected ValidationInfo doValidate() {
String text = myDirectoryTextField.getText();
File dir = new File(text);
if (!dir.isDirectory() || !dir.isAbsolute()) {
return new ValidationInfo("Not a valid directory", myDirectoryTextField);
}
return null;
}
use of com.intellij.openapi.ui.ValidationInfo in project intellij-plugins by JetBrains.
the class AirPackageDialog method doValidate.
protected ValidationInfo doValidate() {
final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCs = getSelectedBCs();
if (modulesAndBCs.isEmpty())
return new ValidationInfo("Please select one or more build configurations");
if (myApkDebugPortTextField.isVisible() && myApkDebugPortPanel.isEnabled()) {
try {
final String portValue = myApkDebugPortTextField.getText().trim();
final int port = portValue.isEmpty() ? AirPackageUtil.DEBUG_PORT_DEFAULT : Integer.parseInt(portValue);
if (port <= 0 || port > 65535)
return new ValidationInfo("Incorrect port", myApkDebugPortPanel);
} catch (NumberFormatException e) {
return new ValidationInfo("Incorrect port", myApkDebugPortTextField);
}
}
for (Pair<Module, FlexBuildConfiguration> moduleAndBC : modulesAndBCs) {
final FlexBuildConfiguration bc = moduleAndBC.second;
if (bc.isSkipCompile() && LocalFileSystem.getInstance().findFileByPath(bc.getActualOutputFilePath()) == null) {
return new ValidationInfo(FlexBundle.message("can.not.package.bc", bc.getName(), FlexBundle.message("compilation.is.switched.off")));
}
final BuildConfigurationNature nature = bc.getNature();
if (nature.isMobilePlatform()) {
if (!bc.getAndroidPackagingOptions().isEnabled() && !bc.getIosPackagingOptions().isEnabled()) {
return new ValidationInfo(FlexBundle.message("can.not.package.bc", bc.getName(), "both Android and iOS packaging disabled"));
}
if (bc.getAndroidPackagingOptions().isEnabled() && bc.getIosPackagingOptions().isEnabled()) {
final AndroidPackageType androidPackage = (AndroidPackageType) myAndroidTypeCombo.getSelectedItem();
final IOSPackageType iosPackage = (IOSPackageType) myIOSTypeCombo.getSelectedItem();
final boolean androidDebug = androidPackage != AndroidPackageType.Release;
final boolean iosDebug = iosPackage == IOSPackageType.DebugOverNetwork;
if (androidDebug != iosDebug) {
return new ValidationInfo(FlexBundle.message("can.not.package.bc", bc.getName(), FlexBundle.message("different.debug.settings", androidDebug ? 1 : 2)));
}
}
}
final Ref<String> firstErrorRef = new Ref<>();
ValidateFlashConfigurationsPrecompileTask.checkPackagingOptions(moduleAndBC.first, bc, problem -> {
if (problem.severity == ProjectStructureProblemType.Severity.ERROR && firstErrorRef.isNull()) {
firstErrorRef.set(problem.errorMessage);
}
});
// todo better error reporting. May be just mention that errors exist in some BC and provide link to Project Structure
if (!firstErrorRef.isNull()) {
return new ValidationInfo(FlexBundle.message("can.not.package.bc", bc.getName(), firstErrorRef.get()));
}
}
return null;
}
Aggregations