Java 类com.intellij.psi.codeStyle.CodeStyleScheme 实例源码

项目:intellij-ce-playground    文件:ManageCodeStyleSchemesDialog.java   
private void onSaveAs() {
  if (mySchemesTableModel.isProjectScheme(getSelectedScheme())) {
    int rowToSelect = mySchemesTableModel.exportProjectScheme();
    if (rowToSelect > 0) {
      mySchemesTable.getSelectionModel().setSelectionInterval(rowToSelect, rowToSelect);
    }
  }
  else {
    CodeStyleScheme[] schemes = CodeStyleSchemes.getInstance().getSchemes();
    ArrayList<String> names = new ArrayList<String>();
    for (CodeStyleScheme scheme : schemes) {
      names.add(scheme.getName());
    }
    String selectedName = getSelectedScheme().getName();
    SaveSchemeDialog saveDialog =
      new SaveSchemeDialog(myParent, ApplicationBundle.message("title.save.code.style.scheme.as"), names, selectedName);
    if (saveDialog.showAndGet()) {
      int row = mySchemesTableModel.createNewScheme(getSelectedScheme(), saveDialog.getSchemeName());
      mySchemesTable.getSelectionModel().setSelectionInterval(row, row);
    }
  }
}
项目:intellij-ce-playground    文件:ManageCodeStyleSchemesDialog.java   
private MySchemesTable() {
  myFixedItemsRenderer = new DefaultTableCellRenderer() {
    @NotNull
    @Override
    public Component getTableCellRendererComponent(@NotNull JTable table,
                                                   Object value,
                                                   boolean isSelected,
                                                   boolean hasFocus,
                                                   int row,
                                                   int column) {
      Component defaultComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
      if (value instanceof CodeStyleScheme) {
        CodeStyleScheme scheme = (CodeStyleScheme)value;
        if (scheme.isDefault() || myModel.isProjectScheme(scheme)) {
          defaultComponent.setFont(defaultComponent.getFont().deriveFont(Font.BOLD));
        }
      }
      return defaultComponent;
    }
  };
}
项目:intellij-ce-playground    文件:ManageCodeStyleSchemesDialog.java   
public int exportProjectScheme() {
  String name = Messages.showInputDialog("Enter new scheme name:", "Copy Project Scheme to Global List", Messages.getQuestionIcon());
  if (name != null && !CodeStyleSchemesModel.PROJECT_SCHEME_NAME.equals(name)) {
    CodeStyleScheme newScheme = mySchemesModel.exportProjectScheme(name);
    updateSchemes();
    int switchToGlobal = Messages
      .showYesNoDialog("Project scheme was copied to global scheme list as '" + newScheme.getName() + "'.\n" +
                       "Switch to this created scheme?",
                       "Copy Project Scheme to Global List", Messages.getQuestionIcon());
    if (switchToGlobal == Messages.YES) {
      mySchemesModel.setUsePerProjectSettings(false);
      mySchemesModel.selectScheme(newScheme, null);
    }
    int row = 0;
    for (CodeStyleScheme scheme : mySchemes) {
      if (scheme == newScheme) {
        fireTableRowsInserted(row, row);
        return switchToGlobal == 0 ? row : -1;
      }
      row++;
    }
  }
  return -1;
}
项目:intellij-ce-playground    文件:CodeStyleSchemesPanel.java   
public void resetSchemesCombo() {
  myIsReset = true;
  try {
    List<CodeStyleScheme> schemes = new ArrayList<CodeStyleScheme>();
    schemes.addAll(myModel.getAllSortedSchemes());
    DefaultComboBoxModel model = new DefaultComboBoxModel(schemes.toArray());
    myCombo.setModel(model);
    if (myModel.isUsePerProjectSettings()) {
      myCombo.setSelectedItem(myModel.getProjectScheme());
    }
    else {
      myCombo.setSelectedItem(myModel.getSelectedGlobalScheme());
    }
  }
  finally {
    myIsReset = false;
  }


}
项目:intellij-ce-playground    文件:CodeStyleMainPanel.java   
private NewCodeStyleSettingsPanel ensurePanel(final CodeStyleScheme scheme) {
  String name = scheme.getName();
  if (!mySettingsPanels.containsKey(name)) {
    NewCodeStyleSettingsPanel panel = myFactory.createPanel(scheme);
    panel.reset();
    panel.setModel(myModel);
    CodeStyleAbstractPanel settingsPanel = panel.getSelectedPanel();
    if (settingsPanel instanceof TabbedLanguageCodeStylePanel) {
      TabbedLanguageCodeStylePanel tabbedPanel = (TabbedLanguageCodeStylePanel)settingsPanel;
      tabbedPanel.setListener(this);
      String currentTab = myProperties.getValue(getSelectedTabPropertyName(tabbedPanel));
      if (currentTab != null) {
        tabbedPanel.changeTab(currentTab);
      }
    }
    mySettingsPanels.put(name, panel);
    mySettingsPanel.add(scheme.getName(), panel);
  }

  return mySettingsPanels.get(name);
}
项目:intellij-ce-playground    文件:CodeStyleSchemesModel.java   
public void reset() {
  myUsePerProjectSettings = getProjectSettings().USE_PER_PROJECT_SETTINGS;

  CodeStyleScheme[] allSchemes = CodeStyleSchemes.getInstance().getSchemes();
  mySettingsToClone.clear();
  mySchemes.clear();
  ContainerUtil.addAll(mySchemes, allSchemes);
  myGlobalSelected = CodeStyleSchemes.getInstance().findPreferredScheme(getProjectSettings().PREFERRED_PROJECT_CODE_STYLE);

  CodeStyleSettings perProjectSettings = getProjectSettings().PER_PROJECT_SETTINGS;
  if (perProjectSettings != null) {
    myProjectScheme.setCodeStyleSettings(perProjectSettings);
  }


  myDispatcher.getMulticaster().schemeListChanged();
  myDispatcher.getMulticaster().currentSchemeChanged(this);

}
项目:intellij-ce-playground    文件:CodeStyleSchemesModel.java   
public List<CodeStyleScheme> getAllSortedSchemes() {
  List<CodeStyleScheme> schemes = new ArrayList<CodeStyleScheme>();
  schemes.addAll(getSchemes());
  schemes.add(myProjectScheme);
  Collections.sort(schemes, new Comparator<CodeStyleScheme>() {
    @Override
    public int compare(CodeStyleScheme s1, CodeStyleScheme s2) {
      if (isProjectScheme(s1)) return -1;
      if (isProjectScheme(s2)) return 1;
      if (s1.isDefault()) return -1;
      if (s2.isDefault()) return 1;
      return s1.getName().compareToIgnoreCase(s2.getName());
    }
  });
  return schemes;
}
项目:intellij-ce-playground    文件:CodeStyleSchemeImpl.java   
private void init(@Nullable CodeStyleScheme parentScheme, Element root) {
  if (parentScheme == null) {
    myCodeStyleSettings = new CodeStyleSettings();
  }
  else {
    CodeStyleSettings parentSettings = parentScheme.getCodeStyleSettings();
    myCodeStyleSettings = parentSettings.clone();
    while (parentSettings.getParentSettings() != null) {
      parentSettings = parentSettings.getParentSettings();
    }
    myCodeStyleSettings.setParentSettings(parentSettings);
  }
  if (root != null) {
    try {
      readExternal(root);
    }
    catch (InvalidDataException e) {
      LOG.error(e);
    }
  }
}
项目:intellij-ce-playground    文件:PersistableCodeStyleSchemes.java   
@Nullable
@Override
public Element getState() {
  CodeStyleScheme currentScheme = getCurrentScheme();
  CURRENT_SCHEME_NAME = currentScheme == null ? null : currentScheme.getName();
  return XmlSerializer.serialize(this, new SerializationFilter() {
    @Override
    public boolean accepts(@NotNull Accessor accessor, @NotNull Object bean) {
      if ("CURRENT_SCHEME_NAME".equals(accessor.getName())) {
        return !DEFAULT_SCHEME_NAME.equals(accessor.read(bean));
      }
      else {
        return accessor.getValueClass().equals(String.class);
      }
    }
  });
}
项目:intellij-ce-playground    文件:QuickChangeCodeStyleSchemeAction.java   
@Override
protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) {
  final CodeStyleSettingsManager manager = CodeStyleSettingsManager.getInstance(project);
  if (manager.PER_PROJECT_SETTINGS != null) {
    //noinspection HardCodedStringLiteral
    group.add(new AnAction("<project>", "",
                           manager.USE_PER_PROJECT_SETTINGS ? ourCurrentAction : ourNotCurrentAction) {
      @Override
      public void actionPerformed(@NotNull AnActionEvent e) {
        manager.USE_PER_PROJECT_SETTINGS = true;
      }
    });
  }

  CodeStyleScheme currentScheme = CodeStyleSchemes.getInstance().getCurrentScheme();
  for (CodeStyleScheme scheme : CodeStyleSchemes.getInstance().getSchemes()) {
    addScheme(group, manager, currentScheme, scheme, false);
  }
}
项目:intellij-ce-playground    文件:EclipseCodeStyleImportWorker.java   
public void importScheme(@NotNull InputStream inputStream, final @Nullable String sourceScheme, final CodeStyleScheme scheme)
  throws SchemeImportException {
  final CodeStyleSettings settings = scheme.getCodeStyleSettings();
  EclipseXmlProfileReader reader = new EclipseXmlProfileReader(new EclipseXmlProfileReader.OptionHandler() {
    private String myCurrScheme;

    @Override
    public void handleOption(@NotNull String eclipseKey, @NotNull String value) throws SchemeImportException {
      if (sourceScheme == null || myCurrScheme != null && myCurrScheme.equals(sourceScheme)) {
        setCodeStyleOption(settings, eclipseKey, value);
      }
    }
    @Override
    public void handleName(String name) {
      myCurrScheme = name;
    }
  });
  reader.readSettings(inputStream);
}
项目:intellij-ce-playground    文件:EclipseCodeStyleSchemeImporter.java   
@Nullable
@Override
public CodeStyleScheme importScheme(@NotNull Project project,
                                    @NotNull VirtualFile selectedFile,
                                    CodeStyleScheme currentScheme,
                                    SchemeFactory<CodeStyleScheme> schemeFactory) throws SchemeImportException {
  final String[] schemeNames = readSchemeNames(selectedFile);
  final ImportSchemeChooserDialog schemeChooserDialog =
    new ImportSchemeChooserDialog(project, schemeNames, !currentScheme.isDefault() ? currentScheme.getName() : null);
  if (! schemeChooserDialog.showAndGet()) return null;
  final CodeStyleScheme scheme = schemeChooserDialog.isUseCurrentScheme() && (! currentScheme.isDefault()) ? currentScheme :
    schemeFactory.createNewScheme(schemeChooserDialog.getTargetName());
  if (scheme == null) return null;
  readFromStream(selectedFile, new ThrowableConsumer<InputStream, SchemeImportException>() {
    @Override
    public void consume(InputStream stream) throws SchemeImportException {
      new EclipseCodeStyleImportWorker().importScheme(stream, schemeChooserDialog.getSelectedName(), scheme);
    }
  });

  return scheme;
}
项目:tools-idea    文件:ManageCodeStyleSchemesDialog.java   
private MySchemesTable() {
  myFixedItemsRenderer = new DefaultTableCellRenderer() {
    @Override
    public Component getTableCellRendererComponent(JTable table,
                                                   Object value,
                                                   boolean isSelected,
                                                   boolean hasFocus,
                                                   int row,
                                                   int column) {
      Component defaultComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
      if (value instanceof CodeStyleScheme) {
        CodeStyleScheme scheme = (CodeStyleScheme)value;
        if (scheme.isDefault() || myModel.isProjectScheme(scheme)) {
          defaultComponent.setFont(defaultComponent.getFont().deriveFont(Font.BOLD));
        }
      }
      return defaultComponent;
    }
  };
}
项目:tools-idea    文件:ManageCodeStyleSchemesDialog.java   
public int exportProjectScheme() {
  String name = Messages.showInputDialog("Enter new scheme name:", "Copy Project Scheme to Global List", Messages.getQuestionIcon());
  if (name != null && !CodeStyleSchemesModel.PROJECT_SCHEME_NAME.equals(name)) {
    CodeStyleScheme newScheme = mySchemesModel.exportProjectScheme(name);
    updateSchemes();
    int switchToGlobal = Messages
      .showYesNoDialog("Project scheme was copied to global scheme list as '" + newScheme.getName() + "'.\n" +
                       "Switch to this created scheme?",
                       "Copy Project Scheme to Global List", Messages.getQuestionIcon());
    if (switchToGlobal == 0) {
      mySchemesModel.setUsePerProjectSettings(false);
      mySchemesModel.selectScheme(newScheme, null);
    }
    int row = 0;
    for (CodeStyleScheme scheme : mySchemes) {
      if (scheme == newScheme) {
        fireTableRowsInserted(row, row);
        return switchToGlobal == 0 ? row : -1;
      }
      row++;
    }
  }
  return -1;
}
项目:tools-idea    文件:ManageCodeStyleSchemesDialog.java   
private void onSaveAs() {
  if (mySchemesTableModel.isProjectScheme(getSelectedScheme())) {
    int rowToSelect = mySchemesTableModel.exportProjectScheme();
    if (rowToSelect > 0) {
      mySchemesTable.getSelectionModel().setSelectionInterval(rowToSelect, rowToSelect);
    }
  }
  else {
    CodeStyleScheme[] schemes = CodeStyleSchemes.getInstance().getSchemes();
    ArrayList<String> names = new ArrayList<String>();
    for (CodeStyleScheme scheme : schemes) {
      names.add(scheme.getName());
    }
    SaveSchemeDialog saveDialog = new SaveSchemeDialog(myParent, ApplicationBundle.message("title.save.code.style.scheme.as"), names);
    saveDialog.show();
    if (saveDialog.isOK()) {
      int row = mySchemesTableModel.createNewScheme(getSelectedScheme(), saveDialog.getSchemeName());
      mySchemesTable.getSelectionModel().setSelectionInterval(row, row);
    }
  }
}
项目:tools-idea    文件:CodeStyleSchemesPanel.java   
public void resetSchemesCombo() {
  myIsReset = true;
  try {
    List<CodeStyleScheme> schemes = new ArrayList<CodeStyleScheme>();
    schemes.addAll(myModel.getAllSortedSchemes());
    DefaultComboBoxModel model = new DefaultComboBoxModel(schemes.toArray());
    myCombo.setModel(model);
    if (myModel.isUsePerProjectSettings()) {
      myCombo.setSelectedItem(myModel.getProjectScheme());
    }
    else {
      myCombo.setSelectedItem(myModel.getSelectedGlobalScheme());
    }
  }
  finally {
    myIsReset = false;
  }


}
项目:tools-idea    文件:CodeStyleSchemesModel.java   
public void reset() {
  myUsePerProjectSettings = getProjectSettings().USE_PER_PROJECT_SETTINGS;

  CodeStyleScheme[] allSchemes = CodeStyleSchemes.getInstance().getSchemes();
  mySettingsToClone.clear();
  mySchemes.clear();
  ContainerUtil.addAll(mySchemes, allSchemes);
  myGlobalSelected = CodeStyleSchemes.getInstance().findPreferredScheme(getProjectSettings().PREFERRED_PROJECT_CODE_STYLE);

  CodeStyleSettings perProjectSettings = getProjectSettings().PER_PROJECT_SETTINGS;
  if (perProjectSettings != null) {
    myProjectScheme.setCodeStyleSettings(perProjectSettings);
  }


  myDispatcher.getMulticaster().schemeListChanged();
  myDispatcher.getMulticaster().currentSchemeChanged(this);

}
项目:tools-idea    文件:CodeStyleSchemesModel.java   
public List<CodeStyleScheme> getAllSortedSchemes() {
  List<CodeStyleScheme> schemes = new ArrayList<CodeStyleScheme>();
  schemes.addAll(getSchemes());
  schemes.add(myProjectScheme);
  Collections.sort(schemes, new Comparator<CodeStyleScheme>() {
    @Override
    public int compare(CodeStyleScheme s1, CodeStyleScheme s2) {
      if (isProjectScheme(s1)) return -1;
      if (isProjectScheme(s2)) return 1;
      if (s1.isDefault()) return -1;
      if (s2.isDefault()) return 1;
      return s1.getName().compareToIgnoreCase(s2.getName());
    }
  });
  return schemes;
}
项目:tools-idea    文件:CodeStyleSchemeImpl.java   
private void init(CodeStyleScheme parentScheme, Element root) {
  CodeStyleSettings parentSettings = parentScheme == null ? null : parentScheme.getCodeStyleSettings();
  if (parentSettings == null){
    myCodeStyleSettings = new CodeStyleSettings();
  }
  else{
    myCodeStyleSettings = parentSettings.clone();
    while(parentSettings.getParentSettings() != null){
      parentSettings = parentSettings.getParentSettings();
    }
    myCodeStyleSettings.setParentSettings(parentSettings);
  }
  if (root != null) {
    try {
      readExternal(root);
    } catch (InvalidDataException e) {
      LOG.error(e);
    }
  }
}
项目:module-code-style    文件:ModuleCodeStyleReformatCodeAction.java   
@Override
public void actionPerformed(AnActionEvent event) {
    final DataContext dataContext = event.getDataContext();
    final Module module = LangDataKeys.MODULE.getData(dataContext);
    if (module != null) {
        ModuleCodeStyleComponent component = module.getComponent(ModuleCodeStyleComponent.class);
        if (component != null && component.getState() != null) {
            final String moduleCodeStyleScheme = component.getState().getCodeStyleSchemeName();
            final CodeStyleSchemes schemes = PersistableCodeStyleSchemes.getInstance();
            final CodeStyleScheme scheme = schemes.findSchemeByName(moduleCodeStyleScheme);
            if (scheme != null)
                schemes.setCurrentScheme(scheme);
        }
    }
    super.actionPerformed(event);
}
项目:module-code-style    文件:ModuleCodeStyleConfigurable.java   
private void loadAvailableCodeStyleSchemes() {
    final CodeStyleSchemes schemes = PersistableCodeStyleSchemes.getInstance();
    if (schemes != null) {
        final List<String> schemesList = new ArrayList<String>(schemes.getSchemes().length);

        String selectedCodeStyleSchemeName = getModuleCodeStyleSchemeName();
        boolean schemeExists = false;
        for (CodeStyleScheme scheme : schemes.getSchemes()) {
            schemesList.add(scheme.getName());
            if (scheme.getName().equals(selectedCodeStyleSchemeName))
                schemeExists = true;
        }

        if (!schemeExists)
            selectedCodeStyleSchemeName = ModuleCodeStyleState.defaultState().getCodeStyleSchemeName();

        final ComboBoxModel model = new CollectionComboBoxModel(schemesList, selectedCodeStyleSchemeName);
        codeStyleSchemesComboBox.setModel(model);
    } else {
        mainPanel.setEnabled(false);
    }
}
项目:consulo    文件:CodeStyleSchemesConfigurable.java   
@Override
protected Configurable[] buildConfigurables() {
  myPanels = new ArrayList<CodeStyleConfigurableWrapper>();

  for (final CodeStyleSettingsProvider provider : CodeStyleSettingsProvider.EXTENSION_POINT_NAME.getExtensions()) {
    if (provider.hasSettingsPage()) {
      myPanels.add(new CodeStyleConfigurableWrapper(provider, new CodeStyleSettingsPanelFactory() {
        @Override
        public NewCodeStyleSettingsPanel createPanel(final CodeStyleScheme scheme) {
          return new NewCodeStyleSettingsPanel(provider.createSettingsPage(scheme.getCodeStyleSettings(), ensureModel().getCloneSettings(scheme)));
        }
      }));
    }
  }

  return myPanels.toArray(new Configurable[myPanels.size()]);
}
项目:consulo    文件:ManageCodeStyleSchemesDialog.java   
private MySchemesTable() {
  myFixedItemsRenderer = new DefaultTableCellRenderer() {
    @Nonnull
    @Override
    public Component getTableCellRendererComponent(@Nonnull JTable table,
                                                   Object value,
                                                   boolean isSelected,
                                                   boolean hasFocus,
                                                   int row,
                                                   int column) {
      Component defaultComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
      if (value instanceof CodeStyleScheme) {
        CodeStyleScheme scheme = (CodeStyleScheme)value;
        if (scheme.isDefault() || myModel.isProjectScheme(scheme)) {
          defaultComponent.setFont(defaultComponent.getFont().deriveFont(Font.BOLD));
        }
      }
      return defaultComponent;
    }
  };
}
项目:consulo    文件:ManageCodeStyleSchemesDialog.java   
public int exportProjectScheme() {
  String name = Messages.showInputDialog("Enter new scheme name:", "Copy Project Scheme to Global List", Messages.getQuestionIcon());
  if (name != null && !CodeStyleSchemesModel.PROJECT_SCHEME_NAME.equals(name)) {
    CodeStyleScheme newScheme = mySchemesModel.exportProjectScheme(name);
    updateSchemes();
    int switchToGlobal = Messages
      .showYesNoDialog("Project scheme was copied to global scheme list as '" + newScheme.getName() + "'.\n" +
                       "Switch to this created scheme?",
                       "Copy Project Scheme to Global List", Messages.getQuestionIcon());
    if (switchToGlobal == Messages.YES) {
      mySchemesModel.setUsePerProjectSettings(false);
      mySchemesModel.selectScheme(newScheme, null);
    }
    int row = 0;
    for (CodeStyleScheme scheme : mySchemes) {
      if (scheme == newScheme) {
        fireTableRowsInserted(row, row);
        return switchToGlobal == 0 ? row : -1;
      }
      row++;
    }
  }
  return -1;
}
项目:consulo    文件:ManageCodeStyleSchemesDialog.java   
private void onSaveAs() {
  if (mySchemesTableModel.isProjectScheme(getSelectedScheme())) {
    int rowToSelect = mySchemesTableModel.exportProjectScheme();
    if (rowToSelect > 0) {
      mySchemesTable.getSelectionModel().setSelectionInterval(rowToSelect, rowToSelect);
    }
  }
  else {
    CodeStyleScheme[] schemes = CodeStyleSchemes.getInstance().getSchemes();
    ArrayList<String> names = new ArrayList<String>();
    for (CodeStyleScheme scheme : schemes) {
      names.add(scheme.getName());
    }
    String selectedName = getSelectedScheme().getName();
    SaveSchemeDialog saveDialog =
      new SaveSchemeDialog(myParent, ApplicationBundle.message("title.save.code.style.scheme.as"), names, selectedName);
    if (saveDialog.showAndGet()) {
      int row = mySchemesTableModel.createNewScheme(getSelectedScheme(), saveDialog.getSchemeName());
      mySchemesTable.getSelectionModel().setSelectionInterval(row, row);
    }
  }
}
项目:consulo    文件:CodeStyleSchemesPanel.java   
public void resetSchemesCombo() {
  myIsReset = true;
  try {
    List<CodeStyleScheme> schemes = new ArrayList<CodeStyleScheme>();
    schemes.addAll(myModel.getAllSortedSchemes());
    DefaultComboBoxModel model = new DefaultComboBoxModel(schemes.toArray());
    myCombo.setModel(model);
    if (myModel.isUsePerProjectSettings()) {
      myCombo.setSelectedItem(myModel.getProjectScheme());
    }
    else {
      myCombo.setSelectedItem(myModel.getSelectedGlobalScheme());
    }
  }
  finally {
    myIsReset = false;
  }
}
项目:consulo    文件:CodeStyleMainPanel.java   
private NewCodeStyleSettingsPanel ensurePanel(final CodeStyleScheme scheme) {
  String name = scheme.getName();
  if (!mySettingsPanels.containsKey(name)) {
    NewCodeStyleSettingsPanel panel = myFactory.createPanel(scheme);
    panel.reset();
    panel.setModel(myModel);
    CodeStyleAbstractPanel settingsPanel = panel.getSelectedPanel();
    if (settingsPanel instanceof TabbedLanguageCodeStylePanel) {
      TabbedLanguageCodeStylePanel tabbedPanel = (TabbedLanguageCodeStylePanel)settingsPanel;
      tabbedPanel.setListener(this);
      String currentTab = myProperties.getValue(getSelectedTabPropertyName(tabbedPanel));
      if (currentTab != null) {
        tabbedPanel.changeTab(currentTab);
      }
    }
    mySettingsPanels.put(name, panel);
    mySettingsPanel.add(scheme.getName(), panel);
  }

  return mySettingsPanels.get(name);
}
项目:consulo    文件:CodeStyleSchemesModel.java   
public void reset() {
  myUsePerProjectSettings = getProjectSettings().USE_PER_PROJECT_SETTINGS;

  CodeStyleScheme[] allSchemes = CodeStyleSchemes.getInstance().getSchemes();
  mySettingsToClone.clear();
  mySchemes.clear();
  ContainerUtil.addAll(mySchemes, allSchemes);
  myGlobalSelected = CodeStyleSchemes.getInstance().findPreferredScheme(getProjectSettings().PREFERRED_PROJECT_CODE_STYLE);

  CodeStyleSettings perProjectSettings = getProjectSettings().PER_PROJECT_SETTINGS;
  if (perProjectSettings != null) {
    myProjectScheme.setCodeStyleSettings(perProjectSettings);
  }


  myDispatcher.getMulticaster().schemeListChanged();
  myDispatcher.getMulticaster().currentSchemeChanged(this);

}
项目:consulo    文件:CodeStyleSchemesModel.java   
public List<CodeStyleScheme> getAllSortedSchemes() {
  List<CodeStyleScheme> schemes = new ArrayList<CodeStyleScheme>();
  schemes.addAll(getSchemes());
  schemes.add(myProjectScheme);
  Collections.sort(schemes, new Comparator<CodeStyleScheme>() {
    @Override
    public int compare(CodeStyleScheme s1, CodeStyleScheme s2) {
      if (isProjectScheme(s1)) return -1;
      if (isProjectScheme(s2)) return 1;
      if (s1.isDefault()) return -1;
      if (s2.isDefault()) return 1;
      return s1.getName().compareToIgnoreCase(s2.getName());
    }
  });
  return schemes;
}
项目:consulo    文件:CodeStyleSchemeImpl.java   
private void init(@Nullable CodeStyleScheme parentScheme, Element root) {
  if (parentScheme == null) {
    myCodeStyleSettings = new CodeStyleSettings();
  }
  else {
    CodeStyleSettings parentSettings = parentScheme.getCodeStyleSettings();
    myCodeStyleSettings = parentSettings.clone();
    while (parentSettings.getParentSettings() != null) {
      parentSettings = parentSettings.getParentSettings();
    }
    myCodeStyleSettings.setParentSettings(parentSettings);
  }
  if (root != null) {
    try {
      readExternal(root);
    }
    catch (InvalidDataException e) {
      LOG.error(e);
    }
  }
}
项目:consulo    文件:QuickChangeCodeStyleSchemeAction.java   
@Override
protected void fillActions(Project project, @Nonnull DefaultActionGroup group, @Nonnull DataContext dataContext) {
  final CodeStyleSettingsManager manager = CodeStyleSettingsManager.getInstance(project);
  if (manager.PER_PROJECT_SETTINGS != null) {
    //noinspection HardCodedStringLiteral
    group.add(new AnAction("<project>", "",
                           manager.USE_PER_PROJECT_SETTINGS ? ourCurrentAction : ourNotCurrentAction) {
      @Override
      public void actionPerformed(@Nonnull AnActionEvent e) {
        manager.USE_PER_PROJECT_SETTINGS = true;
      }
    });
  }

  CodeStyleScheme currentScheme = CodeStyleSchemes.getInstance().getCurrentScheme();
  for (CodeStyleScheme scheme : CodeStyleSchemes.getInstance().getSchemes()) {
    addScheme(group, manager, currentScheme, scheme, false);
  }
}
项目:hybris-integration-intellij-idea-plugin    文件:ImportProjectProgressModalWindow.java   
private void disableWrapOnType(final Language impexLanguage) {
    final CodeStyleScheme currentScheme = CodeStyleSchemes.getInstance().getCurrentScheme();
    final CodeStyleSettings codeStyleSettings = currentScheme.getCodeStyleSettings();
    if (impexLanguage != null) {
        CommonCodeStyleSettings langSettings = codeStyleSettings.getCommonSettings(impexLanguage);
        if (langSettings != null) {
            langSettings.WRAP_ON_TYPING = CommonCodeStyleSettings.WrapOnTyping.NO_WRAP.intValue;
        }
    }
}
项目:intellij-ce-playground    文件:CodeStyleSchemesConfigurable.java   
@Override
public void apply() throws ConfigurationException {
  if (!myApplyCompleted) {
    try {
      super.apply();

      for (CodeStyleScheme scheme : new ArrayList<CodeStyleScheme>(myModel.getSchemes())) {
        final boolean isDefaultModified = CodeStyleSchemesModel.cannotBeModified(scheme) && isSchemeModified(scheme);
        if (isDefaultModified) {
          CodeStyleScheme newscheme = myModel.createNewScheme(null, scheme);
          CodeStyleSettings settingsWillBeModified = scheme.getCodeStyleSettings();
          CodeStyleSettings notModifiedSettings = settingsWillBeModified.clone();
          ((CodeStyleSchemeImpl)scheme).setCodeStyleSettings(notModifiedSettings);
          ((CodeStyleSchemeImpl)newscheme).setCodeStyleSettings(settingsWillBeModified);
          myModel.addScheme(newscheme, false);

          if (myModel.getSelectedScheme() == scheme) {
            myModel.selectScheme(newscheme, this);
          }

        }
      }

      for (CodeStyleConfigurableWrapper panel : myPanels) {
        panel.applyPanel();
      }

      myModel.apply();
      EditorFactory.getInstance().refreshAllEditors();
    }
    finally {
      myApplyCompleted = true;
    }

  }

}
项目:intellij-ce-playground    文件:CodeStyleSchemesConfigurable.java   
private boolean isSchemeModified(final CodeStyleScheme scheme) {
  for (CodeStyleConfigurableWrapper panel : myPanels) {
    if (panel.isPanelModified(scheme)) {
      return true;
    }
  }
  return false;
}
项目:intellij-ce-playground    文件:CodeStyleSchemesConfigurable.java   
private CodeStyleSchemesModel ensureModel() {
  if (myModel == null) {
    myModel = new CodeStyleSchemesModel(myProject);
    myRootSchemesPanel = new CodeStyleSchemesPanel(myModel);

    myModel.addListener(new CodeStyleSettingsListener(){
      @Override
      public void currentSchemeChanged(final Object source) {
        if (source != myRootSchemesPanel) {
          myRootSchemesPanel.onSelectedSchemeChanged();
        }
      }

      @Override
      public void schemeListChanged() {
        myRootSchemesPanel.resetSchemesCombo();
      }

      @Override
      public void currentSettingsChanged() {

      }

      @Override
      public void usePerProjectSettingsOptionChanged() {
        myRootSchemesPanel.usePerProjectSettingsOptionChanged();
      }

      @Override
      public void schemeChanged(final CodeStyleScheme scheme) {
        //do nothing
      }
    });
  }
  return myModel;
}
项目:intellij-ce-playground    文件:CodeStyleSchemeExporterUI.java   
private static String[] enumExporters() {
  List<String> names = new ArrayList<String>();
  Collection<SchemeExporterEP<CodeStyleScheme>> extensions = SchemeExporterEP.getExtensions(CodeStyleScheme.class);
  for (SchemeExporterEP<CodeStyleScheme> extension : extensions) {
    names.add(extension.name);
  }
  return ArrayUtil.toStringArray(names);
}
项目:intellij-ce-playground    文件:ManageCodeStyleSchemesDialog.java   
@Nullable
private CodeStyleScheme importExternalCodeStyle(final SchemeImporter<CodeStyleScheme> importer) throws SchemeImportException {
  final VirtualFile selectedFile = selectImportSource(importer.getSourceExtensions());
  if (selectedFile != null) {
    CodeStyleSchemesUIConfiguration.Util.setRecentImportFile(selectedFile);
    final SchemeCreator schemeCreator = new SchemeCreator();
    final CodeStyleScheme
      schemeImported = importer.importScheme(myModel.getProject(), selectedFile, myModel.getSelectedScheme(), schemeCreator);
    if (schemeImported != null) {
      myModel.fireSchemeChanged(schemeImported);
      return schemeImported;
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:ManageCodeStyleSchemesDialog.java   
@Override
public CodeStyleScheme createNewScheme(@Nullable String targetName) {
  if (targetName == null) targetName = ApplicationBundle.message("code.style.scheme.import.unnamed");
  final int row = mySchemesTableModel.createNewScheme(getSelectedScheme(), targetName);
  mySchemesTable.getSelectionModel().setSelectionInterval(row, row);
  return mySchemesTableModel.getSchemeAt(row);
}
项目:intellij-ce-playground    文件:ManageCodeStyleSchemesDialog.java   
public int createNewScheme(CodeStyleScheme selectedScheme, String schemeName) {
  CodeStyleScheme newScheme = mySchemesModel.createNewScheme(schemeName, selectedScheme);
  mySchemesModel.addScheme(newScheme, true);
  updateSchemes();
  int row = 0;
  for (CodeStyleScheme scheme : mySchemes) {
    if (scheme == newScheme) {
      fireTableRowsInserted(row, row);
      break;
    }
    row ++;
  }
  return row;
}
项目:intellij-ce-playground    文件:ManageCodeStyleSchemesDialog.java   
public int getDefaultRow() {
  int row = 0;
  for (CodeStyleScheme scheme : mySchemes) {
    if (scheme.isDefault()) return row;
    row ++;
  }
  return 0;
}