当前位置: 首页>>代码示例>>Java>>正文


Java PackageEntryTable类代码示例

本文整理汇总了Java中com.intellij.psi.codeStyle.PackageEntryTable的典型用法代码示例。如果您正苦于以下问题:Java PackageEntryTable类的具体用法?Java PackageEntryTable怎么用?Java PackageEntryTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PackageEntryTable类属于com.intellij.psi.codeStyle包,在下文中一共展示了PackageEntryTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: modify

import com.intellij.psi.codeStyle.PackageEntryTable; //导入依赖的package包/类
public static void modify(CodeStyleSettings settings) {
  // Use Android XML formatter by default
  AndroidXmlCodeStyleSettings.getInstance(settings).USE_CUSTOM_SETTINGS = true;

  // XML:
  // Copy Android code style
  AndroidXmlPredefinedCodeStyle xmlStyle = new AndroidXmlPredefinedCodeStyle();
  xmlStyle.apply(settings);

  // Java:
  // Set Import order
  settings.IMPORT_LAYOUT_TABLE.copyFrom(getAndroidImportOrder());

  // Don't use wildcard imports
  settings.PACKAGES_TO_USE_IMPORT_ON_DEMAND.copyFrom(new PackageEntryTable());
  settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND = 99; // Class count to use import with "*"
  settings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND = 99; // Name count to use static import with "*"

  // set margin to 100 columns
  settings.setDefaultRightMargin(100);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:AndroidCodeStyleSettingsModifier.java

示例2: addLineFeedAfter

import com.intellij.psi.codeStyle.PackageEntryTable; //导入依赖的package包/类
protected void addLineFeedAfter(@NotNull PsiElement psiFile, GrImportStatement result) {
  final GroovyCodeStyleSettings settings = CodeStyleSettingsManager.getInstance(psiFile.getProject()).getCurrentSettings().getCustomSettings(GroovyCodeStyleSettings.class);
  final PackageEntryTable layoutTable = settings.IMPORT_LAYOUT_TABLE;
  final PackageEntry[] entries = layoutTable.getEntries();

  PsiElement next = result.getNextSibling();
  if (PsiImplUtil.isWhiteSpaceOrNls(next)) next = next.getNextSibling();
  if (PsiImplUtil.hasElementType(next, GroovyTokenTypes.mSEMI)) next = next.getNextSibling();
  while (PsiImplUtil.isWhiteSpaceOrNls(next)) {
    next = next.getNextSibling();
  }
  if (next instanceof GrImportStatement) {
    final int idx_after = getPackageEntryIdx(entries, (GrImportStatement)next);
    final int idx = getPackageEntryIdx(entries, result);
    final int spaceCount = getMaxSpaceCount(entries, idx, idx_after);


    ASTNode node = psiFile.getNode();
    while (PsiImplUtil.isWhiteSpaceOrNls(next.getPrevSibling())) {
      node.removeChild(next.getPrevSibling().getNode());
    }
    node.addLeaf(GroovyTokenTypes.mNLS, StringUtil.repeat("\n", spaceCount + 1), next.getNode());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:GroovyCodeStyleManagerImpl.java

示例3: addLineFeedAfter

import com.intellij.psi.codeStyle.PackageEntryTable; //导入依赖的package包/类
protected void addLineFeedAfter(GrImportStatement result) {
  final GroovyCodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().getCustomSettings(GroovyCodeStyleSettings.class);
  final PackageEntryTable layoutTable = settings.IMPORT_LAYOUT_TABLE;
  final PackageEntry[] entries = layoutTable.getEntries();

  PsiElement next = result.getNextSibling();
  if (isWhiteSpace(next)) next = next.getNextSibling();
  if (hasElementType(next, GroovyTokenTypes.mSEMI)) next = next.getNextSibling();
  while (isWhiteSpace(next)) {
    next = next.getNextSibling();
  }
  if (next instanceof GrImportStatement) {
    final int idx_after = getPackageEntryIdx(entries, (GrImportStatement)next);
    final int idx = getPackageEntryIdx(entries, result);
    final int spaceCount = getMaxSpaceCount(entries, idx, idx_after);


    final FileASTNode node = getNode();
    while (isWhiteSpace(next.getPrevSibling())) {
      node.removeChild(next.getPrevSibling().getNode());
    }
    node.addLeaf(GroovyTokenTypes.mNLS, StringUtil.repeat("\n", spaceCount + 1), next.getNode());
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:GroovyFileBaseImpl.java

示例4: isToUseImportOnDemand

import com.intellij.psi.codeStyle.PackageEntryTable; //导入依赖的package包/类
private static boolean isToUseImportOnDemand(@NotNull String packageName, int classCount, boolean isStaticImportNeeded, final CodeStyleSettings settings)
{
	if(!settings.USE_SINGLE_CLASS_IMPORTS)
	{
		return true;
	}
	int limitCount = isStaticImportNeeded ? settings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND : settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND;
	if(classCount >= limitCount)
	{
		return true;
	}
	if(packageName.isEmpty())
	{
		return false;
	}
	PackageEntryTable table = settings.PACKAGES_TO_USE_IMPORT_ON_DEMAND;
	return table != null && table.contains(packageName);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:ImportHelper.java

示例5: resizeColumns

import com.intellij.psi.codeStyle.PackageEntryTable; //导入依赖的package包/类
public static void resizeColumns(final PackageEntryTable packageTable, JBTable result, boolean areStaticImportsEnabled) {
  ColoredTableCellRenderer packageRenderer = new ColoredTableCellRenderer() {
    @Override
    protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
      PackageEntry entry = packageTable.getEntryAt(row);

      if (entry == PackageEntry.BLANK_LINE_ENTRY) {
        append("<blank line>", SimpleTextAttributes.GRAYED_ATTRIBUTES);
      }
      else {
        TextAttributes attributes = JavaHighlightingColors.KEYWORD.getDefaultAttributes();
        append("import", SimpleTextAttributes.fromTextAttributes(attributes));
        if (entry.isStatic()) {
          append(" ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
          append("static", SimpleTextAttributes.fromTextAttributes(attributes));
        }
        append(" ", SimpleTextAttributes.REGULAR_ATTRIBUTES);

        if (entry == PackageEntry.ALL_OTHER_IMPORTS_ENTRY || entry == PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY) {
          append("all other imports", SimpleTextAttributes.REGULAR_ATTRIBUTES);
        }
        else {
          append(entry.getPackageName() + ".*", SimpleTextAttributes.REGULAR_ATTRIBUTES);
        }
      }
    }
  };
  if (areStaticImportsEnabled) {
    fixColumnWidthToHeader(result, 0);
    fixColumnWidthToHeader(result, 2);
    result.getColumnModel().getColumn(1).setCellRenderer(packageRenderer);
    result.getColumnModel().getColumn(0).setCellRenderer(new BooleanTableCellRenderer());
    result.getColumnModel().getColumn(2).setCellRenderer(new BooleanTableCellRenderer());
  }
  else {
    fixColumnWidthToHeader(result, 1);
    result.getColumnModel().getColumn(0).setCellRenderer(packageRenderer);
    result.getColumnModel().getColumn(1).setCellRenderer(new BooleanTableCellRenderer());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:ImportLayoutPanel.java

示例6: addPackageToPackages

import com.intellij.psi.codeStyle.PackageEntryTable; //导入依赖的package包/类
private static void addPackageToPackages(JBTable table, PackageEntryTable list) {
  int selected = table.getSelectedRow() + 1;
  if (selected < 0) {
    selected = list.getEntryCount();
  }
  PackageEntry entry = new PackageEntry(false, "", true);
  list.insertEntryAt(entry, selected);
  ImportLayoutPanel.refreshTableModel(selected, table);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:PackagePanel.java

示例7: removeEntryFromPackages

import com.intellij.psi.codeStyle.PackageEntryTable; //导入依赖的package包/类
private static void removeEntryFromPackages(JBTable table, PackageEntryTable list) {
  int selected = table.getSelectedRow();
  if (selected < 0) return;
  TableUtil.stopEditing(table);
  list.removeEntryAt(selected);
  AbstractTableModel model = (AbstractTableModel)table.getModel();
  model.fireTableRowsDeleted(selected, selected);
  if (selected >= list.getEntryCount()) {
    selected--;
  }
  if (selected >= 0) {
    table.setRowSelectionInterval(selected, selected);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:PackagePanel.java

示例8: isModified

import com.intellij.psi.codeStyle.PackageEntryTable; //导入依赖的package包/类
private static boolean isModified(PackageEntryTable list, PackageEntryTable table) {
  if (list.getEntryCount() != table.getEntryCount()) {
    return true;
  }

  for (int i = 0; i < list.getEntryCount(); i++) {
    PackageEntry entry1 = list.getEntryAt(i);
    PackageEntry entry2 = table.getEntryAt(i);
    if (!entry1.equals(entry2)) {
      return true;
    }
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:CodeStyleImportsPanel.java

示例9: isToUseImportOnDemand

import com.intellij.psi.codeStyle.PackageEntryTable; //导入依赖的package包/类
private static boolean isToUseImportOnDemand(@NotNull String packageName,
                                             int classCount,
                                             boolean isStaticImportNeeded,
                                             final CodeStyleSettings settings){
  if (!settings.USE_SINGLE_CLASS_IMPORTS) return true;
  int limitCount = isStaticImportNeeded ? settings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND :
                   settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND;
  if (classCount >= limitCount) return true;
  if (packageName.isEmpty()) return false;
  PackageEntryTable table = settings.PACKAGES_TO_USE_IMPORT_ON_DEMAND;
  return table != null && table.contains(packageName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ImportHelper.java

示例10: getAndroidImportOrder

import com.intellij.psi.codeStyle.PackageEntryTable; //导入依赖的package包/类
private static PackageEntryTable getAndroidImportOrder() {
  PackageEntryTable table = new PackageEntryTable();
  // From http://s.android.com/source/code-style.html, the order should be:
  //  1. Android imports
  //  2. Imports from 3rd parties (com, junit, net, org)
  //  3. java and javax
  table.addEntry(new PackageEntry(false, "android", true));
  table.addEntry(PackageEntry.BLANK_LINE_ENTRY);

  table.addEntry(new PackageEntry(false, "com", true));
  table.addEntry(PackageEntry.BLANK_LINE_ENTRY);

  table.addEntry(new PackageEntry(false, "junit", true));
  table.addEntry(PackageEntry.BLANK_LINE_ENTRY);

  table.addEntry(new PackageEntry(false, "net", true));
  table.addEntry(PackageEntry.BLANK_LINE_ENTRY);

  table.addEntry(new PackageEntry(false, "org", true));
  table.addEntry(PackageEntry.BLANK_LINE_ENTRY);

  table.addEntry(new PackageEntry(false, "java", true));
  table.addEntry(PackageEntry.BLANK_LINE_ENTRY);

  table.addEntry(new PackageEntry(false, "javax", true));
  table.addEntry(PackageEntry.BLANK_LINE_ENTRY);

  // handle any other conditions
  table.addEntry(PackageEntry.ALL_OTHER_IMPORTS_ENTRY);
  table.addEntry(PackageEntry.BLANK_LINE_ENTRY);

  // location of static imports is not defined, we put it last
  table.addEntry(PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY);
  table.addEntry(PackageEntry.BLANK_LINE_ENTRY);

  return table;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:AndroidCodeStyleSettingsModifier.java

示例11: addLineFeedBefore

import com.intellij.psi.codeStyle.PackageEntryTable; //导入依赖的package包/类
protected void addLineFeedBefore(@NotNull PsiElement psiFile, @NotNull GrImportStatement result) {
  final GroovyCodeStyleSettings settings =
    CodeStyleSettingsManager.getInstance(psiFile.getProject()).getCurrentSettings().getCustomSettings(GroovyCodeStyleSettings.class);
  final PackageEntryTable layoutTable = settings.IMPORT_LAYOUT_TABLE;
  final PackageEntry[] entries = layoutTable.getEntries();

  PsiElement prev = result.getPrevSibling();
  while (PsiImplUtil.isWhiteSpaceOrNls(prev)) {
    prev = prev.getPrevSibling();
  }
  if (PsiImplUtil.hasElementType(prev, GroovyTokenTypes.mSEMI)) prev = prev.getPrevSibling();
  if (PsiImplUtil.isWhiteSpaceOrNls(prev)) prev = prev.getPrevSibling();

  if (prev instanceof GrImportStatement) {
    final int idx_before = getPackageEntryIdx(entries, (GrImportStatement)prev);
    final int idx = getPackageEntryIdx(entries, result);
    final int spaceCount = getMaxSpaceCount(entries, idx_before, idx);

    //skip space and semicolon after import
    if (PsiImplUtil.isWhiteSpaceOrNls(prev.getNextSibling()) && PsiImplUtil
      .hasElementType(prev.getNextSibling().getNextSibling(), GroovyTokenTypes.mSEMI)) prev = prev.getNextSibling().getNextSibling();
    ASTNode node = psiFile.getNode();
    while (PsiImplUtil.isWhiteSpaceOrNls(prev.getNextSibling())) {
      node.removeChild(prev.getNextSibling().getNode());
    }
    node.addLeaf(GroovyTokenTypes.mNLS, StringUtil.repeat("\n", spaceCount + 1), result.getNode());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:GroovyCodeStyleManagerImpl.java

示例12: resizeColumns

import com.intellij.psi.codeStyle.PackageEntryTable; //导入依赖的package包/类
public static void resizeColumns(final PackageEntryTable packageTable, JBTable result, boolean areStaticImportsEnabled) {
  ColoredTableCellRenderer packageRenderer = new ColoredTableCellRenderer() {
    @Override
    protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
      PackageEntry entry = packageTable.getEntryAt(row);

      if (entry == PackageEntry.BLANK_LINE_ENTRY) {
        append("                                               <blank line>", SimpleTextAttributes.LINK_ATTRIBUTES);
      }
      else {
        TextAttributes attributes = JavaHighlightingColors.KEYWORD.getDefaultAttributes();
        append("import", SimpleTextAttributes.fromTextAttributes(attributes));
        if (entry.isStatic()) {
          append(" ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
          append("static", SimpleTextAttributes.fromTextAttributes(attributes));
        }
        append(" ", SimpleTextAttributes.REGULAR_ATTRIBUTES);

        if (entry == PackageEntry.ALL_OTHER_IMPORTS_ENTRY || entry == PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY) {
          append("all other imports", SimpleTextAttributes.REGULAR_ATTRIBUTES);
        }
        else {
          append(entry.getPackageName() + ".*", SimpleTextAttributes.REGULAR_ATTRIBUTES);
        }
      }
    }
  };
  if (areStaticImportsEnabled) {
    fixColumnWidthToHeader(result, 0);
    fixColumnWidthToHeader(result, 2);
    result.getColumnModel().getColumn(1).setCellRenderer(packageRenderer);
    result.getColumnModel().getColumn(0).setCellRenderer(new BooleanTableCellRenderer());
    result.getColumnModel().getColumn(2).setCellRenderer(new BooleanTableCellRenderer());
  }
  else {
    fixColumnWidthToHeader(result, 1);
    result.getColumnModel().getColumn(0).setCellRenderer(packageRenderer);
    result.getColumnModel().getColumn(1).setCellRenderer(new BooleanTableCellRenderer());
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:41,代码来源:ImportLayoutPanel.java

示例13: addLineFeedBefore

import com.intellij.psi.codeStyle.PackageEntryTable; //导入依赖的package包/类
protected void addLineFeedBefore(GrImportStatement result) {
  final GroovyCodeStyleSettings settings =
    CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().getCustomSettings(GroovyCodeStyleSettings.class);
  final PackageEntryTable layoutTable = settings.IMPORT_LAYOUT_TABLE;
  final PackageEntry[] entries = layoutTable.getEntries();

  PsiElement prev = result.getPrevSibling();
  while (isWhiteSpace(prev)) {
    prev = prev.getPrevSibling();
  }
  if (hasElementType(prev, GroovyTokenTypes.mSEMI)) prev = prev.getPrevSibling();
  if (isWhiteSpace(prev)) prev = prev.getPrevSibling();

  if (prev instanceof GrImportStatement) {
    final int idx_before = getPackageEntryIdx(entries, (GrImportStatement)prev);
    final int idx = getPackageEntryIdx(entries, result);
    final int spaceCount = getMaxSpaceCount(entries, idx_before, idx);

    //skip space and semicolon after import
    if (isWhiteSpace(prev.getNextSibling()) && hasElementType(prev.getNextSibling().getNextSibling(), GroovyTokenTypes.mSEMI)) prev = prev.getNextSibling().getNextSibling();
    final FileASTNode node = getNode();
    while (isWhiteSpace(prev.getNextSibling())) {
      node.removeChild(prev.getNextSibling().getNode());
    }
    node.addLeaf(GroovyTokenTypes.mNLS, StringUtil.repeat("\n", spaceCount + 1), result.getNode());
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:GroovyFileBaseImpl.java

示例14: getImportLayoutList

import com.intellij.psi.codeStyle.PackageEntryTable; //导入依赖的package包/类
public PackageEntryTable getImportLayoutList() {
  return myImportLayoutList;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:ImportLayoutPanel.java

示例15: refreshTable

import com.intellij.psi.codeStyle.PackageEntryTable; //导入依赖的package包/类
private void refreshTable(final JBTable table, final PackageEntryTable packageTable) {
  AbstractTableModel model = (AbstractTableModel)table.getModel();
  table.createDefaultColumnsFromModel();
  model.fireTableDataChanged();
  ImportLayoutPanel.resizeColumns(packageTable, table, myImportLayoutPanel.areStaticImportsEnabled());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:CodeStyleImportsPanel.java


注:本文中的com.intellij.psi.codeStyle.PackageEntryTable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。