Search in sources :

Example 61 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project netxms by netxms.

the class EventProcessingPolicyEditor method createPartControl.

/*
    * (non-Javadoc)
    * 
    * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
    */
@Override
public void createPartControl(Composite parent) {
    session = (NXCSession) ConsoleSharedData.getSession();
    IDialogSettings settings = Activator.getDefault().getDialogSettings();
    // $NON-NLS-1$
    filterEnabled = settings.getBoolean("EventProcessingPolicyEditor.filterEnabled");
    // Initiate loading of required plugins if they was not loaded yet
    try {
        // $NON-NLS-1$
        Platform.getAdapterManager().loadAdapter(new EventTemplate(0), "org.eclipse.ui.model.IWorkbenchAdapter");
        // $NON-NLS-1$
        Platform.getAdapterManager().loadAdapter(new ServerAction(0), "org.eclipse.ui.model.IWorkbenchAdapter");
        // $NON-NLS-1$
        Platform.getAdapterManager().loadAdapter(session.getTopLevelObjects()[0], "org.eclipse.ui.model.IWorkbenchAdapter");
    } catch (Exception e) {
    }
    // $NON-NLS-1$
    imageStop = Activator.getImageDescriptor("icons/stop.png").createImage();
    // $NON-NLS-1$
    imageAlarm = Activator.getImageDescriptor("icons/alarm.png").createImage();
    // $NON-NLS-1$
    imageSituation = Activator.getImageDescriptor("icons/situation.gif").createImage();
    // $NON-NLS-1$
    imageExecute = Activator.getImageDescriptor("icons/execute.png").createImage();
    // $NON-NLS-1$
    imageTerminate = Activator.getImageDescriptor("icons/terminate.png").createImage();
    imageCollapse = SharedIcons.COLLAPSE.createImage();
    imageExpand = SharedIcons.EXPAND.createImage();
    imageEdit = SharedIcons.EDIT.createImage();
    parent.setLayout(new FormLayout());
    // Create filter area
    filterControl = new FilterText(parent, SWT.NONE);
    filterControl.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            onFilterModify();
        }
    });
    filterControl.setCloseAction(new Action() {

        @Override
        public void run() {
            enableFilter(false);
        }
    });
    scroller = new ScrolledComposite(parent, SWT.V_SCROLL);
    dataArea = new Composite(scroller, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    dataArea.setLayout(layout);
    dataArea.setBackground(BACKGROUND_COLOR);
    scroller.setContent(dataArea);
    scroller.setExpandVertical(true);
    scroller.setExpandHorizontal(true);
    scroller.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            Rectangle r = scroller.getClientArea();
            scroller.setMinSize(dataArea.computeSize(r.width, SWT.DEFAULT));
        }
    });
    // Setup layout
    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(filterControl);
    fd.right = new FormAttachment(100, 0);
    fd.bottom = new FormAttachment(100, 0);
    scroller.setLayoutData(fd);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    filterControl.setLayoutData(fd);
    normalFont = JFaceResources.getDefaultFont();
    boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
    sessionListener = new SessionListener() {

        @Override
        public void notificationHandler(SessionNotification n) {
            processSessionNotification(n);
        }
    };
    session.addListener(sessionListener);
    selection = new TreeSet<RuleEditor>(new Comparator<RuleEditor>() {

        @Override
        public int compare(RuleEditor arg0, RuleEditor arg1) {
            return arg0.getRuleNumber() - arg1.getRuleNumber();
        }
    });
    createActions();
    contributeToActionBars();
    openEventProcessingPolicy();
    activateContext();
    // Set initial focus to filter input line
    if (filterEnabled)
        filterControl.setFocus();
    else
        // Will hide filter area correctly
        enableFilter(false);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ServerAction(org.netxms.client.ServerAction) Action(org.eclipse.jface.action.Action) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) EventTemplate(org.netxms.client.events.EventTemplate) Rectangle(org.eclipse.swt.graphics.Rectangle) Comparator(java.util.Comparator) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) FilterText(org.netxms.ui.eclipse.widgets.FilterText) SessionListener(org.netxms.client.SessionListener) RuleEditor(org.netxms.ui.eclipse.epp.widgets.RuleEditor) ControlEvent(org.eclipse.swt.events.ControlEvent) ServerAction(org.netxms.client.ServerAction) SessionNotification(org.netxms.client.SessionNotification) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 62 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project netxms by netxms.

the class ChildObjectListDialog method createDialogArea.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    AbstractObject object = ((NXCSession) ConsoleSharedData.getSession()).findObjectById(parentObject);
    AbstractObject[] sourceObjects = (object != null) ? object.getChildsAsArray() : new AbstractObject[0];
    GridLayout layout = new GridLayout();
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    dialogArea.setLayout(layout);
    // Create filter area
    Composite filterArea = new Composite(dialogArea, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.horizontalSpacing = WidgetHelper.INNER_SPACING;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    filterArea.setLayout(layout);
    filterArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Label filterLabel = new Label(filterArea, SWT.NONE);
    filterLabel.setText(Messages.get().ChildObjectListDialog_Filter);
    filterText = new Text(filterArea, SWT.BORDER);
    filterText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    filterText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            filter.setFilterString(filterText.getText());
            objectList.refresh(false);
            AbstractObject obj = filter.getLastMatch();
            if (obj != null) {
                objectList.setSelection(new StructuredSelection(obj), true);
                objectList.reveal(obj);
            }
        }
    });
    // Create object list
    objectList = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    TableColumn tc = new TableColumn(objectList.getTable(), SWT.LEFT);
    tc.setText(Messages.get().ChildObjectListDialog_Name);
    tc.setWidth(280);
    objectList.getTable().setHeaderVisible(false);
    objectList.setContentProvider(new ArrayContentProvider());
    objectList.setLabelProvider(new WorkbenchLabelProvider());
    objectList.setComparator(new ViewerComparator());
    filter = new ObjectFilter(null, sourceObjects, classFilter);
    objectList.addFilter(filter);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    objectList.getControl().setLayoutData(gd);
    objectList.getTable().addControlListener(new ControlListener() {

        @Override
        public void controlMoved(ControlEvent e) {
        }

        @Override
        public void controlResized(ControlEvent e) {
            Table table = objectList.getTable();
            int w = table.getSize().x - table.getBorderWidth() * 2;
            ScrollBar sc = table.getVerticalBar();
            if ((sc != null) && sc.isVisible())
                w -= sc.getSize().x;
            table.getColumn(0).setWidth(w);
        }
    });
    if (object != null)
        objectList.setInput(sourceObjects);
    filterText.setFocus();
    return dialogArea;
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) NXCSession(org.netxms.client.NXCSession) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Text(org.eclipse.swt.widgets.Text) ObjectFilter(org.netxms.ui.eclipse.objectbrowser.widgets.internal.ObjectFilter) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) AbstractObject(org.netxms.client.objects.AbstractObject) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 63 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project netxms by netxms.

the class RackTab method createTabContent.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected void createTabContent(Composite parent) {
    scroller = new ScrolledComposite(parent, SWT.H_SCROLL);
    content = new Composite(scroller, SWT.NONE) {

        @Override
        public Point computeSize(int wHint, int hHint, boolean changed) {
            if ((rackFrontWidget == null) || (rackRearWidget == null) || (hHint == SWT.DEFAULT))
                return super.computeSize(wHint, hHint, changed);
            Point s = rackFrontWidget.computeSize(wHint, hHint, changed);
            return new Point(s.x * 2, s.y);
        }
    };
    content.setBackground(SharedColors.getColor(SharedColors.RACK_BACKGROUND, parent.getDisplay()));
    content.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            if ((rackFrontWidget == null) || (rackRearWidget == null))
                return;
            updateRackWidgetsSize();
        }
    });
    scroller.setContent(content);
    scroller.setExpandHorizontal(true);
    scroller.setExpandVertical(true);
    scroller.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            scroller.setMinSize(content.computeSize(SWT.DEFAULT, scroller.getSize().y));
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Point(org.eclipse.swt.graphics.Point) ControlEvent(org.eclipse.swt.events.ControlEvent) Point(org.eclipse.swt.graphics.Point)

Example 64 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project netxms by netxms.

the class ObjectOverview method createTabContent.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected void createTabContent(Composite parent) {
    scroller = new ScrolledComposite(parent, SWT.V_SCROLL);
    scroller.setExpandVertical(true);
    scroller.setExpandHorizontal(true);
    // FIXME: scroller.getVerticalBar().setIncrement(20);
    scroller.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            Rectangle r = scroller.getClientArea();
            scroller.setMinSize(viewArea.computeSize(r.width, SWT.DEFAULT));
            objectChanged(getObject());
        }
    });
    viewArea = new Composite(scroller, SWT.NONE);
    viewArea.setBackground(SharedColors.getColor(SharedColors.OBJECT_TAB_BACKGROUND, parent.getDisplay()));
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    viewArea.setLayout(layout);
    scroller.setContent(viewArea);
    leftColumn = new Composite(viewArea, SWT.NONE);
    leftColumn.setLayout(createColumnLayout());
    leftColumn.setBackground(SharedColors.getColor(SharedColors.OBJECT_TAB_BACKGROUND, parent.getDisplay()));
    GridData gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    leftColumn.setLayoutData(gd);
    rightColumn = new Composite(viewArea, SWT.NONE);
    rightColumn.setLayout(createColumnLayout());
    rightColumn.setBackground(SharedColors.getColor(SharedColors.OBJECT_TAB_BACKGROUND, parent.getDisplay()));
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    gd.horizontalAlignment = SWT.LEFT;
    gd.grabExcessHorizontalSpace = true;
    gd.minimumWidth = SWT.DEFAULT;
    rightColumn.setLayoutData(gd);
    OverviewPageElement e = new GeneralInfo(leftColumn, null, this);
    elements.add(e);
    e = new LastValues(leftColumn, e, this);
    elements.add(e);
    e = new Commands(leftColumn, e, this);
    elements.add(e);
    e = new AvailabilityChart(leftColumn, e, this);
    elements.add(e);
    e = new ExternalResources(leftColumn, e, this);
    elements.add(e);
    e = new Comments(leftColumn, e, this);
    elements.add(e);
    e = new Capabilities(rightColumn, null, this);
    elements.add(e);
    e = new Connection(rightColumn, e, this);
    elements.add(e);
}
Also used : AvailabilityChart(org.netxms.ui.eclipse.objectview.objecttabs.elements.AvailabilityChart) ControlAdapter(org.eclipse.swt.events.ControlAdapter) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) OverviewPageElement(org.netxms.ui.eclipse.objectview.objecttabs.elements.OverviewPageElement) Comments(org.netxms.ui.eclipse.objectview.objecttabs.elements.Comments) Rectangle(org.eclipse.swt.graphics.Rectangle) Connection(org.netxms.ui.eclipse.objectview.objecttabs.elements.Connection) GeneralInfo(org.netxms.ui.eclipse.objectview.objecttabs.elements.GeneralInfo) GridLayout(org.eclipse.swt.layout.GridLayout) Capabilities(org.netxms.ui.eclipse.objectview.objecttabs.elements.Capabilities) GridData(org.eclipse.swt.layout.GridData) LastValues(org.netxms.ui.eclipse.objectview.objecttabs.elements.LastValues) Commands(org.netxms.ui.eclipse.objectview.objecttabs.elements.Commands) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlEvent(org.eclipse.swt.events.ControlEvent) ExternalResources(org.netxms.ui.eclipse.objectview.objecttabs.elements.ExternalResources)

Example 65 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project netxms by netxms.

the class AddressMap method createTabContent.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected void createTabContent(Composite parent) {
    scroller = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    addressMap = new SubnetAddressMap(scroller, SWT.NONE, getViewPart(), new VisibilityValidator() {

        @Override
        public boolean isVisible() {
            return isActive();
        }
    });
    scroller.setContent(addressMap);
    scroller.setExpandVertical(true);
    scroller.setExpandHorizontal(true);
    scroller.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            scroller.setMinSize(addressMap.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        }
    });
}
Also used : VisibilityValidator(org.netxms.ui.eclipse.tools.VisibilityValidator) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) SubnetAddressMap(org.netxms.ui.eclipse.topology.widgets.SubnetAddressMap) ControlEvent(org.eclipse.swt.events.ControlEvent)

Aggregations

ControlEvent (org.eclipse.swt.events.ControlEvent)187 ControlAdapter (org.eclipse.swt.events.ControlAdapter)135 Composite (org.eclipse.swt.widgets.Composite)76 GridData (org.eclipse.swt.layout.GridData)67 ControlListener (org.eclipse.swt.events.ControlListener)54 GridLayout (org.eclipse.swt.layout.GridLayout)50 SelectionEvent (org.eclipse.swt.events.SelectionEvent)49 TableColumn (org.eclipse.swt.widgets.TableColumn)42 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)41 Point (org.eclipse.swt.graphics.Point)38 Table (org.eclipse.swt.widgets.Table)37 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)36 FillLayout (org.eclipse.swt.layout.FillLayout)35 Tree (org.eclipse.swt.widgets.Tree)35 TreeViewer (org.eclipse.jface.viewers.TreeViewer)33 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)32 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)31 AdapterFactoryTreeEditor (org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor)30 AdapterFactoryContentProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider)30 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)30