Search in sources :

Example 21 with Environment

use of com.evolveum.midpoint.studio.impl.Environment in project midpoint-studio by Evolveum.

the class OperationResultDialog method saveResult.

private void saveResult(final Project project, ProgressIndicator indicator, final VirtualFileWrapper fileWrapper, OperationResult result) {
    MidPointService mm = MidPointService.getInstance(project);
    EnvironmentService em = EnvironmentService.getInstance(project);
    Environment environment = em.getSelected();
    RunnableUtils.runWriteActionAndWait(() -> {
        File file = fileWrapper.getFile();
        try {
            if (file.exists()) {
                file.delete();
            }
            file.createNewFile();
        } catch (IOException ex) {
            mm.printToConsole(environment, OperationResultDialog.class, "Couldn't create file " + file.getPath() + " for operation result", ex);
        }
        VirtualFile vFile = fileWrapper.getVirtualFile();
        try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter(vFile.getOutputStream(this), vFile.getCharset()))) {
            MidPointClient client = new MidPointClient(project, environment);
            PrismContext ctx = client.getPrismContext();
            PrismSerializer<String> serializer = ctx.serializerFor(PrismContext.LANG_XML);
            String xml = serializer.serializeAnyData(result.createOperationResultType(), SchemaConstantsGenerated.C_OPERATION_RESULT);
            IOUtils.write(xml, out);
        } catch (IOException | SchemaException ex) {
            mm.printToConsole(environment, OperationResultDialog.class, "Couldn't create file " + file.getPath() + " for operation result", ex);
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismContext(com.evolveum.midpoint.prism.PrismContext) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter) MidPointService(com.evolveum.midpoint.studio.impl.MidPointService) MidPointClient(com.evolveum.midpoint.studio.impl.MidPointClient) Environment(com.evolveum.midpoint.studio.impl.Environment) EnvironmentService(com.evolveum.midpoint.studio.impl.EnvironmentService) OutputStreamWriter(java.io.OutputStreamWriter) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 22 with Environment

use of com.evolveum.midpoint.studio.impl.Environment in project midpoint-studio by Evolveum.

the class EncryptedPropertyEditorDialog method fillInFields.

private void fillInFields() {
    List<Environment> list = new ArrayList<>();
    list.add(null);
    list.addAll(environments);
    ComboBoxModel model = new ListComboBoxModel(list);
    environment.setModel(model);
    key.setText(property.getKey());
    if (property.getEnvironment() != null) {
        Environment env = null;
        for (Environment e : environments) {
            if (Objects.equals(e.getId(), property.getEnvironment())) {
                env = e;
            }
        }
        environment.setSelectedItem(env);
    }
    password.setText(property.getValue());
    description.setText(property.getDescription());
}
Also used : ArrayList(java.util.ArrayList) Environment(com.evolveum.midpoint.studio.impl.Environment) ListComboBoxModel(org.jdesktop.swingx.combobox.ListComboBoxModel) ListComboBoxModel(org.jdesktop.swingx.combobox.ListComboBoxModel)

Example 23 with Environment

use of com.evolveum.midpoint.studio.impl.Environment in project midpoint-studio by Evolveum.

the class EnvironmentEditorDialog method populateBean.

private void populateBean() {
    selectable.setSelected(selected.isSelected());
    Environment environment = selectable.getObject();
    populateEnvironment(environment);
}
Also used : Environment(com.evolveum.midpoint.studio.impl.Environment)

Example 24 with Environment

use of com.evolveum.midpoint.studio.impl.Environment in project midpoint-studio by Evolveum.

the class EnvironmentEditorDialog method executeTestConnection.

private void executeTestConnection(Project project, JLabel testConnection) {
    Environment env = new Environment();
    populateEnvironment(env);
    try {
        MidPointClient client = new MidPointClient(project, env, settings);
        TestConnectionResult result = client.testConnection();
        if (result.success()) {
            updateInAwtThread(ConsoleViewContentType.NORMAL_OUTPUT_KEY.getDefaultAttributes().getForegroundColor(), "Version: " + result.version() + ", revision: " + result.revision());
        } else {
            String msg = result.exception() != null ? result.exception().getMessage() : null;
            updateInAwtThread(ConsoleViewContentType.LOG_ERROR_OUTPUT_KEY.getDefaultAttributes().getForegroundColor(), msg);
        }
    } catch (Exception ex) {
        LOG.error("Couldn't test connection", ex);
        updateInAwtThread(ConsoleViewContentType.LOG_ERROR_OUTPUT_KEY.getDefaultAttributes().getForegroundColor(), ex.getMessage());
    }
}
Also used : MidPointClient(com.evolveum.midpoint.studio.impl.MidPointClient) Environment(com.evolveum.midpoint.studio.impl.Environment) TestConnectionResult(com.evolveum.midpoint.studio.client.TestConnectionResult)

Example 25 with Environment

use of com.evolveum.midpoint.studio.impl.Environment in project midpoint-studio by Evolveum.

the class EnvironmentsPanel method initData.

private void initData() {
    List<Selectable<Environment>> selectables = new ArrayList<>();
    Environment selected = environmentSettings.getSelected();
    environmentSettings.getEnvironments().forEach(e -> {
        Selectable s = new Selectable(new Environment(e));
        if (selected != null) {
            s.setSelected(Objects.equals(e.getId(), selected.getId()));
        }
        selectables.add(s);
    });
    setData(selectables);
}
Also used : Selectable(com.evolveum.midpoint.studio.util.Selectable) ArrayList(java.util.ArrayList) Environment(com.evolveum.midpoint.studio.impl.Environment)

Aggregations

Environment (com.evolveum.midpoint.studio.impl.Environment)32 EnvironmentService (com.evolveum.midpoint.studio.impl.EnvironmentService)13 Project (com.intellij.openapi.project.Project)10 MidPointClient (com.evolveum.midpoint.studio.impl.MidPointClient)8 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 MidPointService (com.evolveum.midpoint.studio.impl.MidPointService)5 PrismContext (com.evolveum.midpoint.prism.PrismContext)4 ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 NotNull (org.jetbrains.annotations.NotNull)4 ComboObjectTypes (com.evolveum.midpoint.studio.action.browse.ComboObjectTypes)3 MidPointObject (com.evolveum.midpoint.studio.client.MidPointObject)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 BufferedWriter (java.io.BufferedWriter)3 OutputStreamWriter (java.io.OutputStreamWriter)3 Writer (java.io.Writer)3 List (java.util.List)3 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)2