Search in sources :

Example 6 with StackLayout

use of org.eclipse.swt.custom.StackLayout in project bndtools by bndtools.

the class WorkspaceMainPart method initialize.

@Override
public void initialize(final IManagedForm form) {
    super.initialize(form);
    final Composite container = (Composite) getSection().getClient();
    // create a layout stack and the first visible component will be an empty component with "waiting" message
    // this will be replaced by real composite once workspace completes
    final StackLayout stackLayout = new StackLayout();
    container.setLayout(stackLayout);
    Composite labelParent = new Composite(container, SWT.NONE);
    FillLayout fillLayout = new FillLayout();
    fillLayout.marginHeight = fillLayout.marginWidth = 10;
    labelParent.setLayout(fillLayout);
    if (!Central.isWorkspaceInited()) {
        Label label = new Label(labelParent, SWT.NONE);
        label.setText("Workspace is loading, please wait...");
        label.setBackground(container.getBackground());
        label.setForeground(container.getForeground());
    }
    stackLayout.topControl = labelParent;
    container.layout();
    Central.onWorkspaceInit(new Success<Workspace, Void>() {

        @Override
        public Promise<Void> call(Promise<Workspace> resolved) throws Exception {
            final Deferred<Void> completion = new Deferred<>();
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    try {
                        IFile buildFile = Central.getWorkspaceBuildFile();
                        if (buildFile == null)
                            return;
                        Composite contents = new Composite(container, SWT.NONE);
                        if (!mainFile) {
                            ImageHyperlink link = form.getToolkit().createImageHyperlink(contents, SWT.CENTER);
                            link.setText("Open main build.bnd file.");
                            link.setImage(bndFileImg);
                            link.addHyperlinkListener(new FileOpenLinkListener(buildFile.getFullPath()));
                        } else {
                            IResource[] extFiles;
                            IContainer cnfDir = buildFile.getParent();
                            IFolder extDir = cnfDir.getFolder(new Path("ext"));
                            if (extDir.exists())
                                extFiles = extDir.members();
                            else
                                extFiles = new IResource[0];
                            if (extFiles.length > 0) {
                                for (IResource extFile : extFiles) {
                                    if (extFile.getType() == IResource.FILE && "bnd".equalsIgnoreCase(extFile.getFileExtension())) {
                                        ImageHyperlink link = form.getToolkit().createImageHyperlink(contents, SWT.CENTER);
                                        link.setText("Open " + extFile.getName());
                                        link.setImage(extFileImg);
                                        link.addHyperlinkListener(new FileOpenLinkListener(extFile.getFullPath()));
                                    }
                                }
                            } else {
                                createMissingExtsWarningPanel(contents, form.getToolkit(), extDir.getFullPath());
                            }
                        }
                        stackLayout.topControl = contents;
                        container.layout();
                        completion.resolve(null);
                    } catch (Exception e) {
                        Plugin.error(Collections.singletonList(e.getMessage()));
                        completion.fail(e);
                    }
                }
            });
            return completion.getPromise();
        }
    });
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) Deferred(org.osgi.util.promise.Deferred) Label(org.eclipse.swt.widgets.Label) FillLayout(org.eclipse.swt.layout.FillLayout) PartInitException(org.eclipse.ui.PartInitException) Promise(org.osgi.util.promise.Promise) StackLayout(org.eclipse.swt.custom.StackLayout) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) Workspace(aQute.bnd.build.Workspace) IFolder(org.eclipse.core.resources.IFolder)

Example 7 with StackLayout

use of org.eclipse.swt.custom.StackLayout in project bndtools by bndtools.

the class JPMBrowserView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    StackLayout stack = new StackLayout();
    parent.setLayout(stack);
    JpmPreferences prefs = new JpmPreferences();
    if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_EXTERNAL) {
        external = true;
        Composite composite = new Composite(parent, SWT.NONE);
        composite.setLayout(new GridLayout(2, false));
        new Label(composite, SWT.NONE).setText("JPM is configured to open in an external browser.");
        Hyperlink linkToPrefs = new Hyperlink(composite, SWT.NONE);
        linkToPrefs.setText("Open Preference Page");
        linkToPrefs.setUnderlined(true);
        linkToPrefs.addHyperlinkListener(new HyperlinkAdapter() {

            @Override
            public void linkActivated(HyperlinkEvent e) {
                PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getViewSite().getShell(), "bndtools.prefPages.jpm", new String[] { "bndtools.prefPages.jpm" }, null);
                dialog.open();
            }
        });
        //            linkToPrefs.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));
        stack.topControl = composite;
    } else {
        if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_PLATFORM_DEFAULT) {
            browser = new Browser(parent, SWT.NONE);
            stack.topControl = browser;
        } else if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_WEBKIT) {
            browser = new Browser(parent, SWT.WEBKIT);
            stack.topControl = browser;
        } else if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_MOZILLA) {
            browser = new Browser(parent, SWT.MOZILLA);
            stack.topControl = browser;
        }
        createActions();
        // Prevent navigation away from JPM4J.org, and redirect from HTTP back to HTTPS
        browser.addLocationListener(new LocationAdapter() {

            @Override
            public void changing(LocationEvent event) {
                setContentDescription(event.location);
            /*
                     *
                    if (event.location.startsWith(HTTPS_URL))
                        return;
                    if (event.location.startsWith(HTTP_URL))
                        event.location = event.location.replaceFirst(HTTP_URL, HTTP_URL);
                    else
                        event.doit = false;
                     */
            }
        });
    }
    selectionService = getViewSite().getWorkbenchWindow().getSelectionService();
    selectionService.addSelectionListener(this);
    handleWorkbenchSelection(selectionService.getSelection());
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) JpmPreferences(bndtools.preferences.JpmPreferences) LocationAdapter(org.eclipse.swt.browser.LocationAdapter) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) StackLayout(org.eclipse.swt.custom.StackLayout) LocationEvent(org.eclipse.swt.browser.LocationEvent) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter) Browser(org.eclipse.swt.browser.Browser)

Example 8 with StackLayout

use of org.eclipse.swt.custom.StackLayout in project eclipse.platform.swt by eclipse.

the class StackLayoutTab method createLayout.

/**
 * Creates the example layout.
 */
@Override
void createLayout() {
    stackLayout = new StackLayout();
    layoutComposite.setLayout(stackLayout);
}
Also used : StackLayout(org.eclipse.swt.custom.StackLayout)

Example 9 with StackLayout

use of org.eclipse.swt.custom.StackLayout in project eclipse.platform.swt by eclipse.

the class StackLayoutTab method createControlWidgets.

/**
 * Creates the control widgets.
 */
@Override
void createControlWidgets() {
    /* Controls the topControl in the StackLayout */
    Group columnGroup = new Group(controlGroup, SWT.NONE);
    // (LayoutExample.getResourceString ("Top_Control"));
    columnGroup.setText("topControl");
    columnGroup.setLayout(new GridLayout(3, false));
    columnGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    backButton = new Button(columnGroup, SWT.PUSH);
    backButton.setText("<<");
    backButton.setEnabled(false);
    backButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
    backButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> setTopControl(currentLayer - 1)));
    topControl = new Label(columnGroup, SWT.BORDER);
    topControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    advanceButton = new Button(columnGroup, SWT.PUSH);
    advanceButton.setText(">>");
    advanceButton.setEnabled(false);
    advanceButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> setTopControl(currentLayer + 1)));
    /* Controls the margins of the StackLayout */
    Group marginGroup = new Group(controlGroup, SWT.NONE);
    marginGroup.setText(LayoutExample.getResourceString("Margins"));
    marginGroup.setLayout(new GridLayout(2, false));
    marginGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    new Label(marginGroup, SWT.NONE).setText("marginWidth");
    marginWidth = new Spinner(marginGroup, SWT.BORDER);
    marginWidth.setSelection(0);
    marginWidth.addSelectionListener(selectionListener);
    new Label(marginGroup, SWT.NONE).setText("marginHeight");
    marginHeight = new Spinner(marginGroup, SWT.BORDER);
    marginHeight.setSelection(0);
    marginHeight.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    marginHeight.addSelectionListener(selectionListener);
    /* Add common controls */
    super.createControlWidgets();
}
Also used : TableEditor(org.eclipse.swt.custom.TableEditor) TableItem(org.eclipse.swt.widgets.TableItem) Text(org.eclipse.swt.widgets.Text) StackLayout(org.eclipse.swt.custom.StackLayout) Button(org.eclipse.swt.widgets.Button) Spinner(org.eclipse.swt.widgets.Spinner) Group(org.eclipse.swt.widgets.Group) MouseListener(org.eclipse.swt.events.MouseListener) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) CCombo(org.eclipse.swt.custom.CCombo) Control(org.eclipse.swt.widgets.Control) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) Spinner(org.eclipse.swt.widgets.Spinner) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label)

Example 10 with StackLayout

use of org.eclipse.swt.custom.StackLayout in project KaiZen-OpenAPI-Editor by RepreZen.

the class JsonEditor method createSourceViewer.

@Override
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout compositeLayout = new GridLayout(1, false);
    compositeLayout.marginHeight = 0;
    compositeLayout.marginWidth = 0;
    compositeLayout.horizontalSpacing = 0;
    compositeLayout.verticalSpacing = 0;
    composite.setLayout(compositeLayout);
    topPanel = new Composite(composite, SWT.NONE);
    topPanel.setLayout(new StackLayout());
    topPanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    Composite editorComposite = new Composite(composite, SWT.NONE);
    editorComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
    fillLayout.marginHeight = 0;
    fillLayout.marginWidth = 0;
    fillLayout.spacing = 0;
    editorComposite.setLayout(fillLayout);
    ISourceViewer result = doCreateSourceViewer(editorComposite, ruler, styles);
    return result;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) StackLayout(org.eclipse.swt.custom.StackLayout) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer)

Aggregations

StackLayout (org.eclipse.swt.custom.StackLayout)18 Composite (org.eclipse.swt.widgets.Composite)16 GridData (org.eclipse.swt.layout.GridData)9 GridLayout (org.eclipse.swt.layout.GridLayout)7 Label (org.eclipse.swt.widgets.Label)6 FillLayout (org.eclipse.swt.layout.FillLayout)5 Text (org.eclipse.swt.widgets.Text)4 Button (org.eclipse.swt.widgets.Button)3 JpmPreferences (bndtools.preferences.JpmPreferences)2 IFile (org.eclipse.core.resources.IFile)2 IResource (org.eclipse.core.resources.IResource)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Color (org.eclipse.swt.graphics.Color)2 Control (org.eclipse.swt.widgets.Control)2 PartInitException (org.eclipse.ui.PartInitException)2 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)2 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)2 Workspace (aQute.bnd.build.Workspace)1 HttpClient (aQute.bnd.http.HttpClient)1