public void init(Object context) {
   try {
     Resources theme = Resources.openLayered("/theme");
     UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0]));
     Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_SIDE_NAVIGATION);
     UIManager.getInstance().getLookAndFeel().setMenuBarClass(SideMenuBar.class);
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
예제 #2
0
 public void init(Object context) {
   try {
     Resources theme = Resources.openLayered("/theme");
     UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0]));
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
예제 #3
0
  public void init(Object context) {
    theme = UIManager.initFirstTheme("/theme");

    // Pro users - uncomment this code to get crash reports sent to you automatically
    /*Display.getInstance().addEdtErrorHandler(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            evt.consume();
            Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown"));
            Log.p("OS " + Display.getInstance().getPlatformName());
            Log.p("Error " + evt.getSource());
            Log.p("Current Form " + Display.getInstance().getCurrent().getName());
            Log.e((Throwable)evt.getSource());
            Log.sendLog();
        }
    });*/
  }
 /** @inheritDoc */
 public Component getCellRendererComponent(
     Component list, Object model, T value, int index, boolean isSelected) {
   if (!alwaysRenderSelection && !Display.getInstance().shouldRenderSelection(list)) {
     isSelected = false;
   }
   setFocus(isSelected);
   if (showNumbers) {
     String text = "" + value;
     Map<String, String> t = UIManager.getInstance().getBundle();
     if (t != null && value != null) {
       Object o = t.get(value.toString());
       if (o != null) {
         text = (String) o;
       }
     }
     if (isRTL()) {
       setText(text + " ." + (index + 1));
     } else {
       setText("" + (index + 1) + ". " + text);
     }
   } else {
     if (value != null) {
       String v = value.toString();
       setText(v);
       if (isRightAlignNumbers()) {
         char c = v.charAt(0);
         Style s = getStyle();
         if (c >= '0' && c <= '9') {
           s.setAlignment(RIGHT);
         } else {
           s.setAlignment(LEFT);
         }
       }
     } else {
       setText("null");
     }
   }
   if (value instanceof Command) {
     setIcon(((Command) value).getIcon());
     setEnabled(((Command) value).isEnabled());
   }
   return this;
 }
예제 #5
0
 public MonthView(long time) {
   super(new BoxLayout(BoxLayout.Y_AXIS));
   setUIID("MonthView");
   titles = new Container(new GridLayout(1, 7));
   days = new Container(new GridLayout(6, 7));
   addComponent(titles);
   addComponent(days);
   if (UIManager.getInstance().isThemeConstant("calTitleDayStyleBool", false)) {
     titles.setUIID("CalendarTitleArea");
     days.setUIID("CalendarDayArea");
   }
   for (int iter = 0; iter < DAYS.length; iter++) {
     titles.addComponent(createDayTitle(iter));
   }
   for (int iter = 0; iter < buttons.length; iter++) {
     buttons[iter] = createDay();
     days.addComponent(buttons[iter]);
     if (iter <= 7) {
       buttons[iter].setNextFocusUp(year);
     }
     buttons[iter].addActionListener(this);
   }
   setCurrentDay(time);
 }
예제 #6
0
  /**
   * Creates a new instance of Calendar set to the given date based on time since epoch (the
   * java.util.Date convention)
   *
   * @param time time since epoch
   * @param tmz a reference timezone
   */
  public Calendar(long time, TimeZone tmz) {
    super(new BorderLayout());
    this.tmz = tmz;
    setUIID("Calendar");
    mv = new MonthView(time);

    Image leftArrow = UIManager.getInstance().getThemeImageConstant("calendarLeftImage");
    if (leftArrow != null) {
      Image rightArrow = UIManager.getInstance().getThemeImageConstant("calendarRightImage");
      final Button left = new Button(leftArrow);
      final Button right = new Button(rightArrow);
      ActionListener progress =
          new ActionListener() {
            private boolean lock = false;

            public void actionPerformed(ActionEvent evt) {
              if (lock) {
                return;
              }
              lock = true;
              int month = mv.getMonth();
              int year = mv.getYear();
              if (evt.getSource() == left) {
                month--;
                if (month < java.util.Calendar.JANUARY) {
                  month = java.util.Calendar.DECEMBER;
                  year--;
                }
              } else {
                month++;
                if (month > java.util.Calendar.DECEMBER) {
                  month = java.util.Calendar.JANUARY;
                  year++;
                }
              }
              boolean tran = UIManager.getInstance().isThemeConstant("calTransitionBool", true);
              if (tran) {
                Transition cm;
                if (UIManager.getInstance().isThemeConstant("calTransitionVertBool", false)) {
                  cm =
                      CommonTransitions.createSlide(
                          CommonTransitions.SLIDE_VERTICAL, evt.getSource() == left, 300);
                } else {
                  cm =
                      CommonTransitions.createSlide(
                          CommonTransitions.SLIDE_HORIZONTAL, evt.getSource() == left, 300);
                }
                MonthView newMv = new MonthView(mv.currentDay);
                newMv.setMonth(year, month);
                replaceAndWait(mv, newMv, cm);
                mv = newMv;
                newMv.fireActionEvent();
              } else {
                mv.setMonth(year, month);
                componentChanged();
              }
              dateLabel.setText(getLocalizedMonth(month) + " " + year);
              lock = false;
            }
          };
      left.addActionListener(progress);
      right.addActionListener(progress);
      left.setUIID("CalendarLeft");
      right.setUIID("CalendarRight");

      Container dateCnt = new Container(new BorderLayout());
      dateCnt.setUIID("CalendarDate");
      dateLabel = new Label();
      dateLabel.setUIID("CalendarDateLabel");
      dateLabel.setText(getLocalizedMonth(mv.getMonth()) + " " + mv.getYear());

      dateCnt.addComponent(BorderLayout.CENTER, dateLabel);
      dateCnt.addComponent(BorderLayout.EAST, right);
      dateCnt.addComponent(BorderLayout.WEST, left);

      addComponent(BorderLayout.NORTH, dateCnt);
    } else {
      month = new ComboBox();
      year = new ComboBox();
      Vector months = new Vector();
      for (int i = 0; i < MONTHS.length; i++) {
        months.addElement("" + getLocalizedMonth(i));
      }
      ListModel monthsModel = new DefaultListModel(months);
      int selected = months.indexOf(getLocalizedMonth(mv.getMonth()));
      month.setModel(monthsModel);
      month.setSelectedIndex(selected);
      month.addActionListener(mv);

      java.util.Calendar cal = java.util.Calendar.getInstance(tmz);
      cal.setTime(new java.util.Date(time));
      month.getStyle().setBgTransparency(0);
      int y = cal.get(java.util.Calendar.YEAR);
      Vector years = new Vector();
      for (int i = 2100; i >= 1900; i--) {
        years.addElement("" + i);
      }
      ListModel yearModel = new DefaultListModel(years);
      selected = years.indexOf("" + y);
      year.setModel(yearModel);
      year.setSelectedIndex(selected);
      year.getStyle().setBgTransparency(0);
      year.addActionListener(mv);
      Container cnt = new Container(new BoxLayout(BoxLayout.X_AXIS));
      cnt.setRTL(false);

      Container dateCnt = new Container(new BoxLayout(BoxLayout.X_AXIS));
      dateCnt.setUIID("CalendarDate");
      dateCnt.addComponent(month);
      dateCnt.addComponent(year);
      cnt.addComponent(dateCnt);

      Container upper = new Container(new FlowLayout(Component.CENTER));
      upper.addComponent(cnt);

      addComponent(BorderLayout.NORTH, upper);
    }
    addComponent(BorderLayout.CENTER, mv);
  }
 /** @inheritDoc */
 protected void initLaf(UIManager uim) {
   super.initLaf(uim);
   if (!showNumbersForce) {
     showNumbers = uim.isThemeConstant("rendererShowsNumbersBool", showNumbersDefault);
   }
 }
예제 #8
0
 protected void initTheme(Resources res) {
   String[] themes = res.getThemeResourceNames();
   if (themes != null && themes.length > 0) {
     UIManager.getInstance().setThemeProps(res.getTheme(themes[0]));
   }
 }