Search in sources :

Example 1 with ConfigurationValidationException

use of org.moe.common.configuration.ConfigurationValidationException in project moe-ide-integration by multi-os-engine.

the class MOERunConfigurationEditor method testRemoteConnection.

private void testRemoteConnection() {
    String moduleName = (String) moduleCombo.getSelectedItem();
    if (moduleName == null || moduleName.isEmpty()) {
        showMessage("Please select module.");
        return;
    }
    Module module = ModuleManager.getInstance(myProject).findModuleByName(moduleName);
    if (module == null) {
        showMessage("Not found module: " + moduleName);
        return;
    }
    Properties properties = RemoteSettings.getProperties(hostTextField.getText(), portTextField.getText(), userTextField.getText(), knownhostsTextField.getText(), identityTextField.getText(), keychainNameTextField.getText(), keychainPassTextField.getText(), keychainLocktimeoutTextField.getText(), gradleRepositoriesTextField.getText());
    try {
        RemoteSettings.validate(properties);
    } catch (ConfigurationValidationException e) {
        showMessage(e.getErrorMessage());
        return;
    }
    File f = new File(ModuleUtils.getModulePath(module));
    final MOEToolWindow toolWindow = MOEToolWindow.getInstance(module.getProject());
    toolWindow.show();
    final StringBuffer runError = new StringBuffer();
    String errorMessage = RemoteSettings.test(f, properties, new ExecRunnerBase.ExecRunnerListener() {

        @Override
        public void stdout(String s) {
            toolWindow.printMessage(s + "\n", ConsoleViewContentType.NORMAL_OUTPUT);
            if (s.toLowerCase().contains("error")) {
                runError.append(s);
            }
        }

        @Override
        public void stderr(String s) {
            toolWindow.printMessage(s + "\n", ConsoleViewContentType.ERROR_OUTPUT);
            runError.append(s);
        }
    });
    String runErrorText = runError.toString();
    if (errorMessage == null && (runErrorText == null || runErrorText.isEmpty())) {
        showMessage("Test successful");
    } else {
        if (errorMessage == null) {
            errorMessage = runErrorText;
        } else {
            errorMessage += " " + runErrorText;
        }
        showMessage(errorMessage);
    }
}
Also used : ConfigurationValidationException(org.moe.common.configuration.ConfigurationValidationException) MOEToolWindow(org.moe.idea.ui.MOEToolWindow) ExecRunnerBase(org.moe.common.exec.ExecRunnerBase) Module(com.intellij.openapi.module.Module) Properties(java.util.Properties) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 2 with ConfigurationValidationException

use of org.moe.common.configuration.ConfigurationValidationException in project moe-ide-integration by multi-os-engine.

the class MOERunConfigurationEditor method applyEditorTo.

@Override
protected void applyEditorTo(MOERunConfiguration configuration) throws ConfigurationException {
    if (configurationCombo.getSelectedItem() != null) {
        configuration.configuration(configurationCombo.getSelectedItem().toString());
    }
    if (simulatorCombo.getSelectedItem() != null) {
        configuration.simulatorDeviceName(simulatorCombo.getSelectedItem().toString());
        configuration.simulatorUdid(((SimulatorComboItem) simulatorCombo.getSelectedItem()).udid());
    }
    if (deviceCombo.getSelectedItem() != null) {
        String deviceUdid = deviceCombo.getSelectedItem().toString();
        if (deviceUdid.equals(MOEText.get("First.Device.Available"))) {
            deviceUdid = "";
        }
        configuration.deviceUdid(deviceUdid);
    }
    if (moduleCombo.getSelectedItem() == null) {
        throw new ConfigurationException("Please select a module");
    }
    try {
        configuration.moduleName(moduleCombo.getSelectedItem().toString());
    } catch (Exception e) {
        throw new ConfigurationException(e.getMessage());
    }
    String port = textDebugPort.getText();
    if (!InputValidationHelper.isInteger(port)) {
        throw new ConfigurationException("Wrong debug port number, please enter a numeric value.");
    }
    configuration.debugPort(Integer.parseInt(port));
    port = textDebugRemotePort.getText();
    if (!InputValidationHelper.isInteger(port)) {
        throw new ConfigurationException("Wrong remote debug port number, please enter a numeric value.");
    }
    if (enableRemoteBuildCheckBox.isSelected()) {
        Properties properties = RemoteSettings.getProperties(hostTextField.getText(), portTextField.getText(), userTextField.getText(), knownhostsTextField.getText(), identityTextField.getText(), keychainNameTextField.getText(), keychainPassTextField.getText(), keychainLocktimeoutTextField.getText(), gradleRepositoriesTextField.getText());
        try {
            RemoteSettings.validate(properties);
        } catch (ConfigurationValidationException e) {
            throw new ConfigurationException(e.getErrorMessage());
        }
    }
    configuration.debugRemotePort(Integer.parseInt(port));
    configuration.runOnSimulator(simulatorRadio.isSelected());
    configuration.runJUnitTests(runJUnitTestsCheckBox.isSelected());
    configuration.setTestType(getTestingType());
    updateButtonsAndLabelComponents(configuration.getTestType());
    configuration.setTestClassName(myClassComponent.getComponent().getText());
    configuration.setTestPackageName(myPackageComponent.getComponent().getText());
    configuration.setRemoteBuildEnabled(enableRemoteBuildCheckBox.isSelected());
    configuration.setRemoteHost(hostTextField.getText());
    String remotePort = portTextField.getText();
    remotePort = remotePort == null || remotePort.isEmpty() ? "0" : remotePort;
    configuration.setRemotePort(Integer.parseInt(remotePort));
    configuration.setRemoteUser(userTextField.getText());
    configuration.setRemoteKnownhosts(knownhostsTextField.getText());
    configuration.setRemoteIdentity(identityTextField.getText());
    configuration.setRemoteKeychainPass(keychainPassTextField.getText());
    configuration.setRemoteKeychainName(keychainNameTextField.getText());
    String remoteBuildTimeout = keychainLocktimeoutTextField.getText();
    remoteBuildTimeout = remoteBuildTimeout == null || remoteBuildTimeout.isEmpty() ? "0" : remoteBuildTimeout;
    configuration.setRemoteKeychainLocktimeout(Integer.parseInt(remoteBuildTimeout));
    configuration.setRemoteGradleRepositories(gradleRepositoriesTextField.getText());
    configuration.setOpenDeploymentTargetDialog(openSelectDeploymentTargetCheckBox.isSelected());
    argumentsPanel.applyEditorTo(configuration);
}
Also used : ConfigurationValidationException(org.moe.common.configuration.ConfigurationValidationException) ConfigurationException(com.intellij.openapi.options.ConfigurationException) Properties(java.util.Properties) ConfigurationValidationException(org.moe.common.configuration.ConfigurationValidationException) ConfigurationException(com.intellij.openapi.options.ConfigurationException) IOException(java.io.IOException)

Example 3 with ConfigurationValidationException

use of org.moe.common.configuration.ConfigurationValidationException in project moe-ide-integration by multi-os-engine.

the class MOERunConfigurationEditor method showSavePropertyDialog.

private void showSavePropertyDialog() {
    final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    descriptor.setTitle("Select save folder");
    descriptor.setHideIgnored(true);
    VirtualFile selected = FileChooser.chooseFile(descriptor, myProject, null);
    if (selected != null) {
        Properties properties = RemoteSettings.getProperties(hostTextField.getText(), portTextField.getText(), userTextField.getText(), knownhostsTextField.getText(), identityTextField.getText(), keychainNameTextField.getText(), keychainPassTextField.getText(), keychainLocktimeoutTextField.getText(), gradleRepositoriesTextField.getText());
        try {
            RemoteSettings.validate(properties);
            RemoteSettings.saveProperties(selected.getCanonicalPath(), properties);
            VfsUtil.markDirtyAndRefresh(false, true, true, selected);
            showMessage("Property file saved.");
        } catch (ConfigurationValidationException e) {
            showMessage(e.getErrorMessage());
            return;
        } catch (IOException e) {
            showMessage(e.getMessage());
            return;
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ConfigurationValidationException(org.moe.common.configuration.ConfigurationValidationException) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) IOException(java.io.IOException) Properties(java.util.Properties)

Aggregations

Properties (java.util.Properties)3 ConfigurationValidationException (org.moe.common.configuration.ConfigurationValidationException)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 IOException (java.io.IOException)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 Module (com.intellij.openapi.module.Module)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 File (java.io.File)1 ExecRunnerBase (org.moe.common.exec.ExecRunnerBase)1 MOEToolWindow (org.moe.idea.ui.MOEToolWindow)1