Editing hints, colors (IDEA-165087, comments #8, #12)

This commit is contained in:
Rustam Vishnyakov
2017-02-08 18:34:51 +03:00
parent 600f713315
commit 5fa29c5f48
2 changed files with 15 additions and 1 deletions
@@ -26,6 +26,7 @@ import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.ui.popup.BalloonBuilder;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.Disposer;
import com.intellij.ui.JBColor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -138,7 +139,7 @@ public abstract class AbstractSchemesPanel<T extends Scheme> extends JPanel {
public final void showInfo(@Nullable String message, @NotNull MessageType messageType) {
myInfoLabel.setText(message);
myInfoLabel.setForeground(messageType.getTitleForeground());
myInfoLabel.setForeground(messageTypeToColor(messageType));
}
public final void clearInfo() {
@@ -179,4 +180,15 @@ public abstract class AbstractSchemesPanel<T extends Scheme> extends JPanel {
balloon.showInCenterOf(myToolbar);
Disposer.register(ProjectManager.getInstance().getDefaultProject(), balloon);
}
@SuppressWarnings("UseJBColor")
private static Color messageTypeToColor(@NotNull MessageType messageType) {
if (messageType == MessageType.INFO) {
return Color.GRAY;
}
else if (messageType == MessageType.ERROR) {
return Color.RED;
}
return JBColor.BLACK;
}
}
@@ -36,6 +36,7 @@ public class SchemesCombo<T extends Scheme> {
public static final String IDE_LEVEL = "IDE";
public static final String EMPTY_NAME_MESSAGE = "The name must not be empty";
public static final String NAME_ALREADY_EXISTS_MESSAGE = "Name is already in use. Please change to unique name.";
private static final String EDITING_HINT = "Enter to save, Esc to cancel.";
// endregion
private ComboBox<MySchemeListItem<T>> myComboBox;
@@ -136,6 +137,7 @@ public class SchemesCombo<T extends Scheme> {
public void startEdit() {
T scheme = getSelectedScheme();
if (scheme != null) {
mySchemesPanel.showInfo(EDITING_HINT, MessageType.INFO);
myNameEditorField.setText(scheme.getName());
myLayout.last(myRootPanel);
myNameEditorField.requestFocus();