mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
actions: support titled separators in plugin.xml
This commit is contained in:
@@ -126,7 +126,7 @@ public class DefaultActionGroup extends ActionGroup {
|
||||
* Adds a separator to the tail.
|
||||
*/
|
||||
public final void addSeparator() {
|
||||
add(Separator.getInstance());
|
||||
add(Separator.create());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,7 +411,7 @@ public class DefaultActionGroup extends ActionGroup {
|
||||
}
|
||||
|
||||
public void addSeparator(@Nullable String separatorText) {
|
||||
add(new Separator(separatorText));
|
||||
add(Separator.create(separatorText));
|
||||
}
|
||||
|
||||
private static class ActionDuplicationException extends IllegalArgumentException {
|
||||
|
||||
@@ -16,20 +16,39 @@
|
||||
package com.intellij.openapi.actionSystem;
|
||||
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a separator.
|
||||
*/
|
||||
public final class Separator extends AnAction implements DumbAware {
|
||||
|
||||
private static final Separator ourInstance = new Separator();
|
||||
|
||||
private String myText;
|
||||
|
||||
public Separator() {
|
||||
@NotNull
|
||||
public static Separator getInstance() {
|
||||
return ourInstance;
|
||||
}
|
||||
|
||||
public Separator(@Nullable final String text) {
|
||||
@NotNull
|
||||
public static Separator create() {
|
||||
return create(null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Separator create(@Nullable String text) {
|
||||
return StringUtil.isEmptyOrSpaces(text)? ourInstance : new Separator(text);
|
||||
}
|
||||
|
||||
private final String myText;
|
||||
|
||||
public Separator() {
|
||||
myText = null;
|
||||
}
|
||||
|
||||
public Separator(@Nullable String text) {
|
||||
myText = text;
|
||||
}
|
||||
|
||||
@@ -37,10 +56,6 @@ public final class Separator extends AnAction implements DumbAware {
|
||||
return myText;
|
||||
}
|
||||
|
||||
public static Separator getInstance() {
|
||||
return ourInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Separator (" + myText + ")";
|
||||
|
||||
+2
-1
@@ -859,7 +859,8 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
reportActionError(pluginId, "unexpected name of element \"" + element.getName() + "\"");
|
||||
return;
|
||||
}
|
||||
Separator separator = Separator.getInstance();
|
||||
String text = element.getAttributeValue(TEXT_ATTR_NAME);
|
||||
Separator separator = text != null ? new Separator(text) : Separator.getInstance();
|
||||
if (parentGroup != null) {
|
||||
parentGroup.add(separator, this);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.idea.devkit.dom;
|
||||
|
||||
import com.intellij.ide.presentation.Presentation;
|
||||
import com.intellij.openapi.actionSystem.Separator;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.util.xml.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -93,7 +94,7 @@ public interface Group extends Actions, ActionOrGroup {
|
||||
* @return the value of the separator child.
|
||||
*/
|
||||
@NotNull
|
||||
List<GenericDomValue<String>> getSeparators();
|
||||
List<Separator> getSeparators();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.idea.devkit.dom;
|
||||
|
||||
import com.intellij.util.xml.GenericAttributeValue;
|
||||
import com.intellij.util.xml.GenericDomValue;
|
||||
import com.intellij.util.xml.Stubbed;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author gregsh
|
||||
*/
|
||||
public interface Separator extends GenericDomValue<String> {
|
||||
@NotNull
|
||||
@Stubbed
|
||||
GenericAttributeValue<String> getText();
|
||||
}
|
||||
Reference in New Issue
Block a user