Search in sources :

Example 1 with SeparatorLafInfo

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();
    }
}
Also used : SystemLafInfo(org.eclipse.wb.internal.swing.laf.model.SystemLafInfo) PluginLafInfo(org.eclipse.wb.internal.swing.laf.model.PluginLafInfo) AbstractCustomLafInfo(org.eclipse.wb.internal.swing.laf.model.AbstractCustomLafInfo) SeparatorLafInfo(org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo) UndefinedLafInfo(org.eclipse.wb.internal.swing.laf.model.UndefinedLafInfo) LafInfo(org.eclipse.wb.internal.swing.laf.model.LafInfo) CategoryInfo(org.eclipse.wb.internal.swing.laf.model.CategoryInfo) LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) PluginLafInfo(org.eclipse.wb.internal.swing.laf.model.PluginLafInfo) SeparatorLafInfo(org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 2 with SeparatorLafInfo

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());
            }
        }
    }
}
Also used : SystemLafInfo(org.eclipse.wb.internal.swing.laf.model.SystemLafInfo) SeparatorLafInfo(org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo) LafInfo(org.eclipse.wb.internal.swing.laf.model.LafInfo) UndefinedLafInfo(org.eclipse.wb.internal.swing.laf.model.UndefinedLafInfo) CategoryInfo(org.eclipse.wb.internal.swing.laf.model.CategoryInfo) SeparatorLafInfo(org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo)

Example 3 with SeparatorLafInfo

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();
}
Also used : SeparatorLafInfo(org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo) LafInfo(org.eclipse.wb.internal.swing.laf.model.LafInfo) SeparatorLafInfo(org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo)

Example 4 with SeparatorLafInfo

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;
}
Also used : SeparatorLafInfo(org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo) LafInfo(org.eclipse.wb.internal.swing.laf.model.LafInfo) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SeparatorLafInfo(org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo)

Example 5 with SeparatorLafInfo

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);
        }
    }
}
Also used : SeparatorLafInfo(org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo) LafInfo(org.eclipse.wb.internal.swing.laf.model.LafInfo) MenuItem(org.eclipse.swt.widgets.MenuItem) SeparatorLafInfo(org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo)

Aggregations

LafInfo (org.eclipse.wb.internal.swing.laf.model.LafInfo)5 SeparatorLafInfo (org.eclipse.wb.internal.swing.laf.model.SeparatorLafInfo)5 CategoryInfo (org.eclipse.wb.internal.swing.laf.model.CategoryInfo)2 SystemLafInfo (org.eclipse.wb.internal.swing.laf.model.SystemLafInfo)2 UndefinedLafInfo (org.eclipse.wb.internal.swing.laf.model.UndefinedLafInfo)2 LookAndFeelInfo (javax.swing.UIManager.LookAndFeelInfo)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1 AbstractCustomLafInfo (org.eclipse.wb.internal.swing.laf.model.AbstractCustomLafInfo)1 PluginLafInfo (org.eclipse.wb.internal.swing.laf.model.PluginLafInfo)1