org.jdesktop.swingx.tips.TipOfTheDayModel Java Examples

The following examples show how to use org.jdesktop.swingx.tips.TipOfTheDayModel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TipOfTheDay.java    From otroslogviewer with Apache License 2.0 6 votes vote down vote up
public void showTipOfTheDayIfNotDisabled(Component parent) {
  Properties p = new Properties();
  try {
    p.load(this.getClass().getClassLoader().getResourceAsStream("tipoftheday.properties"));
    TipOfTheDayModel model = new RandomTipOfTheDayModel(TipLoader.load(p));
    JXTipOfTheDay jxTipOfTheDay = new JXTipOfTheDay(model);
    jxTipOfTheDay.showDialog(parent, new ShowOnStartupChoice() {

      @Override
      public void setShowingOnStartup(boolean arg0) {
        dataConfiguration.setProperty(GUI_SHOW_TIP_OF_THE_DAY, arg0);
      }

      @Override
      public boolean isShowingOnStartup() {
        return dataConfiguration.getBoolean(GUI_SHOW_TIP_OF_THE_DAY, true);
      }
    });
  } catch (IOException e) {
    LOGGER.warn("Can't load tip of the day: " + e.getMessage());
  }
}
 
Example #2
Source File: TipsOfTheDayDialog.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
public TipsOfTheDayDialog() throws IOException {
	Properties tips = new Properties();
	tips.load(MTGConstants.TOOLTIPS_FILE.openStream());
	TipOfTheDayModel model = TipLoader.load(tips);
	setModel(model);

}
 
Example #3
Source File: RandomTipOfTheDayModel.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
public RandomTipOfTheDayModel(TipOfTheDayModel model) {
  super();
  this.model = model;
  randomMapping = new ArrayList<>();
  for (int i = 0; i < model.getTipCount(); i++) {
    randomMapping.add(Integer.valueOf(i));
  }
  Collections.shuffle(randomMapping);
}
 
Example #4
Source File: RandomTipOfTheDayModelTest.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
@BeforeMethod
public void prepare() {
  ArrayList<Tip> tips = new ArrayList<>();
  for (int i = 0; i < TIPS_SIZE; i++) {
    tips.add(new DefaultTip(Integer.toString(i), Integer.toString(i)));

  }
  TipOfTheDayModel model = new DefaultTipOfTheDayModel(tips);
  tipsModel = new RandomTipOfTheDayModel(model);
}
 
Example #5
Source File: JXTipOfTheDay.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
public void setModel(TipOfTheDayModel model) {
  if (model == null) {
    throw new IllegalArgumentException("model can not be null");
  }
  TipOfTheDayModel old = this.model;
  this.model = model;
  firePropertyChange("model", old, model);
}
 
Example #6
Source File: TipsOfTheDay.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
private static TipOfTheDayModel loadModel() throws IOException {
    var properties = new Properties();
    TipOfTheDayModel model;
    try (var propertiesInputStream = TipsOfTheDay.class.getResourceAsStream("/tips.properties")) {
        properties.load(propertiesInputStream);
        model = TipLoader.load(properties);
    }
    return model;
}
 
Example #7
Source File: TipOfTheDay.java    From orbit-image-analysis with GNU General Public License v3.0 4 votes vote down vote up
private TipOfTheDayModel loadModel() throws Exception {
    Properties properties = new Properties();
    InputStream propertiesIn = OrbitUtils.DARKUI ? OrbitImageAnalysis.class.getResourceAsStream("/resource/tips.properties") : OrbitImageAnalysis.class.getResourceAsStream("/resource/tipsold.properties");
    properties.load(propertiesIn);
    return TipLoader.load(properties);
}
 
Example #8
Source File: JXTipOfTheDay.java    From Pixelitor with GNU General Public License v3.0 4 votes vote down vote up
public TipOfTheDayModel getModel() {
  return model;
}
 
Example #9
Source File: JXTipOfTheDay.java    From Pixelitor with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Constructs a new <code>JXTipOfTheDay</code> showing tips from the given
 * TipOfTheDayModel.
 *
 * @param model
 */
public JXTipOfTheDay(TipOfTheDayModel model) {
  this.model = model;
  updateUI();
}