@Override @NotNull public Document[] getUncommittedDocuments() { ApplicationManager.getApplication().assertIsDispatchThread(); Document[] documents = myUncommittedDocuments.toArray(new Document[myUncommittedDocuments.size()]); return ArrayUtil.stripTrailingNulls(documents); }
@Nullable private static InjectionPlace[] dropKnownInvalidPlaces(InjectionPlace[] places) { InjectionPlace[] result = places; for (InjectionPlace place : places) { if (place.getText().contains("matches(\"[^${}/\\\\]+\")")) { result = ArrayUtil.remove(result, place); } } return places.length != 0 && result.length == 0 ? null : result; }
private ColumnInfo[] createInjectionColumnInfos() { final TableCellRenderer booleanCellRenderer = createBooleanCellRenderer(); final TableCellRenderer displayNameCellRenderer = createDisplayNameCellRenderer(); final TableCellRenderer languageCellRenderer = createLanguageCellRenderer(); final Comparator<InjInfo> languageComparator = new Comparator<InjInfo>() { public int compare(final InjInfo o1, final InjInfo o2) { return Comparing.compare( o1.injection.getInjectedLanguageId(), o2.injection.getInjectedLanguageId()); } }; final Comparator<InjInfo> displayNameComparator = new Comparator<InjInfo>() { public int compare(final InjInfo o1, final InjInfo o2) { final int support = Comparing.compare(o1.injection.getSupportId(), o2.injection.getSupportId()); if (support != 0) return support; return Comparing.compare(o1.injection.getDisplayName(), o2.injection.getDisplayName()); } }; final ColumnInfo[] columnInfos = { new ColumnInfo<InjInfo, Boolean>(" ") { @Override public Class getColumnClass() { return Boolean.class; } @Override public Boolean valueOf(final InjInfo o) { return o.injection.isEnabled(); } @Override public boolean isCellEditable(final InjInfo injection) { return true; } @Override public void setValue(final InjInfo injection, final Boolean value) { injection.injection.setPlaceEnabled(null, value.booleanValue()); } @Override public TableCellRenderer getRenderer(final InjInfo injection) { return booleanCellRenderer; } }, new ColumnInfo<InjInfo, InjInfo>("Name") { @Override public InjInfo valueOf(final InjInfo info) { return info; } @Override public Comparator<InjInfo> getComparator() { return displayNameComparator; } @Override public TableCellRenderer getRenderer(final InjInfo injection) { return displayNameCellRenderer; } }, new ColumnInfo<InjInfo, InjInfo>("Language") { @Override public InjInfo valueOf(final InjInfo info) { return info; } @Override public Comparator<InjInfo> getComparator() { return languageComparator; } @Override public TableCellRenderer getRenderer(final InjInfo info) { return languageCellRenderer; } } }; if (myInfos.length > 1) { final TableCellRenderer typeRenderer = createTypeRenderer(); return ArrayUtil.append( columnInfos, new ColumnInfo<InjInfo, String>("Scope") { @Override public String valueOf(final InjInfo info) { return info.bundled ? "Built-in" : info.cfgInfo.title; } @Override public TableCellRenderer getRenderer(final InjInfo injInfo) { return typeRenderer; } @Override public int getWidth(final JTable table) { return table .getFontMetrics(table.getFont()) .stringWidth(StringUtil.repeatSymbol('m', 6)); } @Override public Comparator<InjInfo> getComparator() { return new Comparator<InjInfo>() { @Override public int compare(final InjInfo o1, final InjInfo o2) { return Comparing.compare(valueOf(o1), valueOf(o2)); } }; } }); } return columnInfos; }