下面列出了怎么用org.eclipse.ui.help.IWorkbenchHelpSystem的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Opens the internal help in the Studio's internal browser.
*
* @param url
* @return A boolean value indicating a successful operations or not.
*/
public static boolean openHelpInBrowser(String url)
{
IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench != null)
{
IWorkbenchHelpSystem helpSystem = workbench.getHelpSystem();
URL resolvedURL = helpSystem.resolve(url, true);
if (resolvedURL != null)
{
return openInBroswer(resolvedURL, true, IWorkbenchBrowserSupport.AS_EDITOR
| IWorkbenchBrowserSupport.STATUS);
}
else
{
IdeLog.logError(UIPlugin.getDefault(), "Unable to resolve the Help URL for " + url); //$NON-NLS-1$
return false;
}
}
return false;
}
@Override
public void run() {
final IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
if (contextId == null) {
helpSystem.displayHelp();
} else {
helpSystem.displayHelp(contextId);
}
}
@Override
public void run() {
final IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench()
.getHelpSystem();
helpSystem.displayHelp("org.yakindu.sct.ui.editor.stext_keyword");
}
/**
* Creates the field editors. Field editors are abstractions of
* the common GUI blocks needed to manipulate various types
* of preferences. Each field editor knows how to save and
* restore itself.
*/
public void createFieldEditors() {
TexlipsePreferencePage.addSpacer(getFieldEditorParent());
addField(new BooleanFieldEditor(TexlipseProperties.TEX_COMPLETION, TexlipsePlugin.getResourceString("preferenceTexCompletion"), getFieldEditorParent()));
String completionMessage = TexlipsePlugin.getResourceString("preferenceTexCompletionDelay").replaceFirst("%1", "" + MIN_COMPLETION_DELAY).replaceFirst("%2", "" + MAX_COMPLETION_DELAY);
IntegerFieldEditor completionDelay = new IntegerFieldEditor(TexlipseProperties.TEX_COMPLETION_DELAY, completionMessage, getFieldEditorParent());
completionDelay.setValidateStrategy(IntegerFieldEditor.VALIDATE_ON_KEY_STROKE);
completionDelay.setValidRange(MIN_COMPLETION_DELAY, MAX_COMPLETION_DELAY);
addField(completionDelay);
//TexlipsePreferencePage.addSpacer(getFieldEditorParent());
// auto \item completion
addField(new BooleanFieldEditor(TexlipseProperties.TEX_ITEM_COMPLETION,
TexlipsePlugin.getResourceString("preferenceTexItemCompletion"),
getFieldEditorParent()));
Label itemLabel = new Label(getFieldEditorParent(), SWT.LEFT | SWT.WRAP);
itemLabel.setText(TexlipsePlugin.getResourceString("preferenceTexItemCompletionText"));
//TexlipsePreferencePage.addSpacer(getFieldEditorParent());
// auto parsing
addField(new BooleanFieldEditor(TexlipseProperties.AUTO_PARSING,
TexlipsePlugin.getResourceString("preferenceAutoParsing"),
getFieldEditorParent()));
String autoParsingMessage = TexlipsePlugin.getResourceString(
"preferenceAutoParsingDelay").replaceFirst("%1",
"" + MIN_AUTO_DELAY).replaceFirst("%2", "" + MAX_AUTO_DELAY);
IntegerFieldEditor autoDelay = new IntegerFieldEditor(TexlipseProperties.AUTO_PARSING_DELAY,
autoParsingMessage, getFieldEditorParent());
autoDelay.setValidateStrategy(IntegerFieldEditor.VALIDATE_ON_KEY_STROKE);
autoDelay.setValidRange(MIN_AUTO_DELAY, MAX_AUTO_DELAY);
addField(autoDelay);
// Check for missing sections
addField(new BooleanFieldEditor(TexlipseProperties.SECTION_CHECK,
TexlipsePlugin.getResourceString("preferenceSectionCheck"),
getFieldEditorParent()));
// Mark occurences (references and environments)
addField(new BooleanFieldEditor(TexlipseProperties.TEX_EDITOR_ANNOTATATIONS,
TexlipsePlugin.getResourceString("preferencesEditorHighlighting"),
getFieldEditorParent()));
TexlipsePreferencePage.addSpacer(getFieldEditorParent());
// word wrapping
Group group = new Group(getFieldEditorParent(), SWT.NONE);
group.setText(TexlipsePlugin.getResourceString("preferenceWrapping"));
group.setLayout(new GridLayout());
GridData layData = new GridData(GridData.FILL_HORIZONTAL);
layData.horizontalSpan = 2;
group.setLayoutData(layData);
Composite wordWrapParent = getFieldEditorParent(group);
// default on/off wrapping
addField(new BooleanFieldEditor(TexlipseProperties.WORDWRAP_DEFAULT, TexlipsePlugin.getResourceString("preferenceWrappingDefault"), wordWrapParent));
TexlipsePreferencePage.addSpacer(wordWrapParent);
String message = TexlipsePlugin.getResourceString("preferenceWrapLineLength").replaceFirst("%1", ""+MIN_WRAP_LENGTH).replaceFirst("%2", ""+MAX_WRAP_LENGTH);
IntegerFieldEditor wordWrapLength = new IntegerFieldEditor(TexlipseProperties.WORDWRAP_LENGTH, message, wordWrapParent);
wordWrapLength.setValidateStrategy(IntegerFieldEditor.VALIDATE_ON_KEY_STROKE);
wordWrapLength.setValidRange(MIN_WRAP_LENGTH, MAX_WRAP_LENGTH);
addField(wordWrapLength);
IWorkbenchHelpSystem helpsystem = workbench.getHelpSystem();
helpsystem.setHelp(wordWrapLength.getTextControl(wordWrapParent), TexlipseHelpIds.WRAP_LENGTH);
//WorkbenchHelp.setHelp(wordWrapLength.getTextControl(wordWrapParent), TexlipseHelpIds.WRAP_LENGTH);
TexlipsePreferencePage.addSpacer(wordWrapParent);
Label label = new Label(wordWrapParent, SWT.LEFT | SWT.WRAP);
label.setText(TexlipsePlugin.getResourceString("preferenceWrapSoftWarning"));
GridData lgl = new GridData(GridData.FILL_HORIZONTAL);
lgl.horizontalSpan = 2;
label.setLayoutData(lgl);
addField(new RadioGroupFieldEditor(TexlipseProperties.WORDWRAP_TYPE, TexlipsePlugin.getResourceString("preferenceWrapType"), 1,
new String[][] {//{ TexlipsePlugin.getResourceString("preferenceWrapNoneLabel"), TexlipseProperties.WORDWRAP_TYPE_NONE },
{ TexlipsePlugin.getResourceString("preferenceWrapSoftLabel"), TexlipseProperties.WORDWRAP_TYPE_SOFT },
{ TexlipsePlugin.getResourceString("preferenceWrapHardLabel"), TexlipseProperties.WORDWRAP_TYPE_HARD }},
getFieldEditorParent(group)));
}
protected void setHelpContext(Control control, String helpId) {
IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
helpSystem.setHelp(control, helpId);
}
@Override
protected void createGraphicalViewer(Composite parent) {
super.createGraphicalViewer(parent);
IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
helpSystem.setHelp(getGraphicalViewer().getControl(), HelpContextIds.SC_EDITOR_GRAPHICAL_VIEWER);
}