Package org.eclipse.nebula.widgets.nattable.examples

Examples of org.eclipse.nebula.widgets.nattable.examples.INatExample


        return null;
    }

    public static INatExample getExample(String examplePath) {
        INatExample example = examplePathMap.get(examplePath);
        if (example == null) {
            String path = examplePath;
            if (examplePath.startsWith("/"
                    + INatExample.TUTORIAL_EXAMPLES_PREFIX)) {
                path = examplePath.replace("/"
View Full Code Here


        }
        return example;
    }

    private static void openExampleInTab(final String examplePath) {
        final INatExample example = getExample(examplePath);
        if (example == null) {
            return;
        }

        final String exampleName = example.getName();
        final CTabItem tabItem = new CTabItem(tabFolder, SWT.CLOSE);
        tabItem.setText(exampleName);
        tabItem.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                // Stop
                example.onStop();

                Control exampleControl = exampleControlMap.get(example);
                if (exampleControl != null && !exampleControl.isDisposed()) {
                    exampleControl.dispose();
                }

                exampleControlMap.remove(example);
                examplePathMap.remove(examplePath);
                link.dispose();
            }
        });

        final Composite tabComposite = new Composite(tabFolder, SWT.NONE);
        tabComposite.setLayout(new GridLayout(1, false));

        // Create example control
        final Control exampleControl = example
                .createExampleControl(tabComposite);
        exampleControl.setLayoutData(new GridData(GridData.FILL_BOTH));
        exampleControlMap.put(example, exampleControl);

        // Description
        final String description = example.getDescription();
        if (description != null && description.length() > 0) {
            final Group descriptionGroup = new Group(tabComposite, SWT.NONE);
            descriptionGroup.setText("Description");
            descriptionGroup.setLayoutData(new GridData(
                    GridData.FILL_HORIZONTAL));
            descriptionGroup.setLayout(new FillLayout());

            final Label descriptionLabel = new Label(descriptionGroup, SWT.WRAP);
            descriptionLabel.setText(description);
        }

        link = new Link(tabComposite, SWT.NONE);
        link.setText("<a href=\"" + examplePath + "\">View source</a>");

        final SelectionAdapter linkSelectionListener = new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent event) {
                String path = event.text;
                if (path.startsWith("/" + INatExample.TUTORIAL_EXAMPLES_PREFIX)) {
                    path = path.replace("/"
                            + INatExample.TUTORIAL_EXAMPLES_PREFIX,
                            INatExample.BASE_PATH + "/");
                } else if (path.startsWith("/"
                        + INatExample.CLASSIC_EXAMPLES_PREFIX)) {
                    path = path.replace("/"
                            + INatExample.CLASSIC_EXAMPLES_PREFIX,
                            INatExample.CLASSIC_BASE_PATH + "/");
                }
                String source = getResourceAsString(path + ".java");
                if (source != null) {
                    viewSource(exampleName, source);
                }
            }
        };
        link.addSelectionListener(linkSelectionListener);

        tabItem.setControl(tabComposite);

        // Start
        example.onStart();

        tabFolder.setSelection(tabItem);
    }
View Full Code Here

    @Override
    public String getText(Object element) {
        String str = (String) element;
        if (!contentProvider.hasChildren(element)) {
            INatExample example = TabbedNatExampleRunner.getExample(str);
            return example.getName();
        }

        int lastSlashIndex = str.lastIndexOf('/');
        if (lastSlashIndex < 0) {
            return format(str);
View Full Code Here

TOP

Related Classes of org.eclipse.nebula.widgets.nattable.examples.INatExample

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.