private static String getStatusMessage(final CvsHandler handler) {
   final String actionName = handler.getTitle();
   if (handler.getErrors().isEmpty()) {
     return CvsBundle.message("status.text.action.completed", actionName);
   } else {
     return CvsBundle.message("status.text.action.completed.with.errors", actionName);
   }
 }
 public ErrorTreeView getErrorsTreeView() {
   if (myErrorsView == null) {
     myErrorsView =
         ErrorViewFactory.SERVICE
             .getInstance()
             .createErrorTreeView(
                 myProject,
                 null,
                 true,
                 new AnAction[] {
                   (DefaultActionGroup) ActionManager.getInstance().getAction("CvsActions")
                 },
                 new AnAction[] {new GlobalCvsSettingsAction(), new ReconfigureCvsRootAction()},
                 new ContentManagerProvider() {
                   public ContentManager getParentContent() {
                     return getContentManager();
                   }
                 });
     addTab(
         CvsBundle.message("tab.title.errors"),
         myErrorsView.getComponent(),
         true,
         false,
         true,
         false,
         null,
         "cvs.errors");
   }
   return myErrorsView;
 }
 public MyCopyAction() {
   super(CvsBundle.message("action.name.copy"), null, IconLoader.getIcon("/general/copy.png"));
   registerCustomShortcutSet(
       new CustomShortcutSet(
           KeyStroke.getKeyStroke(
               KeyEvent.VK_C, SystemInfo.isMac ? KeyEvent.META_MASK : KeyEvent.CTRL_MASK)),
       myList);
 }
 protected Action[] createLeftSideActions() {
   AbstractAction globalSettingsAction =
       new AbstractAction(CvsBundle.message("button.text.global.settings")) {
         public void actionPerformed(ActionEvent e) {
           new ConfigureCvsGlobalSettingsDialog().show();
         }
       };
   return new Action[] {globalSettingsAction};
 }
  public CvsConfigurationsListEditor(List<CvsRootConfiguration> configs, Project project) {
    super(true);
    myCvs2SettingsEditPanel = new Cvs2SettingsEditPanel(project);
    setTitle(CvsBundle.message("operation.name.edit.configurations"));
    myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    selectNone();
    fillModel(configs);

    myCvs2SettingsEditPanel.addCvsRootChangeListener(
        new CvsRootChangeListener() {
          public void onCvsRootChanged() {
            if (mySelection == null) return;
            myCvs2SettingsEditPanel.saveTo(mySelection, false);
            myList.repaint();
          }
        });

    setTitle(CvsBundle.message("dialog.title.cvs.roots"));

    if (!configs.isEmpty()) {
      myList.setSelectedIndex(0);
    }
    init();
  }
 public Editor addOutput(Editor output) {
   LOG.assertTrue(myOutput == null);
   if (myOutput == null) {
     addTab(
         CvsBundle.message("tab.title.cvs.output"),
         output.getComponent(),
         false,
         false,
         false,
         true,
         null,
         "cvs.cvsOutput");
     myOutput = output;
   }
   return myOutput;
 }
示例#7
0
 public Settings createConfiguration(String rootAsString, boolean check) {
   final CvsRootParser root = CvsRootParser.valueOf(rootAsString, check);
   final Settings result = myBuilder.createSettings(root.METHOD, rootAsString);
   if (CvsMethod.LOCAL_METHOD.equals(root.METHOD)) {
     fillLocalSettings(root.REPOSITORY, result);
   } else if (CvsMethod.PSERVER_METHOD.equals(root.METHOD)) {
     fillPServerSettings(root, result, rootAsString);
   } else if (CvsMethod.EXT_METHOD.equals(root.METHOD)) {
     fillSettings(root, result);
   } else if (CvsMethod.SSH_METHOD.equals(root.METHOD)) {
     fillSettings(root, result);
   } else {
     throw new CvsRootException(
         CvsBundle.message("exception.text.unsupported.method", root.METHOD, rootAsString));
   }
   return result;
 }
 public ReconfigureCvsRootAction() {
   super(CvsBundle.message("action.name.reconfigure.cvs.root"), null, AllIcons.Nodes.Cvs_roots);
 }
 public GlobalCvsSettingsAction() {
   super(
       CvsBundle.message("configure.global.cvs.settings.action.name"),
       null,
       AllIcons.Nodes.Cvs_global);
 }
/** author: lesya */
public class KeywordSubstitutionWrapper {

  private final KeywordSubstitution myKeywordSubstitution;
  private final String myDisplayName;

  public static final KeywordSubstitutionWrapper BINARY =
      new KeywordSubstitutionWrapper(
          KeywordSubstitution.BINARY,
          com.intellij.CvsBundle.message("keyword.substitution.binary"));
  public static final KeywordSubstitutionWrapper KEYWORD_COMPRESSION =
      new KeywordSubstitutionWrapper(
          KeywordSubstitution.KEYWORD_COMPRESSION,
          com.intellij.CvsBundle.message("keyword.substitution.compression"));
  public static final KeywordSubstitutionWrapper KEYWORD_EXPANSION =
      new KeywordSubstitutionWrapper(
          KeywordSubstitution.KEYWORD_EXPANSION,
          com.intellij.CvsBundle.message("keyword.substitution.expansion"));
  public static final KeywordSubstitutionWrapper KEYWORD_EXPANSION_LOCKER =
      new KeywordSubstitutionWrapper(
          KeywordSubstitution.KEYWORD_EXPANSION_LOCKER,
          com.intellij.CvsBundle.message("keyword.substitution.expansion.locker"));
  public static final KeywordSubstitutionWrapper NO_SUBSTITUTION =
      new KeywordSubstitutionWrapper(
          KeywordSubstitution.NO_SUBSTITUTION,
          com.intellij.CvsBundle.message("keyword.substitution.no.substitution"));
  public static final KeywordSubstitutionWrapper KEYWORD_REPLACEMENT =
      new KeywordSubstitutionWrapper(
          KeywordSubstitution.KEYWORD_REPLACEMENT,
          com.intellij.CvsBundle.message("keyword.substitution.replacement"));

  private KeywordSubstitutionWrapper(KeywordSubstitution keywordSubstitution, String displayName) {
    myKeywordSubstitution = keywordSubstitution;
    myDisplayName = displayName;
  }

  public KeywordSubstitution getSubstitution() {
    return myKeywordSubstitution;
  }

  public String toString() {
    return myDisplayName;
  }

  public static KeywordSubstitutionWrapper getValue(String substitution) {
    KeywordSubstitution keywordSubstitution = KeywordSubstitution.getValue(substitution);
    return getValue(keywordSubstitution);
  }

  public static KeywordSubstitutionWrapper getValue(KeywordSubstitution substitution) {
    if (substitution == KeywordSubstitution.BINARY) return KeywordSubstitutionWrapper.BINARY;
    if (substitution == KeywordSubstitution.KEYWORD_COMPRESSION)
      return KeywordSubstitutionWrapper.KEYWORD_COMPRESSION;
    if (substitution == KeywordSubstitution.KEYWORD_EXPANSION)
      return KeywordSubstitutionWrapper.KEYWORD_EXPANSION;
    if (substitution == KeywordSubstitution.KEYWORD_EXPANSION_LOCKER)
      return KeywordSubstitutionWrapper.KEYWORD_EXPANSION_LOCKER;
    if (substitution == KeywordSubstitution.NO_SUBSTITUTION)
      return KeywordSubstitutionWrapper.NO_SUBSTITUTION;
    if (substitution == KeywordSubstitution.KEYWORD_REPLACEMENT)
      return KeywordSubstitutionWrapper.KEYWORD_REPLACEMENT;
    return null;
  }

  public String getStringRepresentation() {
    if (myKeywordSubstitution == null) return null;
    return myKeywordSubstitution.toString();
  }
}
 public MyRemoveAction() {
   super(
       CvsBundle.message("action.name.remove"), null, IconLoader.getIcon("/general/remove.png"));
   registerCustomShortcutSet(CommonShortcuts.DELETE, myList);
 }
 public MyAddAction() {
   super(CvsBundle.message("action.name.add"), null, IconLoader.getIcon("/general/add.png"));
   registerCustomShortcutSet(CommonShortcuts.INSERT, myList);
 }
/** author: lesya, Bas Leijdekkers */
public class CustomizeKeywordSubstitutionDialog extends DialogWrapper {

  private static final DefaultCellEditor EDITOR =
      new DefaultCellEditor(new JComboBox(KeywordSubstitutionWrapper.values().toArray()));
  private static final DefaultTableCellRenderer RENDERER = new DefaultTableCellRenderer();
  private static final ColumnInfo KEYWORD_SUBSTITUTION =
      new ColumnInfo<FileExtension, KeywordSubstitutionWrapper>(
          CvsBundle.message("import.wizard.keyword.substitution.column.name")) {

        @Override
        public KeywordSubstitutionWrapper valueOf(FileExtension extension) {
          return extension.getKeywordSubstitution();
        }

        @Override
        public Comparator<FileExtension> getComparator() {
          return new Comparator<FileExtension>() {
            @Override
            public int compare(FileExtension extension1, FileExtension extension2) {
              final KeywordSubstitutionWrapper firstSubstitution =
                  extension1.getKeywordSubstitutionsWithSelection().getSelection();
              final KeywordSubstitutionWrapper secondSubstitution =
                  extension2.getKeywordSubstitutionsWithSelection().getSelection();
              return firstSubstitution.toString().compareTo(secondSubstitution.toString());
            }
          };
        }

        @Override
        public boolean isCellEditable(FileExtension extension) {
          return true;
        }

        @Override
        public void setValue(FileExtension extension, KeywordSubstitutionWrapper aValue) {
          extension.setKeywordSubstitution(aValue);
        }

        @Override
        public TableCellRenderer getRenderer(FileExtension extension) {
          return RENDERER;
        }

        @Override
        public TableCellEditor getEditor(FileExtension extension) {
          return EDITOR;
        }

        @Override
        public int getAdditionalWidth() {
          return 20;
        }

        @Override
        public String getMaxStringValue(JTable table) {
          return KeywordSubstitutionWrapper.KEYWORD_EXPANSION_LOCKER.toString();
        }
      };

  private static final ColumnInfo EXTENSION_COLUMN =
      new ColumnInfo<FileExtension, String>(
          CvsBundle.message("import.wizard.file.extension.column.name")) {
        @Override
        public String valueOf(FileExtension o) {
          return o.getExtension();
        }

        @Override
        public Comparator<FileExtension> getComparator() {
          return new Comparator<FileExtension>() {
            @Override
            public int compare(FileExtension extension1, FileExtension extension2) {
              return extension1.getExtension().compareTo(extension2.getExtension());
            }
          };
        }

        @Override
        public int getAdditionalWidth() {
          return 50;
        }

        @Override
        public String getMaxStringValue(JTable table) {
          return getName();
        }
      };

  private static final ColumnInfo[] COLUMNS =
      new ColumnInfo[] {EXTENSION_COLUMN, KEYWORD_SUBSTITUTION};

  private final ListTableModel<FileExtension> myModel;
  private final ImportConfiguration myImportConfiguration;

  public CustomizeKeywordSubstitutionDialog(
      Project project, String description, ImportConfiguration importConfiguration) {
    super(project);
    setTitle(description);
    myImportConfiguration = importConfiguration;
    myModel = new ListTableModel<FileExtension>(COLUMNS);
    myModel.setItems(collectFileTypes());
    init();
    pack();
  }

  private List<FileExtension> collectFileTypes() {
    final Collection<FileExtension> storedExtensions = myImportConfiguration.getExtensions();

    final ArrayList<FileExtension> result = new ArrayList<FileExtension>();
    result.addAll(storedExtensions);
    final FileType[] fileTypes = FileTypeManager.getInstance().getRegisteredFileTypes();
    for (FileType fileType : fileTypes) {
      final String[] extensions = FileTypeManager.getInstance().getAssociatedExtensions(fileType);
      for (String extension : extensions) {
        final FileExtension fileExtension = new FileExtension(extension);
        if (!result.contains(fileExtension)) result.add(fileExtension);
      }
    }
    return result;
  }

  @Override
  protected void doOKAction() {
    myImportConfiguration.setExtensions(myModel.getItems());
    super.doOKAction();
  }

  @Override
  protected JComponent createCenterPanel() {
    final TableView<FileExtension> table = new TableView<FileExtension>(myModel);
    final Dimension preferredSize = table.getPreferredSize();
    final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table);
    final Dimension scrollPaneSize = scrollPane.getPreferredSize();
    scrollPaneSize.width = preferredSize.width;
    scrollPane.setPreferredSize(scrollPaneSize);
    return scrollPane;
  }

  public List<FileExtension> getFileExtensions() {
    return myModel.getItems();
  }
}