use of org.eclipse.swt.widgets.Layout in project xtext-eclipse by eclipse.
the class XbaseInformationControl method createContent.
/**
* Xbase - modification+ added detailPane
*/
@Override
protected void createContent(Composite parent) {
fSashForm = new SashForm(parent, parent.getStyle());
fSashForm.setOrientation(SWT.VERTICAL);
fBrowser = new Browser(fSashForm, SWT.NONE);
fBrowser.setJavascriptEnabled(false);
Display display = getShell().getDisplay();
ColorRegistry registry = JFaceResources.getColorRegistry();
// $NON-NLS-1$
Color foreground = registry.get("org.eclipse.ui.workbench.HOVER_FOREGROUND");
// $NON-NLS-1$
Color background = registry.get("org.eclipse.ui.workbench.HOVER_BACKGROUND");
if (background != null && foreground != null) {
fBrowser.setForeground(foreground);
fBrowser.setBackground(background);
} else {
fBrowser.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
fBrowser.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
}
fBrowser.addProgressListener(new ProgressAdapter() {
@Override
public void completed(ProgressEvent event) {
fCompleted = true;
}
});
fBrowser.addOpenWindowListener(new OpenWindowListener() {
@Override
public void open(WindowEvent event) {
// Cancel opening of new windows
event.required = true;
}
});
// Replace browser's built-in context menu with none
fSashForm.setMenu(new Menu(getShell(), SWT.NONE));
detailPaneComposite = createComposite(fSashForm, 1, 1, GridData.FILL_BOTH);
Layout layout = detailPaneComposite.getLayout();
if (layout instanceof GridLayout) {
GridLayout gl = (GridLayout) layout;
gl.marginHeight = 0;
gl.marginWidth = 0;
gl.numColumns = 1;
}
if (background != null && foreground != null) {
detailPaneComposite.setForeground(foreground);
detailPaneComposite.setBackground(background);
} else {
detailPaneComposite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
detailPaneComposite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
}
resourceProvider = new HoverEditedResourceProvider();
embeddedEditor = xbaseHoverConfiguration.getEditorFactory().newEditor(resourceProvider).readOnly().processIssuesBy(new IValidationIssueProcessor() {
@Override
public void processIssues(List<Issue> issues, IProgressMonitor monitor) {
}
}).withParent(detailPaneComposite);
Control viewerControl = embeddedEditor.getViewer().getControl();
if (background != null && foreground != null) {
viewerControl.setForeground(foreground);
viewerControl.setBackground(background);
} else {
viewerControl.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
viewerControl.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
}
embeddedEditor.getDocument().setValidationJob(null);
createTextLayout();
parent.addDisposeListener(e -> {
if (fTextLayout != null && !fTextLayout.isDisposed()) {
fTextLayout.dispose();
}
});
}
use of org.eclipse.swt.widgets.Layout in project cogtool by cogtool.
the class CogTool method reportTopLevelAnomaly.
/**
* Attend to an Exception or Error caught at top level.
* Attempts to interact with the user, presenting a stack trace and
* related information. If this also throws an Exception, we just
* give up in disgust, spitting out what we know to the console.
*
* @param e the Throwable that was caught at top level
*/
public static void reportTopLevelAnomaly(Throwable e) {
try {
final Shell window = new Shell(WindowUtil.GLOBAL_DISPLAY, SWT.TITLE | SWT.BORDER | SWT.RESIZE);
window.setText(L10N.get("UnexpectedError", "Unexpected Error"));
Layout layout = new GridLayout(1, false);
window.setLayout(layout);
Label announcement = new Label(window, SWT.LEFT);
announcement.setText(L10N.get("ErrorHappened", "An unexpected error has occurred. Please contact CogTool support with the following information:"));
GridData announcementLayout = new GridData();
announcementLayout.grabExcessHorizontalSpace = true;
announcement.setLayoutData(announcementLayout);
Text trace = new Text(window, SWT.LEFT | SWT.READ_ONLY | SWT.MULTI | SWT.V_SCROLL);
StringWriter stringBuffer = new StringWriter();
String version = getVersion();
stringBuffer.write(version);
stringBuffer.write('\n');
String runtimeDesc = OSUtils.runtimeDescription();
stringBuffer.write(runtimeDesc);
stringBuffer.write('\n');
stringBuffer.write(getMemoryUsage());
stringBuffer.write('\n');
e.printStackTrace(new PrintWriter(stringBuffer));
// echo version and trace information to the console
System.err.println(version);
System.err.println(runtimeDesc);
if (!(e instanceof Error)) {
// If it's an Error, we've already done this
e.printStackTrace();
}
trace.setText(stringBuffer.toString());
int lineHeight = trace.getLineHeight();
int lineCount = trace.getLineCount();
int height = (OSUtils.MACOSX) ? ERROR_HEIGHT : Math.min(lineHeight * lineCount, ERROR_HEIGHT);
GridData traceLayout = new GridData();
traceLayout.grabExcessHorizontalSpace = true;
traceLayout.heightHint = height;
trace.setLayoutData(traceLayout);
Button okButton = new Button(window, SWT.PUSH);
okButton.setText(L10N.get("B.Exit", "Exit CogTool"));
// ignore return value from setFocus()
okButton.setFocus();
window.setDefaultButton(okButton);
GridData okLayout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
okButton.setLayoutData(okLayout);
// Dismiss the dialog box when OK button selected, with success
okButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event evt) {
window.close();
}
});
// Exits when window has been disposed.
WindowUtil.displayAndInteract(window);
} catch (Throwable anotherExceptionOrError) {
// Again, no need to localize
System.err.println("Another Exception or Error was thrown while " + "attending to one caught at top level. " + "This is a bug.");
System.err.println("\n*** The new Exception or Error:");
anotherExceptionOrError.printStackTrace();
System.err.println("\n*** The original Exception or Error:");
e.printStackTrace();
System.exit(ERROR_STATUS);
}
}
use of org.eclipse.swt.widgets.Layout in project linuxtools by eclipse.
the class SSHPasswordDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite comp = (Composite) super.createDialogArea(parent);
Layout layout = comp.getLayout();
if (!(layout instanceof GridLayout)) {
layout = new GridLayout();
comp.setLayout(layout);
}
((GridLayout) layout).numColumns = 2;
Label passwordTitle = new Label(comp, SWT.RIGHT);
Label passwordLabel = new Label(comp, SWT.RIGHT);
GridData gridData = new GridData(GridData.VERTICAL_ALIGN_END);
gridData.horizontalSpan = 2;
gridData.horizontalAlignment = GridData.FILL;
passwordTitle.setLayoutData(gridData);
if (host != null && user != null) {
passwordTitle.setText(MessageFormat.format(Messages.SSHPasswordDialog_Password_Title, user, host));
}
passwordLabel.setText(Messages.SSHPasswordDialog_Password);
passwordField = new Text(comp, SWT.SINGLE | SWT.PASSWORD);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
passwordField.setLayoutData(data);
return comp;
}
use of org.eclipse.swt.widgets.Layout in project BiglyBT by BiglySoftware.
the class TaggingView method initialize.
private void initialize() {
if (cMainComposite == null || cMainComposite.isDisposed()) {
if (parent == null || parent.isDisposed()) {
return;
}
sc = new ScrolledComposite(parent, SWT.V_SCROLL);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
sc.getVerticalBar().setIncrement(16);
Layout parentLayout = parent.getLayout();
if (parentLayout instanceof GridLayout) {
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
sc.setLayoutData(gd);
} else if (parentLayout instanceof FormLayout) {
sc.setLayoutData(Utils.getFilledFormData());
}
cMainComposite = new Composite(sc, SWT.NONE);
sc.setContent(cMainComposite);
} else {
Utils.disposeComposite(cMainComposite, false);
}
cMainComposite.setLayout(new GridLayout(1, false));
TagManager tm = TagManagerFactory.getTagManager();
int[] tagTypesWanted = { TagType.TT_DOWNLOAD_MANUAL // TagType.TT_DOWNLOAD_CATEGORY
};
tagButtonsUI = new TagButtonsUI();
List<Tag> listAllTags = new ArrayList<>();
for (int tagType : tagTypesWanted) {
TagType tt = tm.getTagType(tagType);
List<Tag> tags = tt.getTags();
listAllTags.addAll(tags);
}
tagButtonsUI.buildTagGroup(listAllTags, cMainComposite, new TagButtonTrigger() {
@Override
public void tagButtonTriggered(Tag tag, boolean doTag) {
for (Taggable taggable : taggables) {
if (doTag) {
tag.addTaggable(taggable);
} else {
tag.removeTaggable(taggable);
}
swt_updateFields();
}
}
});
Button buttonAdd = new Button(cMainComposite, SWT.PUSH);
buttonAdd.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, false, false));
Messages.setLanguageText(buttonAdd, "label.add.tag");
buttonAdd.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
TagUIUtils.createManualTag(new TagReturner() {
@Override
public void returnedTags(Tag[] tags) {
if (taggables == null) {
return;
}
for (Tag tag : tags) {
for (Taggable taggable : taggables) {
tag.addTaggable(taggable);
}
}
}
});
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
sc.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
Rectangle r = sc.getClientArea();
Point size = cMainComposite.computeSize(r.width, SWT.DEFAULT);
sc.setMinSize(size);
}
});
swt_updateFields();
Rectangle r = sc.getClientArea();
Point size = cMainComposite.computeSize(r.width, SWT.DEFAULT);
sc.setMinSize(size);
}
use of org.eclipse.swt.widgets.Layout in project BiglyBT by BiglySoftware.
the class MyTorrentsSubView method initComposite.
/* (non-Javadoc)
* @see com.biglybt.ui.swt.views.table.impl.TableViewTab#initComposite(org.eclipse.swt.widgets.Composite)
*/
@Override
public Composite initComposite(Composite composite) {
Composite parent = new Composite(composite, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = layout.marginWidth = 0;
layout.horizontalSpacing = layout.verticalSpacing = 0;
parent.setLayout(layout);
Layout compositeLayout = composite.getLayout();
if (compositeLayout instanceof GridLayout) {
parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
} else if (compositeLayout instanceof FormLayout) {
parent.setLayoutData(Utils.getFilledFormData());
}
Composite cTop = new Composite(parent, SWT.NONE);
GridData gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
cTop.setLayoutData(gd);
cTop.setLayout(new FormLayout());
btnAnyTags = new Button(cTop, SWT.CHECK);
Messages.setLanguageText(btnAnyTags, "TorrentTags.Button.Any");
btnAnyTags.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
COConfigurationManager.setParameter("TorrentTags.Any", !anyTorrentTags);
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
anyTorrentTags = COConfigurationManager.getBooleanParameter("TorrentTags.Any");
btnAnyTags.setSelection(anyTorrentTags);
setCurrentTagsAny(anyTorrentTags);
updateButtonVisibility(getCurrentTags());
Composite tableParent = new Composite(parent, SWT.NONE);
tableParent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout gridLayout = new GridLayout();
gridLayout.horizontalSpacing = gridLayout.verticalSpacing = 0;
gridLayout.marginHeight = gridLayout.marginWidth = 0;
tableParent.setLayout(gridLayout);
parent.setTabList(new Control[] { tableParent, cTop });
return tableParent;
}
Aggregations