use of org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo in project windowbuilder by eclipse.
the class LafSupport method createLAFList.
/**
* Enumerates all available {@link LafInfo} and stores it into <code>m_lafList</code>.
*/
private static void createLAFList() {
if (m_lafList == null) {
m_lafList = Lists.newArrayList();
CategoryInfo rootCategory = new CategoryInfo(ROOT_ID, "<root>");
m_lafList.add(rootCategory);
// add "undefined" and "current system"
rootCategory.add(SystemLafInfo.INSTANCE);
rootCategory.add(UndefinedLafInfo.INSTANCE);
rootCategory.add(new SeparatorLafInfo());
// enumerate system LAFs
CategoryInfo jdkCategory = new CategoryInfo("JRE", "JRE");
m_lafList.add(jdkCategory);
LookAndFeelInfo[] systemLAFs = UIManager.getInstalledLookAndFeels();
for (int i = 0; i < systemLAFs.length; i++) {
LookAndFeelInfo laf = systemLAFs[i];
jdkCategory.add(new LafInfo(laf.getName(), laf.getName(), laf.getClassName()));
}
// add LAFs using plugin API
List<IConfigurationElement> categoryElements = ExternalFactoriesHelper.getElements(EXTERNAL_LAF_POINT, "category");
for (IConfigurationElement categoryElement : categoryElements) {
CategoryInfo category;
if (ROOT_ID.equals(ExternalFactoriesHelper.getRequiredAttribute(categoryElement, "id"))) {
category = rootCategory;
} else {
category = new CategoryInfo(categoryElement);
m_lafList.add(category);
}
for (IConfigurationElement lafElement : categoryElement.getChildren("LookAndFeel")) {
if (isConditionTrue(lafElement)) {
category.add(new PluginLafInfo(lafElement));
}
}
}
// apply commands
commands_apply();
}
}
use of org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo in project windowbuilder by eclipse.
the class LookAndFeelTest method test_getLAFList.
/**
* Test fetching LAF list.
*/
public void test_getLAFList() throws Exception {
List<CategoryInfo> categoryList = LafSupport.getLAFCategoriesList();
assertNotNull(categoryList);
assertFalse(categoryList.isEmpty());
// check LAF classes
for (CategoryInfo categoryInfo : categoryList) {
List<LafInfo> lafList = categoryInfo.getLAFList();
for (LafInfo lafInfo : lafList) {
if (!(lafInfo instanceof SeparatorLafInfo)) {
assertNotNull(lafInfo.getLookAndFeelInstance());
}
}
}
}
use of org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo in project windowbuilder by eclipse.
the class LafPreferencePage method handleSetDefaultLAF.
/**
* Called by pressing "default" button or double-clicking in LAF list. Marks selected LAF as
* default.
*/
private void handleSetDefaultLAF() {
final LafInfo selectedLAF = getSelectedLAF();
if (selectedLAF == null || selectedLAF instanceof SeparatorLafInfo) {
return;
}
m_defaultLAF = selectedLAF;
refreshViewer();
}
use of org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo in project windowbuilder by eclipse.
the class LafPreferencePage method getSelectedLAF.
// //////////////////////////////////////////////////////////////////////////
//
// Utils/Misc
//
// //////////////////////////////////////////////////////////////////////////
/**
* @return the currently selected {@link LafInfo} from LAF table or <code>null</code> if nothing
* or separator selected.
*/
private LafInfo getSelectedLAF() {
IStructuredSelection selection = (IStructuredSelection) m_lafTree.getSelection();
if (selection == null) {
return null;
}
Object firstElement = selection.getFirstElement();
return firstElement instanceof LafInfo && !(firstElement instanceof SeparatorLafInfo) ? (LafInfo) firstElement : null;
}
use of org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo in project windowbuilder by eclipse.
the class LafSelectionItem method createLAFMenuItem.
/**
* Traverses via LAF items in given <code>category</code> and add menu item into given parent
* <code>menu</code>.
*/
private void createLAFMenuItem(Menu parentMenu, CategoryInfo category) {
boolean skippedFirstSeparator = false;
for (final LafInfo lafInfo : category.getLAFList()) {
if (lafInfo.isVisible()) {
// check for separator
if (lafInfo instanceof SeparatorLafInfo) {
if (skippedFirstSeparator) {
new MenuItem(parentMenu, SWT.SEPARATOR);
}
continue;
}
skippedFirstSeparator = true;
createLAFMenuItem(parentMenu, lafInfo);
}
}
}
Aggregations