Java 类com.intellij.lang.LanguageImportStatements 实例源码

项目:intellij-ce-playground    文件:LayoutCodeDialog.java   
private void setUpActions() {
  boolean canOptimizeImports = !LanguageImportStatements.INSTANCE.forFile(myFile).isEmpty();
  myOptimizeImportsCb.setVisible(canOptimizeImports);
  if (canOptimizeImports) {
    myOptimizeImportsCb.setSelected(myLastRunOptions.getLastOptimizeImports());
  }

  boolean canRearrangeCode = Rearranger.EXTENSION.forLanguage(myFile.getLanguage()) != null;
  myRearrangeCodeCb.setVisible(canRearrangeCode);
  if (canRearrangeCode) {
    myRearrangeCodeCb.setSelected(myLastRunOptions.isRearrangeCode(myFile.getLanguage()));
  }

  myOptionalLabel.setVisible(canOptimizeImports || canRearrangeCode);
}
项目:tools-idea    文件:LayoutCodeDialog.java   
private void updateState() {
  myCbIncludeSubdirs.setEnabled(myRbDirectory.isSelected());
  myCbOptimizeImports.setEnabled(
    !myRbSelectedText.isSelected()
    && !(myFile != null && LanguageImportStatements.INSTANCE.forFile(myFile).isEmpty() && myRbFile.isSelected())
  );
  myCbArrangeEntries.setEnabled(myFile != null
                                && Rearranger.EXTENSION.forLanguage(myFile.getLanguage()) != null
  );

  myCbOnlyVcsChangedRegions.setEnabled(canTargetVcsRegions());
  myDoNotAskMeCheckBox.setEnabled(!myRbDirectory.isSelected());
  myRbDirectory.setEnabled(!myDoNotAskMeCheckBox.isSelected());
}
项目:consulo    文件:LayoutCodeDialog.java   
private void setUpActions() {
  boolean canOptimizeImports = !LanguageImportStatements.INSTANCE.forFile(myFile).isEmpty();
  myOptimizeImportsCb.setVisible(canOptimizeImports);
  if (canOptimizeImports) {
    myOptimizeImportsCb.setSelected(myLastRunOptions.getLastOptimizeImports());
  }

  boolean canRearrangeCode = Rearranger.EXTENSION.forLanguage(myFile.getLanguage()) != null;
  myRearrangeCodeCb.setVisible(canRearrangeCode);
  if (canRearrangeCode) {
    myRearrangeCodeCb.setSelected(myLastRunOptions.isRearrangeCode(myFile.getLanguage()));
  }

  myOptionalLabel.setVisible(canOptimizeImports || canRearrangeCode);
}
项目:intellij-ce-playground    文件:OptimizeImportsAction.java   
private static boolean isOptimizeImportsAvailable(final PsiFile file) {
  return !LanguageImportStatements.INSTANCE.forFile(file).isEmpty();
}
项目:tools-idea    文件:OptimizeImportsAction.java   
private static boolean isOptimizeImportsAvailable(final PsiFile file) {
  return !LanguageImportStatements.INSTANCE.forFile(file).isEmpty();
}
项目:tools-idea    文件:LayoutCodeDialog.java   
@Override
protected JComponent createCenterPanel() {
  JPanel panel = new JPanel(new GridBagLayout());
  panel.setBorder(BorderFactory.createEmptyBorder(4, 8, 8, 0));
  GridBagConstraints gbConstraints = new GridBagConstraints();
  gbConstraints.gridy = 0;
  gbConstraints.gridx = 0;
  gbConstraints.gridwidth = 3;
  gbConstraints.gridheight = 1;
  gbConstraints.weightx = 1;

  gbConstraints.fill = GridBagConstraints.BOTH;
  gbConstraints.insets = new Insets(0, 0, 0, 0);

  myRbFile = new JRadioButton(CodeInsightBundle.message("process.scope.file",
                                                        (myFile != null ? "'" + myFile.getVirtualFile().getPresentableUrl() + "'" : "")));
  panel.add(myRbFile, gbConstraints);

  myRbSelectedText = new JRadioButton(CodeInsightBundle.message("reformat.option.selected.text"));
  if (myTextSelected != null) {
    gbConstraints.gridy++;
    gbConstraints.insets = new Insets(0, 0, 0, 0);
    panel.add(myRbSelectedText, gbConstraints);
  }

  myRbDirectory = new JRadioButton();
  myCbIncludeSubdirs = new JCheckBox(CodeInsightBundle.message("reformat.option.include.subdirectories"));
  if (myDirectory != null) {
    myRbDirectory.setText(CodeInsightBundle.message("reformat.option.all.files.in.directory",
                                                    myDirectory.getVirtualFile().getPresentableUrl()));
    gbConstraints.gridy++;
    gbConstraints.insets = new Insets(0, 0, 0, 0);
    panel.add(myRbDirectory, gbConstraints);

    if (myDirectory.getSubdirectories().length > 0) {
      gbConstraints.gridy++;
      gbConstraints.insets = new Insets(0, 20, 0, 0);
      panel.add(myCbIncludeSubdirs, gbConstraints);
    }
  }

  myCbOptimizeImports = new JCheckBox(CodeInsightBundle.message("reformat.option.optimize.imports"));
  if (myTextSelected != null && LanguageImportStatements.INSTANCE.hasAnyExtensions()) {
    gbConstraints.gridy++;
    gbConstraints.insets = new Insets(0, 0, 0, 0);
    panel.add(myCbOptimizeImports, gbConstraints);
  }

  myCbArrangeEntries = new JCheckBox(CodeInsightBundle.message("reformat.option.rearrange.entries"));
  if (myFile != null && Rearranger.EXTENSION.forLanguage(myFile.getLanguage()) != null) {
    gbConstraints.gridy++;
    gbConstraints.insets = new Insets(0, 0, 0, 0);
    panel.add(myCbArrangeEntries, gbConstraints);
  }

  myCbOnlyVcsChangedRegions = new JCheckBox(CodeInsightBundle.message("reformat.option.vcs.changed.region"));
  gbConstraints.gridy++;
  panel.add(myCbOnlyVcsChangedRegions, gbConstraints);

  ButtonGroup buttonGroup = new ButtonGroup();
  buttonGroup.add(myRbFile);
  buttonGroup.add(myRbSelectedText);
  buttonGroup.add(myRbDirectory);

  myRbFile.setEnabled(myFile != null);
  myRbSelectedText.setEnabled(myTextSelected == Boolean.TRUE);

  return panel;
}
项目:consulo    文件:OptimizeImportsAction.java   
private static boolean isOptimizeImportsAvailable(final PsiFile file) {
  return !LanguageImportStatements.INSTANCE.forFile(file).isEmpty();
}