private Hyperlink createStaticPage(Composite parent) { Form mainForm = toolkit.createForm(parent); Composite body = mainForm.getBody(); GridLayout gl = new GridLayout(); body.setLayout(gl); String label = Messages.StaticHTML_welcome; Hyperlink link = toolkit.createHyperlink(body, label, SWT.WRAP); link.setFont(PageStyleManager.getHeaderFont()); GridData gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL); gd.horizontalAlignment = GridData.CENTER; gd.verticalAlignment = GridData.CENTER; link.setLayoutData(gd); link.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { Hyperlink link = (Hyperlink) e.getSource(); Util.openBrowser((String) link.getHref()); return; } }); return link; }
protected Control createInfoTextArea(Composite parent) { Composite infoComposite = new Composite(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(2, false); gridLayout.marginHeight = 0; gridLayout.marginWidth = 0; infoComposite.setLayout(gridLayout); GridData gd = new GridData(GridData.FILL_BOTH); infoComposite.setLayoutData(gd); nsInfoLabel = new Label(infoComposite, SWT.LEFT); nsInfoLabel.setText(infoText); Font font = nsInfoLabel.getFont(); FontData[] fontDatas = font.getFontData(); for (int i = 0; i < fontDatas.length; i++) { fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10); } infoFont = new Font(nsInfoLabel.getDisplay(), fontDatas); nsInfoLabel.setFont(infoFont); gd = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); nsInfoLabel.setLayoutData(gd); nsInfoLabel.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW)); link = new Hyperlink(infoComposite, SWT.RIGHT); link.setText(Messages._UI_ACTION_OPEN_IN_NEW_EDITOR); link.setFont(infoFont); link.addHyperlinkListener(linkListener); return infoComposite; }
private void createHeadLink(final Repository repository, Composite composite) throws IOException { final ObjectId objectId = repository .resolve(repository.getFullBranch()); if (objectId == null) { Text headLabel = createLabeledReadOnlyText(composite, UIText.GitProjectPropertyPage_LabelId); if (repository.getAllRefs().size() == 0) headLabel.setText(UIText.GitProjectPropertyPage_ValueEmptyRepository); else headLabel.setText(UIText.GitProjectPropertyPage_ValueUnbornBranch); } else { Hyperlink headLink = createHeadHyperLink(composite, UIText.GitProjectPropertyPage_LabelId); headLink.setText(objectId.name()); headLink.setUnderlined(true); headLink.setFont(JFaceResources.getDialogFont()); headLink.setForeground(JFaceColors.getHyperlinkText(headLink .getDisplay())); headLink.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { RepositoryCommit commit = getCommit(repository, objectId); if(commit != null) CommitEditor.openQuiet(commit); } }); } }
linkControl.setFont(PageStyleManager.getBannerFont()); colorControl(linkControl, link); linkControl.setHref(link.getUrl());