@RequiredDispatchThread public FlatWelcomeScreen(FlatWelcomeFrame welcomeFrame) { super(new JBCardLayout()); myWelcomeFrame = welcomeFrame; myMainWelcomePanel = new FlatWelcomePanel(welcomeFrame) { @Override @RequiredDispatchThread public JComponent createActionPanel() { return FlatWelcomeScreen.this.createActionPanel(this); } }; add(myMainWelcomePanel, MAIN); registerKeyboardAction(e -> { for (Component component : getComponents()) { if (component.isVisible() && component != myMainWelcomePanel) { replacePanel((JComponent)component); break; } } }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); }
public ActionCallback goLeft() { if (mySelectedIndex == 0) { return ActionCallback.REJECTED; } mySelectedIndex--; return applySlide(JBCardLayout.SwipeDirection.BACKWARD); }
public ActionCallback swipe(String id, JBCardLayout.SwipeDirection direction) { final ActionCallback done = new ActionCallback(); getLayout().swipe(this, id, direction, new Runnable() { @Override public void run() { done.setDone(); } }); return done; }
public ActionCallback goRight() { if (mySelectedIndex == mySlides.size() - 1) { return ActionCallback.REJECTED; } mySelectedIndex++; return applySlide(JBCardLayout.SwipeDirection.FORWARD); }
private ActionCallback applySlide(JBCardLayout.SwipeDirection direction) { final ActionCallback callback = new ActionCallback(); getLayout().swipe(this, mySlides.get(mySelectedIndex).first, direction, new Runnable() { @Override public void run() { callback.setDone(); } }); return callback; }
private void showStepComponent(final Component component) { String id = myComponentToIdMap.get(component); if (id == null) { id = addStepComponent(component); myContentPanel.revalidate(); myContentPanel.repaint(); } ((JBCardLayout)myContentPanel.getLayout()).swipe(myContentPanel, id, JBCardLayout.SwipeDirection.AUTO); }
private HeaderPanel(String text, final String parentId) { super(new BorderLayout(5, 5)); setBackground(WelcomeScreenColors.CAPTION_BACKGROUND); if (parentId != null) { AnAction back = new AnAction("Back", null, AllIcons.Actions.Back) { @Override public void actionPerformed(AnActionEvent e) { myLayout.swipe(myContent, parentId, JBCardLayout.SwipeDirection.BACKWARD); } }; ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.CONTEXT_TOOLBAR, new DefaultActionGroup(back), true); JComponent toolbarComponent = toolbar.getComponent(); toolbarComponent.setOpaque(false); add(toolbarComponent, BorderLayout.WEST); } JLabel title = new JLabel(text); title.setHorizontalAlignment(SwingConstants.CENTER); title.setForeground(WelcomeScreenColors.CAPTION_FOREGROUND); add(title, BorderLayout.CENTER); setBorder(new BottomLineBorder()); }
private void initCurrentStep(boolean forward) { final AbstractCustomizeWizardStep myCurrentStep = mySteps.get(myIndex); myCurrentStep.beforeShown(forward); myCardLayout.swipe(myContentPanel, myCurrentStep.getTitle(), JBCardLayout.SwipeDirection.AUTO, new Runnable() { @Override public void run() { Component component = myCurrentStep.getDefaultFocusedComponent(); if (component != null) { component.requestFocus(); } } }); myBackButton.setVisible(myIndex > 0); if (myIndex > 0) { myBackButton.setText("Back to " + mySteps.get(myIndex - 1).getTitle()); } mySkipButton.setText("Skip " + (myIndex > 0 ? "Remaining" : "All") + " and Set Defaults"); myNextButton.setText(myIndex < mySteps.size() - 1 ? "Next: " + mySteps.get(myIndex + 1).getTitle() : "Start using " + ApplicationNamesInfo.getInstance().getFullProductName()); myHeaderLabel.setText(ensureHTML(myCurrentStep.getHTMLHeader())); myFooterLabel.setText(ensureHTML(myCurrentStep.getHTMLFooter())); StringBuilder navHTML = new StringBuilder("<html><body>"); for (int i = 0; i < mySteps.size(); i++) { if (i > 0) navHTML.append(" → "); if (i == myIndex) navHTML.append("<b>"); navHTML.append(mySteps.get(i).getTitle()); if (i == myIndex) navHTML.append("</b>"); } myNavigationLabel.setText(navHTML.toString()); }
private JComponent createGallery() { myGallery = new ASGallery<Optional<TemplateEntry>>(); Dimension thumbnailSize = DEFAULT_GALLERY_THUMBNAIL_SIZE; myGallery.setThumbnailSize(thumbnailSize); myGallery.setMinimumSize(new Dimension(thumbnailSize.width * 2 + 1, thumbnailSize.height)); myGallery.setLabelProvider(new Function<Optional<TemplateEntry>, String>() { @Override public String apply(Optional<TemplateEntry> template) { if (template.isPresent()) { return template.get().getTitle(); } else { return getNoTemplateEntryName(); } } }); myGallery.setImageProvider(new Function<Optional<TemplateEntry>, Image>() { @Override public Image apply(Optional<TemplateEntry> input) { return input.isPresent() ? input.get().getImage() : null; } }); myGallery.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { saveState(myGallery); } }); myGallery.setName("Templates Gallery"); AccessibleContext accessibleContext = myGallery.getAccessibleContext(); if (accessibleContext != null) { accessibleContext.setAccessibleDescription(getStepTitle()); } JPanel panel = new JPanel(new JBCardLayout()); panel.add("only card", new JBScrollPane(myGallery)); return panel; }
private void showDownloadLink(final HyperlinkLabel link, final RemotePkgInfo remote, final JPanel cardPanel) { link.addHyperlinkListener(new HyperlinkAdapter() { @Override protected void hyperlinkActivated(HyperlinkEvent e) { showDownloadWizard(remote.getPkgDesc()); populateAdditionalFormFactors(); myFormFactorPanel.validate(); } }); ((JBCardLayout)cardPanel.getLayout()).show(cardPanel, DOWNLOAD_LINK_CARD); }
private void createUIComponents() { myVersionLabel = new JBLabel(); myDefaultLabelColor = myVersionLabel.getForeground(); myVersionPanel = new JPanel(new JBCardLayout()); JPanel gettingVersionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); AsyncProcessIcon gettingVersionIcon = new AsyncProcessIcon(SquirrelBundle.message("getting.squirrel.sdk.version")); gettingVersionPanel.add(gettingVersionIcon); gettingVersionPanel.add(new JLabel(SquirrelBundle.message("getting"))); myVersionPanel.add(gettingVersionPanel, VERSION_GETTING); myVersionPanel.add(myVersionLabel, VERSION_RESULT); setVersion(null); }
public StudyToolWindow() { super(true, true); myCardLayout = new JBCardLayout(); myContentPanel = new JPanel(myCardLayout); mySplitPane = new OnePixelSplitter(myVertical = true); }
@SuppressWarnings("unused") public void showPanelById(@NotNull final String panelId) { myCardLayout.swipe(myContentPanel, panelId, JBCardLayout.SwipeDirection.AUTO); }
public JBSlidingPanel() { setLayout(new JBCardLayout()); }
@Override public JBCardLayout getLayout() { return (JBCardLayout)super.getLayout(); }
@Override public void actionPerformed(AnActionEvent e) { myLayout.swipe(myContent, myId, JBCardLayout.SwipeDirection.FORWARD); }
private void initCurrentStep(boolean forward) { final AbstractCustomizeWizardStep myCurrentStep = mySteps.get(myIndex); boolean disableBack = myCurrentStep.beforeShown(forward); myCardLayout.swipe(myContentPanel, myCurrentStep.getTitle(), JBCardLayout.SwipeDirection.AUTO, new Runnable() { @Override public void run() { Component component = myCurrentStep.getDefaultFocusedComponent(); if (component != null) { IdeFocusManager.getGlobalInstance().doForceFocusWhenFocusSettlesDown(component); } } }); myBackButton.setVisible(myIndex > 0); if (disableBack) { myBackButton.setVisible(false); mySkipButton.setVisible(false); } if (myIndex > 0) { myBackButton.setText("Back to " + mySteps.get(myIndex - 1).getTitle()); } mySkipButton.setText("Skip " + (myIndex > 0 ? "Remaining" : "All")); boolean nextButton = myIndex < mySteps.size() - 1; if (nextButton) { myNextButton.setText("Next: " + mySteps.get(myIndex + 1).getTitle()); } else { myNextButton.setVisible(false); } myHeaderLabel.setText(myCurrentStep.getHTMLHeader()); myFooterLabel.setText(myCurrentStep.getHTMLFooter()); StringBuilder navHTML = new StringBuilder("<html><body>"); for (int i = 0; i < mySteps.size(); i++) { if (i > 0) navHTML.append(" → "); if (i == myIndex) navHTML.append("<b>"); navHTML.append(mySteps.get(i).getTitle()); if (i == myIndex) navHTML.append("</b>"); } myNavigationLabel.setText(navHTML.toString()); }
@RequiredDispatchThread private JComponent createActionPanel(FlatWelcomePanel welcomePanel) { JPanel actions = new NonOpaquePanel(); actions.setBorder(JBUI.Borders.emptyLeft(10)); actions.setLayout(new BoxLayout(actions, BoxLayout.Y_AXIS)); ActionManager actionManager = ActionManager.getInstance(); ActionGroup quickStart = (ActionGroup)actionManager.getAction(IdeActions.GROUP_WELCOME_SCREEN_QUICKSTART); List<AnAction> group = new ArrayList<>(); collectAllActions(group, quickStart); for (AnAction action : group) { AnActionEvent e = AnActionEvent.createFromAnAction(action, null, ActionPlaces.WELCOME_SCREEN, DataManager.getInstance().getDataContext(welcomePanel)); action.update(e); if (action instanceof WelcomeScreenSlideAction) { final WelcomeScreenSlideAction oldAction = (WelcomeScreenSlideAction)action; action = new AnAction() { @RequiredDispatchThread @Override public void actionPerformed(@Nonnull AnActionEvent e) { JComponent panel = oldAction.createSlide(myWelcomeFrame, myWelcomeFrame::setTitle); JBCardLayout layout = (JBCardLayout)FlatWelcomeScreen.this.getLayout(); String id = oldAction.getClass().getName(); FlatWelcomeScreen.this.add(panel, id); layout.swipe(FlatWelcomeScreen.this, id, JBCardLayout.SwipeDirection.FORWARD); } }; action.copyFrom(oldAction); } Presentation presentation = e.getPresentation(); if (presentation.isVisible()) { String text = presentation.getText(); if (text != null && text.endsWith("...")) { text = text.substring(0, text.length() - 3); } ActionLink link = new ActionLink(text, presentation.getIcon(), action, createUsageTracker(action)); // Don't allow focus, as the containing panel is going to focusable. link.setFocusable(false); link.setPaintUnderline(false); link.setNormalColor(WelcomeScreenConstants.getLinkNormalColor()); FlatWelcomePanel.JActionLinkPanel button = new FlatWelcomePanel.JActionLinkPanel(link); button.setBorder(JBUI.Borders.empty(8, 20)); if (action instanceof WelcomePopupAction) { button.add(FlatWelcomePanel.createArrow(link), BorderLayout.EAST); } welcomePanel.installFocusable(button, action, KeyEvent.VK_UP, KeyEvent.VK_DOWN, true); actions.add(button); } } JPanel panel = new JPanel(); //panel.setBackground(FlatWelcomeFrame.getMainBackground()); panel.add(actions); return panel; }
public void replacePanel(JComponent oldCard) { JBCardLayout layout = (JBCardLayout)getLayout(); layout.swipe(this, MAIN, JBCardLayout.SwipeDirection.BACKWARD, () -> remove(oldCard)); myWelcomeFrame.setDefaultTitle(); }