Package krasa.formatter.settings

Examples of krasa.formatter.settings.Settings


        }
    }

    private void changeFormatter(Project project, Settings.Formatter lf) {
        ProjectSettingsComponent instance = ProjectSettingsComponent.getInstance(project);
        final Settings state = instance.getState();
        state.setFormatter(lf);
        instance.loadState(state);
    }
View Full Code Here


  }

  private void verifySettingsOf(@Nullable ProjectSettingsForm form) throws ConfigurationException {
    try {
      if (form != null) {
        Settings test = settings.clone();
        form.exportTo(test);
        SettingsManager.verify( test );
      }
    } catch (IllegalSettingsException e) {
      LOG.info(e);
View Full Code Here

                                                           Settings defaultSettings) {
        Project[] openProjects = ProjectManagerImpl.getInstance().getOpenProjects();
        for (Project openProject : openProjects) {
            ProjectSettingsComponent component = openProject.getComponent(ProjectSettingsComponent.class);
            if (component != null) {
                Settings state = component.getSettings();
                if (deletedSettings.getId().equals(state.getId())) {
                    component.loadState(defaultSettings);
                    if (project != openProject) {
                        Notifier.notifyDeletedSettings(component.getProject());
                    }
                }
View Full Code Here

    public static void applyToAllOpenedProjects(Settings updatedSettings) {
        Project[] openProjects = ProjectManagerImpl.getInstance().getOpenProjects();
        for (Project openProject : openProjects) {
            ProjectSettingsComponent component = openProject.getComponent(ProjectSettingsComponent.class);
            if (component != null) {
                Settings state = component.getSettings();
                if (updatedSettings.getId().equals(state.getId())) {
                    component.install(updatedSettings);
                }
            }
        }
    }
View Full Code Here

          createProfile();
        }
      }

      private void createProfile() {
        Settings settings = GlobalSettings.getInstance().newSettings();
        refreshProfilesModel();
        profiles.setSelectedItem(settings);
      }
    });
    copyProfile.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        if (isModified(displayedSettings)) {
          ListPopup confirmation = createConfirmation(
              "Profile was modified, save changes to current profile?", "Yes", "No", new Runnable() {
                @Override
                public void run() {
                  exportDisplayedSettings();
                  copyProfile();
                }
              }, new Runnable() {
                @Override
                public void run() {
                  importFrom(displayedSettings);
                  copyProfile();
                }
              }, 0
          );

          confirmation.showInFocusCenter();
        } else {
          copyProfile();
        }
      }

      private void copyProfile() {
        Settings settings = GlobalSettings.getInstance().copySettings(displayedSettings);
        refreshProfilesModel();
        profiles.setSelectedItem(settings);

      }
    });
    setJavaFormatterProfileModel();
    setJavaScriptFormatterProfileModel();
       
    profilesModel = createProfilesModel();
    profiles.setModel(profilesModel);
    profiles.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        // && isSameId()
        if (displayedSettings != null && getSelectedItem() != null && isModified(displayedSettings)) {
          showConfirmationDialogOnProfileChange();
        } else if (displayedSettings != null && getSelectedItem() != null) {
          importFromInternal(getSelectedItem());
        }
      }

    });

    profiles.setRenderer(new ListCellRendererWrapper(profiles.getRenderer()) {
      @Override
      public void customize(JList jList, Object value, int i, boolean b, boolean b1) {
        if (value != null) {
          setText(((Settings) value).getName());
        }
      }
    });
    rename.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        final JTextField content = new JTextField();
        content.setText(displayedSettings.getName());
        JBPopup balloon = PopupFactoryImpl.getInstance().createComponentPopupBuilder(content, content).createPopup();
        balloon.setMinimumSize(new Dimension(200, 20));
        balloon.addListener(new JBPopupListener() {
          @Override
          public void beforeShown(LightweightWindowEvent event) {
          }

          @Override
          public void onClosed(LightweightWindowEvent event) {
            displayedSettings.setName(content.getText());
          }
        });
        balloon.showUnderneathOf(rename);
      }
    });
    delete.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        int selectedIndex = profiles.getSelectedIndex();
        GlobalSettings.getInstance().delete(getSelectedItem(), getProject());
        profiles.setModel(profilesModel = createProfilesModel());
        int itemCount = profiles.getItemCount();
        if (selectedIndex < itemCount && selectedIndex >= 0) {
          Object itemAt = profiles.getItemAt(selectedIndex);
          importFromInternal((Settings) itemAt);
          profiles.setSelectedIndex(selectedIndex);
        }
        if (selectedIndex == itemCount && selectedIndex - 1 >= 0) {
          Object itemAt = profiles.getItemAt(selectedIndex - 1);
          importFromInternal((Settings) itemAt);
          profiles.setSelectedIndex(selectedIndex - 1);
        } else {
          Settings defaultSettings = GlobalSettings.getInstance().getDefaultSettings();
          importFromInternal(defaultSettings);
          profiles.setSelectedItem(defaultSettings);
        }

      }
View Full Code Here

    }

  private void changeFormatter( Project project, Settings.Formatter lf )
  {
    ProjectSettingsComponent instance = ProjectSettingsComponent.getInstance( project );
    final Settings state = instance.getState();
    state.setFormatter(lf);
    instance.loadState(state);
  }
View Full Code Here

    public static final String[] ORDER = new String[]{"java", "javax", "org", "com", "br.gov.bcb"};

    @Test
    public void testReadFile() throws Exception {
        Settings settings = new Settings();
        File file = FileUtils.getFile("test/resources/bcjur2.importorder");
        settings.setImportOrderConfigFilePath(file.getAbsolutePath());
        ImportOrderProvider importOrderProvider = new ImportOrderProvider(settings);
        List<String> stringList = importOrderProvider.get();

        org.junit.Assert.assertArrayEquals(ORDER, stringList.toArray(new String[stringList.size()]));
    }
View Full Code Here

        }
    }

    private void changeFormatter(Project project, Settings.Formatter formatter) {
        ProjectSettingsComponent instance = ProjectSettingsComponent.getInstance(project);
        final Settings state = instance.getState();
        state.setFormatter(formatter);
        ProjectUtils.applyToAllOpenedProjects(state);
    }
View Full Code Here

  public static final Icon ICON = IconLoader.getIcon("/krasa/formatter/eclipse.gif");
  public static final Icon ICON1 = IconLoader.getIcon("/krasa/formatter/IDEA.gif");

  public void actionPerformed(AnActionEvent e) {
    final Settings state = getSettings(e);
    if (state != null) {
      state.setFormatter(Settings.Formatter.DEFAULT == state.getFormatter() ? Settings.Formatter.ECLIPSE : Settings.Formatter.DEFAULT);
      ProjectUtils.applyToAllOpenedProjects(state);
      updateIcon(state, e.getPresentation());
    }
  }
View Full Code Here

  @Override
  public void update(AnActionEvent e) {
    super.update(e);
    try {
      Presentation presentation = e.getPresentation();
      final Settings state = getSettings(e);
      if (state != null) {
        updateIcon(state, presentation);
      }
    } catch (Throwable e1) {
      e.getPresentation().setEnabled(false);
View Full Code Here

TOP

Related Classes of krasa.formatter.settings.Settings

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.