/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/ConfigureFileDefaultEncodingAction.java

https://bitbucket.org/nbargnesi/idea · Java · 44 lines · 24 code · 5 blank · 15 comment · 3 complexity · ecef366d796abfb8f6ed254e52f4dc1d MD5 · raw file

  1. /*
  2. * Copyright 2000-2009 JetBrains s.r.o.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.intellij.openapi.vfs.encoding;
  17. import com.intellij.openapi.actionSystem.AnAction;
  18. import com.intellij.openapi.actionSystem.AnActionEvent;
  19. import com.intellij.openapi.actionSystem.PlatformDataKeys;
  20. import com.intellij.openapi.options.ShowSettingsUtil;
  21. import com.intellij.openapi.project.Project;
  22. import com.intellij.openapi.vfs.VirtualFile;
  23. public class ConfigureFileDefaultEncodingAction extends AnAction {
  24. public void actionPerformed(final AnActionEvent e) {
  25. final Project project = e.getData(PlatformDataKeys.PROJECT);
  26. final VirtualFile virtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE);
  27. final FileEncodingConfigurable configurable = new FileEncodingConfigurable(project);
  28. ShowSettingsUtil.getInstance().editConfigurable(project, configurable, new Runnable(){
  29. public void run() {
  30. if (virtualFile != null) {
  31. configurable.selectFile(virtualFile);
  32. }
  33. }
  34. });
  35. }
  36. public void update(final AnActionEvent e) {
  37. e.getPresentation().setEnabled(e.getData(PlatformDataKeys.PROJECT) != null);
  38. }
  39. }