customize welcome screen

This commit is contained in:
Konstantin Bulenkov
2012-04-30 14:18:03 +02:00
parent 466ef53a16
commit 18598bbb1b
6 changed files with 78 additions and 12 deletions
@@ -0,0 +1,27 @@
/*
* Copyright 2000-2012 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.openapi.wm;
import com.intellij.openapi.Disposable;
import javax.swing.*;
/**
* @author Konstantin Bulenkov
*/
public interface WelcomeScreen extends Disposable {
JComponent getWelcomePanel();
}
@@ -0,0 +1,31 @@
/*
* Copyright 2000-2012 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.openapi.wm;
import com.intellij.openapi.extensions.ExtensionPointName;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
/**
* @author Konstantin Bulenkov
*/
public interface WelcomeScreenProvider {
ExtensionPointName<WelcomeScreenProvider> EP_NAME = ExtensionPointName.create("com.intellij.welcomeScreen");
@Nullable
WelcomeScreen createWelcomeScreen(JRootPane rootPane);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 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.
@@ -32,8 +32,9 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.IdeFrame;
import com.intellij.openapi.wm.WelcomeScreen;
import com.intellij.openapi.wm.impl.IdeRootPane;
import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreen;
import com.intellij.openapi.wm.impl.welcomeScreen.DefaultWelcomeScreen;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.messages.MessageBus;
import org.jetbrains.annotations.NotNull;
@@ -214,9 +215,9 @@ public abstract class RecentProjectsManagerBase implements PersistentStateCompon
IdeFrame frame = e.getData(IdeFrame.KEY);
if (frame != null) {
IdeRootPane rootPane = (IdeRootPane) frame.getComponent();
WelcomeScreen welcomeScreen = rootPane.getWelcomeScreen();
if (welcomeScreen != null) {
welcomeScreen.hideRecentProjectsPanel();
final WelcomeScreen welcomeScreen = rootPane.getWelcomeScreen();
if (welcomeScreen instanceof DefaultWelcomeScreen) {
((DefaultWelcomeScreen)welcomeScreen).hideRecentProjectsPanel();
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 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.
@@ -41,7 +41,7 @@ import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.wm.*;
import com.intellij.openapi.wm.impl.status.IdeStatusBarImpl;
import com.intellij.openapi.wm.impl.status.MemoryUsagePanel;
import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreen;
import com.intellij.openapi.wm.impl.welcomeScreen.DefaultWelcomeScreen;
import com.intellij.ui.PopupHandler;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.messages.MessageBusConnection;
@@ -81,7 +81,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
private final UISettings myUISettings;
private WelcomeScreen myWelcomeScreen;
private Component myWelcomePane;
private JComponent myWelcomePane;
private final boolean myGlassPaneInitialized;
private final IdeGlassPaneImpl myGlassPane;
@@ -129,7 +129,13 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
}
void showWelcomeScreen() {
myWelcomeScreen = new WelcomeScreen(this);
for (WelcomeScreenProvider provider : WelcomeScreenProvider.EP_NAME.getExtensions()) {
myWelcomeScreen = provider.createWelcomeScreen(this);
if (myWelcomeScreen != null) break;
}
if (myWelcomeScreen == null) {
myWelcomeScreen = new DefaultWelcomeScreen(this);
}
Disposer.register(myDisposable, myWelcomeScreen);
myWelcomePane = myWelcomeScreen.getWelcomePanel();
myContentPane.add(myWelcomePane);
@@ -22,7 +22,6 @@ import com.intellij.ide.ReopenProjectAction;
import com.intellij.ide.dnd.FileCopyPasteUtil;
import com.intellij.ide.highlighter.ProjectFileType;
import com.intellij.ide.plugins.*;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.ActionButtonLook;
import com.intellij.openapi.actionSystem.impl.PresentationFactory;
@@ -34,6 +33,7 @@ import com.intellij.openapi.ui.Messages;
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.WelcomeScreen;
import com.intellij.openapi.wm.impl.IdeRootPane;
import com.intellij.ui.*;
import com.intellij.util.containers.ContainerUtil;
@@ -57,7 +57,7 @@ import static java.awt.GridBagConstraints.*;
/**
* @author pti
*/
public class WelcomeScreen implements Disposable {
public class DefaultWelcomeScreen implements WelcomeScreen {
private static final Insets ACTION_GROUP_CAPTION_INSETS = new Insets(20, 30, 5, 0);
private static final Insets PLUGINS_CAPTION_INSETS = new Insets(20, 25, 0, 0);
private static final Insets ACTION_ICON_INSETS = new Insets(5, 20, 15, 0);
@@ -122,7 +122,7 @@ public class WelcomeScreen implements Disposable {
return myWelcomePanel;
}
public WelcomeScreen(IdeRootPane rootPane) {
public DefaultWelcomeScreen(IdeRootPane rootPane) {
initApplicationSpecificImages();
myWelcomePanel = new JPanel(new GridBagLayout());
@@ -98,6 +98,7 @@
<extensionPoint name="bundledKeymapProvider" interface="com.intellij.openapi.keymap.impl.BundledKeymapProvider"/>
<extensionPoint name="toolWindow" beanClass="com.intellij.openapi.wm.ToolWindowEP"/>
<extensionPoint name="welcomeScreen" interface="com.intellij.openapi.wm.WelcomeScreenProvider"/>
<extensionPoint name="productivityFeaturesProvider" interface="com.intellij.featureStatistics.ProductivityFeaturesProvider"/>