Ejemplo n.º 1
0
  /* (non-Javadoc)
   * @see java.text.Format#format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)
   */
  public StringBuffer format(Object durationObject, StringBuffer toAppendTo, FieldPosition pos) {
    long duration = ((Duration) durationObject).getEncodedMillis();
    if (((Duration) durationObject).isWork()
        && Duration.getType(duration) != TimeUnit.NON_TEMPORAL) {
      duration = Duration.setAsTimeUnit(duration, ScheduleOption.getInstance().getWorkUnit());
    }

    double value = Duration.getValue(duration);
    int type = Duration.getEffectiveType(duration);
    if (value > 0D && showPlusSign) toAppendTo.append("+");
    boolean isPercent = Duration.isPercent(duration);
    if (isPercent) value *= 100.0;
    DECIMAL_FORMAT.format(value, toAppendTo, pos);

    String unit =
        formatTypeUnit(
            type,
            (Math.abs(value) == 1.0),
            EditOption.getInstance().isAddSpaceBeforeLabel(),
            Duration.isPercent(duration),
            Duration.isEstimated(duration),
            EditOption.getInstance().getViewAs(type));
    toAppendTo.append(unit);
    return toAppendTo;
  }
Ejemplo n.º 2
0
 public static String formatTypeUnit(int type) {
   DurationFormat.getInstance(); // make sure it is initialized
   return formatTypeUnit(
       type, true, false, false, false, EditOption.getInstance().getViewAs(type));
 }
Ejemplo n.º 3
0
  public static void clear(boolean graphic) {
    ProjectFactory.getInstance()
        .setPromptDisabled(true); // prevent remove projects job from prompting to save
    Job job =
        ProjectFactory.getInstance().getPortfolio().getRemoveAllProjectsJob(null, false, null);
    SessionFactory.getInstance().getLocalSession().schedule(job);
    try {
      job.waitResult();
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    if (graphic) {
      GraphicManager gm = GraphicManager.getInstance();
      if (gm != null) ((DefaultFrameManager) gm.getFrameManager()).cleanUp(false);
    }
    ProjectFactory.getInstance().getPortfolio().getObjectEventManager().removeAll();
    ProjectFactory.getInstance().setPromptDisabled(false); // enable prompting again

    // Singletons, most of them can cause problems when it re-used.
    // Other singletons shouldn't be problem but have a cleanUp method just in case
    SessionFactory.cleanUp();
    ProjectFactory.cleanUp();
    ResourcePoolFactory.cleanUp();
    UniqueIdPool.cleanUp();
    MainFrame.cleanUp();
    GraphicManager.cleanUpStatic();
    StartupFactory.cleanUpStatic();

    CalendarCatalog.cleanUp();
    CalendarDefinition.cleanUp();
    CalendarService.cleanUp();
    WorkingCalendar.cleanUp();

    AdvancedOption.cleanUp();
    CalculationOption.cleanUp();
    CalendarOption.cleanUp();
    EditOption.cleanUp();
    GanttOption.cleanUp();
    GeneralOption.cleanUp();
    ScheduleOption.cleanUp();
    TimesheetOption.cleanUp();

    FieldConverter.cleanUp();

    ActionLists.cleanUp();
    CellStyles.cleanUp();
    Configuration.cleanUp();
    Dictionary.cleanUp();

    Factory.cleanUp();
    ImportedCalendarService.cleanUp(); // remove dep
    NotAssignmentFilter.cleanUp();
    NotVoidFilter.cleanUp();
    HelpUtil.cleanUp();
    ZeroFunctor.cleanUp();
    NameCellComponent.cleanUp();
    ScheduleService.cleanUp();
    PageSizes.cleanUp();
    ContextStore.cleanUp();
    CustomFieldsMapper.cleanUp(); // remove dep
  }