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); } } }
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); }
@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); } }
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); } } }
@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); }
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); } }
@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); } }
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; } } }
public boolean isSchemeListModified() { CodeStyleSchemes schemes = CodeStyleSchemes.getInstance(); if (getProjectSettings().USE_PER_PROJECT_SETTINGS != myUsePerProjectSettings) return true; if (!myUsePerProjectSettings && getSelectedScheme() != schemes.findPreferredScheme(getProjectSettings().PREFERRED_PROJECT_CODE_STYLE)) { return true; } Set<CodeStyleScheme> configuredSchemesSet = new HashSet<CodeStyleScheme>(getSchemes()); Set<CodeStyleScheme> savedSchemesSet = new HashSet<CodeStyleScheme>(Arrays.asList(schemes.getSchemes())); return !configuredSchemesSet.equals(savedSchemesSet); }
public void apply() { CodeStyleSettingsManager projectSettingsManager = getProjectSettings(); projectSettingsManager.USE_PER_PROJECT_SETTINGS = myUsePerProjectSettings; projectSettingsManager.PREFERRED_PROJECT_CODE_STYLE = myUsePerProjectSettings || myGlobalSelected == null ? null : myGlobalSelected.getName(); projectSettingsManager.PER_PROJECT_SETTINGS = myProjectScheme.getCodeStyleSettings(); ((CodeStyleSchemesImpl)CodeStyleSchemes.getInstance()).getSchemeManager().setSchemes(mySchemes, myGlobalSelected, null); // We want to avoid the situation when 'real code style' differs from the copy stored here (e.g. when 'real code style' changes // are 'committed' by pressing 'Apply' button). So, we reset the copies here assuming that this method is called on 'Apply' // button processing mySettingsToClone.clear(); }
public boolean isSchemeListModified() { CodeStyleSchemes schemes = CodeStyleSchemes.getInstance(); if (getProjectSettings().USE_PER_PROJECT_SETTINGS != myUsePerProjectSettings) return true; if (!myUsePerProjectSettings && (getSelectedScheme() != schemes.findPreferredScheme(getProjectSettings().PREFERRED_PROJECT_CODE_STYLE))) { return true; } Set<CodeStyleScheme> configuredSchemesSet = new HashSet<CodeStyleScheme>(getSchemes()); Set<CodeStyleScheme> savedSchemesSet = new HashSet<CodeStyleScheme>(Arrays.asList(schemes.getSchemes())); if (!configuredSchemesSet.equals(savedSchemesSet)) return true; return false; }
public void apply() { CodeStyleSettingsManager projectSettingsManager = getProjectSettings(); projectSettingsManager.USE_PER_PROJECT_SETTINGS = myUsePerProjectSettings; projectSettingsManager.PREFERRED_PROJECT_CODE_STYLE = myUsePerProjectSettings || myGlobalSelected == null ? null : myGlobalSelected.getName(); projectSettingsManager.PER_PROJECT_SETTINGS = myProjectScheme.getCodeStyleSettings(); final CodeStyleScheme[] savedSchemes = CodeStyleSchemes.getInstance().getSchemes(); final Set<CodeStyleScheme> savedSchemesSet = new HashSet<CodeStyleScheme>(Arrays.asList(savedSchemes)); List<CodeStyleScheme> configuredSchemes = getSchemes(); for (CodeStyleScheme savedScheme : savedSchemes) { if (!configuredSchemes.contains(savedScheme)) { CodeStyleSchemes.getInstance().deleteScheme(savedScheme); } } for (CodeStyleScheme configuredScheme : configuredSchemes) { if (!savedSchemesSet.contains(configuredScheme)) { CodeStyleSchemes.getInstance().addScheme(configuredScheme); } } CodeStyleSchemes.getInstance().setCurrentScheme(myGlobalSelected); // We want to avoid the situation when 'real code style' differs from the copy stored here (e.g. when 'real code style' changes // are 'committed' by pressing 'Apply' button). So, we reset the copies here assuming that this method is called on 'Apply' // button processing mySettingsToClone.clear(); }
@Override protected CodeStyleSettings getCurrentCodeStyleSettings() { if (CodeStyleSchemes.getInstance().getCurrentScheme() == null) return new CodeStyleSettings(); return CodeStyleSettingsManager.getSettings(getProject()); }
protected CodeStyleSettings getCurrentCodeStyleSettings() { if (CodeStyleSchemes.getInstance().getCurrentScheme() == null) return new CodeStyleSettings(); return CodeStyleSettingsManager.getSettings(getProject()); }
protected CodeStyleSettings getCurrentCodeStyleSettings() { if (CodeStyleSchemes.getInstance().getCurrentScheme() == null) return new CodeStyleSettings(); return CodeStyleSettingsManager.getInstance().getCurrentSettings(); }
public Set<String> processListOptions() { final CodeStyleScheme defaultScheme = CodeStyleSchemes.getInstance().getDefaultScheme(); final NewCodeStyleSettingsPanel panel = ensurePanel(defaultScheme); return panel.processListOptions(); }
public CodeStyleSchemesModel(Project project) { myProject = project; myProjectScheme = new CodeStyleSchemeImpl(PROJECT_SCHEME_NAME, false, CodeStyleSchemes.getInstance().getDefaultScheme()); reset(); myDefault = CodeStyleSchemes.getInstance().getDefaultScheme(); }
public void init(@NotNull CodeStyleSchemes schemesManager) { LOG.assertTrue(myCodeStyleSettings == null, "Already initialized"); init(myParentSchemeName == null ? null : schemesManager.findSchemeByName(myParentSchemeName), myRootElement); myParentSchemeName = null; myRootElement = null; }
@Override protected boolean isEnabled() { return CodeStyleSchemes.getInstance().getSchemes().length > 1; }
@Override public void run() { checkInstallation(); cleanUpIdePreferences(); if (!Boolean.getBoolean(USE_IDEA_NEW_PROJECT_WIZARDS)) { replaceIdeaNewProjectActions(); } if (!Boolean.getBoolean(USE_IDEA_PROJECT_STRUCTURE)) { replaceProjectStructureActions(); } if (!Boolean.getBoolean(USE_JPS_MAKE_ACTIONS)) { replaceIdeaMakeActions(); } if (!Boolean.getBoolean(USE_IDEA_NEW_FILE_POPUPS)) { hideIdeaNewFilePopupActions(); } try { // Setup JDK and Android SDK if necessary setupSdks(); } catch (Exception e) { LOG.error("Unexpected error while setting up SDKs: ", e); } addExtraBuildActions(); hideMiscActions(); registerAppClosing(); // Always reset the Default scheme to match Android standards // User modifications won't be lost since they are made in a separate scheme (copied off of this default scheme) CodeStyleScheme scheme = CodeStyleSchemes.getInstance().getDefaultScheme(); if (scheme != null) { CodeStyleSettings settings = scheme.getCodeStyleSettings(); if (settings != null) { AndroidCodeStyleSettingsModifier.modify(settings); } } // Modify built-in "Default" color scheme to remove background from XML tags. // "Darcula" and user schemes will not be touched. EditorColorsScheme colorsScheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME); TextAttributes textAttributes = colorsScheme.getAttributes(HighlighterColors.TEXT); TextAttributes xmlTagAttributes = colorsScheme.getAttributes(XmlHighlighterColors.XML_TAG); xmlTagAttributes.setBackgroundColor(textAttributes.getBackgroundColor()); checkAndSetAndroidSdkSources(); }
static SchemesManager<CodeStyleScheme, CodeStyleSchemeImpl> getSchemesManager() { return ((CodeStyleSchemesImpl) CodeStyleSchemes.getInstance()).getSchemesManager(); }
public void init(CodeStyleSchemes schemesManager) { LOG.assertTrue(myCodeStyleSettings == null, "Already initialized"); init(schemesManager.findSchemeByName(myParentSchemeName), myRootElement); myParentSchemeName = null; myRootElement = null; }