Search in sources :

Example 1 with KarmaScopeKind

use of com.intellij.javascript.karma.scope.KarmaScopeKind in project intellij-plugins by JetBrains.

the class KarmaRunSettingsSerializationUtil method writeXml.

public static void writeXml(@NotNull Element element, @NotNull KarmaRunSettings settings) {
    JDOMExternalizerUtil.addElementWithValueAttribute(element, CONFIG_FILE, settings.getConfigSystemIndependentPath());
    if (StringUtil.isNotEmpty(settings.getBrowsers())) {
        JDOMExternalizerUtil.addElementWithValueAttribute(element, BROWSERS, settings.getBrowsers());
    }
    if (settings.getKarmaPackage() != null) {
        JDOMExternalizerUtil.addElementWithValueAttribute(element, KARMA_PACKAGE_DIR, settings.getKarmaPackage().getSystemIndependentPath());
    }
    JDOMExternalizerUtil.addElementWithValueAttribute(element, NODE_INTERPRETER, settings.getInterpreterRef().getReferenceName());
    settings.getEnvData().writeExternal(element);
    KarmaScopeKind scopeKind = settings.getScopeKind();
    if (scopeKind != KarmaScopeKind.ALL) {
        JDOMExternalizerUtil.addElementWithValueAttribute(element, SCOPE_KIND, scopeKind.name());
    }
    if (scopeKind == KarmaScopeKind.TEST_FILE) {
        JDOMExternalizerUtil.addElementWithValueAttribute(element, TEST_FILE_PATH, settings.getTestFileSystemIndependentPath());
    } else if (scopeKind == KarmaScopeKind.SUITE || scopeKind == KarmaScopeKind.TEST) {
        Element testNamesElement = new Element(TEST_NAMES);
        if (!settings.getTestNames().isEmpty()) {
            JDOMExternalizerUtil.addChildrenWithValueAttribute(testNamesElement, TEST_NAME, settings.getTestNames());
        }
        element.addContent(testNamesElement);
    }
}
Also used : KarmaScopeKind(com.intellij.javascript.karma.scope.KarmaScopeKind) Element(org.jdom.Element)

Example 2 with KarmaScopeKind

use of com.intellij.javascript.karma.scope.KarmaScopeKind in project intellij-plugins by JetBrains.

the class KarmaRunConfigurationEditor method createScopeKindRadioButtonPanel.

@NotNull
private JPanel createScopeKindRadioButtonPanel() {
    JPanel testKindPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, JBUI.scale(40), 0));
    testKindPanel.setBorder(IdeBorderFactory.createEmptyBorder(0, 10, 0, 0));
    ButtonGroup buttonGroup = new ButtonGroup();
    for (KarmaScopeKind scopeKind : KarmaScopeKind.values()) {
        JRadioButton radioButton = new JRadioButton(UIUtil.removeMnemonic(scopeKind.getName()));
        final int index = UIUtil.getDisplayMnemonicIndex(scopeKind.getName());
        if (index != -1) {
            radioButton.setMnemonic(scopeKind.getName().charAt(index + 1));
            radioButton.setDisplayedMnemonicIndex(index);
        }
        radioButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                setScopeKind(scopeKind);
            }
        });
        myRadioButtonMap.put(scopeKind, radioButton);
        testKindPanel.add(radioButton);
        buttonGroup.add(radioButton);
    }
    return testKindPanel;
}
Also used : KarmaScopeKind(com.intellij.javascript.karma.scope.KarmaScopeKind) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with KarmaScopeKind

use of com.intellij.javascript.karma.scope.KarmaScopeKind in project intellij-plugins by JetBrains.

the class KarmaRunSettingsSerializationUtil method readXml.

public static KarmaRunSettings readXml(@NotNull Element element) {
    KarmaRunSettings.Builder builder = new KarmaRunSettings.Builder();
    builder.setConfigPath(JDOMExternalizerUtil.getFirstChildValueAttribute(element, CONFIG_FILE));
    builder.setBrowsers(JDOMExternalizerUtil.getFirstChildValueAttribute(element, BROWSERS));
    String karmaPackageDir = JDOMExternalizerUtil.getFirstChildValueAttribute(element, KARMA_PACKAGE_DIR);
    if (karmaPackageDir != null) {
        builder.setKarmaPackage(new NodePackage(karmaPackageDir));
    }
    String interpreterRefName = JDOMExternalizerUtil.getFirstChildValueAttribute(element, NODE_INTERPRETER);
    builder.setInterpreterRef(NodeJsInterpreterRef.create(interpreterRefName));
    EnvironmentVariablesData envData = EnvironmentVariablesData.readExternal(element);
    builder.setEnvData(envData);
    KarmaScopeKind scopeKind = readScopeKind(element);
    builder.setScopeKind(scopeKind);
    if (scopeKind == KarmaScopeKind.TEST_FILE) {
        builder.setTestFilePath(JDOMExternalizerUtil.getFirstChildValueAttribute(element, TEST_FILE_PATH));
    } else if (scopeKind == KarmaScopeKind.SUITE || scopeKind == KarmaScopeKind.TEST) {
        builder.setTestNames(readTestNames(element));
    }
    return builder.build();
}
Also used : KarmaScopeKind(com.intellij.javascript.karma.scope.KarmaScopeKind) EnvironmentVariablesData(com.intellij.execution.configuration.EnvironmentVariablesData) NodePackage(com.intellij.javascript.nodejs.util.NodePackage)

Example 4 with KarmaScopeKind

use of com.intellij.javascript.karma.scope.KarmaScopeKind in project intellij-plugins by JetBrains.

the class KarmaRunConfiguration method suggestedName.

@Override
public String suggestedName() {
    KarmaRunSettings settings = myRunSettings;
    KarmaScopeKind scopeKind = settings.getScopeKind();
    if (scopeKind == KarmaScopeKind.ALL) {
        return PathUtil.getFileName(settings.getConfigPath());
    }
    if (scopeKind == KarmaScopeKind.TEST_FILE) {
        return PathUtil.getFileName(settings.getTestFileSystemDependentPath());
    }
    if (scopeKind == KarmaScopeKind.SUITE || scopeKind == KarmaScopeKind.TEST) {
        return JsTestFqn.getPresentableName(settings.getTestNames());
    }
    return super.suggestedName();
}
Also used : KarmaScopeKind(com.intellij.javascript.karma.scope.KarmaScopeKind)

Example 5 with KarmaScopeKind

use of com.intellij.javascript.karma.scope.KarmaScopeKind in project intellij-plugins by JetBrains.

the class KarmaRunConfigurationEditor method applyEditorTo.

@Override
protected void applyEditorTo(@NotNull KarmaRunConfiguration runConfiguration) throws ConfigurationException {
    KarmaRunSettings.Builder builder = new KarmaRunSettings.Builder();
    builder.setConfigPath(myConfigPathField.getChildComponent().getText());
    builder.setBrowsers(StringUtil.notNullize(myBrowsers.getText()));
    builder.setInterpreterRef(myNodeInterpreterField.getInterpreterRef());
    builder.setEnvData(myEnvVarsComponent.getData());
    builder.setKarmaPackage(myKarmaPackageField.getSelected());
    KarmaScopeKind scopeKind = getScopeKind();
    if (scopeKind != null) {
        builder.setScopeKind(scopeKind);
        KarmaScopeView view = getScopeKindView(scopeKind);
        view.applyTo(builder);
    }
    runConfiguration.setRunSettings(builder.build());
}
Also used : KarmaScopeKind(com.intellij.javascript.karma.scope.KarmaScopeKind) KarmaScopeView(com.intellij.javascript.karma.scope.KarmaScopeView)

Aggregations

KarmaScopeKind (com.intellij.javascript.karma.scope.KarmaScopeKind)6 KarmaScopeView (com.intellij.javascript.karma.scope.KarmaScopeView)2 EnvironmentVariablesData (com.intellij.execution.configuration.EnvironmentVariablesData)1 NodePackage (com.intellij.javascript.nodejs.util.NodePackage)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 Element (org.jdom.Element)1 NotNull (org.jetbrains.annotations.NotNull)1