static void replace(
     GregorianCalendarManager manager,
     String oldName,
     String newName,
     IGregorianCalendarProvider newObj,
     ItemWsNode node) {
   manager.remove(oldName);
   manager.set(newName, newObj);
   node.getWorkspace().remove(node.getItem());
   node.getWorkspace().add(CalendarDocumentManager.systemItem(newName, newObj));
 }
  @Messages({"editChainedCalendar.dialog.title=Edit Chained Gregorian Calendar"})
  static void editChainedCalendar(
      GregorianCalendarManager manager, ChainedGregorianCalendarProvider p, ItemWsNode node) {
    String oldName = manager.get(p);

    ChainedGregorianCalendarPanel panel = new ChainedGregorianCalendarPanel();
    panel.setCalendarName(oldName);
    panel.setFirstCalendar(p.first);
    panel.setSecondCalendar(p.second);
    panel.setDayBreak(p.breakDay);

    DialogDescriptor dd = panel.createDialogDescriptor(Bundle.editChainedCalendar_dialog_title());
    if (DialogDisplayer.getDefault().notify(dd) == NotifyDescriptor.OK_OPTION) {
      String name = panel.getCalendarName();
      String first = panel.getFirstCalendar();
      String second = panel.getSecondCalendar();
      Day dayBreak = panel.getDayBreak();
      replace(
          manager,
          oldName,
          name,
          new ChainedGregorianCalendarProvider(first, dayBreak, second),
          node);
    }
  }
  @Messages({"editCompositeCalendar.dialog.title=Edit Composite Gregorian Calendar"})
  static void editCompositeCalendar(
      GregorianCalendarManager manager, CompositeGregorianCalendarProvider p, ItemWsNode node) {
    String oldName = manager.get(p);

    CompositeGregorianCalendarPanel panel = new CompositeGregorianCalendarPanel(oldName);
    panel.setWeightedItems(ImmutableList.copyOf(p.items()));

    DialogDescriptor dd = panel.createDialogDescriptor(Bundle.editCompositeCalendar_dialog_title());
    if (DialogDisplayer.getDefault().notify(dd) == NotifyDescriptor.OK_OPTION) {
      String name = panel.getCalendarName();
      CompositeGregorianCalendarProvider newObj = new CompositeGregorianCalendarProvider();
      newObj.add(panel.getWeightedItems());
      replace(manager, oldName, name, newObj, node);
    }
  }
  @Messages({"editNationalCalendar.dialog.title=Edit National Calendar"})
  static void editNationalCalendar(
      GregorianCalendarManager manager, NationalCalendarProvider p, ItemWsNode node) {
    String oldName = manager.get(p);

    NationalCalendarPanel panel = new NationalCalendarPanel();
    panel.setCalendarName(oldName);
    panel.setMeanCorrection(p.isLongTermMeanCorrection());
    panel.setJulianEaster(p.isJulianEaster());
    panel.setSpecialDayEvents(ImmutableList.copyOf(p.events()));

    DialogDescriptor dd = panel.createDialogDescriptor(Bundle.editNationalCalendar_dialog_title());
    if (DialogDisplayer.getDefault().notify(dd) == NotifyDescriptor.OK_OPTION) {
      String name = panel.getCalendarName();
      boolean mean = panel.isMeanCorrection();
      boolean julian = panel.isJulianCalendar();
      Collection<SpecialDayEvent> events = panel.getSpecialDayEvents();
      NationalCalendarProvider np = new NationalCalendarProvider(events, mean, julian);
      replace(manager, oldName, name, np, node);
    }
  }