Search in sources :

Example 1 with OrchidResourceSource

use of com.eden.orchid.api.resources.resourceSource.OrchidResourceSource in project Orchid by JavaEden.

the class OrchidContextImpl method reorderThemes.

private void reorderThemes() {
    Class<?> superclass = getTheme().getClass();
    int i = 0;
    // find the highest priority of any Theme
    int highestThemePriority = 0;
    for (OrchidResourceSource resourceSourceEntry : OrchidUtils.resolveSet(this, OrchidResourceSource.class)) {
        if (resourceSourceEntry instanceof Theme) {
            highestThemePriority = Math.max(highestThemePriority, resourceSourceEntry.getPriority());
        }
    }
    // Go through all Themes and set each parent theme as the next-highest Theme priority
    while (!superclass.equals(Theme.class)) {
        for (OrchidResourceSource resourceSourceEntry : OrchidUtils.resolveSet(this, OrchidResourceSource.class)) {
            if (resourceSourceEntry instanceof Theme) {
                Theme theme = (Theme) resourceSourceEntry;
                if (theme.getClass().equals(superclass)) {
                    theme.setPriority((highestThemePriority) - i);
                    break;
                }
            }
        }
        i++;
        superclass = superclass.getSuperclass();
    }
}
Also used : Theme(com.eden.orchid.api.theme.Theme) OrchidResourceSource(com.eden.orchid.api.resources.resourceSource.OrchidResourceSource)

Example 2 with OrchidResourceSource

use of com.eden.orchid.api.resources.resourceSource.OrchidResourceSource in project Orchid by JavaEden.

the class OrchidContextImpl method reorderResourceSources.

private void reorderResourceSources() {
    Theme theme = getTheme();
    reorderThemes();
    for (OrchidResourceSource source : OrchidUtils.resolveSet(this, DefaultResourceSource.class)) {
        if (source instanceof Theme) {
            if (!source.getClass().isAssignableFrom(theme.getClass())) {
                source.setPriority(-1);
            }
        }
    }
}
Also used : Theme(com.eden.orchid.api.theme.Theme) OrchidResourceSource(com.eden.orchid.api.resources.resourceSource.OrchidResourceSource)

Example 3 with OrchidResourceSource

use of com.eden.orchid.api.resources.resourceSource.OrchidResourceSource in project Orchid by JavaEden.

the class ListResourceSourcesTask method run.

@Override
public void run() {
    Clog.logger(OrchidTasks.loggerKey, "" + "#{ $0 | fg('cyan') }[Priority]#{$0 |reset}" + "#{ $0 | fg('magenta') }[Source]#{$0 |reset}" + "");
    Clog.logger(OrchidTasks.loggerKey, "------------------------------------------------------------------------------------");
    Clog.logger(OrchidTasks.loggerKey, "------------------------------------------------------------------------------------");
    for (OrchidResourceSource source : new ObservableTreeSet<>(sources)) {
        String message;
        if (source.getPriority() < 0) {
            message = "#{ $0 | fg('red') }[#{$1}][#{$2}]";
            message += "(inactive)#{$0 |reset}";
        } else {
            message = "#{ $0 | fg('cyan') }[#{$1}]#{$0 |reset}";
            message += "#{ $0 | fg('magenta') }[#{$2}]#{$0 |reset}";
        }
        Clog.logger(OrchidTasks.loggerKey, message, new Object[] { source.getPriority(), source.getClass().getName() });
    }
}
Also used : ObservableTreeSet(com.eden.orchid.utilities.ObservableTreeSet) OrchidResourceSource(com.eden.orchid.api.resources.resourceSource.OrchidResourceSource)

Aggregations

OrchidResourceSource (com.eden.orchid.api.resources.resourceSource.OrchidResourceSource)3 Theme (com.eden.orchid.api.theme.Theme)2 ObservableTreeSet (com.eden.orchid.utilities.ObservableTreeSet)1