Search in sources :

Example 31 with ImageHyperlink

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

the class DashboardMainPage method displayFeed.

private void displayFeed(SyndEntry entry, Composite composite, final Section section, final 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 {
        final ImageHyperlink newLink = toolkit.createImageHyperlink(composite, SWT.NONE);
        feedControls.add(newLink);
        link = newLink;
        link.addHyperlinkListener(new HyperlinkAdapter() {

            @Override
            public void linkActivated(HyperlinkEvent e) {
                Object source = e.getSource();
                if (source instanceof ImageHyperlink && ((ImageHyperlink) source).getData() != null) {
                    SyndEntry entry = (SyndEntry) ((ImageHyperlink) source).getData();
                    String url = entry.getLink();
                    if (url == null) {
                        return;
                    }
                    int urlPos = url.indexOf("?");
                    String newUrl = url;
                    if (urlPos > 0) {
                        newUrl = url.substring(0, urlPos + 1) + url.substring(urlPos + 1).replaceAll("\\?", "&");
                    }
                    TasksUiUtil.openUrl(url);
                    prefStore.setValue(IIdeUiConstants.PREF_FEED_ENTRY_READ_STATE + ":" + newUrl, true);
                    IdeUiPlugin.getDefault().savePluginPreferences();
                    newLink.setImage(IdeUiPlugin.getImage(ICON_BLOG_BLANK));
                }
            }
        });
        // text = new Text(composite, SWT.WRAP | SWT.MULTI |
        // SWT.NO_BACKGROUND);
        text = new FormText(composite, SWT.WRAP | SWT.MULTI | SWT.NO_BACKGROUND | SWT.NO_FOCUS);
        text.setHyperlinkSettings(toolkit.getHyperlinkGroup());
        feedControls.add(text);
        final TableWrapData data = new TableWrapData();
        data.indent = UPDATE_INDENTATION;
        data.maxWidth = section.getSize().x - FEEDS_TEXT_WRAP_INDENT;
        data.grabVertical = true;
        text.setLayoutData(data);
        text.addPaintListener(new PaintListener() {

            public void paintControl(PaintEvent e) {
                data.maxWidth = section.getSize().x - FEEDS_TEXT_WRAP_INDENT;
            }
        });
        text.setForeground(feedColor);
        text.setBackground(toolkit.getColors().getBackground());
    }
    String title = entry.getTitle();
    Date entryDate = new Date(0);
    if (entry.getUpdatedDate() != null) {
        entryDate = entry.getUpdatedDate();
    } else {
        entryDate = entry.getPublishedDate();
    }
    String dateString = "";
    if (entryDate != null) {
        dateString = DateFormat.getDateInstance(DateFormat.MEDIUM).format(entryDate);
    }
    String entryAuthor = "";
    if (entry.getAuthor() != null && entry.getAuthor().trim() != "") {
        entryAuthor = " by " + entry.getAuthor();
    }
    if (dateString.length() > 0 && entryAuthor.length() > 0) {
        link.setText(removeHtmlEntities(title));
    }
    TableWrapData linkData = new TableWrapData();
    if (!prefStore.getBoolean(IIdeUiConstants.PREF_FEED_ENTRY_READ_STATE + ":" + entry.getLink())) {
        link.setImage(IdeUiPlugin.getImage(ICON_BLOG_INCOMING));
        linkData.indent = 0;
    } else {
        // link.setImage(IdeUiPlugin.getImage(ICON_BLOG_BLANK));
        linkData.indent = UPDATE_INDENTATION - 1;
    }
    link.setLayoutData(linkData);
    link.setData(entry);
    String description = trimText(getDescription(entry));
    text.setText(description + " (" + dateString + entryAuthor + ")", false, false);
}
Also used : TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) PaintListener(org.eclipse.swt.events.PaintListener) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) FormText(org.eclipse.ui.forms.widgets.FormText) Date(java.util.Date) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 32 with ImageHyperlink

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

the class CommonMultiPageEditor method createViewModeToolbar.

protected void createViewModeToolbar(Composite parent) {
    EditorModeManager manager = (EditorModeManager) getAdapter(EditorModeManager.class);
    final ProductCustomizationProvider productCustomizationProvider = (ProductCustomizationProvider) getAdapter(ProductCustomizationProvider.class);
    EditorMode[] modeList = manager.getModes();
    int modeListLength = modeList.length;
    boolean showToolBar = modeListLength > 1;
    if (showToolBar) {
        toolbar = new Composite(parent, SWT.FLAT | SWT.DRAW_TRANSPARENT);
        toolbar.setBackground(ColorConstants.listBackground);
        toolbar.addPaintListener(new PaintListener() {

            public void paintControl(PaintEvent e) {
                Rectangle clientArea = toolbar.getClientArea();
                e.gc.setForeground(ColorConstants.lightGray);
                e.gc.drawRectangle(clientArea.x, clientArea.y, clientArea.width - 1, clientArea.height - 1);
            }
        });
        GridLayout gridLayout = new GridLayout(3, false);
        toolbar.setLayout(gridLayout);
        Label label = new Label(toolbar, SWT.FLAT | SWT.HORIZONTAL);
        label.setBackground(ColorConstants.listBackground);
        label.setText(Messages._UI_LABEL_VIEW);
        label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));
        modeCombo = new FlatCCombo(toolbar, SWT.FLAT);
        modeCombo.setEditable(false);
        modeCombo.setText(getEditModeName(manager.getCurrentMode(), productCustomizationProvider));
        GC gc = new GC(modeCombo);
        int textWidth = 0;
        maxLength = 0;
        // populate combo with modes
        editorModeAndCustomizedNames = new EditorModeAndCustomizedName[modeListLength];
        for (int i = 0; i < modeListLength; i++) {
            EditorModeAndCustomizedName entry = new EditorModeAndCustomizedName();
            editorModeAndCustomizedNames[i] = entry;
            entry.name = getEditModeName(modeList[i], productCustomizationProvider);
            entry.mode = modeList[i];
        }
        Arrays.sort(editorModeAndCustomizedNames, new Comparator() {

            public int compare(Object arg0, Object arg1) {
                EditorModeAndCustomizedName a = (EditorModeAndCustomizedName) arg0;
                EditorModeAndCustomizedName b = (EditorModeAndCustomizedName) arg1;
                return Collator.getInstance().compare(a.name, b.name);
            }
        });
        for (int i = 0; i < editorModeAndCustomizedNames.length; i++) {
            EditorModeAndCustomizedName entry = editorModeAndCustomizedNames[i];
            modeCombo.add(entry.name);
            maxLength = Math.max(gc.stringExtent(entry.name).x, maxLength);
            int approxWidthOfStrings = Math.max(gc.stringExtent(entry.name).x, textWidth);
            if (approxWidthOfStrings > maxLength)
                maxLength = approxWidthOfStrings;
        }
        maxLength += gc.stringExtent(Messages._UI_LABEL_VIEW).x;
        gc.dispose();
        modeComboListener = new ModeComboListener();
        modeCombo.addSelectionListener(modeComboListener);
        modeCombo.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_END));
        modeCombo.setBackground(toolbar.getBackground());
        ImageHyperlink hyperlink = new ImageHyperlink(toolbar, SWT.FLAT);
        hyperlink.setBackground(ColorConstants.white);
        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=154457
        Image image = XSDEditorPlugin.getDefault().getIconImage("etool16/help_contents");
        hyperlink.setImage(image);
        hyperlink.setToolTipText(Messages._UI_HOVER_VIEW_MODE_DESCRIPTION);
        hyperlink.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));
        hyperlink.addMouseListener(new MouseAdapter() {

            public void mouseDown(MouseEvent e) {
                if (productCustomizationProvider != null) {
                    productCustomizationProvider.handleAction("showEditorModeHelp");
                }
            }
        });
    }
}
Also used : PaintEvent(org.eclipse.swt.events.PaintEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) PaintListener(org.eclipse.swt.events.PaintListener) Rectangle(org.eclipse.swt.graphics.Rectangle) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Image(org.eclipse.swt.graphics.Image) Point(org.eclipse.draw2d.geometry.Point) Comparator(java.util.Comparator) GridLayout(org.eclipse.swt.layout.GridLayout) FlatCCombo(org.eclipse.wst.xsd.ui.internal.adt.design.FlatCCombo) GridData(org.eclipse.swt.layout.GridData) EventObject(java.util.EventObject) GC(org.eclipse.swt.graphics.GC)

Example 33 with ImageHyperlink

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

the class EventConditionEditor method createContent.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.logviewer.widgets.ConditionEditor#createContent(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected void createContent(Composite parent, ColumnFilter initialFilter) {
    Composite group = new Composite(this, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.horizontalSpacing = WidgetHelper.INNER_SPACING;
    layout.numColumns = 2;
    group.setLayout(layout);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    group.setLayoutData(gd);
    objectName = new CLabel(group, SWT.NONE);
    toolkit.adapt(objectName);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.TOP;
    objectName.setLayoutData(gd);
    objectName.setText(EMPTY_SELECTION_TEXT);
    final ImageHyperlink selectionLink = toolkit.createImageHyperlink(group, SWT.NONE);
    selectionLink.setImage(SharedIcons.IMG_FIND);
    selectionLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            selectEvent();
        }
    });
    if ((initialFilter != null) && (initialFilter.getType() == ColumnFilterType.EQUALS)) {
        setSelectedOperation(initialFilter.isNegated() ? 1 : 0);
        eventCode = initialFilter.getNumericValue();
        EventObject o = ConsoleSharedData.getSession().findEventObjectByCode(eventCode);
        if (o != null && o instanceof EventObject) {
            objectName.setText(o.getName());
            objectName.setImage(labelProvider.getImage(o));
        } else {
            objectName.setImage(StatusDisplayInfo.getStatusImage(Severity.UNKNOWN));
            // $NON-NLS-1$ //$NON-NLS-2$
            objectName.setText("[" + eventCode + "]");
        }
    }
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) 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) EventObject(org.netxms.client.events.EventObject) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 34 with ImageHyperlink

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

the class ZoneConditionEditor method createContent.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.logviewer.widgets.ConditionEditor#createContent(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected void createContent(Composite parent, ColumnFilter initialFilter) {
    Composite group = new Composite(this, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.horizontalSpacing = WidgetHelper.INNER_SPACING;
    layout.numColumns = 2;
    group.setLayout(layout);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    group.setLayoutData(gd);
    objectName = new CLabel(group, SWT.NONE);
    toolkit.adapt(objectName);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.TOP;
    objectName.setLayoutData(gd);
    objectName.setText(EMPTY_SELECTION_TEXT);
    final ImageHyperlink selectionLink = toolkit.createImageHyperlink(group, SWT.NONE);
    selectionLink.setImage(SharedIcons.IMG_FIND);
    selectionLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            selectObject();
        }
    });
    if (initialFilter != null) {
        if (initialFilter.getType() == ColumnFilterType.EQUALS) {
            setSelectedOperation(initialFilter.isNegated() ? 1 : 0);
            zoneUin = initialFilter.getNumericValue();
        }
        if (zoneUin != 0) {
            Zone zone = ConsoleSharedData.getSession().findZone(zoneUin);
            if (zone != null) {
                objectName.setText(zone.getObjectName());
                objectName.setImage(labelProvider.getImage(zone));
            } else {
                // $NON-NLS-1$ //$NON-NLS-2$
                objectName.setText("[" + zoneUin + "]");
            }
        }
    }
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) 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) Zone(org.netxms.client.objects.Zone) GridData(org.eclipse.swt.layout.GridData) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 35 with ImageHyperlink

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

the class FilterBuilder method createOrderingSection.

/**
 * Create ordering section
 */
private void createOrderingSection() {
    ordering = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    ordering.setText(Messages.get().FilterBuilder_Ordering);
    TableWrapData twd = new TableWrapData();
    twd.grabHorizontal = false;
    twd.align = TableWrapData.FILL;
    ordering.setLayoutData(twd);
    final Composite clientArea = toolkit.createComposite(ordering);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    clientArea.setLayout(layout);
    ordering.setClient(clientArea);
    orderingList = new TableViewer(clientArea, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    toolkit.adapt(orderingList.getTable());
    TableViewerColumn column = new TableViewerColumn(orderingList, SWT.LEFT);
    column.getColumn().setText(Messages.get().FilterBuilder_Column);
    column.getColumn().setWidth(200);
    column = new TableViewerColumn(orderingList, SWT.LEFT);
    column.getColumn().setText(Messages.get().FilterBuilder_Descending);
    column.getColumn().setWidth(60);
    column.setEditingSupport(new OrderingColumnEditingSupport(orderingList));
    orderingList.getTable().setLinesVisible(true);
    orderingList.getTable().setHeaderVisible(true);
    orderingList.setContentProvider(new ArrayContentProvider());
    orderingList.setLabelProvider(new OrderingListLabelProvider());
    orderingList.setInput(orderingColumns.toArray());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalSpan = 2;
    gd.heightHint = 60;
    orderingList.getControl().setLayoutData(gd);
    final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);
    linkAdd.setText(Messages.get().FilterBuilder_Add);
    linkAdd.setImage(SharedIcons.IMG_ADD_OBJECT);
    linkAdd.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            addSortingColumn(linkAdd);
        }
    });
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    linkAdd.setLayoutData(gd);
    final ImageHyperlink linkRemove = toolkit.createImageHyperlink(clientArea, SWT.NONE);
    linkRemove.setText(Messages.get().FilterBuilder_Remove);
    linkRemove.setImage(SharedIcons.IMG_DELETE_OBJECT);
    linkRemove.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            removeSortingColumn();
        }
    });
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    linkRemove.setLayoutData(gd);
    linkRemove.setEnabled(false);
    orderingList.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            linkRemove.setEnabled(!orderingList.getSelection().isEmpty());
        }
    });
}
Also used : OrderingColumnEditingSupport(org.netxms.ui.eclipse.logviewer.widgets.helpers.OrderingColumnEditingSupport) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) OrderingListLabelProvider(org.netxms.ui.eclipse.logviewer.widgets.helpers.OrderingListLabelProvider) 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