Search in sources :

Example 26 with ImageHyperlink

use of org.eclipse.ui.forms.widgets.ImageHyperlink in project eclipse-integration-commons by spring-projects.

the class DashboardMainPage method createNewProjectLink.

private void createNewProjectLink(Composite parent, String name, Image image, IHyperlinkListener listener) {
    ImageHyperlink link = toolkit.createImageHyperlink(parent, SWT.NONE);
    link.setText(name);
    link.setImage(image);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(link);
    if (listener != null) {
        link.addHyperlinkListener(listener);
    }
}
Also used : ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink)

Example 27 with ImageHyperlink

use of org.eclipse.ui.forms.widgets.ImageHyperlink in project bndtools by bndtools.

the class BuildOperationsPart method createClient.

/**
 * Fill the section.
 */
private void createClient(Section section, FormToolkit toolkit) {
    section.setText("Build Operations");
    Composite container = toolkit.createComposite(section);
    section.setClient(container);
    container.setLayout(new GridLayout(1, false));
    ImageHyperlink lnkRebuildProject = toolkit.createImageHyperlink(container, SWT.NONE);
    lnkRebuildProject.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            IResource resource = findEditorResource();
            if (resource != null) {
                RebuildJob job = new RebuildJob(resource.getProject(), IncrementalProjectBuilder.FULL_BUILD);
                job.setUser(true);
                job.schedule();
            }
        }
    });
    toolkit.paintBordersFor(lnkRebuildProject);
    lnkRebuildProject.setText("Rebuild Project");
    lnkRebuildProject.setImage(refreshImg);
    ImageHyperlink lnkCleanProject = toolkit.createImageHyperlink(container, SWT.NONE);
    toolkit.paintBordersFor(lnkCleanProject);
    lnkCleanProject.setText("Clean Project");
    lnkCleanProject.setImage(cleanImg);
    lnkCleanProject.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            IResource resource = findEditorResource();
            if (resource != null) {
                RebuildJob job = new RebuildJob(resource.getProject(), IncrementalProjectBuilder.CLEAN_BUILD);
                job.setUser(true);
                job.schedule();
            }
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) IResource(org.eclipse.core.resources.IResource) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 28 with ImageHyperlink

use of org.eclipse.ui.forms.widgets.ImageHyperlink in project bndtools by bndtools.

the class WorkspaceMainPart method initialize.

@Override
public void initialize(final IManagedForm form) {
    super.initialize(form);
    final Composite container = (Composite) getSection().getClient();
    // create a layout stack and the first visible component will be an empty component with "waiting" message
    // this will be replaced by real composite once workspace completes
    final StackLayout stackLayout = new StackLayout();
    container.setLayout(stackLayout);
    Composite labelParent = new Composite(container, SWT.NONE);
    FillLayout fillLayout = new FillLayout();
    fillLayout.marginHeight = fillLayout.marginWidth = 10;
    labelParent.setLayout(fillLayout);
    if (!Central.isWorkspaceInited()) {
        Label label = new Label(labelParent, SWT.NONE);
        label.setText("Workspace is loading, please wait...");
        label.setBackground(container.getBackground());
        label.setForeground(container.getForeground());
    }
    stackLayout.topControl = labelParent;
    container.layout();
    Central.onWorkspaceAsync(workspace -> {
        IFile buildFile = Central.getWorkspaceBuildFile();
        if (buildFile == null)
            return;
        Composite contents = new Composite(container, SWT.NONE);
        if (!mainFile) {
            ImageHyperlink link = form.getToolkit().createImageHyperlink(contents, SWT.CENTER);
            link.setText("Open main build.bnd file.");
            link.setImage(bndFileImg);
            link.addHyperlinkListener(new FileOpenLinkListener(buildFile.getFullPath()));
        } else {
            IResource[] extFiles;
            IContainer cnfDir = buildFile.getParent();
            IFolder extDir = cnfDir.getFolder(new Path("ext"));
            if (extDir.exists())
                extFiles = extDir.members();
            else
                extFiles = new IResource[0];
            if (extFiles.length > 0) {
                for (IResource extFile : extFiles) {
                    if (extFile.getType() == IResource.FILE && "bnd".equalsIgnoreCase(extFile.getFileExtension())) {
                        ImageHyperlink link = form.getToolkit().createImageHyperlink(contents, SWT.CENTER);
                        link.setText("Open " + extFile.getName());
                        link.setImage(extFileImg);
                        link.addHyperlinkListener(new FileOpenLinkListener(extFile.getFullPath()));
                    }
                }
            } else {
                createMissingExtsWarningPanel(contents, form.getToolkit(), extDir.getFullPath());
            }
        }
        stackLayout.topControl = contents;
        container.layout();
    }).onFailure(e -> Plugin.error(Collections.singletonList(e.getMessage())));
}
Also used : IFolder(org.eclipse.core.resources.IFolder) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) Image(org.eclipse.swt.graphics.Image) ErrorDialog(org.eclipse.jface.dialogs.ErrorDialog) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) IContainer(org.eclipse.core.resources.IContainer) SectionPart(org.eclipse.ui.forms.SectionPart) IPath(org.eclipse.core.runtime.IPath) Plugin(bndtools.Plugin) Composite(org.eclipse.swt.widgets.Composite) PartInitException(org.eclipse.ui.PartInitException) AbstractUIPlugin(org.eclipse.ui.plugin.AbstractUIPlugin) IFile(org.eclipse.core.resources.IFile) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) Section(org.eclipse.ui.forms.widgets.Section) FileEditorInput(org.eclipse.ui.part.FileEditorInput) StackLayout(org.eclipse.swt.custom.StackLayout) PlatformUI(org.eclipse.ui.PlatformUI) Central(bndtools.central.Central) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) IManagedForm(org.eclipse.ui.forms.IManagedForm) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Color(org.eclipse.swt.graphics.Color) IResource(org.eclipse.core.resources.IResource) Path(org.eclipse.core.runtime.Path) SWT(org.eclipse.swt.SWT) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter) Collections(java.util.Collections) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) StackLayout(org.eclipse.swt.custom.StackLayout) Label(org.eclipse.swt.widgets.Label) FillLayout(org.eclipse.swt.layout.FillLayout) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Example 29 with ImageHyperlink

use of org.eclipse.ui.forms.widgets.ImageHyperlink in project cubrid-manager by CUBRID.

the class NoticeDashboardPage method createActionSection.

@SuppressWarnings("unused")
private void createActionSection(Composite parent) {
    Section section = createStaticSection(parent, Messages.titleCommonAction);
    Composite composite = toolkit.createComposite(section);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    composite.setLayout(gridLayout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    section.setClient(composite);
    GridData data = new GridData(GridData.BEGINNING);
    data.widthHint = 200;
    ImageHyperlink addHost = toolkit.createImageHyperlink(composite, SWT.NONE);
    addHost.setLayoutData(data);
    addHost.setImage(CommonUIPlugin.getImageDescriptor("icons/action/host_add.png").createImage());
    addHost.setText(Messages.titleAddHostBtn);
    addHost.addHyperlinkListener(new IHyperlinkListener() {

        public void linkExited(HyperlinkEvent e) {
        }

        public void linkEntered(HyperlinkEvent e) {
        }

        public void linkActivated(HyperlinkEvent e) {
            ActionManager.getInstance().getAction("com.cubrid.cubridmanager.ui.host.action.AddHostAction").run();
        }
    });
    ImageHyperlink connectHost = toolkit.createImageHyperlink(composite, SWT.NONE);
    connectHost.setLayoutData(data);
    connectHost.setImage(CommonUIPlugin.getImageDescriptor("icons/action/host_connect.png").createImage());
    connectHost.setText(Messages.titleConHostBtn);
    connectHost.addHyperlinkListener(new IHyperlinkListener() {

        public void linkExited(HyperlinkEvent e) {
        }

        public void linkEntered(HyperlinkEvent e) {
        }

        public void linkActivated(HyperlinkEvent e) {
            ActionManager.getInstance().getAction("com.cubrid.cubridmanager.ui.host.action.ConnectHostAction").run();
        }
    });
    ImageHyperlink preferences = toolkit.createImageHyperlink(composite, SWT.NONE);
    preferences.setLayoutData(data);
    preferences.setImage(CommonUIPlugin.getImageDescriptor("icons/action/property.png").createImage());
    preferences.setText(Messages.titlePreferencesBtn);
    preferences.addHyperlinkListener(new IHyperlinkListener() {

        public void linkExited(HyperlinkEvent e) {
        }

        public void linkEntered(HyperlinkEvent e) {
        }

        public void linkActivated(HyperlinkEvent e) {
            ActionManager.getInstance().getAction("preferences").run();
        }
    });
    ImageHyperlink help = toolkit.createImageHyperlink(composite, SWT.NONE);
    help.setLayoutData(data);
    help.setImage(CommonUIPlugin.getImageDescriptor("icons/action/help.png").createImage());
    help.setText(Messages.titleHelpBtn);
    help.addHyperlinkListener(new IHyperlinkListener() {

        public void linkExited(HyperlinkEvent e) {
        }

        public void linkEntered(HyperlinkEvent e) {
        }

        public void linkActivated(HyperlinkEvent e) {
            ActionManager.getInstance().getAction(HelpDocumentAction.ID).run();
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) GridData(org.eclipse.swt.layout.GridData) IHyperlinkListener(org.eclipse.ui.forms.events.IHyperlinkListener) Section(org.eclipse.ui.forms.widgets.Section)

Example 30 with ImageHyperlink

use of org.eclipse.ui.forms.widgets.ImageHyperlink in project eclipse-integration-commons by spring-projects.

the class DashboardMainPage method displayUpdate.

private void displayUpdate(final SyndEntry entry, String severity, Composite composite, int pos, Control[] children) {
    ImageHyperlink link;
    FormText text;
    if (pos < children.length / 2) {
        link = (ImageHyperlink) children[pos * 2];
        link.setVisible(true);
        text = (FormText) children[pos * 2 + 1];
        text.setVisible(true);
    } else {
        link = toolkit.createImageHyperlink(composite, SWT.NONE);
        text = new FormText(composite, SWT.WRAP | SWT.MULTI | SWT.NO_BACKGROUND | SWT.NO_FOCUS);
        text.setHyperlinkSettings(toolkit.getHyperlinkGroup());
        final TableWrapData data = new TableWrapData();
        data.indent = UPDATE_INDENTATION;
        data.maxWidth = updateSection.getSize().x - UPDATE_TEXT_WRAP_INDENT;
        text.setLayoutData(data);
        text.addPaintListener(new PaintListener() {

            public void paintControl(PaintEvent e) {
                data.maxWidth = updateSection.getSize().x - UPDATE_TEXT_WRAP_INDENT;
            }
        });
        text.setBackground(toolkit.getColors().getBackground());
        text.addHyperlinkListener(new HyperlinkAdapter() {

            @Override
            public void linkActivated(HyperlinkEvent e) {
                if (e.data instanceof String) {
                    TasksUiUtil.openUrl((String) e.data);
                }
            }
        });
    }
    link.setText(entry.getTitle());
    TableWrapData linkData = new TableWrapData();
    if ("important".equals(severity)) {
        link.setImage(StsUiImages.getImage(StsUiImages.IMPORTANT));
        linkData.indent = 0;
    } else if ("warning".equals(severity)) {
        link.setImage(StsUiImages.getImage(StsUiImages.WARNING));
        linkData.indent = 0;
    } else {
        // link.setImage(IdeUiPlugin.getImage(ICON_BLOG_BLANK));
        linkData.indent = UPDATE_INDENTATION - 1;
    }
    link.setLayoutData(linkData);
    link.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            String url = entry.getLink();
            if (url == null) {
                return;
            }
            TasksUiUtil.openUrl(url);
        }
    });
    String description = getDescription(entry);
    if (entry.getPublishedDate() != null && description.endsWith("</p></form>")) {
        String dateString = DateFormat.getDateInstance(DateFormat.MEDIUM).format(entry.getPublishedDate());
        description = description.replace("</p></form>", " (" + dateString + ")</p></form>");
    } else if (entry.getPublishedDate() != null) {
        String dateString = DateFormat.getDateInstance(DateFormat.MEDIUM).format(entry.getPublishedDate());
        description = description + " (" + dateString + ")";
    }
    text.setText(description, description.startsWith("<form>"), true);
    text.setForeground(feedColor);
    text.setBackground(toolkit.getColors().getBackground());
    addImages(text, description);
}
Also used : TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) PaintEvent(org.eclipse.swt.events.PaintEvent) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) PaintListener(org.eclipse.swt.events.PaintListener) FormText(org.eclipse.ui.forms.widgets.FormText) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Aggregations

ImageHyperlink (org.eclipse.ui.forms.widgets.ImageHyperlink)50 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)46 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)45 GridLayout (org.eclipse.swt.layout.GridLayout)37 Composite (org.eclipse.swt.widgets.Composite)35 GridData (org.eclipse.swt.layout.GridData)34 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)19 TableViewer (org.eclipse.jface.viewers.TableViewer)17 Section (org.eclipse.ui.forms.widgets.Section)16 TableWrapData (org.eclipse.ui.forms.widgets.TableWrapData)16 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)8 CLabel (org.eclipse.swt.custom.CLabel)7 List (java.util.List)5 Image (org.eclipse.swt.graphics.Image)5 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)4 Control (org.eclipse.swt.widgets.Control)4 Label (org.eclipse.swt.widgets.Label)4 ArrayList (java.util.ArrayList)3 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)3 DisposeEvent (org.eclipse.swt.events.DisposeEvent)3