mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
tweaking recent projects display on welcome screen (IDEA-75483)
This commit is contained in:
@@ -18,7 +18,6 @@ package com.intellij.ide;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ProjectManagerAdapter;
|
||||
@@ -32,7 +31,6 @@ import com.intellij.util.messages.MessageBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.event.InputEvent;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
@@ -271,30 +269,6 @@ public abstract class RecentProjectsManagerBase implements PersistentStateCompon
|
||||
return null;
|
||||
}
|
||||
|
||||
private class ReopenProjectAction extends AnAction implements DumbAware {
|
||||
private final String myProjectPath;
|
||||
|
||||
public ReopenProjectAction(final String projectPath, final String projectName) {
|
||||
myProjectPath = projectPath;
|
||||
|
||||
String _text = projectPath;
|
||||
if (projectName != null) {
|
||||
_text = String.format("%s", projectName);
|
||||
}
|
||||
|
||||
final Presentation presentation = getTemplatePresentation();
|
||||
presentation.setText(_text, false);
|
||||
presentation.setDescription(projectPath);
|
||||
}
|
||||
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final int modifiers = e.getModifiers();
|
||||
final boolean forceOpenInNewFrame = (modifiers & InputEvent.CTRL_MASK) != 0 || (modifiers & InputEvent.SHIFT_MASK) != 0;
|
||||
doOpenProject(myProjectPath, PlatformDataKeys.PROJECT.getData(e.getDataContext()), forceOpenInNewFrame);
|
||||
}
|
||||
}
|
||||
|
||||
private class MyAppLifecycleListener extends AppLifecycleListener.Adapter {
|
||||
public void appFrameCreated(final String[] commandLineArgs, @NotNull final Ref<Boolean> willOpenProject) {
|
||||
if (GeneralSettings.getInstance().isReopenLastProject() && getLastProjectPath() != null) {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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 com.intellij.ide;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class ReopenProjectAction extends AnAction implements DumbAware {
|
||||
private final String myProjectPath;
|
||||
|
||||
public ReopenProjectAction(final String projectPath, final String projectName) {
|
||||
myProjectPath = projectPath;
|
||||
|
||||
String _text = projectPath;
|
||||
if (projectName != null) {
|
||||
_text = String.format("%s", projectName);
|
||||
}
|
||||
|
||||
final Presentation presentation = getTemplatePresentation();
|
||||
presentation.setText(_text, false);
|
||||
presentation.setDescription(projectPath);
|
||||
}
|
||||
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final int modifiers = e.getModifiers();
|
||||
final boolean forceOpenInNewFrame = (modifiers & InputEvent.CTRL_MASK) != 0 || (modifiers & InputEvent.SHIFT_MASK) != 0;
|
||||
Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
RecentProjectsManagerBase.getInstance().doOpenProject(myProjectPath, project, forceOpenInNewFrame);
|
||||
}
|
||||
|
||||
public String getProjectPath() {
|
||||
return myProjectPath;
|
||||
}
|
||||
}
|
||||
+18
-5
@@ -18,6 +18,7 @@ package com.intellij.openapi.wm.impl.welcomeScreen;
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.RecentProjectsManagerBase;
|
||||
import com.intellij.ide.ReopenProjectAction;
|
||||
import com.intellij.ide.plugins.*;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
@@ -27,11 +28,10 @@ import com.intellij.openapi.application.ex.ApplicationInfoEx;
|
||||
import com.intellij.openapi.application.impl.PluginsFacade;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.impl.IdeRootPane;
|
||||
import com.intellij.ui.LabeledIcon;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.UIBundle;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -82,6 +82,10 @@ public class WelcomeScreen implements Disposable {
|
||||
private static final Color PLUGINS_PANEL_BACKGROUND = new Color(248, 248, 248);
|
||||
private static final Color PLUGINS_PANEL_BORDER = new Color(234, 234, 234);
|
||||
private static final Color CAPTION_COLOR = new Color(47, 67, 96);
|
||||
public static final SimpleTextAttributes CAPTION_BOLD_UNDERLINE_ATTRIBUTES =
|
||||
new SimpleTextAttributes(SimpleTextAttributes.STYLE_UNDERLINE | SimpleTextAttributes.STYLE_BOLD, CAPTION_COLOR);
|
||||
public static final SimpleTextAttributes CAPTION_UNDERLINE_ATTRIBUTES =
|
||||
new SimpleTextAttributes(SimpleTextAttributes.STYLE_UNDERLINE, CAPTION_COLOR);
|
||||
private static final Color DISABLED_CAPTION_COLOR = UIUtil.getInactiveTextColor();
|
||||
private static final Color ACTION_BUTTON_COLOR = WELCOME_PANEL_BACKGROUND;
|
||||
private static final Color BUTTON_POPPED_COLOR = new Color(241, 241, 241);
|
||||
@@ -238,8 +242,17 @@ public class WelcomeScreen implements Disposable {
|
||||
|
||||
int row = 1;
|
||||
for (final AnAction action : recentProjectsActions) {
|
||||
JLabel actionLabel = new JLabel(underlineHtmlText(row + ". " + StringUtil.escapeXml(action.getTemplatePresentation().getText())));
|
||||
actionLabel.setFont(LINK_FONT);
|
||||
SimpleColoredComponent actionLabel = new SimpleColoredComponent();
|
||||
actionLabel.append(String.valueOf(row), CAPTION_UNDERLINE_ATTRIBUTES);
|
||||
actionLabel.append(". ", new SimpleTextAttributes(0, CAPTION_COLOR));
|
||||
actionLabel.append(action.getTemplatePresentation().getText(), CAPTION_BOLD_UNDERLINE_ATTRIBUTES);
|
||||
|
||||
if (action instanceof ReopenProjectAction) {
|
||||
String path = FileUtil.getLocationRelativeToUserHome(((ReopenProjectAction)action).getProjectPath());
|
||||
actionLabel.append(" " + path, new SimpleTextAttributes(SimpleTextAttributes.STYLE_SMALLER, Color.GRAY));
|
||||
}
|
||||
|
||||
actionLabel.setFont(new Font(CAPTION_FONT_NAME, Font.PLAIN, 12));
|
||||
actionLabel.setForeground(CAPTION_COLOR);
|
||||
actionLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
actionLabel.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@@ -282,18 +282,22 @@ public class UIUtil {
|
||||
|
||||
@NotNull
|
||||
public static Font getFont(@NotNull FontSize size, @Nullable Font base) {
|
||||
Font defFont = getLabelFont();
|
||||
if (base == null) base = defFont;
|
||||
if (base == null) base = getLabelFont();
|
||||
|
||||
return base.deriveFont(getFontSize(size));
|
||||
}
|
||||
|
||||
public static float getFontSize(FontSize size) {
|
||||
int defSize = getLabelFont().getSize();
|
||||
switch (size) {
|
||||
case TREE:
|
||||
return base.deriveFont(Math.max(defFont.getSize() - 2f, 12f));
|
||||
return Math.max(defSize - 2f, 12f);
|
||||
case SMALL:
|
||||
return base.deriveFont(Math.max(defFont.getSize() - 2f, 11f));
|
||||
return Math.max(defSize - 2f, 11f);
|
||||
case MINI:
|
||||
return base.deriveFont(defFont.getSize() - 4f);
|
||||
return defSize - 4f;
|
||||
default:
|
||||
return base.deriveFont(defFont.getSize());
|
||||
return defSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user