public ActionButtonWithText(
     final AnAction action,
     final Presentation presentation,
     final String place,
     final Dimension minimumSize) {
   super(action, presentation, place, minimumSize);
   setFont(UIUtil.getLabelFont());
   setForeground(UIUtil.getLabelForeground());
   myPresentation.addPropertyChangeListener(
       new PropertyChangeListener() {
         @Override
         public void propertyChange(PropertyChangeEvent evt) {
           if (evt.getPropertyName().equals(Presentation.PROP_MNEMONIC_KEY)) {
             Integer oldValue =
                 evt.getOldValue() instanceof Integer ? (Integer) evt.getOldValue() : 0;
             Integer newValue =
                 evt.getNewValue() instanceof Integer ? (Integer) evt.getNewValue() : 0;
             updateMnemonic(oldValue, newValue);
           }
         }
       });
   getActionMap()
       .put(
           "doClick",
           new AbstractAction() {
             @Override
             public void actionPerformed(ActionEvent e) {
               click();
             }
           });
   updateMnemonic(0, myPresentation.getMnemonic());
 }
 @Nullable
 @Override
 public JComponent createComponent() {
   myEnabled = new JBCheckBox("Enable EditorConfig support");
   final JPanel result = new JPanel();
   result.setLayout(new BoxLayout(result, BoxLayout.LINE_AXIS));
   final JPanel panel = new JPanel(new VerticalFlowLayout());
   result.setBorder(IdeBorderFactory.createTitledBorder("EditorConfig", false));
   panel.add(myEnabled);
   final JLabel warning = new JLabel("EditorConfig may override the IDE code style settings");
   warning.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
   warning.setBorder(IdeBorderFactory.createEmptyBorder(0, 20, 0, 0));
   panel.add(warning);
   panel.setAlignmentY(Component.TOP_ALIGNMENT);
   result.add(panel);
   final JButton export = new JButton("Export");
   export.addActionListener(
       (event) -> {
         final Component parent = UIUtil.findUltimateParent(result);
         if (parent instanceof IdeFrame) {
           Utils.export(((IdeFrame) parent).getProject());
         }
       });
   export.setAlignmentY(Component.TOP_ALIGNMENT);
   result.add(export);
   return result;
 }
Пример #3
0
 public void updateUI() {
   setUI(StripeButtonUI.createUI(this));
   Font font = UIUtil.getLabelFont(UIUtil.FontSize.SMALL);
   /*
   if (font.getSize() % 2 == 1) { // that's a trick. Size of antialiased font isn't properly calculated for fonts with odd size
     font = font.deriveFont(font.getStyle(), font.getSize() - 1);
   }
   */
   setFont(font);
 }
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);

    if (myCurrentWindow == null || myCurrentWindow.getFiles().length == 0) {
      g.setColor(UIUtil.isUnderDarcula() ? UIUtil.getBorderColor() : new Color(0, 0, 0, 50));
      g.drawLine(0, 0, getWidth(), 0);
    }

    if (showEmptyText()) {
      UIUtil.applyRenderingHints(g);
      g.setColor(new JBColor(Gray._100, Gray._160));
      g.setFont(UIUtil.getLabelFont().deriveFont(UIUtil.isUnderDarcula() ? 24f : 18f));

      final UIUtil.TextPainter painter =
          new UIUtil.TextPainter().withShadow(true).withLineSpacing(1.4f);
      painter.appendLine("No files are open").underlined(new JBColor(Gray._150, Gray._100));

      if (!isProjectViewVisible()) {
        painter
            .appendLine(
                "Open Project View with "
                    + KeymapUtil.getShortcutText(
                        new KeyboardShortcut(
                            KeyStroke.getKeyStroke((SystemInfo.isMac ? "meta" : "alt") + " 1"),
                            null)))
            .smaller()
            .withBullet();
      }

      painter
          .appendLine("Open a file by name with " + getActionShortcutText("GotoFile"))
          .smaller()
          .withBullet()
          .appendLine(
              "Open Recent files with " + getActionShortcutText(IdeActions.ACTION_RECENT_FILES))
          .smaller()
          .withBullet()
          .appendLine("Open Navigation Bar with " + getActionShortcutText("ShowNavBar"))
          .smaller()
          .withBullet()
          .appendLine("Drag'n'Drop file(s) here from " + ShowFilePathAction.getFileManagerName())
          .smaller()
          .withBullet()
          .draw(
              g,
              new PairFunction<Integer, Integer, Pair<Integer, Integer>>() {
                @Override
                public Pair<Integer, Integer> fun(Integer width, Integer height) {
                  final Dimension s = getSize();
                  return Pair.create((s.width - width) / 2, (s.height - height) / 2);
                }
              });
    }
  }
    public InstalledPluginsTableRenderer(IdeaPluginDescriptor pluginDescriptor) {
      myPluginDescriptor = pluginDescriptor;

      myNameLabel.setFont(PluginManagerColumnInfo.getNameFont());
      myBundledLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
      myPanel.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 1));

      myNameLabel.setOpaque(true);
      myPanel.add(myNameLabel, BorderLayout.WEST);
      myPanel.add(myBundledLabel, BorderLayout.EAST);
    }
  ParameterInfoComponent(
      Object[] objects,
      Editor editor,
      @NotNull ParameterInfoHandler handler,
      boolean requestFocus) {
    super(new BorderLayout());
    myRequestFocus = requestFocus;

    if (!ApplicationManager.getApplication().isUnitTestMode()) {
      JComponent editorComponent = editor.getComponent();
      JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane();
      myWidthLimit = layeredPane.getWidth();
    }

    NORMAL_FONT = UIUtil.getLabelFont();
    BOLD_FONT = NORMAL_FONT.deriveFont(Font.BOLD);

    myObjects = objects;

    setBackground(BACKGROUND_COLOR);

    myHandler = handler;
    myPanels = new OneElementComponent[myObjects.length];
    final JPanel panel = new JPanel(new GridBagLayout());
    for (int i = 0; i < myObjects.length; i++) {
      myPanels[i] = new OneElementComponent();
      panel.add(
          myPanels[i],
          new GridBagConstraints(
              0,
              i,
              1,
              1,
              1,
              0,
              GridBagConstraints.WEST,
              GridBagConstraints.HORIZONTAL,
              new Insets(0, 0, 0, 0),
              0,
              0));
    }
    if (myRequestFocus) {
      AccessibleContextUtil.setName(
          this, "Parameter Info. Press TAB to navigate through each element. Press ESC to close.");
    }

    final JScrollPane pane = ScrollPaneFactory.createScrollPane(panel);
    pane.setBorder(null);
    pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    add(pane, BorderLayout.CENTER);

    myCurrentParameterIndex = -1;
  }
Пример #7
0
    public UpdateInfoPanel() {
      ApplicationInfo appInfo = ApplicationInfo.getInstance();
      myBuildNumber.setText(appInfo.getBuild().asString() + ")");
      final String version = appInfo.getFullVersion();

      myVersionNumber.setText(version);
      myNewBuildNumber.setText(myLatestBuild.getNumber().asString() + ")");
      myNewVersionNumber.setText(myLatestBuild.getVersion());
      myUpdateMessageLabel.setBackground(UIUtil.getLabelBackground());
      myScrollPane.setBackground(UIUtil.getLabelBackground());
      myScrollPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
      if (myLatestBuild.getMessage() != null) {
        StringBuilder builder = new StringBuilder();
        builder
            .append("<html><head>")
            .append(UIUtil.getCssFontDeclaration(UIUtil.getLabelFont()))
            .append("</head><body>")
            .append(StringUtil.formatLinks(myLatestBuild.getMessage()))
            .append("</body></html>");
        myUpdateMessageLabel.setText(builder.toString());
        myUpdateMessageLabel.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
      } else {
        myUpdateMessageLabel.setVisible(false);
      }

      PatchInfo patch = myLatestBuild.findPatchForCurrentBuild();
      if (patch == null) {
        myPatchAvailableLabel.setVisible(false);
        myPatchSizeLabel.setVisible(false);
      } else {
        myPatchSizeLabel.setText(patch.getSize() + "MB");
      }

      if (SystemInfo.isMac) {
        myManualCheckLabel.setText(
            "<html><br>To check for new updates manually, use the <b>"
                + ApplicationNamesInfo.getInstance().getProductName()
                + " | Check for Updates</b> command.</html>");
      }

      LabelTextReplacingUtil.replaceText(myPanel);
    }
    private Font getProductFont() {
      String name = "/fonts/Roboto-Light.ttf";
      URL url = AppUIUtil.class.getResource(name);
      if (url == null) {
        Logger.getInstance(AppUIUtil.class).warn("Resource missing: " + name);
      } else {

        try {
          InputStream is = url.openStream();
          try {
            return Font.createFont(Font.TRUETYPE_FONT, is);
          } finally {
            is.close();
          }
        } catch (Throwable t) {
          Logger.getInstance(AppUIUtil.class).warn("Cannot load font: " + url, t);
        }
      }
      return UIUtil.getLabelFont();
    }
Пример #9
0
  private void buildInProcessCount() {
    removeAll();
    setLayout(new BorderLayout());

    final JPanel progressCountPanel = new JPanel(new BorderLayout(0, 0));
    progressCountPanel.setOpaque(false);
    String processWord = myOriginals.size() == 1 ? " process" : " processes";
    final LinkLabel label =
        new LinkLabel(
            myOriginals.size() + processWord + " running...",
            null,
            new LinkListener() {
              @Override
              public void linkSelected(final LinkLabel aSource, final Object aLinkData) {
                triggerPopupShowing();
              }
            });

    if (SystemInfo.isMac) label.setFont(UIUtil.getLabelFont().deriveFont(11.0f));

    label.setOpaque(false);

    final Wrapper labelComp = new Wrapper(label);
    labelComp.setOpaque(false);
    progressCountPanel.add(labelComp, BorderLayout.CENTER);

    // myProgressIcon.setBorder(new IdeStatusBarImpl.MacStatusBarWidgetBorder());
    progressCountPanel.add(myProgressIcon, BorderLayout.WEST);

    add(myRefreshAndInfoPanel, BorderLayout.CENTER);

    progressCountPanel.setBorder(new EmptyBorder(0, 0, 0, 4));
    add(progressCountPanel, BorderLayout.EAST);

    revalidate();
    repaint();
  }
  @SuppressWarnings("MethodMayBeStatic")
  private String formatWc(
      @NotNull WCInfo info, @NotNull Collection<WorkingCopyFormat> upgradeFormats) {
    final StringBuilder sb =
        new StringBuilder()
            .append("<html><head>")
            .append(UIUtil.getCssFontDeclaration(UIUtil.getLabelFont()))
            .append("</head><body><table bgColor=\"")
            .append(ColorUtil.toHex(UIUtil.getPanelBackground()))
            .append("\">");

    sb.append("<tr valign=\"top\"><td colspan=\"3\"><b>")
        .append(info.getPath())
        .append("</b></td></tr>");
    if (info.hasError()) {
      sb.append("<tr valign=\"top\"><td>URL:</td><td colspan=\"2\" color=\"")
          .append(ColorUtil.toHex(JBColor.red))
          .append("\">")
          .append(info.getErrorMessage())
          .append("</td></tr>");
    } else {
      sb.append("<tr valign=\"top\"><td>URL:</td><td colspan=\"2\">")
          .append(info.getRootUrl())
          .append("</td></tr>");
    }
    if (upgradeFormats.size() > 1) {
      sb.append("<tr valign=\"top\"><td>Format:</td><td>")
          .append(info.getFormat().getName())
          .append("</td><td><a href=\"")
          .append(CHANGE_FORMAT)
          .append("\">Change</a></td></tr>");
    } else {
      sb.append("<tr valign=\"top\"><td>Format:</td><td colspan=\"2\">")
          .append(info.getFormat().getName())
          .append("</td></tr>");
    }

    if (!Depth.INFINITY.equals(info.getStickyDepth()) && !info.hasError()) {
      // can fix
      sb.append("<tr valign=\"top\"><td>Depth:</td><td>")
          .append(info.getStickyDepth().getName())
          .append("</td><td><a href=\"")
          .append(FIX_DEPTH)
          .append("\">Fix</a></td></tr>");
    } else {
      sb.append("<tr valign=\"top\"><td>Depth:</td><td colspan=\"2\">")
          .append(info.getStickyDepth().getName())
          .append("</td></tr>");
    }

    final NestedCopyType type = info.getType();
    if (NestedCopyType.external.equals(type) || NestedCopyType.switched.equals(type)) {
      sb.append("<tr valign=\"top\"><td colspan=\"3\"><i>")
          .append(type.getName())
          .append("</i></td></tr>");
    }
    if (info.isIsWcRoot()) {
      sb.append("<tr valign=\"top\"><td colspan=\"3\"><i>")
          .append("Working copy root</i></td></tr>");
    }
    if (!info.hasError()) {
      if (info.getFormat().isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN)) {
        sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"")
            .append(CLEANUP)
            .append("\">Cleanup</a></td></tr>");
      }
      sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"")
          .append(CONFIGURE_BRANCHES)
          .append("\">Configure Branches</a></td></tr>");
      sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"")
          .append(MERGE_FROM)
          .append("\"><b>Merge From...</b></a></i></td></tr>");

      sb.append("</table></body></html>");
    }
    return sb.toString();
  }
    public ComboBoxButton(Presentation presentation) {
      myPresentation = presentation;
      setModel(new MyButtonModel());
      setHorizontalAlignment(LEFT);
      setFocusable(false);
      Insets margins = getMargin();
      setMargin(new Insets(margins.top, 2, margins.bottom, 2));
      if (isSmallVariant()) {
        setBorder(IdeBorderFactory.createEmptyBorder(0, 2, 0, 2));
        if (!UIUtil.isUnderGTKLookAndFeel()) {
          setFont(UIUtil.getLabelFont().deriveFont(11.0f));
        }
      }
      addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              if (!myForcePressed) {
                IdeFocusManager.getGlobalInstance()
                    .doWhenFocusSettlesDown(
                        new Runnable() {
                          public void run() {
                            showPopup();
                          }
                        });
              }
            }
          });

      //noinspection HardCodedStringLiteral
      putClientProperty("Quaqua.Button.style", "placard");
      addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseEntered(MouseEvent e) {
              myMouseInside = true;
              repaint();
            }

            @Override
            public void mouseExited(MouseEvent e) {
              myMouseInside = false;
              repaint();
            }

            @Override
            public void mousePressed(final MouseEvent e) {
              if (SwingUtilities.isLeftMouseButton(e)) {
                e.consume();
                doClick();
              }
            }

            @Override
            public void mouseReleased(MouseEvent e) {
              dispatchEventToPopup(e);
            }
          });
      addMouseMotionListener(
          new MouseMotionListener() {
            @Override
            public void mouseDragged(MouseEvent e) {
              mouseMoved(
                  new MouseEvent(
                      e.getComponent(),
                      MouseEvent.MOUSE_MOVED,
                      e.getWhen(),
                      e.getModifiers(),
                      e.getX(),
                      e.getY(),
                      e.getClickCount(),
                      e.isPopupTrigger(),
                      e.getButton()));
            }

            @Override
            public void mouseMoved(MouseEvent e) {
              dispatchEventToPopup(e);
            }
          });
    }
Пример #12
0
  public ModuleTypeStep(boolean createNewProject) {
    myPanel = new JPanel(new GridBagLayout());
    myPanel.setBorder(BorderFactory.createEtchedBorder());

    myModuleDescriptionPane = new JEditorPane();
    myModuleDescriptionPane.setContentType(UIUtil.HTML_MIME);
    myModuleDescriptionPane.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              try {
                BrowserUtil.launchBrowser(e.getURL().toString());
              } catch (IllegalThreadStateException ex) {
                // it's nnot a problem
              }
            }
          }
        });
    myModuleDescriptionPane.setEditable(false);

    final ModuleType[] allModuleTypes = ModuleTypeManager.getInstance().getRegisteredTypes();

    myTypesList = new JList(allModuleTypes);
    myTypesList.setSelectionModel(new PermanentSingleSelectionModel());
    myTypesList.setCellRenderer(new ModuleTypesListCellRenderer());
    myTypesList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
              return;
            }
            final ModuleType typeSelected = (ModuleType) myTypesList.getSelectedValue();
            myModuleType = typeSelected;
            //noinspection HardCodedStringLiteral
            myModuleDescriptionPane.setText(
                "<html><body><font face=\"verdana\" size=\"-1\">"
                    + typeSelected.getDescription()
                    + "</font></body></html>");
            myEventDispatcher.getMulticaster().moduleTypeSelected(typeSelected);
          }
        });
    myTypesList.setSelectedIndex(0);
    myTypesList.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              if (myDoubleClickAction != null) {
                if (myTypesList.getSelectedValue() != null) {
                  myDoubleClickAction.run();
                }
              }
            }
          }
        });

    myRbCreateNewModule = new JRadioButton(IdeBundle.message("radio.create.new.module"), true);
    myRbImportModule = new JRadioButton(IdeBundle.message("radio.import.existing.module"));
    myButtonGroup = new ButtonGroup();
    myButtonGroup.add(myRbCreateNewModule);
    myButtonGroup.add(myRbImportModule);
    ModulesRbListener listener = new ModulesRbListener();
    myRbCreateNewModule.addItemListener(listener);
    myRbImportModule.addItemListener(listener);

    JTextField tfModuleFilePath = new JTextField();
    final String productName = ApplicationNamesInfo.getInstance().getProductName();
    myModulePathFieldPanel =
        createFieldPanel(
            tfModuleFilePath,
            IdeBundle.message("label.path.to.module.file", productName),
            new BrowseFilesListener(
                tfModuleFilePath,
                IdeBundle.message("prompt.select.module.file.to.import", productName),
                null,
                new ModuleFileChooserDescriptor()));
    myModulePathFieldPanel.setEnabled(false);

    if (createNewProject) {
      final JLabel moduleTypeLabel = new JLabel(IdeBundle.message("label.select.module.type"));
      moduleTypeLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
      myPanel.add(moduleTypeLabel, LABEL_CONSTRAINT);
    } else {
      myPanel.add(
          myRbCreateNewModule,
          new GridBagConstraints(
              0,
              GridBagConstraints.RELATIVE,
              1,
              1,
              0.0,
              0.0,
              GridBagConstraints.NORTHWEST,
              GridBagConstraints.NONE,
              new Insets(8, 10, 8, 10),
              0,
              0));
    }
    final JLabel descriptionLabel = new JLabel(IdeBundle.message("label.description"));
    descriptionLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
    myPanel.add(
        descriptionLabel,
        new GridBagConstraints(
            1,
            GridBagConstraints.RELATIVE,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.SOUTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));

    final JScrollPane typesListScrollPane = ScrollPaneFactory.createScrollPane(myTypesList);
    final Dimension preferredSize = calcTypeListPreferredSize(allModuleTypes);
    typesListScrollPane.setPreferredSize(preferredSize);
    typesListScrollPane.setMinimumSize(preferredSize);
    myPanel.add(
        typesListScrollPane,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            0.2,
            (createNewProject ? 1.0 : 0.0),
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, createNewProject ? 10 : 30, 0, 10),
            0,
            0));

    final JScrollPane descriptionScrollPane =
        ScrollPaneFactory.createScrollPane(myModuleDescriptionPane);
    descriptionScrollPane.setPreferredSize(
        new Dimension(preferredSize.width * 3, preferredSize.height));
    myPanel.add(
        descriptionScrollPane,
        new GridBagConstraints(
            1,
            GridBagConstraints.RELATIVE,
            1,
            1,
            0.8,
            (createNewProject ? 1.0 : 0.0),
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 10),
            0,
            0));

    if (!createNewProject) {
      myPanel.add(
          myRbImportModule,
          new GridBagConstraints(
              0,
              GridBagConstraints.RELATIVE,
              2,
              1,
              1.0,
              0.0,
              GridBagConstraints.NORTHWEST,
              GridBagConstraints.NONE,
              new Insets(16, 10, 0, 10),
              0,
              0));
      myPanel.add(
          myModulePathFieldPanel,
          new GridBagConstraints(
              0,
              GridBagConstraints.RELATIVE,
              2,
              1,
              1.0,
              1.0,
              GridBagConstraints.NORTHWEST,
              GridBagConstraints.HORIZONTAL,
              new Insets(8, 30, 0, 10),
              0,
              0));
    }
  }
Пример #13
0
  /**
   * CLSdkChooserPanel - the panel to choose Common Lisp SDK
   *
   * @param project Current project
   */
  public CLSdkChooserPanel(final Project project) {
    myJdkChooser =
        new JdkChooserPanel(
            project, ApplicationManager.getApplication().getComponent(CLSdkType.class));

    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEtchedBorder());

    final JLabel label = new JLabel(CLBundle.message("module.cl.select.jdk"));
    label.setUI(new MultiLineLabelUI());
    add(
        label,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            2,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(8, 10, 8, 10),
            0,
            0));

    final JLabel jdklabel = new JLabel(CLBundle.message("module.cl.prompt.label.project.jdk"));
    jdklabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
    add(
        jdklabel,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            2,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(8, 10, 0, 10),
            0,
            0));

    add(
        myJdkChooser,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(2, 10, 10, 5),
            0,
            0));
    JButton configureButton = new JButton(CLBundle.message("button.configure"));
    add(
        configureButton,
        new GridBagConstraints(
            1,
            GridBagConstraints.RELATIVE,
            1,
            1,
            0.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(2, 0, 10, 5),
            0,
            0));

    configureButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            myJdkChooser.editJdkTable();
          }
        });
  }
  public GoToHashOrRefPopup(
      @NotNull final Project project,
      @NotNull Collection<VcsRef> variants,
      Collection<VirtualFile> roots,
      @NotNull Function<String, Future> onSelectedHash,
      @NotNull Function<VcsRef, Future> onSelectedRef,
      @NotNull VcsLogColorManager colorManager,
      @NotNull Comparator<VcsRef> comparator) {
    myOnSelectedHash = onSelectedHash;
    myOnSelectedRef = onSelectedRef;
    myTextField =
        new TextFieldWithProgress<VcsRef>(
            project,
            new VcsRefCompletionProvider(project, variants, roots, colorManager, comparator)) {
          @Override
          public void onOk() {
            if (myFuture == null) {
              final Future future =
                  ((mySelectedRef == null || (!mySelectedRef.getName().equals(getText().trim())))
                      ? myOnSelectedHash.fun(getText().trim())
                      : myOnSelectedRef.fun(mySelectedRef));
              myFuture = future;
              showProgress();
              ApplicationManager.getApplication()
                  .executeOnPooledThread(
                      new Runnable() {
                        @Override
                        public void run() {
                          try {
                            future.get();
                            okPopup();
                          } catch (CancellationException ex) {
                            cancelPopup();
                          } catch (InterruptedException ex) {
                            cancelPopup();
                          } catch (ExecutionException ex) {
                            LOG.error(ex);
                            cancelPopup();
                          }
                        }
                      });
            }
          }
        };
    myTextField.setAlignmentX(Component.LEFT_ALIGNMENT);

    JBLabel label = new JBLabel("Enter hash or branch/tag name:");
    label.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
    label.setAlignmentX(Component.LEFT_ALIGNMENT);

    JPanel panel = new JPanel();
    BoxLayout layout = new BoxLayout(panel, BoxLayout.PAGE_AXIS);
    panel.setLayout(layout);
    panel.add(label);
    panel.add(myTextField);
    panel.setBorder(new EmptyBorder(2, 2, 2, 2));

    myPopup =
        JBPopupFactory.getInstance()
            .createComponentPopupBuilder(panel, myTextField.getPreferableFocusComponent())
            .setCancelOnClickOutside(true)
            .setCancelOnWindowDeactivation(true)
            .setCancelKeyEnabled(true)
            .setRequestFocus(true)
            .createPopup();
    myPopup.addListener(
        new JBPopupListener.Adapter() {
          @Override
          public void onClosed(LightweightWindowEvent event) {
            if (!event.isOk()) {
              if (myFuture != null) {
                myFuture.cancel(true);
              }
            }
            myFuture = null;
            myTextField.hideProgress();
          }
        });
  }
 public SeparatorWithText() {
   setBorder(BorderFactory.createEmptyBorder(getVgap(), 0, getVgap(), 0));
   setFont(UIUtil.getLabelFont());
   setFont(getFont().deriveFont(Font.BOLD));
 }
  public ProjectCreateModeStep(final String defaultPath, final WizardContext wizardContext) {
    final StringBuilder buf = new StringBuilder();
    for (WizardMode mode : Extensions.getExtensions(WizardMode.MODES)) {
      if (mode.isAvailable(wizardContext)) {
        myModes.add(mode);
        if (defaultPath != null && wizardContext.isCreatingNewProject()) {
          if (mode instanceof CreateFromSourcesMode) {
            myMode = mode;
          }
        } else if (mode instanceof CreateFromScratchMode) {
          myMode = mode;
        }
      }
      final String footnote = mode.getFootnote(wizardContext);
      if (footnote != null) {
        if (buf.length() > 0) buf.append("<br>");
        buf.append(footnote);
      }
    }

    if (myMode == null) {
      myMode = myModes.get(0);
    }

    myWizardContext = wizardContext;
    myWholePanel = new JPanel(new GridBagLayout());
    myWholePanel.setBorder(BorderFactory.createEtchedBorder());

    final Insets insets = new Insets(0, 0, 0, 5);
    GridBagConstraints gc =
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1,
            0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            insets,
            0,
            0);
    final ButtonGroup group = new ButtonGroup();
    for (final WizardMode mode : myModes) {
      insets.top = 15;
      insets.left = 5;
      final JRadioButton rb = new JRadioButton(mode.getDisplayName(wizardContext), mode == myMode);
      rb.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
      rb.addActionListener(
          new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
              setMode(mode);
            }
          });
      rb.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
              if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
                wizardContext.requestNextStep();
              }
            }
          });

      myWholePanel.add(rb, gc);
      group.add(rb);
      insets.top = 5;
      insets.left = 20;
      final JLabel description = new JLabel(mode.getDescription(wizardContext));
      myWholePanel.add(description, gc);
      final JComponent settings = mode.getAdditionalSettings(wizardContext);
      if (settings != null) {
        myWholePanel.add(settings, gc);
      }
    }
    myMode.onChosen(true);
    gc.weighty = 1;
    gc.fill = GridBagConstraints.BOTH;
    myWholePanel.add(Box.createVerticalBox(), gc);
    final JLabel note =
        new JLabel(
            "<html>" + buf.toString() + "</html>",
            IconLoader.getIcon("/nodes/warningIntroduction.png"),
            SwingConstants.LEFT);
    note.setVisible(buf.length() > 0);
    gc.weighty = 0;
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.insets.bottom = 5;
    myWholePanel.add(note, gc);
  }
  public AndroidThemePreviewPanel(@NotNull ThemeEditorContext context, @NotNull Color background) {
    super(BoxLayout.PAGE_AXIS);

    setOpaque(true);
    setMinimumSize(JBUI.size(200, 0));

    myContext = context;
    myAndroidPreviewPanel = new AndroidPreviewPanel(myContext.getConfiguration());
    myContext.addChangeListener(
        new ThemeEditorContext.ChangeListener() {
          @Override
          public void onNewConfiguration(ThemeEditorContext context) {
            refreshConfiguration();
          }
        });
    myAndroidPreviewPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));

    myBreadcrumbs = new NavigationComponent<Breadcrumb>();
    myBreadcrumbs.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));

    myDumbService = DumbService.getInstance(context.getProject());

    myScrollPane =
        new JBScrollPane(
            myAndroidPreviewPanel,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    myScrollPane.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    myScrollPane.setBorder(null);
    myScrollPane.setViewportBorder(null);
    mySearchTextField = new SearchTextField(true);
    // Avoid search box stretching more than 1 line.
    mySearchTextField.setMaximumSize(
        new Dimension(Integer.MAX_VALUE, mySearchTextField.getPreferredSize().height));
    mySearchTextField.setBorder(IdeBorderFactory.createEmptyBorder(0, 30, 0, 30));
    final Runnable delayedUpdate =
        new Runnable() {
          @Override
          public void run() {
            rebuild();
          }
        };

    // We use a timer when we detect a change in the search field to avoid re-creating the preview
    // if it's not necessary.
    mySearchTextField.addDocumentListener(
        new DocumentAdapter() {
          @Override
          protected void textChanged(DocumentEvent e) {
            Document document = e.getDocument();
            try {
              String search = document.getText(0, document.getLength());

              // Only use search terms longer than 3 characters.
              String newSearchTerm = search.length() < 3 ? "" : search;
              if (newSearchTerm.equals(mySearchTerm)) {
                return;
              }
              if (myPendingSearch != null) {
                myPendingSearch.cancel(true);
              }
              mySearchTerm = newSearchTerm;
              myPendingSearch =
                  mySearchScheduler.schedule(delayedUpdate, 300, TimeUnit.MILLISECONDS);
            } catch (BadLocationException e1) {
              LOG.error(e1);
            }
          }
        });

    myBreadcrumbs.setRootItem(new Breadcrumb("All components"));

    add(Box.createRigidArea(new Dimension(0, 5)));
    add(myBreadcrumbs);
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(mySearchTextField);
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(myScrollPane);

    setBackground(background);
    reloadComponents();

    myBreadcrumbs.addItemListener(
        new NavigationComponent.ItemListener<Breadcrumb>() {
          @Override
          public void itemSelected(@NotNull Breadcrumb item) {
            myBreadcrumbs.goTo(item);
            rebuild();
          }
        });

    myAndroidPreviewPanel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            ViewInfo view = myAndroidPreviewPanel.findViewAtPoint(e.getPoint());

            if (view == null) {
              return;
            }

            mySearchTextField.setText("");

            Object cookie = view.getCookie();
            if (cookie instanceof MergeCookie) {
              cookie = ((MergeCookie) cookie).getCookie();
            }

            if (!(cookie instanceof Element)) {
              return;
            }

            NamedNodeMap attributes = ((Element) cookie).getAttributes();
            Node group =
                attributes.getNamedItemNS(
                    ThemePreviewBuilder.BUILDER_URI, ThemePreviewBuilder.BUILDER_ATTR_GROUP);

            if (group != null) {
              myBreadcrumbs.push(
                  new Breadcrumb(ThemePreviewBuilder.ComponentGroup.valueOf(group.getNodeValue())));
              rebuild();
            }
          }
        });

    myContext.addConfigurationListener(
        new ConfigurationListener() {
          @Override
          public boolean changed(int flags) {
            refreshConfiguration();

            if ((flags & ConfigurationListener.CFG_THEME) != 0) {
              boolean appCompatTheme = isAppCompatTheme(myContext.getConfiguration());
              if (appCompatTheme != myIsAppCompatTheme) {
                rebuild();
              }
            }

            return true;
          }
        });
  }
Пример #18
0
  private String formatWc(WCInfo info) {
    final StringBuilder sb =
        new StringBuilder()
            .append("<html><head>")
            .append(UIUtil.getCssFontDeclaration(UIUtil.getLabelFont()))
            .append("</head><body><table bgColor=\"")
            .append(ColorUtil.toHex(UIUtil.getPanelBackground()))
            .append("\">");

    sb.append("<tr valign=\"top\"><td colspan=\"3\"><b>")
        .append(info.getPath())
        .append("</b></td></tr>");
    sb.append("<tr valign=\"top\"><td>URL:</td><td colspan=\"2\">")
        .append(info.getRootUrl())
        .append("</td></tr>");
    if (!WorkingCopyFormat.ONE_DOT_SEVEN.equals(info.getFormat())) {
      // can convert
      sb.append("<tr valign=\"top\"><td>Format:</td><td>")
          .append(info.getFormat().getName())
          .append("</td><td><a href=\"")
          .append(CHANGE_FORMAT)
          .append("\">Change</a></td></tr>");
    } else {
      sb.append("<tr valign=\"top\"><td>Format:</td><td colspan=\"2\">")
          .append(info.getFormat().getName())
          .append("</td></tr>");
    }

    if (!SVNDepth.INFINITY.equals(info.getStickyDepth())) {
      // can fix
      sb.append("<tr valign=\"top\"><td>Depth:</td><td>")
          .append(info.getStickyDepth().getName())
          .append("</td><td><a href=\"")
          .append(FIX_DEPTH)
          .append("\">Fix</a></td></tr>");
    } else {
      sb.append("<tr valign=\"top\"><td>Depth:</td><td colspan=\"2\">")
          .append(info.getStickyDepth().getName())
          .append("</td></tr>");
    }

    final NestedCopyType type = info.getType();
    if (NestedCopyType.external.equals(type) || NestedCopyType.switched.equals(type)) {
      sb.append("<tr valign=\"top\"><td colspan=\"3\"><i>")
          .append(type.getName())
          .append("</i></td></tr>");
    }
    if (info.isIsWcRoot()) {
      sb.append("<tr valign=\"top\"><td colspan=\"3\"><i>")
          .append("Working copy root</i></td></tr>");
    }
    sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"")
        .append(CONFIGURE_BRANCHES)
        .append("\">Configure Branches</a></td></tr>");
    sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"")
        .append(MERGE_FROM)
        .append("\"><b>Merge From...</b></a></i></td></tr>");

    sb.append("</table></body></html>");
    return sb.toString();
  }
 protected TextPanel() {
   setFont(SystemInfo.isMac ? UIUtil.getLabelFont().deriveFont(11.0f) : UIUtil.getLabelFont());
   setOpaque(false);
 }
Пример #20
0
 @NotNull
 public static String getHtmlWithFonts(@NotNull String input) {
   Font font = UIUtil.getLabelFont();
   return getHtmlWithFonts(input, font.getStyle(), font);
 }
 @NotNull
 private Font getBaseFont() {
   Font font = getFont();
   if (font == null) font = UIUtil.getLabelFont();
   return font;
 }
 private static JLabel markLabel(final String text) {
   JLabel label = new JLabel(text);
   label.setFont(UIUtil.getLabelFont());
   return label;
 }
  public BaseGoogleLoginUI(@NotNull String signinText) {
    setLayout(new GridBagLayout());
    setPreferredSize(new Dimension(MIN_WIDTH, PREFERRED_HEIGHT));
    setOpaque(false);

    JLabel googleIcon = new JBLabel();

    setBorder(BorderFactory.createEmptyBorder(10, 15, 15, 15));
    googleIcon.setHorizontalAlignment(SwingConstants.CENTER);
    googleIcon.setVerticalAlignment(SwingConstants.CENTER);
    googleIcon.setOpaque(false);
    googleIcon.setIcon(GoogleLoginIcons.GOOGLE_LOGO);
    googleIcon.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weighty = 0;
    add(googleIcon, c);

    JTextArea signinTextArea = new JTextArea();
    signinTextArea.setFont(UIUtil.getLabelFont());
    signinTextArea.setLineWrap(true);
    signinTextArea.setWrapStyleWord(true);
    signinTextArea.setOpaque(false);
    signinTextArea.setText(signinText);
    c.gridx = 0;
    c.gridy = 1;
    c.weighty = 1;
    c.gridwidth = 2;
    c.weightx = 1;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    add(signinTextArea, c);
  }