@Override public void preShow() { setTitle(Localizer.get("title.AvailableVariables")); panel.setLayout(new MigLayout(new LC().gridGap("8pt", "4pt"))); JLabel jlName = new JLabel(Localizer.get("label.Name")); JLabel jlExample = new JLabel(Localizer.get("label.Example")); panel.add(jlName, new CC().pushX().growX()); panel.add(jlExample, new CC().pushX().growX().wrap()); panel.add(new SeparatorComponent(10), new CC().pushX().growX().wrap().spanX()); for (Map.Entry<String, String> entry : ptWrapper.getFakeProperties().entrySet()) { JTextField key = new JTextField (entry.getKey()); JTextField value = new JTextField (entry.getValue()); key.setEditable(false); value.setEditable(false); panel.add(key, new CC().pushX().growX()); panel.add(value, new CC().pushX().growX().wrap()); } pack(); }
private void buildFavouritesUI() { resetFavourites(); createFavouriteRadioButtons(); if (!listButtons.isEmpty()) { cbCompactNames = new JCheckBox(Localizer.get("label.CompactNames"), isCompactNames); cbCompactNames.addItemListener(e -> { isCompactNames = e.getStateChange() == ItemEvent.SELECTED; buildFavouritesUI(); }); favouritesPanel.add(new SeparatorComponent(), new CC().growX().spanX().wrap()); favouritesPanel.add(new JBLabel(Localizer.get("label.Favourites")), new CC().growX().spanX().pushX().wrap().alignX("center")); favouritesPanel.add(cbCompactNames, new CC().spanX().wrap().gapY("0", "10pt")); for (JBRadioButton radioButton : listButtons) { favouritesPanel.add(radioButton, new CC().growX().spanX().wrap()); } listButtons.get(0).doClick(); } else { rbFromPath.doClick(); } }
private void updateServicePanels(@NotNull ServiceCategory serviceCategory) { for (DeveloperServicePanel developerServicePanel : myPanelsList) { developerServicePanel.dispose(); } myPanelsList.clear(); myServicesPanel.removeAll(); Module module = (Module)myModuleCombo.getSelectedItem(); if (module == null) { return; } for (DeveloperService service : DeveloperServices.getFor(module, serviceCategory)) { myPanelsList.add(new DeveloperServicePanel(service)); } for (DeveloperServicePanel panel : myPanelsList) { if (myServicesPanel.getComponentCount() > 0) { myServicesPanel.add(new SeparatorComponent()); } myServicesPanel.add(panel); } // For some reason, requesting a layout and paint update is required here, as otherwise // previous content may not be cleared and new content may not be laid out. myServicesPanel.validate(); myServicesPanel.repaint(); }
private void rebuildCommitPanels(int[] selection) { myEmptyText.setText(""); int selectionLength = selection.length; // for each commit besides the first there are two components: Separator and CommitPanel int existingCount = (myMainContentPanel.getComponentCount() + 1) / 2; int requiredCount = Math.min(selectionLength, MAX_ROWS); for (int i = existingCount; i < requiredCount; i++) { if (i > 0) { myMainContentPanel.add(new SeparatorComponent(0, OnePixelDivider.BACKGROUND, null)); } myMainContentPanel.add(new CommitPanel(myLogData, myColorManager)); } // clear superfluous items while (myMainContentPanel.getComponentCount() > 2 * requiredCount - 1) { myMainContentPanel.remove(myMainContentPanel.getComponentCount() - 1); } if (selectionLength > MAX_ROWS) { myMainContentPanel.add(new SeparatorComponent(0, OnePixelDivider.BACKGROUND, null)); JBLabel label = new JBLabel("(showing " + MAX_ROWS + " of " + selectionLength + " selected commits)"); label.setFont(VcsHistoryUtil.getCommitDetailsFont()); label.setBorder(CommitPanel.getDetailsBorder()); myMainContentPanel.add(label); } mySelection = Ints.asList(Arrays.copyOf(selection, requiredCount)); repaint(); }
public JPanel buildView() { if (panel == null) { panel = new JPanel(new MigLayout(new LC().insets("0").fillX().gridGapY("1pt"))); } // Properties panelProperties = new JPanel(new MigLayout(new LC().insets("0").gridGap("0", "0"))); buildProperties(); panel.add(panelProperties, new CC().spanX().wrap().pushX().growX()); // Globals panel.add(new SeparatorComponent(6), new CC().pushX().growX().wrap().spanX()); JLabel jlGlobals = new JLabel(Localizer.get("GlobalVariables"), JLabel.CENTER); panel.add(jlGlobals, new CC().wrap().growX().pushX().spanX().gapY("0", "4pt")); panelGlobals = new JPanel(new MigLayout(new LC().insets("0").gridGap("0", "0"))); buildGlobals(); panel.add(panelGlobals, new CC().spanX().pushX().growX().wrap()); initAvailableVariablesButton(); // Files and Directories | Elements panel.add(new SeparatorComponent(6), new CC().pushX().growX().wrap().spanX()); JLabel jlFilesAndDirs = new JLabel(Localizer.get("FilesAndDirs"), JLabel.CENTER); panel.add(jlFilesAndDirs, new CC().wrap().growX().pushX().spanX().gapY("0", "4pt")); panelElements = new JPanel(new MigLayout(new LC().insets("0").gridGap("0", "2pt"))); buildElements(); panel.add(panelElements, new CC().spanX().pushX().growX().wrap()); // Text Injection panel.add(new SeparatorComponent(6), new CC().pushX().growX().wrap().spanX()); JLabel jlTextInjection = new JLabel(Localizer.get("TextInjection"), JLabel.CENTER); panel.add(jlTextInjection, new CC().wrap().growX().pushX().spanX()); panelTextInjection = new JPanel(new MigLayout(new LC().insets("0").gridGap("0", "0"))); buildTextInjections(); panel.add(panelTextInjection, new CC().spanX().pushX().growX().wrap()); initTextInjectionAddButton(); return panel; }
private void addSeparator() { panel.add(new SeparatorComponent(), new CC().growX().spanX().wrap()); }
private void buildAutoImportBlock() { panel.add(new SeparatorComponent(10), new CC().pushX().growX().wrap().spanX()); panel.add(new JLabel(Localizer.get("settings.AutoImport"), JLabel.CENTER), new CC().wrap().growX().pushX().spanX()); //Type ArrayList<WriteRules> actionTypes = new ArrayList<>(); actionTypes.add(WriteRules.USE_EXISTING); actionTypes.add(WriteRules.ASK_ME); actionTypes.add(WriteRules.OVERWRITE); comboBoxRules = new ComboBox(actionTypes.toArray()); comboBoxRules.setRenderer(new WriteRulesCellRenderer()); panel.add(comboBoxRules, new CC().pushX().growX().spanX().gapY("10","10")); paths = new ArrayList<>(); lvAutoImport = new ListView<String>(paths) { @Nullable @Override public CollectDataFromUI onBuildView(String item, int pos) { TextFieldWithBrowseButton btnPath = new TextFieldWithBrowseButton(); btnPath.setText(item); btnPath.addBrowseFolderListener(Localizer.get("SelectDirectoryToImport"), "", project, FileReaderUtil.getDirectoryDescriptor()); JButton btnDelete = new JButton(IconUtil.getRemoveIcon()); btnDelete.addMouseListener(new ClickListener() { @Override public void mouseClicked(MouseEvent e) { lvAutoImport.collectDataFromUI(); presenter.removeImportPath(paths, pos); } }); add(btnDelete, new CC().split(2).spanX()); add(btnPath, new CC().pushX().growX()); return () -> list.set(pos, btnPath.getText()); } }; panel.add(lvAutoImport, new CC().spanX().pushX().growX().wrap()); JButton btnAdd = new JButton(Localizer.get("action.AddPath"), IconUtil.getAddIcon()); btnAdd.addMouseListener(new ClickListener() { @Override public void mouseClicked(MouseEvent e) { lvAutoImport.collectDataFromUI(); presenter.addImportPath(paths); } }); panel.add(btnAdd, new CC().wrap()); presenter.loadAutoImport(); }
protected JComponent createCenterPanel() { JPanel result = new JPanel(new BorderLayout()); JPanel icon = new JPanel(new BorderLayout()); icon.add(myIcon, BorderLayout.NORTH); result.add(icon, BorderLayout.WEST); JPanel header = new JPanel(); header.setLayout(new BoxLayout(header, BoxLayout.Y_AXIS)); header.add(myHeader); header.add(Box.createVerticalStrut(4)); header.add(myExplanation); header.add(Box.createVerticalStrut(4)); header.add(new SeparatorComponent(0, Color.gray, null)); header.setBorder(BorderFactory.createEmptyBorder(4, 2, 4, 2)); JPanel content = new JPanel(new BorderLayout(12, 12)); content.add(header, BorderLayout.NORTH); myCardLayout = new CardLayout(); myStepContent = new JPanel(myCardLayout) { public Dimension getPreferredSize() { Dimension custom = getWindowPreferredSize(); Dimension superSize = super.getPreferredSize(); if (custom != null) { custom.width = custom.width > 0 ? custom.width : superSize.width; custom.height = custom.height > 0 ? custom.height : superSize.height; } else { custom = superSize; } return custom; } }; content.add(header, BorderLayout.NORTH); content.add(myStepContent, BorderLayout.CENTER); result.add(content, BorderLayout.CENTER); //myHeader.setFont(myHeader.getFont().deriveFont(Font.BOLD, 14)); //myHeader.setFont(myHeader.getFont().deriveFont(Font.PLAIN, 12)); return result; }