Add actions: to configure project and to configure project with javascript
This commit is contained in:
@@ -73,6 +73,21 @@
|
|||||||
<action id="ShowKotlinSignatures" class="org.jetbrains.jet.plugin.ktSignature.ShowKotlinSignaturesAction"/>
|
<action id="ShowKotlinSignatures" class="org.jetbrains.jet.plugin.ktSignature.ShowKotlinSignaturesAction"/>
|
||||||
<add-to-group group-id="EditorGutterPopupMenu" anchor="last"/>
|
<add-to-group group-id="EditorGutterPopupMenu" anchor="last"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
|
<group id="KotlinToolsGroup" popup="true" text="Kotlin" icon="/org/jetbrains/jet/plugin/icons/kotlin13.png"
|
||||||
|
class="org.jetbrains.jet.plugin.actions.KotlinActionGroup">
|
||||||
|
<add-to-group group-id="ToolsMenu" anchor="last"/>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<action id="ConfigureKotlinInProject" class="org.jetbrains.jet.plugin.actions.ConfigureKotlinInProjectAction"
|
||||||
|
text="Configure Kotlin in Project">
|
||||||
|
<add-to-group group-id="KotlinToolsGroup"/>
|
||||||
|
</action>
|
||||||
|
|
||||||
|
<action id="ConfigureKotlinJsInProject" class="org.jetbrains.jet.plugin.actions.ConfigureKotlinJsInProjectAction"
|
||||||
|
text="Configure Kotlin (JavaScript) in Project">
|
||||||
|
<add-to-group group-id="KotlinToolsGroup"/>
|
||||||
|
</action>
|
||||||
</actions>
|
</actions>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="com.intellij">
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package org.jetbrains.jet.plugin.actions;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.collect.Collections2;
|
||||||
|
import com.intellij.openapi.actionSystem.AnAction;
|
||||||
|
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||||
|
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.ui.Messages;
|
||||||
|
import org.jetbrains.jet.plugin.configuration.ConfigureKotlinInProjectUtils;
|
||||||
|
import org.jetbrains.jet.plugin.configuration.KotlinJsModuleConfigurator;
|
||||||
|
import org.jetbrains.jet.plugin.configuration.KotlinProjectConfigurator;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class ConfigureKotlinInProjectAction extends AnAction {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(AnActionEvent e) {
|
||||||
|
Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
|
||||||
|
if (project == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ConfigureKotlinInProjectUtils.isProjectConfigured(project)) {
|
||||||
|
Messages.showInfoMessage("All modules with kotlin files are configured", "Configure Project Info");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Collection<KotlinProjectConfigurator> configurators =
|
||||||
|
Collections2.filter(ConfigureKotlinInProjectUtils.getApplicableConfigurators(project), new Predicate<KotlinProjectConfigurator>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(KotlinProjectConfigurator input) {
|
||||||
|
return !input.getName().equals(KotlinJsModuleConfigurator.NAME);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (configurators.size() == 1) {
|
||||||
|
configurators.iterator().next().configure(project);
|
||||||
|
}
|
||||||
|
else if (configurators.isEmpty()) {
|
||||||
|
Messages.showErrorDialog("There aren't configurators available", "Configure Kotlin in Project");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Messages.showErrorDialog("More than one configurator are available", "Configure Kotlin in Project");
|
||||||
|
ConfigureKotlinInProjectUtils.showConfigureKotlinNotificationIfNeeded(project);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package org.jetbrains.jet.plugin.actions;
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.AnAction;
|
||||||
|
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||||
|
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.ui.Messages;
|
||||||
|
import org.jetbrains.jet.plugin.configuration.ConfigureKotlinInProjectUtils;
|
||||||
|
import org.jetbrains.jet.plugin.configuration.KotlinJsModuleConfigurator;
|
||||||
|
import org.jetbrains.jet.plugin.configuration.KotlinProjectConfigurator;
|
||||||
|
|
||||||
|
public class ConfigureKotlinJsInProjectAction extends AnAction {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(AnActionEvent e) {
|
||||||
|
Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
|
||||||
|
if (project == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
KotlinProjectConfigurator configurator = ConfigureKotlinInProjectUtils.getConfiguratorByName(KotlinJsModuleConfigurator.NAME);
|
||||||
|
|
||||||
|
assert configurator != null : "JsModuleConfigurator should be non-null";
|
||||||
|
|
||||||
|
if (ConfigureKotlinInProjectUtils.getNonConfiguredModules(project, configurator).isEmpty()) {
|
||||||
|
Messages.showInfoMessage("All modules are configured", "Configure Project Info");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
configurator.configure(project);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2000-2010 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.jetbrains.jet.plugin.actions;
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||||
|
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||||
|
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||||
|
import com.intellij.openapi.actionSystem.Presentation;
|
||||||
|
|
||||||
|
public class KotlinActionGroup extends DefaultActionGroup {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(AnActionEvent event) {
|
||||||
|
Presentation p = event.getPresentation();
|
||||||
|
boolean hasProject = event.getData(CommonDataKeys.PROJECT) != null;
|
||||||
|
|
||||||
|
p.setVisible(hasProject);
|
||||||
|
p.setEnabled(hasProject);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user