Search in sources :

Example 16 with ImageHyperlink

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

the class DateFieldEditor method createContent.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.reporter.widgets.FieldEditor#createContent(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContent(Composite parent) {
    final ImageCache imageCache = new ImageCache(this);
    final Composite content = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 4;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.horizontalSpacing = WidgetHelper.INNER_SPACING;
    layout.makeColumnsEqualWidth = true;
    content.setLayout(layout);
    Calendar dateTime = Calendar.getInstance();
    try {
        dateTime.setTime(new Date(Long.parseLong(parameter.getDefaultValue()) * 1000));
    } catch (NumberFormatException e) {
        dateTime.setTime(new Date());
    }
    final String[] dateElementNames = { Messages.get().DateFieldEditor_Year, Messages.get().DateFieldEditor_Month, Messages.get().DateFieldEditor_Day };
    dateElements = new Combo[dateElementNames.length];
    for (int idx = 0; idx < dateElementNames.length; idx++) {
        Combo cb = WidgetHelper.createLabeledCombo(content, SWT.BORDER, dateElementNames[idx], WidgetHelper.DEFAULT_LAYOUT_DATA);
        cb.setText(getDateTimeText(idx, dateTime));
        // $NON-NLS-1$
        cb.add("current");
        // $NON-NLS-1$
        cb.add("previous");
        // $NON-NLS-1$
        cb.add("next");
        dateElements[idx] = cb;
    }
    final ImageHyperlink link = toolkit.createImageHyperlink(content, SWT.NONE);
    // $NON-NLS-1$
    link.setImage(imageCache.add(Activator.getImageDescriptor("icons/calendar.png")));
    link.setToolTipText(Messages.get().DateFieldEditor_Calendar);
    link.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            createPopupCalendar(link);
        }
    });
    GridData gd = new GridData();
    gd.verticalAlignment = SWT.BOTTOM;
    gd.horizontalAlignment = SWT.LEFT;
    link.setLayoutData(gd);
    return content;
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) Calendar(java.util.Calendar) Combo(org.eclipse.swt.widgets.Combo) Date(java.util.Date) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) ImageCache(org.netxms.ui.eclipse.tools.ImageCache) GridData(org.eclipse.swt.layout.GridData) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 17 with ImageHyperlink

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

the class EventFieldEditor method createContent.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.reporter.widgets.FieldEditor#createContent(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContent(Composite parent) {
    Composite content = toolkit.createComposite(parent, SWT.BORDER);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.horizontalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    content.setLayout(layout);
    text = new CLabel(content, SWT.NONE);
    toolkit.adapt(text);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.TOP;
    text.setLayoutData(gd);
    text.setText(EMPTY_SELECTION_TEXT);
    final ImageHyperlink selectionLink = toolkit.createImageHyperlink(content, SWT.NONE);
    selectionLink.setImage(SharedIcons.IMG_FIND);
    selectionLink.setToolTipText(Messages.get().EventFieldEditor_SelectEvent);
    selectionLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            selectEvent();
        }
    });
    final ImageHyperlink clearLink = toolkit.createImageHyperlink(content, SWT.NONE);
    clearLink.setImage(SharedIcons.IMG_CLEAR);
    clearLink.setToolTipText(Messages.get().EventFieldEditor_ClearSelection);
    clearLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            eventCode = 0;
            text.setText(EMPTY_SELECTION_TEXT);
            text.setImage(null);
        }
    });
    return content;
}
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) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 18 with ImageHyperlink

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

the class SnmpCredentials method createSnmpCommunitySection.

/**
 * Create "SNMP Communities" section
 */
private void createSnmpCommunitySection() {
    Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TITLE_BAR);
    section.setText(Messages.get().SnmpConfigurator_SectionCommunities);
    section.setDescription(Messages.get().SnmpConfigurator_SectionCommunitiesDescr);
    TableWrapData td = new TableWrapData();
    td.align = TableWrapData.FILL;
    td.grabHorizontal = true;
    section.setLayoutData(td);
    Composite clientArea = toolkit.createComposite(section);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    clientArea.setLayout(layout);
    section.setClient(clientArea);
    snmpCommunityList = new TableViewer(clientArea, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    toolkit.adapt(snmpCommunityList.getTable());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.verticalSpan = 2;
    gd.heightHint = 150;
    snmpCommunityList.getTable().setLayoutData(gd);
    snmpCommunityList.getTable().setSortDirection(SWT.UP);
    snmpCommunityList.setContentProvider(new ArrayContentProvider());
    snmpCommunityList.setComparator(new StringComparator());
    final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);
    linkAdd.setText(Messages.get().SnmpConfigurator_Add);
    linkAdd.setImage(SharedIcons.IMG_ADD_OBJECT);
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    linkAdd.setLayoutData(gd);
    linkAdd.addHyperlinkListener(new HyperlinkAdapter() {

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

        @Override
        public void linkActivated(HyperlinkEvent e) {
            removeCommunity();
        }
    });
}
Also used : TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) 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) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Section(org.eclipse.ui.forms.widgets.Section) TableViewer(org.eclipse.jface.viewers.TableViewer) StringComparator(org.netxms.ui.eclipse.tools.StringComparator) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 19 with ImageHyperlink

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

the class ExportFileBuilder method createScriptSection.

/**
 * Create "Scripts" section
 */
private void createScriptSection() {
    Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    section.setText("Scripts");
    TableWrapData td = new TableWrapData();
    td.align = TableWrapData.FILL;
    td.grabHorizontal = true;
    section.setLayoutData(td);
    Composite clientArea = toolkit.createComposite(section);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    clientArea.setLayout(layout);
    section.setClient(clientArea);
    scriptViewer = new TableViewer(clientArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    toolkit.adapt(ruleViewer.getTable());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.heightHint = 200;
    gd.verticalSpan = 2;
    scriptViewer.getTable().setLayoutData(gd);
    scriptViewer.setContentProvider(new ArrayContentProvider());
    scriptViewer.setLabelProvider(new ScriptLabelProvider());
    scriptViewer.setComparator(new ScriptComparator());
    scriptViewer.getTable().setSortDirection(SWT.UP);
    final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);
    linkAdd.setText(Messages.get().ExportFileBuilder_Add);
    linkAdd.setImage(SharedIcons.IMG_ADD_OBJECT);
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    linkAdd.setLayoutData(gd);
    linkAdd.addHyperlinkListener(new HyperlinkAdapter() {

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

        @Override
        public void linkActivated(HyperlinkEvent e) {
            removeObjects(scriptViewer, scripts);
        }
    });
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) Section(org.eclipse.ui.forms.widgets.Section) ScriptLabelProvider(org.netxms.ui.eclipse.serverconfig.views.helpers.ScriptLabelProvider) TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ScriptComparator(org.netxms.ui.eclipse.serverconfig.views.helpers.ScriptComparator) TableViewer(org.eclipse.jface.viewers.TableViewer) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 20 with ImageHyperlink

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

the class ExportFileBuilder method createRuleSection.

/**
 * Create "Rules" section
 */
private void createRuleSection() {
    Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    section.setText(Messages.get().ExportFileBuilder_SectionRules);
    TableWrapData td = new TableWrapData();
    td.align = TableWrapData.FILL;
    td.grabHorizontal = true;
    section.setLayoutData(td);
    Composite clientArea = toolkit.createComposite(section);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    clientArea.setLayout(layout);
    section.setClient(clientArea);
    ruleViewer = new TableViewer(clientArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    ruleViewer.getTable().setLinesVisible(true);
    ruleViewer.getTable().setHeaderVisible(true);
    TableColumn column = new TableColumn(ruleViewer.getTable(), SWT.LEFT);
    column.setText("Rule #");
    column.setWidth(60);
    column = new TableColumn(ruleViewer.getTable(), SWT.LEFT);
    column.setText("Rule Name");
    column.setWidth(250);
    toolkit.adapt(ruleViewer.getTable());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.heightHint = 200;
    gd.verticalSpan = 2;
    ruleViewer.getTable().setLayoutData(gd);
    ruleViewer.setContentProvider(new ArrayContentProvider());
    ruleViewer.setLabelProvider(new RuleLabelProvider());
    ruleViewer.setComparator(new RuleComparator());
    ruleViewer.getTable().setSortDirection(SWT.UP);
    final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);
    linkAdd.setText(Messages.get().ExportFileBuilder_Add);
    linkAdd.setImage(SharedIcons.IMG_ADD_OBJECT);
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    linkAdd.setLayoutData(gd);
    linkAdd.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            if (rulesCache == null) {
                new ConsoleJob(Messages.get().ExportFileBuilder_EPPLoadJobName, ExportFileBuilder.this, Activator.PLUGIN_ID, null) {

                    @Override
                    protected void runInternal(IProgressMonitor monitor) throws Exception {
                        rulesCache = session.getEventProcessingPolicy().getRules();
                        runInUIThread(new Runnable() {

                            @Override
                            public void run() {
                                addRules();
                            }
                        });
                    }

                    @Override
                    protected String getErrorMessage() {
                        return Messages.get().ExportFileBuilder_EPPLoadJobError;
                    }
                }.start();
            } else {
                addRules();
            }
        }
    });
    final ImageHyperlink linkRemove = toolkit.createImageHyperlink(clientArea, SWT.NONE);
    linkRemove.setText(Messages.get().ExportFileBuilder_Remove);
    linkRemove.setImage(SharedIcons.IMG_DELETE_OBJECT);
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    linkRemove.setLayoutData(gd);
    linkRemove.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            removeObjects(ruleViewer, rules);
        }
    });
}
Also used : RuleComparator(org.netxms.ui.eclipse.serverconfig.views.helpers.RuleComparator) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) Section(org.eclipse.ui.forms.widgets.Section) TableColumn(org.eclipse.swt.widgets.TableColumn) TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RuleLabelProvider(org.netxms.ui.eclipse.serverconfig.views.helpers.RuleLabelProvider) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) TableViewer(org.eclipse.jface.viewers.TableViewer) 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