Java 类com.intellij.ui.TitledSeparator 实例源码

项目:intellij-ce-playground    文件:MoveInstanceMethodDialog.java   
@Nullable
private JPanel createParametersPanel () {
  myThisClassesMap = MoveInstanceMembersUtil.getThisClassesToMembers(myMethod);
  myOldClassParameterNameFields = new HashMap<PsiClass, EditorTextField>();
  if (myThisClassesMap.size() == 0) return null;
  JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, true));
  for (PsiClass aClass : myThisClassesMap.keySet()) {
    final String text = RefactoringBundle.message("move.method.this.parameter.label", aClass.getName());
    panel.add(new TitledSeparator(text, null));

    String suggestedName = MoveInstanceMethodHandler.suggestParameterNameForThisClass(aClass);
    final EditorTextField field = new EditorTextField(suggestedName, getProject(), StdFileTypes.JAVA);
    field.setMinimumSize(new Dimension(field.getPreferredSize()));
    myOldClassParameterNameFields.put(aClass, field);
    panel.add(field);
  }
  panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
  return panel;
}
项目:intellij-ce-playground    文件:IdeaTitledBorder.java   
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  int labelX = x + outsideInsets.left;
  int labelY = y + outsideInsets.top;

  TitledSeparator titledSeparator = getTitledSeparator(c);
  JLabel label = titledSeparator.getLabel();
  Dimension labelSize = label.getPreferredSize();
  label.setSize(labelSize);
  g.translate(labelX, labelY);
  label.paint(g);

  int separatorX = labelX + labelSize.width + TitledSeparator.SEPARATOR_LEFT_INSET;
  int separatorY = labelY +  (UIUtil.isUnderAquaLookAndFeel() ? 2 : labelSize.height / 2 - 1);
  int separatorW = Math.max(0, width - separatorX - TitledSeparator.SEPARATOR_RIGHT_INSET);
  int separatorH = 2;

  JSeparator separator = titledSeparator.getSeparator();
  separator.setSize(separatorW, separatorH);
  g.translate(separatorX - labelX, separatorY - labelY);
  separator.paint(g);

  g.translate(-separatorX, -separatorY);
}
项目:tools-idea    文件:MoveInstanceMethodDialog.java   
@Nullable
private JPanel createParametersPanel () {
  myThisClassesMap = MoveInstanceMembersUtil.getThisClassesToMembers(myMethod);
  myOldClassParameterNameFields = new HashMap<PsiClass, EditorTextField>();
  if (myThisClassesMap.size() == 0) return null;
  JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, true));
  for (PsiClass aClass : myThisClassesMap.keySet()) {
    final String text = RefactoringBundle.message("move.method.this.parameter.label", aClass.getName());
    panel.add(new TitledSeparator(text, null));

    String suggestedName = MoveInstanceMethodHandler.suggestParameterNameForThisClass(aClass);
    final EditorTextField field = new EditorTextField(suggestedName, getProject(), StdFileTypes.JAVA);
    field.setMinimumSize(new Dimension(field.getPreferredSize()));
    myOldClassParameterNameFields.put(aClass, field);
    panel.add(field);
  }
  panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
  return panel;
}
项目:tools-idea    文件:IdeaTitledBorder.java   
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  int labelX = x + outsideInsets.left;
  int labelY = y + outsideInsets.top;

  TitledSeparator titledSeparator = getTitledSeparator(c);
  JLabel label = titledSeparator.getLabel();
  Dimension labelSize = label.getPreferredSize();
  label.setSize(labelSize);
  g.translate(labelX, labelY);
  label.paint(g);

  int separatorX = labelX + labelSize.width + TitledSeparator.SEPARATOR_LEFT_INSET;
  int separatorY = labelY +  (UIUtil.isUnderAquaLookAndFeel() ? 2 : labelSize.height / 2 - 1);
  int separatorW = Math.max(0, width - separatorX - TitledSeparator.SEPARATOR_RIGHT_INSET);
  int separatorH = 2;

  JSeparator separator = titledSeparator.getSeparator();
  separator.setSize(separatorW, separatorH);
  g.translate(separatorX - labelX, separatorY - labelY);
  separator.paint(g);

  g.translate(-separatorX, -separatorY);
}
项目:consulo    文件:IdeaTitledBorder.java   
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  int labelX = x + outsideInsets.left;
  int labelY = y + outsideInsets.top;

  TitledSeparator titledSeparator = getTitledSeparator(c);
  JLabel label = titledSeparator.getLabel();
  Dimension labelSize = label.getPreferredSize();
  label.setSize(labelSize);
  g.translate(labelX, labelY);
  label.paint(g);

  int separatorX = labelX + labelSize.width + TitledSeparator.SEPARATOR_LEFT_INSET;
  int separatorY = labelY +  (UIUtil.isUnderAquaLookAndFeel() ? 2 : labelSize.height / 2 - 1);
  int separatorW = Math.max(0, width - separatorX - TitledSeparator.SEPARATOR_RIGHT_INSET);
  int separatorH = 2;

  JSeparator separator = titledSeparator.getSeparator();
  separator.setSize(separatorW, separatorH);
  g.translate(separatorX - labelX, separatorY - labelY);
  if (myShowLine) {
    separator.paint(g);
  }
  g.translate(-separatorX, -separatorY);
}
项目:consulo-java    文件:MoveInstanceMethodDialog.java   
@Nullable
private JPanel createParametersPanel () {
  myThisClassesMap = MoveInstanceMembersUtil.getThisClassesToMembers(myMethod);
  myOldClassParameterNameFields = new HashMap<PsiClass, EditorTextField>();
  if (myThisClassesMap.size() == 0) return null;
  JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, true));
  for (PsiClass aClass : myThisClassesMap.keySet()) {
    final String text = RefactoringBundle.message("move.method.this.parameter.label", aClass.getName());
    panel.add(new TitledSeparator(text, null));

    String suggestedName = MoveInstanceMethodHandler.suggestParameterNameForThisClass(aClass);
    final EditorTextField field = new EditorTextField(suggestedName, getProject(), JavaFileType.INSTANCE);
    field.setMinimumSize(new Dimension(field.getPreferredSize()));
    myOldClassParameterNameFields.put(aClass, field);
    panel.add(field);
  }
  panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
  return panel;
}
项目:intellij-ce-playground    文件:InferNullityAnnotationsAction.java   
@Override
protected JComponent getAdditionalActionSettings(Project project, BaseAnalysisActionDialog dialog) {
  final JPanel panel = new JPanel(new VerticalFlowLayout());
  panel.add(new TitledSeparator());
  myAnnotateLocalVariablesCb = new JCheckBox("Annotate local variables", PropertiesComponent.getInstance().getBoolean(ANNOTATE_LOCAL_VARIABLES));
  panel.add(myAnnotateLocalVariablesCb);
  return panel;
}
项目:intellij-ce-playground    文件:MoveInstanceMethodDialog.java   
protected JComponent createCenterPanel() {
  JPanel mainPanel = new JPanel(new GridBagLayout());
  final TitledSeparator separator = new TitledSeparator();
  mainPanel.add(separator, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0), 0,0));

  myList = createTargetVariableChooser();
  myList.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      validateTextFields(e.getFirstIndex());
    }
  });

  separator.setText(RefactoringBundle.message("moveInstanceMethod.select.an.instance.parameter"));

  final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myList);
  mainPanel.add(scrollPane, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0,0));

  myVisibilityPanel = createVisibilityPanel();
  mainPanel.add(myVisibilityPanel, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0,0,0,0), 0,0));

  final JPanel parametersPanel = createParametersPanel();
  if (parametersPanel != null) {
    mainPanel.add(parametersPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0), 0,0));
  }

  mainPanel.add(initOpenInEditorCb(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0), 0,0));

  separator.setLabelFor(myList);
  validateTextFields(myList.getSelectedIndex());

  updateOnChanged(myList);
  return mainPanel;
}
项目:intellij-ce-playground    文件:IdeaTitledBorder.java   
public IdeaTitledBorder(String title, int indent, Insets insets) {
  super(title);
  titledSeparator = new TitledSeparator(title);
  titledSeparator.setText(title);
  DialogUtil.registerMnemonic(titledSeparator.getLabel(), null);

  outsideInsets = JBInsets.create(insets);
  insideInsets = new JBInsets(TitledSeparator.BOTTOM_INSET, indent, 0, 0);
}
项目:intellij-ce-playground    文件:IdeaTitledBorder.java   
@Override
public Insets getBorderInsets(Component c, final Insets insets) {
  insets.top += getTitledSeparator(c).getPreferredSize().getHeight() - TitledSeparator.TOP_INSET - TitledSeparator.BOTTOM_INSET;
  insets.top += UIUtil.DEFAULT_VGAP;
  insets.top += insideInsets.top;
  insets.left += insideInsets.left;
  insets.bottom += insideInsets.bottom;
  insets.right += insideInsets.right;
  insets.top += outsideInsets.top;
  insets.left += outsideInsets.left;
  insets.bottom += outsideInsets.bottom;
  insets.right += outsideInsets.right;
  return insets;
}
项目:intellij-ce-playground    文件:MergedCompositeConfigurable.java   
@NotNull
static JPanel createPanel(boolean isUseTitledBorder) {
  int verticalGap = TitledSeparator.TOP_INSET;
  JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, isUseTitledBorder ? 0 : verticalGap, true, true));
  // VerticalFlowLayout incorrectly use vertical gap as top inset
  if (!isUseTitledBorder) {
    panel.setBorder(new EmptyBorder(-verticalGap, 0, 0, 0));
  }
  return panel;
}
项目:intellij-ce-playground    文件:UpdateCopyrightAction.java   
@Nullable
@Override
protected JComponent getAdditionalActionSettings(Project project, BaseAnalysisActionDialog dialog) {
  final JPanel panel = new JPanel(new VerticalFlowLayout());
  panel.add(new TitledSeparator());
  myUpdateExistingCopyrightsCb = new JCheckBox("Update existing copyrights", 
                                               PropertiesComponent.getInstance().getBoolean(UPDATE_EXISTING_COPYRIGHTS, true));
  panel.add(myUpdateExistingCopyrightsCb);
  return panel;
}
项目:tools-idea    文件:InferNullityAnnotationsAction.java   
@Override
protected JComponent getAdditionalActionSettings(Project project, BaseAnalysisActionDialog dialog) {
  final JPanel panel = new JPanel(new VerticalFlowLayout());
  panel.add(new TitledSeparator());
  myAnnotateLocalVariablesCb = new JCheckBox("Annotate local variables", false);
  panel.add(myAnnotateLocalVariablesCb);
  return panel;
}
项目:tools-idea    文件:MoveInstanceMethodDialog.java   
protected JComponent createCenterPanel() {
  JPanel mainPanel = new JPanel(new GridBagLayout());
  final TitledSeparator separator = new TitledSeparator();
  mainPanel.add(separator, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0), 0,0));

  myList = createTargetVariableChooser();
  myList.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      validateTextFields(e.getFirstIndex());
    }
  });

  separator.setText(RefactoringBundle.message("moveInstanceMethod.select.an.instance.parameter"));

  final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myList);
  mainPanel.add(scrollPane, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0,0));

  myVisibilityPanel = createVisibilityPanel();
  mainPanel.add(myVisibilityPanel, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0,0,0,0), 0,0));

  final JPanel parametersPanel = createParametersPanel();
  if (parametersPanel != null) {
    mainPanel.add(parametersPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0), 0,0));
  }

  separator.setLabelFor(myList);
  validateTextFields(myList.getSelectedIndex());

  updateOnChanged(myList);
  return mainPanel;
}
项目:tools-idea    文件:IdeaTitledBorder.java   
public IdeaTitledBorder(String title, int indent, Insets insets) {
  super(title);
  titledSeparator = new TitledSeparator(title);
  titledSeparator.setText(title);
  DialogUtil.registerMnemonic(titledSeparator.getLabel(), null);

  this.outsideInsets = new Insets(insets.top, insets.left, insets.bottom, insets.right);

  this.insideInsets = new Insets(TitledSeparator.BOTTOM_INSET, indent, 0, 0);
}
项目:tools-idea    文件:IdeaTitledBorder.java   
@Override
public Insets getBorderInsets(Component c, final Insets insets) {
  insets.top += getTitledSeparator(c).getPreferredSize().getHeight() - TitledSeparator.TOP_INSET - TitledSeparator.BOTTOM_INSET;
  insets.top += UIUtil.DEFAULT_VGAP;
  insets.top += insideInsets.top;
  insets.left += insideInsets.left;
  insets.bottom += insideInsets.bottom;
  insets.right += insideInsets.right;
  insets.top += outsideInsets.top;
  insets.left += outsideInsets.left;
  insets.bottom += outsideInsets.bottom;
  insets.right += outsideInsets.right;
  return insets;
}
项目:consulo    文件:IdeaTitledBorder.java   
public IdeaTitledBorder(String title, int indent, Insets insets) {
  super(title);
  titledSeparator = new TitledSeparator(title);
  titledSeparator.setText(title);
  DialogUtil.registerMnemonic(titledSeparator.getLabel(), null);

  outsideInsets = JBInsets.create(insets);
  insideInsets = new JBInsets(TitledSeparator.BOTTOM_INSET, indent, 0, 0);
}
项目:consulo    文件:IdeaTitledBorder.java   
@Override
public Insets getBorderInsets(Component c, final Insets insets) {
  insets.top += getTitledSeparator(c).getPreferredSize().getHeight() - TitledSeparator.TOP_INSET - TitledSeparator.BOTTOM_INSET;
  insets.top += UIUtil.DEFAULT_VGAP;
  insets.top += insideInsets.top;
  insets.left += insideInsets.left;
  insets.bottom += insideInsets.bottom;
  insets.right += insideInsets.right;
  insets.top += outsideInsets.top;
  insets.left += outsideInsets.left;
  insets.bottom += outsideInsets.bottom;
  insets.right += outsideInsets.right;
  return insets;
}
项目:consulo    文件:MergedCompositeConfigurable.java   
@Nonnull
static JPanel createPanel(boolean isUseTitledBorder) {
  int verticalGap = TitledSeparator.TOP_INSET;
  JPanel panel = new JPanel(new VerticalFlowLayout(0, isUseTitledBorder ? 0 : verticalGap));
  // VerticalFlowLayout incorrectly use vertical gap as top inset
  if (!isUseTitledBorder) {
    panel.setBorder(new EmptyBorder(-verticalGap, 0, 0, 0));
  }
  return panel;
}
项目:consulo-java    文件:InferNullityAnnotationsAction.java   
@Override
protected JComponent getAdditionalActionSettings(Project project, BaseAnalysisActionDialog dialog)
{
    final JPanel panel = new JPanel(new VerticalFlowLayout());
    panel.add(new TitledSeparator());
    myAnnotateLocalVariablesCb = new JCheckBox("Annotate local variables", PropertiesComponent.getInstance().getBoolean(ANNOTATE_LOCAL_VARIABLES));
    panel.add(myAnnotateLocalVariablesCb);
    return panel;
}
项目:consulo-java    文件:MoveInstanceMethodDialog.java   
protected JComponent createCenterPanel() {
  JPanel mainPanel = new JPanel(new GridBagLayout());
  final TitledSeparator separator = new TitledSeparator();
  mainPanel.add(separator, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0), 0,0));

  myList = createTargetVariableChooser();
  myList.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      validateTextFields(e.getFirstIndex());
    }
  });

  separator.setText(RefactoringBundle.message("moveInstanceMethod.select.an.instance.parameter"));

  final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myList);
  mainPanel.add(scrollPane, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0,0));

  myVisibilityPanel = createVisibilityPanel();
  mainPanel.add(myVisibilityPanel, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0,0,0,0), 0,0));

  final JPanel parametersPanel = createParametersPanel();
  if (parametersPanel != null) {
    mainPanel.add(parametersPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0), 0,0));
  }

  separator.setLabelFor(myList);
  validateTextFields(myList.getSelectedIndex());

  updateOnChanged(myList);
  return mainPanel;
}
项目:intellij-ce-playground    文件:EqualsHashCodeTemplatesPanel.java   
@Override
protected UnnamedConfigurable createConfigurable(Couple<TemplateResource> item) {
  final GenerateTemplateConfigurable equalsConfigurable = new GenerateTemplateConfigurable(item.first, GenerateEqualsHelper.getEqualsImplicitVars(myProject), myProject);
  final GenerateTemplateConfigurable hashCodeConfigurable = new GenerateTemplateConfigurable(item.second, GenerateEqualsHelper.getHashCodeImplicitVars(), myProject);
  return new UnnamedConfigurable() {
    @Nullable
    @Override
    public JComponent createComponent() {
      final Splitter splitter = new Splitter(true);

      final JPanel eqPanel = new JPanel(new BorderLayout());
      eqPanel.add(new TitledSeparator("Equals Template:"), BorderLayout.NORTH);
      final JComponent eqPane = equalsConfigurable.createComponent();
      eqPane.setPreferredSize(JBUI.size(300, 200));
      eqPanel.add(eqPane, BorderLayout.CENTER);
      splitter.setFirstComponent(eqPanel);

      final JPanel hcPanel = new JPanel(new BorderLayout());
      hcPanel.add(new TitledSeparator("HashCode Template:"), BorderLayout.NORTH);
      final JComponent hcPane = hashCodeConfigurable.createComponent();
      hcPane.setPreferredSize(JBUI.size(300, 200));
      hcPanel.add(hcPane, BorderLayout.CENTER);
      splitter.setSecondComponent(hcPanel);

      return splitter;
    }

    @Override
    public boolean isModified() {
      return equalsConfigurable.isModified() || hashCodeConfigurable.isModified();
    }

    @Override
    public void apply() throws ConfigurationException {
      equalsConfigurable.apply();
      hashCodeConfigurable.apply();
    }

    @Override
    public void reset() {
      equalsConfigurable.reset();
      hashCodeConfigurable.reset();
    }

    @Override
    public void disposeUIResources() {
      equalsConfigurable.disposeUIResources();
      hashCodeConfigurable.disposeUIResources();
    }
  };
}
项目:intellij-ce-playground    文件:IdeaTitledBorder.java   
private TitledSeparator getTitledSeparator(Component c) {
  titledSeparator.setEnabled(c.isEnabled());
  return titledSeparator;
}
项目:intellij-ce-playground    文件:IntentionDescriptionPanel.java   
private static void showUsages(final JPanel panel,
                               final TitledSeparator separator,
                               final List<IntentionUsagePanel> usagePanels,
                               @Nullable final TextDescriptor[] exampleUsages) throws IOException {
  GridBagConstraints gb = null;
  boolean reuse = exampleUsages != null && panel.getComponents().length == exampleUsages.length;
  if (!reuse) {
    disposeUsagePanels(usagePanels);
    panel.setLayout(new GridBagLayout());
    panel.removeAll();
    gb = new GridBagConstraints();
    gb.anchor = GridBagConstraints.NORTHWEST;
    gb.fill = GridBagConstraints.BOTH;
    gb.gridheight = GridBagConstraints.REMAINDER;
    gb.gridwidth = 1;
    gb.gridx = 0;
    gb.gridy = 0;
    gb.insets = new Insets(0,0,0,0);
    gb.ipadx = 5;
    gb.ipady = 5;
    gb.weightx = 1;
    gb.weighty = 1;
  }

  if (exampleUsages != null) {
    for (int i = 0; i < exampleUsages.length; i++) {
      final TextDescriptor exampleUsage = exampleUsages[i];
      final String name = exampleUsage.getFileName();
      final FileTypeManagerEx fileTypeManager = FileTypeManagerEx.getInstanceEx();
      final String extension = fileTypeManager.getExtension(name);
      final FileType fileType = fileTypeManager.getFileTypeByExtension(extension);

      IntentionUsagePanel usagePanel;
      if (reuse) {
        usagePanel = (IntentionUsagePanel)panel.getComponent(i);
      }
      else {
        usagePanel = new IntentionUsagePanel();
        usagePanels.add(usagePanel);
      }
      usagePanel.reset(exampleUsage.getText(), fileType);

      if (!reuse) {
        if (i == exampleUsages.length) {
          gb.gridwidth = GridBagConstraints.REMAINDER;
        }
        panel.add(usagePanel, gb);
        gb.gridx++;
      }
    }
  }
  panel.revalidate();
  panel.repaint();
}
项目:intellij-ce-playground    文件:BrowserSettingsPanel.java   
public BrowserSettingsPanel() {
  alternativeBrowserPathField.addBrowseFolderListener(IdeBundle.message("title.select.path.to.browser"), null, null, APP_FILE_CHOOSER_DESCRIPTOR);
  defaultBrowserPanel.setBorder(TitledSeparator.EMPTY_BORDER);

  ArrayList<DefaultBrowserPolicy> defaultBrowserPolicies = new ArrayList<DefaultBrowserPolicy>();
  if (BrowserLauncherAppless.canUseSystemDefaultBrowserPolicy()) {
    defaultBrowserPolicies.add(DefaultBrowserPolicy.SYSTEM);
  }
  defaultBrowserPolicies.add(DefaultBrowserPolicy.FIRST);
  defaultBrowserPolicies.add(DefaultBrowserPolicy.ALTERNATIVE);

  //noinspection Since15,unchecked
  defaultBrowserPolicyComboBox.setModel(new ListComboBoxModel<DefaultBrowserPolicy>(defaultBrowserPolicies));
  defaultBrowserPolicyComboBox.addItemListener(new ItemListener() {
    @Override
    public void itemStateChanged(@NotNull ItemEvent e) {
      boolean customPathEnabled = e.getItem() == DefaultBrowserPolicy.ALTERNATIVE;
      if (e.getStateChange() == ItemEvent.DESELECTED) {
        if (customPathEnabled) {
          customPathValue = alternativeBrowserPathField.getText();
        }
      }
      else if (e.getStateChange() == ItemEvent.SELECTED) {
        alternativeBrowserPathField.setEnabled(customPathEnabled);
        updateCustomPathTextFieldValue((DefaultBrowserPolicy)e.getItem());
      }
    }
  });

  defaultBrowserPolicyComboBox.setRenderer(new ListCellRendererWrapper<DefaultBrowserPolicy>() {
    @Override
    public void customize(JList list, DefaultBrowserPolicy value, int index, boolean selected, boolean hasFocus) {
      String name;
      switch (value) {
        case SYSTEM:
          name = "System default";
          break;
        case FIRST:
          name = "First listed";
          break;
        case ALTERNATIVE:
          name = "Custom path";
          break;
        default:
          throw new IllegalStateException();
      }

      setText(name);
    }
  });

  if (UIUtil.isUnderAquaLookAndFeel()) {
    defaultBrowserPolicyComboBox.setBorder(new EmptyBorder(3, 0, 0, 0));
  }
}
项目:tools-idea    文件:IdeaTitledBorder.java   
private TitledSeparator getTitledSeparator(Component c) {
  titledSeparator.setEnabled(c.isEnabled());
  return titledSeparator;
}
项目:tools-idea    文件:IntentionDescriptionPanel.java   
private static void showUsages(final JPanel panel,
                               final TitledSeparator separator,
                               final List<IntentionUsagePanel> usagePanels,
                               @Nullable final TextDescriptor[] exampleUsages) throws IOException {
  GridBagConstraints gb = null;
  boolean reuse = exampleUsages != null && panel.getComponents().length == exampleUsages.length;
  if (!reuse) {
    disposeUsagePanels(usagePanels);
    panel.setLayout(new GridBagLayout());
    panel.removeAll();
    gb = new GridBagConstraints();
    gb.anchor = GridBagConstraints.NORTHWEST;
    gb.fill = GridBagConstraints.BOTH;
    gb.gridheight = GridBagConstraints.REMAINDER;
    gb.gridwidth = 1;
    gb.gridx = 0;
    gb.gridy = 0;
    gb.insets = new Insets(0,0,0,0);
    gb.ipadx = 5;
    gb.ipady = 5;
    gb.weightx = 1;
    gb.weighty = 1;
  }

  if (exampleUsages != null) {
    for (int i = 0; i < exampleUsages.length; i++) {
      final TextDescriptor exampleUsage = exampleUsages[i];
      final String name = exampleUsage.getFileName();
      final FileTypeManagerEx fileTypeManager = FileTypeManagerEx.getInstanceEx();
      final String extension = fileTypeManager.getExtension(name);
      final FileType fileType = fileTypeManager.getFileTypeByExtension(extension);

      IntentionUsagePanel usagePanel;
      if (reuse) {
        usagePanel = (IntentionUsagePanel)panel.getComponent(i);
      }
      else {
        usagePanel = new IntentionUsagePanel();
        usagePanels.add(usagePanel);
      }
      usagePanel.reset(exampleUsage.getText(), fileType);

      if (!reuse) {
        if (i == exampleUsages.length) {
          gb.gridwidth = GridBagConstraints.REMAINDER;
        }
        panel.add(usagePanel, gb);
        gb.gridx++;
      }
    }
  }
  panel.revalidate();
  panel.repaint();
}
项目:consulo-tasks    文件:UntrustedCertificateWarningDialog.java   
@SuppressWarnings("MethodMayBeStatic")
private FormBuilder updateBuilderWithTitle(FormBuilder builder, String title) {
  return builder.addComponent(new TitledSeparator(title), IdeBorderFactory.TITLED_BORDER_TOP_INSET);
}
项目:consulo    文件:IdeaTitledBorder.java   
private TitledSeparator getTitledSeparator(Component c) {
  titledSeparator.setEnabled(c.isEnabled());
  return titledSeparator;
}
项目:consulo    文件:IntentionDescriptionPanel.java   
private static void showUsages(final JPanel panel,
                               final TitledSeparator separator,
                               final List<IntentionUsagePanel> usagePanels,
                               @Nullable final TextDescriptor[] exampleUsages) throws IOException {
  GridBagConstraints gb = null;
  boolean reuse = exampleUsages != null && panel.getComponents().length == exampleUsages.length;
  if (!reuse) {
    disposeUsagePanels(usagePanels);
    panel.setLayout(new GridBagLayout());
    panel.removeAll();
    gb = new GridBagConstraints();
    gb.anchor = GridBagConstraints.NORTHWEST;
    gb.fill = GridBagConstraints.BOTH;
    gb.gridheight = GridBagConstraints.REMAINDER;
    gb.gridwidth = 1;
    gb.gridx = 0;
    gb.gridy = 0;
    gb.insets = new Insets(0,0,0,0);
    gb.ipadx = 5;
    gb.ipady = 5;
    gb.weightx = 1;
    gb.weighty = 1;
  }

  if (exampleUsages != null) {
    for (int i = 0; i < exampleUsages.length; i++) {
      final TextDescriptor exampleUsage = exampleUsages[i];
      final String name = exampleUsage.getFileName();
      final FileTypeManagerEx fileTypeManager = FileTypeManagerEx.getInstanceEx();
      final String extension = fileTypeManager.getExtension(name);
      final FileType fileType = fileTypeManager.getFileTypeByExtension(extension);

      IntentionUsagePanel usagePanel;
      if (reuse) {
        usagePanel = (IntentionUsagePanel)panel.getComponent(i);
      }
      else {
        usagePanel = new IntentionUsagePanel();
        usagePanels.add(usagePanel);
      }
      usagePanel.reset(exampleUsage.getText(), fileType);

      if (!reuse) {
        if (i == exampleUsages.length) {
          gb.gridwidth = GridBagConstraints.REMAINDER;
        }
        panel.add(usagePanel, gb);
        gb.gridx++;
      }
    }
  }
  panel.revalidate();
  panel.repaint();
}
项目:consulo-java    文件:EqualsHashCodeTemplatesPanel.java   
@Override
protected UnnamedConfigurable createConfigurable(Couple<TemplateResource> item)
{
    final GenerateTemplateConfigurable equalsConfigurable = new GenerateTemplateConfigurable(item.first, GenerateEqualsHelper.getEqualsImplicitVars(myProject), myProject);
    final GenerateTemplateConfigurable hashCodeConfigurable = new GenerateTemplateConfigurable(item.second, GenerateEqualsHelper.getHashCodeImplicitVars(), myProject);
    return new UnnamedConfigurable()
    {
        @Nullable
        @Override
        public JComponent createComponent()
        {
            final Splitter splitter = new Splitter(true);

            final JPanel eqPanel = new JPanel(new BorderLayout());
            eqPanel.add(new TitledSeparator("Equals Template:"), BorderLayout.NORTH);
            final JComponent eqPane = equalsConfigurable.createComponent();
            eqPane.setPreferredSize(JBUI.size(300, 200));
            eqPanel.add(eqPane, BorderLayout.CENTER);
            splitter.setFirstComponent(eqPanel);

            final JPanel hcPanel = new JPanel(new BorderLayout());
            hcPanel.add(new TitledSeparator("HashCode Template:"), BorderLayout.NORTH);
            final JComponent hcPane = hashCodeConfigurable.createComponent();
            hcPane.setPreferredSize(JBUI.size(300, 200));
            hcPanel.add(hcPane, BorderLayout.CENTER);
            splitter.setSecondComponent(hcPanel);

            return splitter;
        }

        @Override
        public boolean isModified()
        {
            return equalsConfigurable.isModified() || hashCodeConfigurable.isModified();
        }

        @Override
        public void apply() throws ConfigurationException
        {
            equalsConfigurable.apply();
            hashCodeConfigurable.apply();
        }

        @Override
        public void reset()
        {
            equalsConfigurable.reset();
            hashCodeConfigurable.reset();
        }

        @Override
        public void disposeUIResources()
        {
            equalsConfigurable.disposeUIResources();
            hashCodeConfigurable.disposeUIResources();
        }
    };
}