use of org.eclipse.swt.events.HelpListener in project translationstudio8 by heartsome.
the class TSWizardDialog method configureShell.
/*
* (non-Javadoc) Method declared on Window.
*/
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
// Register help listener on the shell
newShell.addHelpListener(new HelpListener() {
public void helpRequested(HelpEvent event) {
// call perform help on the current page
if (currentPage != null) {
currentPage.performHelp();
}
}
});
}
use of org.eclipse.swt.events.HelpListener in project translationstudio8 by heartsome.
the class ProjectSettingDialog method addListeners.
protected void addListeners(final TreeViewer viewer) {
viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
private void handleError() {
try {
// remove the listener temporarily so that the events caused
// by the error handling dont further cause error handling
// to occur.
viewer.removePostSelectionChangedListener(this);
// select Current PageAgain;
if (lastSuccessfulNode == null) {
return;
}
getTreeViewer().setSelection(new StructuredSelection(lastSuccessfulNode));
getCurrentPage().setVisible(true);
// clear Selected Node
setSelectedNodePreference(null);
} finally {
viewer.addPostSelectionChangedListener(this);
}
}
public void selectionChanged(SelectionChangedEvent event) {
final Object selection = getSingleSelection(event.getSelection());
if (selection instanceof IPreferenceNode) {
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
public void run() {
if (!isCurrentPageValid()) {
handleError();
} else if (!showPage((IPreferenceNode) selection)) {
// Page flipping wasn't successful
handleError();
} else {
// Everything went well
lastSuccessfulNode = (IPreferenceNode) selection;
}
}
});
}
}
});
((Tree) viewer.getControl()).addSelectionListener(new SelectionAdapter() {
public void widgetDefaultSelected(final SelectionEvent event) {
ISelection selection = viewer.getSelection();
if (selection.isEmpty()) {
return;
}
IPreferenceNode singleSelection = getSingleSelection(selection);
boolean expanded = viewer.getExpandedState(singleSelection);
viewer.setExpandedState(singleSelection, !expanded);
}
});
// Register help listener on the tree to use context sensitive help
viewer.getControl().addHelpListener(new HelpListener() {
public void helpRequested(HelpEvent event) {
if (getCurrentPage() == null) {
// no current page? open dialog's help
openDialogHelp();
return;
}
// A) A typical path: the current page has registered its own help link
// via WorkbenchHelpSystem#setHelp(). When just call it and let
// it handle the help request.
Control pageControl = getCurrentPage().getControl();
if (pageControl != null && pageControl.isListening(SWT.Help)) {
getCurrentPage().performHelp();
return;
}
// B) Less typical path: no standard listener has been created for the page.
// In this case we may or may not have an override of page's #performHelp().
// 1) Try to get default help opened for the dialog;
openDialogHelp();
// 2) Next call currentPage's #performHelp(). If it was overridden, it might switch help
// to something else.
getCurrentPage().performHelp();
}
private void openDialogHelp() {
if (getPageContainer() == null)
return;
for (Control currentControl = getPageContainer(); currentControl != null; currentControl = currentControl.getParent()) {
if (currentControl.isListening(SWT.Help)) {
currentControl.notifyListeners(SWT.Help, new Event());
break;
}
}
}
});
}
use of org.eclipse.swt.events.HelpListener in project dbeaver by serge-rider.
the class BaseObjectEditPage method createControl.
@Override
public final void createControl(Composite parent) {
Control pageContents = createPageContents(parent);
setControl(pageContents);
pageContents.addHelpListener(new HelpListener() {
@Override
public void helpRequested(HelpEvent e) {
performHelp();
}
});
}
use of org.eclipse.swt.events.HelpListener in project yyl_example by Relucent.
the class MyGridLayout method main.
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
gridLayout.makeColumnsEqualWidth = false;
//# GridLayout gridLayout = new GridLayout(2,false);
gridLayout.marginTop = 10;
gridLayout.marginLeft = 5;
gridLayout.verticalSpacing = 2;
new Button(shell, SWT.NONE).setText("b1");
new Button(shell, SWT.NONE).setText("button2");
Button b3 = new Button(shell, SWT.NONE);
b3.setText("b3");
new Button(shell, SWT.NONE).setText("button5");
new Button(shell, SWT.NONE).setText("btn6");
//选中按钮,点击F1帮助 执行该事件
b3.addHelpListener(new HelpListener() {
public void helpRequested(HelpEvent arg0) {
System.out.println("点击了帮助");
}
});
GridData gridData = new GridData();
//# new GridData(GridData.HORIZONTAL_ALIGN_FILL);
//# new GridData(GridData.FILL_HORIZONTAL);
//# new GridData(GridData.FILL_VERTICAL);
//# new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 2;
//# gridData.horizontalAlignment = GridData.BEGINNING;
//# gridData.horizontalAlignment = GridData.CENTER;
//# gridData.horizontalAlignment = GridData.END;
//# gridData.horizontalAlignment = GridData.FILL;
// gridDate.horizontalAlignment = 10;
gridData.grabExcessHorizontalSpace = false;
// gridData.widthHint = 80;
// gridData.heightHint = 20;
b3.setLayoutData(gridData);
shell.setLayout(gridLayout);
shell.setText("GridLayout");
shell.setSize(200, 200);
shell.layout();
shell.open();
while (!shell.isDisposed()) if (!display.readAndDispatch())
display.sleep();
}
Aggregations