Skip to content

Publish Scenebuilder App as well #842

@Maran23

Description

@Maran23

In my projects, I, at one point started to clone the Scenebuilder in order to build on top of it.
I did that because this way, I can add all my custom components to it (into the Library) and commit that.
All other developers have access to it, and there is no further maintenance / installation needed for all of us (beside updating).

You can start the Scenebuilder in your IDE, and all your custom components are in there directly. The startup is also very fast, even with many components. Adding new components is very easy as well.

If the Scenebuilder App is published as well into the Maven Repository, it can be added as dependency and therefore used and updated much easier.

Example how I add the components before launch:

import java.util.ArrayList;
import java.util.List;

import com.oracle.javafx.scenebuilder.app.SceneBuilderApp;
import com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument;
import com.oracle.javafx.scenebuilder.kit.fxom.FXOMInstance;
import com.oracle.javafx.scenebuilder.kit.library.BuiltinLibrary;
import com.oracle.javafx.scenebuilder.kit.library.LibraryItem;
.....

public class CustomScenebuilder extends SceneBuilderApp {

    private static final String CUSTOM = "Custom";
    private static final String CONTROLS_FX = "ControlsFX";

    public CustomScenebuilder() {}

    @Override
    public void handleLaunch(List<String> files) {
        prepareLibrary();
        super.handleLaunch(files);
    }

    private static LibraryItem createCustomLibraryItem(Class<?> clazz, String group) {
        return new CustomLibraryItem(clazz, group);
    }

    private void prepareLibrary() {
        List<LibraryItem> customLibraryItems = createCustomLibraryItems();
        BuiltinLibrary.getLibrary().getItems().addAll(customLibraryItems);
    }

    private List<LibraryItem> createCustomLibraryItems() {
        List<LibraryItem> customLibraryItems = new ArrayList<>();

        customLibraryItems.add(createCustomLibraryItem(LimitedTextField.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(LimitedTextArea.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(LinkTextarea.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomAutoCompleteComboBox.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomTableView.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomComboBox.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomCheckComboBox.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomAutoCompleteCheckComboBox.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomSelectionView.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomTreeTableView.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomTreeTableColumn.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomTableColumn.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(StandardTable.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomListView.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(SortableCustomListView.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(StandardForm.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomNavigatableCombobox.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomMasterDetailView.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomTinyClock.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomWizard.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomAutoCompleteTextField.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(CustomToggleSwitch.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(ImageViewEditDelete.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(FormattedBigDecimalTextField.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(StrategyCheckComboBox.class, CUSTOM));
        customLibraryItems.add(createCustomLibraryItem(FilterableListSelectionView.class, CUSTOM));

        customLibraryItems.add(createCustomLibraryItem(BreadCrumbBar.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(CheckComboBox.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(CheckListView.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(GridView.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(HiddenSidesPane.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(HyperlinkLabel.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(MasterDetailPane.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(NotificationPane.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(PlusMinusSlider.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(PropertySheet.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(RangeSlider.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(Rating.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(SegmentedButton.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(SnapshotView.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(CustomPasswordField.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(CustomTextField.class, CONTROLS_FX));
        customLibraryItems.add(createCustomLibraryItem(ListSelectionView.class, CONTROLS_FX));
        return customLibraryItems;
    }

    private static class CustomLibraryItem extends LibraryItem {

        private final Class<?> clazz;

        CustomLibraryItem(Class<?> clazz, String group) {
            super(clazz.getSimpleName(), group, "", null, SceneBuilderApp.getSingleton().getUserLibrary());
            this.clazz = clazz;
        }

        @Override
        public FXOMDocument instantiate() {
            FXOMDocument document = new FXOMDocument();
            FXOMInstance instance = new FXOMInstance(document, clazz);
            document.setFxomRoot(instance);
            document.setSampleDataEnabled(true);
            return document;
        }
    }
}

This can be easily launched with Application.launch(..).

If there are outstanding things to do first, let me know, I will try to help where I can!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions