use of org.eclipse.wb.internal.swing.laf.model.AbstractCustomLafInfo in project windowbuilder by eclipse.
the class LafSupport method selectLAF.
/**
* Selects the LAF. Stores selected LAF into both persistence's and applies in main() method if
* needed.
*/
public static void selectLAF(JavaInfo javaInfo, LafInfo lafInfo) throws Exception {
Assert.isNotNull(lafInfo);
// ensure LAF list created
createLAFList();
Assert.isLegal(lookupLAFByID(lafInfo.getID()) == lafInfo);
// store selected LAF
setLAFArbitraryID(javaInfo, lafInfo.getID());
setLAFPersistentID(javaInfo, lafInfo.getID());
if (getPreferenceStore().getBoolean(IPreferenceConstants.P_APPLY_IN_MAIN)) {
IJavaProject javaProject = javaInfo.getEditor().getJavaProject();
if (lafInfo instanceof AbstractCustomLafInfo && !ProjectUtils.hasType(javaProject, lafInfo.getClassName())) {
// add LAF jar into project classpath
ProjectUtils.addJar(javaProject, ((AbstractCustomLafInfo) lafInfo).getJarFile(), null);
}
lafInfo.applyInMain(javaInfo.getEditor());
}
// maintain MRU list
lafInfo.increaseUsageCount();
if (m_mruLAFList.contains(lafInfo)) {
// remove to exclude duplicates
m_mruLAFList.remove(lafInfo);
}
m_mruLAFList.add(lafInfo);
// keep 5 items, but show only 3 with greatest usage count
if (m_mruLAFList.size() > 5) {
m_mruLAFList.remove(0);
}
}
Aggregations