Search in sources :

Example 76 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project m2e-core by eclipse-m2e.

the class OverviewPage method createModulesSection.

private void createModulesSection(FormToolkit toolkit, Composite composite, WidthGroup widthGroup) {
    // XXX should disable Modules actions based on artifact packaging and only add modules when packaging is "pom"
    modulesSection = // 
    toolkit.createSection(// 
    composite, ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE);
    GridData moduleSectionData = new GridData(SWT.FILL, SWT.FILL, true, true);
    modulesSection.setLayoutData(moduleSectionData);
    modulesSection.setText(Messages.OverviewPage_section_modules);
    // $NON-NLS-1$ //$NON-NLS-2$
    modulesSection.setData("name", "modulesSection");
    modulesSection.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            moduleSectionData.grabExcessVerticalSpace = e.getState();
            modulesSection.getParent().layout();
        }
    });
    modulesSectionComposite = toolkit.createComposite(modulesSection);
    modulesStack = new StackLayout();
    modulesSectionComposite.setLayout(modulesStack);
    modulesSection.setClient(modulesSectionComposite);
    noModules = toolkit.createComposite(modulesSectionComposite);
    noModules.setLayout(new GridLayout(1, false));
    Label label = toolkit.createLabel(noModules, Messages.OverviewPage_msg_not_pom_packaging);
    GridData gd_label = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
    gd_label.verticalIndent = 12;
    gd_label.horizontalIndent = 12;
    label.setLayoutData(gd_label);
    modulesEditor = new ListEditorComposite<>(modulesSectionComposite, SWT.NONE, true);
    // $NON-NLS-1$ //$NON-NLS-2$
    modulesEditor.getViewer().getTable().setData("name", "modulesEditor");
    toolkit.paintBordersFor(modulesEditor);
    toolkit.adapt(modulesEditor);
    modulesEditor.setContentProvider(new ListEditorContentProvider<>());
    modulesEditor.setLabelProvider(new ModulesLabelProvider(this));
    modulesEditor.setOpenListener(openevent -> {
        final List<String> selection = modulesEditor.getSelection();
        new Job(Messages.OverviewPage_opening_editors) {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
                for (String module : selection) {
                    IMavenProjectFacade projectFacade = findModuleProject(module);
                    if (projectFacade != null) {
                        ArtifactKey key = projectFacade.getArtifactKey();
                        OpenPomAction.openEditor(key.getGroupId(), key.getArtifactId(), key.getVersion(), getPomEditor().getMavenProject(), monitor);
                    } else {
                        IFile modulePom = findModuleFile(module);
                        if (modulePom != null && modulePom.isAccessible()) {
                            // $NON-NLS-1$
                            OpenPomAction.openEditor(new FileEditorInput(modulePom), "pom.xml");
                        }
                    }
                }
                return Status.OK_STATUS;
            }
        }.schedule();
    });
    modulesEditor.setAddButtonListener(SelectionListener.widgetSelectedAdapter(e -> {
        final Set<Object> moduleContainers = new HashSet<>();
        final List<String> modules = new ArrayList<>();
        try {
            performOnDOMDocument(new OperationTuple(getPomEditor().getDocument(), document -> {
                Element modsEl = findChild(document.getDocumentElement(), MODULES);
                for (Element el : findChilds(modsEl, MODULE)) {
                    String m = getTextValue(el);
                    if (m != null) {
                        modules.add(m);
                    }
                }
            }, true));
        } catch (Exception e1) {
            LOG.error("Cannot load modules", e1);
        }
        for (String module : modules) {
            IMavenProjectFacade facade = findModuleProject(module);
            if (facade != null) {
                moduleContainers.add(facade.getProject().getLocation());
            }
            IFile file = findModuleFile(module);
            if (file != null) {
                moduleContainers.add(file.getParent().getLocation());
            }
        }
        moduleContainers.add(getProject().getLocation());
        MavenModuleSelectionDialog dialog = new MavenModuleSelectionDialog(getSite().getShell(), moduleContainers);
        if (dialog.open() == Window.OK) {
            addSelectedModules(dialog.getResult(), dialog.isPomUpdateRequired());
        }
    }));
    modulesEditor.setCreateButtonListener(SelectionListener.widgetSelectedAdapter(e -> {
        IEditorInput editorInput = OverviewPage.this.pomEditor.getEditorInput();
        if (editorInput instanceof FileEditorInput) {
            MavenModuleWizard wizard = new MavenModuleWizard(true);
            wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(((FileEditorInput) editorInput).getFile()));
            WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
            int res = dialog.open();
            if (res == Window.OK) {
                createNewModule(wizard.getModuleName());
            }
        }
    }));
    modulesEditor.setRemoveButtonListener(SelectionListener.widgetSelectedAdapter(e -> {
        try {
            performEditOperation(document -> {
                Element root = document.getDocumentElement();
                Element modules = findChild(root, MODULES);
                if (modules != null) {
                    for (String module : modulesEditor.getSelection()) {
                        Element modEl = findChild(modules, MODULE, textEquals(module));
                        if (modEl != null) {
                            modules.removeChild(modEl);
                        }
                    }
                    // now remove the <modules> element itself when there are no more elements left
                    removeIfNoChildElement(modules);
                }
            }, LOG, "error removing module entry");
        } finally {
            loadThis(RELOAD_MODULES);
        }
    }));
    modulesEditor.setCellModifier(new ICellModifier() {

        @Override
        public boolean canModify(Object element, String property) {
            return true;
        }

        @Override
        public Object getValue(Object element, String property) {
            return element;
        }

        @Override
        public void modify(Object element, String property, final Object value) {
            final int n = modulesEditor.getViewer().getTable().getSelectionIndex();
            try {
                performEditOperation(document -> {
                    Element root = document.getDocumentElement();
                    Element module = findChild(findChild(root, MODULES), MODULE, childAt(n));
                    if (module != null && !value.equals(getTextValue(module))) {
                        setText(module, value.toString());
                    }
                }, LOG, "error changing module entry");
            } finally {
                loadThis(RELOAD_MODULES);
            }
        }
    });
    modulesEditor.getViewer().addDropSupport(DND.DROP_COPY | DND.DROP_LINK | DND.DROP_MOVE, new Transfer[] { ResourceTransfer.getInstance() }, new DropTargetAdapter() {

        @Override
        public void dragEnter(DropTargetEvent event) {
            event.detail = DND.DROP_LINK;
        }

        @Override
        public void dragOperationChanged(DropTargetEvent event) {
            event.detail = DND.DROP_LINK;
        }

        @Override
        public void drop(DropTargetEvent event) {
            if (event.data instanceof Object[]) {
                addSelectedModules((Object[]) event.data, true);
            }
        }
    });
    newModuleElementAction = new Action(Messages.OverviewPage_action_newModuleElement, MavenImages.NEW_POM) {

        @Override
        public void run() {
            // $NON-NLS-1$
            createNewModule("?");
        }
    };
    // newModuleProjectAction = new Action(Messages.OverviewPage_action_new_module_project, MavenEditorImages.ADD_MODULE) {
    // public void run() {
    // IEditorInput editorInput = OverviewPage.this.pomEditor.getEditorInput();
    // if(editorInput instanceof FileEditorInput) {
    // MavenModuleWizard wizard = new MavenModuleWizard(true);
    // wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(((FileEditorInput) editorInput).getFile()));
    // WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
    // int res = dialog.open();
    // if(res == Window.OK) {
    // createNewModule(wizard.getModuleName());
    // }
    // }
    // }
    // };
    ToolBarManager modulesToolBarManager = new ToolBarManager(SWT.FLAT);
    modulesToolBarManager.add(newModuleElementAction);
    // modulesToolBarManager.add(newModuleProjectAction);
    Composite toolbarComposite = toolkit.createComposite(modulesSection);
    GridLayout toolbarLayout = new GridLayout(1, true);
    toolbarLayout.marginHeight = 0;
    toolbarLayout.marginWidth = 0;
    toolbarComposite.setLayout(toolbarLayout);
    toolbarComposite.setBackground(null);
    modulesToolBarManager.createControl(toolbarComposite);
    modulesSection.setTextClient(toolbarComposite);
    modulesEditor.setReadOnly(pomEditor.isReadOnly());
    newModuleElementAction.setEnabled(!pomEditor.isReadOnly());
// newModuleProjectAction.setEnabled(!pomEditor.isReadOnly());
}
Also used : Notification(org.eclipse.emf.common.notify.Notification) MavenModuleWizard(org.eclipse.m2e.core.ui.internal.wizards.MavenModuleWizard) DND(org.eclipse.swt.dnd.DND) CoreException(org.eclipse.core.runtime.CoreException) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) RELATIVE_PATH(org.eclipse.m2e.core.ui.internal.editing.PomEdits.RELATIVE_PATH) Document(org.w3c.dom.Document) Composite(org.eclipse.swt.widgets.Composite) SCM(org.eclipse.m2e.core.ui.internal.editing.PomEdits.SCM) PomEdits.removeChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeChild) Text(org.eclipse.swt.widgets.Text) M2EUIUtils(org.eclipse.m2e.core.ui.internal.util.M2EUIUtils) IEditorInput(org.eclipse.ui.IEditorInput) PlatformUI(org.eclipse.ui.PlatformUI) Set(java.util.Set) Status(org.eclipse.core.runtime.Status) ResourceTransfer(org.eclipse.ui.part.ResourceTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Window(org.eclipse.jface.window.Window) NAME(org.eclipse.m2e.core.ui.internal.editing.PomEdits.NAME) PomEdits.createElementWithText(org.eclipse.m2e.core.ui.internal.editing.PomEdits.createElementWithText) MavenImages(org.eclipse.m2e.core.ui.internal.MavenImages) PomEdits.removeIfNoChildElement(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeIfNoChildElement) Path(org.eclipse.core.runtime.Path) SWT(org.eclipse.swt.SWT) CI_MANAGEMENT(org.eclipse.m2e.core.ui.internal.editing.PomEdits.CI_MANAGEMENT) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Operation(org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation) SelectionListener(org.eclipse.swt.events.SelectionListener) ISSUE_MANAGEMENT(org.eclipse.m2e.core.ui.internal.editing.PomEdits.ISSUE_MANAGEMENT) URL(org.eclipse.m2e.core.ui.internal.editing.PomEdits.URL) PARENT(org.eclipse.m2e.core.ui.internal.editing.PomEdits.PARENT) StringLabelProvider(org.eclipse.m2e.editor.composites.StringLabelProvider) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) PomEdits(org.eclipse.m2e.core.ui.internal.editing.PomEdits) PomEdits.getChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.getChild) ArrayList(java.util.ArrayList) IContainer(org.eclipse.core.resources.IContainer) IMavenConstants(org.eclipse.m2e.core.internal.IMavenConstants) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) INCEPTION_YEAR(org.eclipse.m2e.core.ui.internal.editing.PomEdits.INCEPTION_YEAR) VERSION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.VERSION) MavenRepositorySearchDialog(org.eclipse.m2e.core.ui.internal.dialogs.MavenRepositorySearchDialog) IFile(org.eclipse.core.resources.IFile) GridData(org.eclipse.swt.layout.GridData) OpenPomAction(org.eclipse.m2e.core.ui.internal.actions.OpenPomAction) LinkedHashSet(java.util.LinkedHashSet) Section(org.eclipse.ui.forms.widgets.Section) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) FileEditorInput(org.eclipse.ui.part.FileEditorInput) StackLayout(org.eclipse.swt.custom.StackLayout) ListEditorContentProvider(org.eclipse.m2e.editor.composites.ListEditorContentProvider) FormUtils.setText(org.eclipse.m2e.editor.pom.FormUtils.setText) PROPERTIES(org.eclipse.m2e.core.ui.internal.editing.PomEdits.PROPERTIES) Plugin(org.apache.maven.model.Plugin) ModifyListener(org.eclipse.swt.events.ModifyListener) DocumentBuilder(javax.xml.parsers.DocumentBuilder) MODULES(org.eclipse.m2e.core.ui.internal.editing.PomEdits.MODULES) MavenEditorImages(org.eclipse.m2e.editor.MavenEditorImages) GridLayout(org.eclipse.swt.layout.GridLayout) ArtifactKey(org.eclipse.m2e.core.embedder.ArtifactKey) LoggerFactory(org.slf4j.LoggerFactory) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) JarFile(java.util.jar.JarFile) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) MavenModuleSelectionDialog(org.eclipse.m2e.editor.dialogs.MavenModuleSelectionDialog) PomEdits.getTextValue(org.eclipse.m2e.core.ui.internal.editing.PomEdits.getTextValue) IStatus(org.eclipse.core.runtime.IStatus) PomEdits.performOnDOMDocument(org.eclipse.m2e.core.ui.internal.editing.PomEdits.performOnDOMDocument) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) MavenPluginActivator(org.eclipse.m2e.core.internal.MavenPluginActivator) IPath(org.eclipse.core.runtime.IPath) ARTIFACT_ID(org.eclipse.m2e.core.ui.internal.editing.PomEdits.ARTIFACT_ID) OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) TAG(org.eclipse.m2e.core.ui.internal.editing.PomEdits.TAG) Artifact(org.apache.maven.artifact.Artifact) ListEditorComposite(org.eclipse.m2e.editor.composites.ListEditorComposite) PomEdits.setText(org.eclipse.m2e.core.ui.internal.editing.PomEdits.setText) CCombo(org.eclipse.swt.custom.CCombo) Messages(org.eclipse.m2e.editor.internal.Messages) PomEdits.format(org.eclipse.m2e.core.ui.internal.editing.PomEdits.format) NLS(org.eclipse.osgi.util.NLS) WidthGroup(org.eclipse.m2e.core.ui.internal.wizards.WidthGroup) Display(org.eclipse.swt.widgets.Display) IManagedForm(org.eclipse.ui.forms.IManagedForm) MODULE(org.eclipse.m2e.core.ui.internal.editing.PomEdits.MODULE) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) List(java.util.List) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) PomEdits.textEquals(org.eclipse.m2e.core.ui.internal.editing.PomEdits.textEquals) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SYSTEM(org.eclipse.m2e.core.ui.internal.editing.PomEdits.SYSTEM) Label(org.eclipse.swt.widgets.Label) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) PomEdits.findChilds(org.eclipse.m2e.core.ui.internal.editing.PomEdits.findChilds) ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) CONNECTION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.CONNECTION) ORGANIZATION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.ORGANIZATION) Image(org.eclipse.swt.graphics.Image) PACKAGING(org.eclipse.m2e.core.ui.internal.editing.PomEdits.PACKAGING) HashSet(java.util.HashSet) ProposalUtil(org.eclipse.m2e.core.ui.internal.util.ProposalUtil) JarEntry(java.util.jar.JarEntry) DESCRIPTION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.DESCRIPTION) GROUP_ID(org.eclipse.m2e.core.ui.internal.editing.PomEdits.GROUP_ID) Node(org.w3c.dom.Node) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) PomEdits.findChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.findChild) FormUtils.nvl(org.eclipse.m2e.editor.pom.FormUtils.nvl) ICellModifier(org.eclipse.jface.viewers.ICellModifier) Packaging(org.eclipse.m2e.core.ui.internal.search.util.Packaging) Logger(org.slf4j.Logger) NodeList(org.w3c.dom.NodeList) Job(org.eclipse.core.runtime.jobs.Job) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Action(org.eclipse.jface.action.Action) PomEdits.childAt(org.eclipse.m2e.core.ui.internal.editing.PomEdits.childAt) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) Element(org.w3c.dom.Element) ToolBarManager(org.eclipse.jface.action.ToolBarManager) IndexedArtifactFile(org.eclipse.m2e.core.internal.index.IndexedArtifactFile) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter) DEV_CONNECTION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.DEV_CONNECTION) Control(org.eclipse.swt.widgets.Control) IStatus(org.eclipse.core.runtime.IStatus) OpenPomAction(org.eclipse.m2e.core.ui.internal.actions.OpenPomAction) Action(org.eclipse.jface.action.Action) ArtifactKey(org.eclipse.m2e.core.embedder.ArtifactKey) IFile(org.eclipse.core.resources.IFile) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) PomEdits.removeIfNoChildElement(org.eclipse.m2e.core.ui.internal.editing.PomEdits.removeIfNoChildElement) Element(org.w3c.dom.Element) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ToolBarManager(org.eclipse.jface.action.ToolBarManager) GridLayout(org.eclipse.swt.layout.GridLayout) StackLayout(org.eclipse.swt.custom.StackLayout) ICellModifier(org.eclipse.jface.viewers.ICellModifier) ArrayList(java.util.ArrayList) List(java.util.List) NodeList(org.w3c.dom.NodeList) Job(org.eclipse.core.runtime.jobs.Job) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) MavenModuleSelectionDialog(org.eclipse.m2e.editor.dialogs.MavenModuleSelectionDialog) MavenModuleWizard(org.eclipse.m2e.core.ui.internal.wizards.MavenModuleWizard) Composite(org.eclipse.swt.widgets.Composite) ListEditorComposite(org.eclipse.m2e.editor.composites.ListEditorComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) CoreException(org.eclipse.core.runtime.CoreException) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) FileEditorInput(org.eclipse.ui.part.FileEditorInput) GridData(org.eclipse.swt.layout.GridData) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IEditorInput(org.eclipse.ui.IEditorInput)

Example 77 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project gda-core by openGDA.

the class AddDevicesComposite method addDevices.

private void addDevices(final Composite composite) {
    createFindScannable(composite);
    createFindDetector(composite);
    configureDevicesExpandableComposite.setClient(composite);
    ExpansionAdapter addScannableExpansionListener = new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            GridUtils.layoutFull(composite.getParent());
        }
    };
    configureDevicesExpandableComposite.addExpansionListener(addScannableExpansionListener);
}
Also used : ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 78 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project gda-core by openGDA.

the class CommissioningView method createSection.

private Composite createSection(String title, String description, int numColumns) {
    Section section = toolkit.createSection(form.getBody(), ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION | ExpandableComposite.EXPANDED);
    section.setText(title);
    section.setDescription(description);
    Composite client = toolkit.createComposite(section);
    GridLayout layout = new GridLayout();
    layout.marginWidth = layout.marginHeight = 0;
    layout.numColumns = numColumns;
    client.setLayout(layout);
    section.setClient(client);
    section.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            form.reflow(false);
        }
    });
    return client;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Section(org.eclipse.ui.forms.widgets.Section) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 79 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project netxms-ocilib by stevemqeen.

the class AlarmDetails method createDataSection.

/**
 * Create data section
 */
private void createDataSection() {
    final Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.EXPANDED | Section.TWISTIE | Section.COMPACT);
    section.setText(Messages.get().AlarmDetails_LastValues);
    final GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    section.setLayoutData(gd);
    section.addExpansionListener(new IExpansionListener() {

        @Override
        public void expansionStateChanging(ExpansionEvent e) {
            gd.grabExcessVerticalSpace = e.getState();
        }

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
        }
    });
    dataArea = toolkit.createComposite(section);
    section.setClient(dataArea);
    dataArea.setLayout(new FillLayout());
}
Also used : IExpansionListener(org.eclipse.ui.forms.events.IExpansionListener) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) Section(org.eclipse.ui.forms.widgets.Section) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 80 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project netxms-ocilib by stevemqeen.

the class AlarmDetails method createEventsSection.

/**
 * Create events section
 */
private void createEventsSection() {
    final Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.EXPANDED | Section.TWISTIE | Section.COMPACT);
    section.setText(Messages.get().AlarmDetails_RelatedEvents);
    final GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    section.setLayoutData(gd);
    section.addExpansionListener(new IExpansionListener() {

        @Override
        public void expansionStateChanging(ExpansionEvent e) {
            gd.grabExcessVerticalSpace = e.getState();
        }

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
        }
    });
    final Composite content = toolkit.createComposite(section);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    content.setLayout(layout);
    section.setClient(content);
    final String[] names = { Messages.get().AlarmDetails_Column_Severity, Messages.get().AlarmDetails_Column_Source, Messages.get().AlarmDetails_Column_Name, Messages.get().AlarmDetails_Column_Message, Messages.get().AlarmDetails_Column_Timestamp };
    final int[] widths = { 130, 160, 160, 400, 150 };
    eventViewer = new SortableTreeViewer(content, names, widths, EV_COLUMN_TIMESTAMP, SWT.DOWN, SWT.BORDER | SWT.FULL_SELECTION);
    eventViewer.setContentProvider(new EventTreeContentProvider());
    eventViewer.setLabelProvider(new EventTreeLabelProvider());
    eventViewer.setComparator(new EventTreeComparator());
    eventViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    final IDialogSettings settings = Activator.getDefault().getDialogSettings();
    // $NON-NLS-1$
    WidgetHelper.restoreTreeViewerSettings(eventViewer, settings, "AlarmDetails.Events");
    eventViewer.getControl().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            // $NON-NLS-1$
            WidgetHelper.saveTreeViewerSettings(eventViewer, settings, "AlarmDetails.Events");
        }
    });
}
Also used : SortableTreeViewer(org.netxms.ui.eclipse.widgets.SortableTreeViewer) DisposeListener(org.eclipse.swt.events.DisposeListener) IExpansionListener(org.eclipse.ui.forms.events.IExpansionListener) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) EventTreeContentProvider(org.netxms.ui.eclipse.alarmviewer.views.helpers.EventTreeContentProvider) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Section(org.eclipse.ui.forms.widgets.Section) GridLayout(org.eclipse.swt.layout.GridLayout) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) GridData(org.eclipse.swt.layout.GridData) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) EventTreeLabelProvider(org.netxms.ui.eclipse.alarmviewer.views.helpers.EventTreeLabelProvider) EventTreeComparator(org.netxms.ui.eclipse.alarmviewer.views.helpers.EventTreeComparator)

Aggregations

ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)94 ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)73 Composite (org.eclipse.swt.widgets.Composite)71 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)70 GridData (org.eclipse.swt.layout.GridData)62 GridLayout (org.eclipse.swt.layout.GridLayout)56 Section (org.eclipse.ui.forms.widgets.Section)45 IExpansionListener (org.eclipse.ui.forms.events.IExpansionListener)18 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)16 Label (org.eclipse.swt.widgets.Label)16 SelectionEvent (org.eclipse.swt.events.SelectionEvent)15 Point (org.eclipse.swt.graphics.Point)14 TableViewer (org.eclipse.jface.viewers.TableViewer)12 ArrayList (java.util.ArrayList)11 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)10 Button (org.eclipse.swt.widgets.Button)10 SelectionListener (org.eclipse.swt.events.SelectionListener)9 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)9 List (java.util.List)8 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)8