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();
}
});
}
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());
}
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);
}
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();
}
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;
}
Aggregations