下面列出了org.eclipse.ui.forms.widgets.ImageHyperlink#setImage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected void createHelpWidget(final Composite parent, final Control control, String helpId) {
final ImageHyperlink helpWidget = toolkit.createImageHyperlink(parent, SWT.CENTER);
Image defaultImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_LCL_LINKTO_HELP);
helpWidget.setImage(defaultImage);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).applyTo(helpWidget);
helpWidget.setToolTipText(JFaceResources.getString(IDialogLabelKeys.HELP_LABEL_KEY));
helpWidget.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
control.setFocus();
PlatformUI.getWorkbench().getHelpSystem().displayDynamicHelp();
}
});
GridDataFactory.fillDefaults().applyTo(helpWidget);
helpWidget.setEnabled(true);
setHelpContext(control, helpId);
}
private void createControls() {
Composite cloudForgeComposite = new Composite(this, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
cloudForgeComposite.setLayout(layout);
GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
cloudForgeComposite.setLayoutData(data);
ImageHyperlink cloudForgeLink = new ImageHyperlink(cloudForgeComposite, SWT.NONE);
cloudForgeLink.setImage(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_CLOUDFORGE).createImage());
cloudForgeLink.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent evt) {
try {
PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(SIGNUP_URL));
} catch (Exception e) {
MessageDialog.openError(getShell(), "Sign-up for CloudForge", e.getMessage());
}
}
});
cloudForgeLink.setToolTipText(SIGNUP_URL);
}
public void loadErrorPage() {
if (scrolledForm != null) {
Stream.of(toolBarManager.getItems()).forEach(IContributionItem::update);
disposePageContent();
final Composite composite = toolkit.createComposite(scrolledForm.getBody());
composite.setLayout(GridLayoutFactory.fillDefaults().create());
composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).align(SWT.CENTER, SWT.CENTER).create());
final ImageHyperlink imageHyperlink = toolkit.createImageHyperlink(composite, SWT.NONE);
imageHyperlink.setLayoutData(GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).create());
imageHyperlink.setImage(UIPlugin.getImage("icons/error.png"));
imageHyperlink.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
getEditor().setActiveEditor(getSourceEditor());
}
});
final Label label = toolkit.createLabel(composite, Messages.parseError);
label.setLayoutData(GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).create());
label.setFont(BonitaStudioFontRegistry.getPreferenceTitleFont());
scrolledForm.getParent().layout(true, true);
}
}
private void createItems() {
LinkClick click = new LinkClick();
for (Descriptor d : getPageResults()) {
Composite comp = tk.createComposite(pageComposite);
UI.gridData(comp, true, false);
UI.gridLayout(comp, 1).verticalSpacing = 3;
ImageHyperlink link = tk.createImageHyperlink(comp, SWT.TOP);
link.setText(Labels.name(d));
link.setImage(Images.get(d));
link.setForeground(Colors.linkBlue());
link.setData(d);
link.addHyperlinkListener(click);
renderCategory(tk, d, comp);
renderDescription(tk, d, comp);
}
}
private void element(String text, Object model, int colorIndex) {
if (model instanceof CategorizedDescriptor || model instanceof CategorizedEntity) {
ImageHyperlink link = new ImageHyperlink(composite, SWT.TOP);
link.setText(text);
link.setImage(getImage(colorIndex));
Controls.onClick(link, (e) -> {
if (model instanceof CategorizedDescriptor) {
App.openEditor((CategorizedDescriptor) model);
} else if (model instanceof CategorizedEntity) {
App.openEditor((CategorizedEntity) model);
}
});
createdLinks.push(link);
} else {
CLabel label = new CLabel(composite, SWT.TOP);
label.setImage(getImage(colorIndex));
label.setText(text);
createdLinks.push(label);
}
}
private Composite createEmptyBDMComposite(Composite parent) {
Composite client = widgetFactory.createComposite(parent);
client.setLayout(GridLayoutFactory.fillDefaults().create());
client.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
Composite emptyBDMComposite = widgetFactory.createComposite(client);
emptyBDMComposite.setLayout(GridLayoutFactory.fillDefaults().create());
emptyBDMComposite
.setLayoutData(GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, true).create());
final ImageHyperlink imageHyperlink = widgetFactory.createImageHyperlink(emptyBDMComposite, SWT.NO_FOCUS);
imageHyperlink.setLayoutData(GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.FILL).create());
imageHyperlink.setImage(Pics.getImage("defineBdm_60.png", DataPlugin.getDefault()));
imageHyperlink.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
commandExecutor.executeCommand(DEFINE_BDM_COMMAND, null);
}
});
Link labelLink = new Link(emptyBDMComposite, SWT.NO_FOCUS);
widgetFactory.adapt(labelLink, false, false);
labelLink.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.CENTER).create());
labelLink.setText(Messages.defineBdmTooltip);
labelLink.addListener(SWT.Selection, e -> commandExecutor.executeCommand(DEFINE_BDM_COMMAND, null));
return client;
}
@Override
public Composite createControl(final Composite parent){
// Form form=tk.createForm(parent);
// form.setLayoutData(SWTHelper.getFillGridData(1,true,1,false));
// Composite ret=form.getBody();
Composite ret = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginWidth = 0;
ret.setLayout(layout);
ret.setBackground(parent.getBackground());
ImageHyperlink hClr = tk.createImageHyperlink(ret, SWT.NONE); //$NON-NLS-1$
hClr.setImage(Images.IMG_CLEAR.getImage());
hClr.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(final HyperlinkEvent e){
clearValues();
}
});
hClr.setBackground(parent.getBackground());
inner = new Composite(ret, SWT.NONE);
GridLayout lRet = new GridLayout(fields.length, true);
inner.setLayout(lRet);
inner.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
populateInnerComposite();
return ret;
}
private void renderFlowLink(Image image, Composite composite,
ProcessDescriptor d) {
ImageHyperlink link = new ImageHyperlink(composite, SWT.TOP);
link.setText(Labels.name(d));
if (d.description != null) {
link.setToolTipText(d.description);
}
link.setImage(image);
link.setForeground(Colors.linkBlue());
Controls.onClick(link, e -> {
ProcessDao dao = new ProcessDao(database);
Process p = dao.getForId(d.id);
App.openEditor(p);
});
}
private void initControl(Composite parent, FormToolkit toolkit) {
if (!App.isCommentingEnabled() || comments == null || !comments.hasPath(path)) {
UI.filler(parent, toolkit);
return;
}
ImageHyperlink control = new ImageHyperlink(parent, SWT.NONE);
UI.gridData(control, false, false).verticalAlignment = SWT.TOP;
Controls.onClick(control, (e) -> {
new CommentDialog(path, comments).open();
});
control.setImage(Icon.SHOW_COMMENTS.get());
control.setToolTipText(M.Comment);
}
private void generalSection(FormToolkit tk, Composite body) {
Composite comp = UI.formSection(body, tk, "General statistics");
UI.gridLayout(comp, 2, 15, 10);
UI.formLabel(comp, "Number of processes");
bind(UI.formLabel(comp, ""), label -> {
label.setText(Integer.toString(stats.processCount));
});
UI.formLabel(comp, "Number of process links");
bind(UI.formLabel(comp, ""), label -> {
label.setText(Integer.toString(stats.linkCount));
});
UI.formLabel(comp, "Connected graph / can calculate?");
bind(UI.formLabel(comp, ""), label -> {
String text = stats.connectedGraph
? "yes"
: "no";
label.setText(text);
});
UI.formLabel(comp, "Reference process");
ImageHyperlink link = new ImageHyperlink(comp, SWT.TOP);
link.setForeground(Colors.linkBlue());
link.setImage(Images.get(ModelType.PROCESS));
Controls.onClick(link, e -> {
if (stats != null) {
App.openEditor(stats.refProcess);
}
});
bind(link, l -> {
l.setText(Labels.name(stats.refProcess));
});
UI.formLabel(comp, "");
Button btn = tk.createButton(comp, M.Update, SWT.NONE);
Controls.onSelect(btn, e -> calculate());
}