Search in sources :

Example 26 with SelectionChangedEvent

use of org.eclipse.jface.viewers.SelectionChangedEvent in project tdi-studio-se by Talend.

the class DatabaseTypeFilter method createDialogArea.

protected Control createDialogArea(Composite parent, String specifiedPId) {
    Composite container = (Composite) super.createDialogArea(parent);
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "before createDialogArea...");
    GridData data = (GridData) container.getLayoutData();
    data.minimumHeight = 400;
    data.heightHint = 400;
    data.minimumWidth = 500;
    data.widthHint = 500;
    container.setLayoutData(data);
    createFilterField(container);
    Composite viewContainer = new Composite(container, SWT.BORDER);
    viewContainer.setLayout(new GridLayout());
    viewContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
    repositoryTreeViewer = RepoCommonViewerProvider.NORMAL.createViewer(viewContainer, specifiedPId);
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "finshed createViewer");
    repositoryTreeViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    addFilter(textFilter);
    if (dbSupportFilter != null) {
        addFilter(dbSupportFilter);
    }
    if (additionalFilters != null) {
        addFilter(additionalFilters);
    }
    ViewerFilter filter = typeProcessor.makeFilter();
    addFilter(filter);
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "finshed add Filters");
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "set input");
    repositoryTreeViewer.expandToLevel(2);
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "expandAll");
    final Label label = new Label(container, SWT.NONE);
    //$NON-NLS-1$
    label.setText(Messages.getString("RepositoryReviewDialog.label"));
    label.setForeground(new Color(null, 250, 0, 0));
    label.setVisible(false);
    // see feature 0003664: tRunJob: When opening the tree dialog to select the job target, it could be useful to
    // open it on previous selected job if exists
    selectNode();
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "selectNode");
    repositoryTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            boolean highlightOKButton = isSelectionValid(event);
            getButton(IDialogConstants.OK_ID).setEnabled(highlightOKButton);
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection != null && !selection.isEmpty()) {
                RepositoryNode node = (RepositoryNode) selection.getFirstElement();
                if (!highlightOKButton && node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getObjectType().equals(ERepositoryObjectType.METADATA_VALIDATION_RULES)) {
                    label.setVisible(true);
                } else {
                    label.setVisible(false);
                }
            }
        }
    });
    repositoryTreeViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            if (getButton(IDialogConstants.OK_ID).isEnabled()) {
                okPressed();
            }
        }
    });
    //$NON-NLS-1$
    TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "finished createDialogArea...");
    TimeMeasure.end(RepositoryReviewDialog.class.getSimpleName());
    TimeMeasure.display = false;
    TimeMeasure.displaySteps = false;
    TimeMeasure.measureActive = false;
    return container;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Color(org.eclipse.swt.graphics.Color) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) GridLayout(org.eclipse.swt.layout.GridLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData)

Example 27 with SelectionChangedEvent

use of org.eclipse.jface.viewers.SelectionChangedEvent in project tdi-studio-se by Talend.

the class BusinessAssignmentComposite method createSelectionListener.

private void createSelectionListener() {
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            BusinessAssignment businessAssignment = getBusinessAssignment(event.getSelection());
            if (businessAssignment != null) {
                final IRepositoryView repositoryView = getRepositoryView();
                if (repositoryView != null) {
                    IProjectRepositoryNode rootRepositoryNode = repositoryView.getRoot();
                    TalendItem item = businessAssignment.getTalendItem();
                    //
                    if (item instanceof Routine && rootRepositoryNode instanceof ProjectRepositoryNode) {
                        RepositoryNodeUtilities.expandParentNode(getRepositoryView(), ((ProjectRepositoryNode) rootRepositoryNode).getRootRepositoryNode(ERepositoryObjectType.CODE));
                    }
                    selectChild(item, (IRepositoryNode) rootRepositoryNode);
                }
            }
        }

        private void selectChild(TalendItem item, IRepositoryNode rootRepositoryNode) {
            try {
                RepositoryNode curNode = null;
                JobSettingsView viewer = (JobSettingsView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(JobSettingsView.ID);
                IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(item.getId());
                if (lastVersion != null) {
                    curNode = RepositoryNodeUtilities.getRepositoryNode(lastVersion);
                    select(viewer, curNode);
                } else if (item instanceof TableMetadata) {
                    MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(item.getId());
                    if (table != null) {
                        //$NON-NLS-1$
                        String id = item.getId().split(" - ")[0];
                        RepositoryNode node = RepositoryNodeUtilities.getMetadataTableFromConnection(item.getId());
                        IRepositoryView view = getRepositoryView();
                        if (view != null) {
                            RepositoryNodeUtilities.expandParentNode(view, node);
                            select(viewer, node);
                        }
                    }
                } else if (item instanceof Query) {
                    org.talend.core.model.metadata.builder.connection.Query query = MetadataToolHelper.getQueryFromRepository(item.getId());
                    if (query != null) {
                        //$NON-NLS-1$
                        String id = item.getId().split(" - ")[0];
                        IRepositoryView view = getRepositoryView();
                        RepositoryNode node = RepositoryNodeUtilities.getQueryFromConnection(item.getId());
                        RepositoryNodeUtilities.expandParentNode(view, node);
                        select(viewer, node);
                    }
                } else if (item instanceof SAPFunction) {
                    SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(item.getId());
                    if (function != null) {
                        IRepositoryView view = getRepositoryView();
                        RepositoryNode node = RepositoryNodeUtilities.getSAPFunctionFromConnection(item.getId());
                        RepositoryNodeUtilities.expandParentNode(view, node);
                        select(viewer, node);
                    }
                } else {
                    for (IRepositoryNode node : rootRepositoryNode.getChildren()) {
                        RepositoryNode rNode = (RepositoryNode) node;
                        if (item instanceof SQLPattern && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.SQLPATTERNS) {
                            if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
                                SQLPatternItem sqlItem = (SQLPatternItem) rNode.getObject().getProperty().getItem();
                                if (sqlItem.isSystem() && item.getLabel().equals(rNode.getObject().getLabel())) {
                                    select(viewer, rNode);
                                }
                            } else {
                                selectChild(item, rNode);
                            }
                        } else if (item instanceof Routine && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.ROUTINES) {
                            if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
                                RoutineItem sqlItem = (RoutineItem) rNode.getObject().getProperty().getItem();
                                if (sqlItem.isBuiltIn() && item.getLabel().equals(rNode.getObject().getLabel())) {
                                    select(viewer, rNode);
                                }
                            } else {
                                selectChild(item, rNode);
                            }
                        }
                    }
                }
            } catch (PersistenceException e) {
                // TODO Auto-generated catch block
                // e.printStackTrace();
                ExceptionHandler.process(e);
            }
        }

        private void select(JobSettingsView viewer, RepositoryNode repositoryNode) {
            if (viewer == null) {
                return;
            }
            if (repositoryNode == null) {
                return;
            }
            CorePlugin.getDefault().getRepositoryService().removeRepositoryTreeViewListener(viewer);
            final IRepositoryView repositoryView = getRepositoryView();
            if (repositoryView != null) {
                repositoryView.getViewer().setSelection(new StructuredSelection(repositoryNode));
            }
            CorePlugin.getDefault().getRepositoryService().addRepositoryTreeViewListener(viewer);
        }
    });
}
Also used : JobSettingsView(org.talend.designer.core.ui.views.jobsettings.JobSettingsView) BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) Query(org.talend.designer.business.model.business.Query) SAPFunctionUnit(org.talend.core.model.metadata.builder.connection.SAPFunctionUnit) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) TalendItem(org.talend.designer.business.model.business.TalendItem) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) TableMetadata(org.talend.designer.business.model.business.TableMetadata) SAPFunction(org.talend.designer.business.model.business.SAPFunction) SQLPattern(org.talend.designer.business.model.business.SQLPattern) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) RoutineItem(org.talend.core.model.properties.RoutineItem) Routine(org.talend.designer.business.model.business.Routine) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 28 with SelectionChangedEvent

use of org.eclipse.jface.viewers.SelectionChangedEvent in project ACS by ACS-Community.

the class ChannelTreePart method postConstruct.

/**
	 * See http://www.vogella.com/articles/EclipseJFaceTree/article.html
	 */
@PostConstruct
public void postConstruct(Composite parent, final IEclipseContext context, EMenuService menuService, IEventBroker eventBroker) {
    try {
        eventModel = EventModel.getInstance();
    } catch (Throwable thr) {
        thr.printStackTrace();
        IStatus someStatus = statusReporter.newStatus(IStatus.ERROR, "Connection with NCs failed.", thr);
        statusReporter.report(someStatus, StatusReporter.SHOW);
        throw new RuntimeException(thr);
    }
    //		eventModel.getLogger().info("ChannelTreePart got EventModel instance.");
    statusLineWriter = new StatusLineWriter(eventBroker);
    viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    viewer.setContentProvider(new ChannelTreeContentProvider());
    viewer.setLabelProvider(new ChannelTreeLabelProvider());
    // Expand the tree. '2' means to show only the visible top-level nodes.
    viewer.setAutoExpandLevel(2);
    viewer.setComparator(new ServiceViewerComparator());
    // Provide the root node to the ContentProvider
    viewer.setInput(eventModel.getNotifyServicesRoot());
    // Expand with doubleclick
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection thisSelection = (IStructuredSelection) event.getSelection();
            Object selectedNode = thisSelection.getFirstElement();
            viewer.setExpandedState(selectedNode, !viewer.getExpandedState(selectedNode));
        }
    });
    // Attach a selection listener to our tree that will post selections to the ESelectionService
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            selectionService.setSelection(selection.size() == 1 ? selection.getFirstElement() : selection.toArray());
        }
    });
    // TODO: Take care of help system. Here's the E3 code:
    //		// Create the help context id for the viewer's control
    //		PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "alma.acs.eventbrowser.viewer");
    hookContextMenu(menuService);
    // TODO: this could be used by handlers etc, currently it's not
    context.set(ChannelTreePart.class, this);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ChannelTreeContentProvider(alma.acs.eventbrowser.parts.ChannelTreeProviders.ChannelTreeContentProvider) StatusLineWriter(alma.acs.eventbrowser.status.StatusLineWriter) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ChannelTreeLabelProvider(alma.acs.eventbrowser.parts.ChannelTreeProviders.ChannelTreeLabelProvider) PostConstruct(javax.annotation.PostConstruct)

Example 29 with SelectionChangedEvent

use of org.eclipse.jface.viewers.SelectionChangedEvent in project ACS by ACS-Community.

the class EventListPart method postConstruct.

/**
	 */
@PostConstruct
public void postConstruct(Composite parent, final IEclipseContext context, IEventBroker eventBroker, EMenuService menuService) {
    try {
        em = EventModel.getInstance();
    } catch (Throwable thr) {
        thr.printStackTrace();
        IStatus someStatus = statusReporter.newStatus(IStatus.ERROR, "Connection with NCs failed.", thr);
        statusReporter.report(someStatus, StatusReporter.SHOW);
        throw new RuntimeException(thr);
    }
    logger = em.getLogger();
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.verticalSpacing = 0;
    parent.setLayout(gridLayout);
    // TODO: We currently have the filter text control in the regular view toolbar.
    //       The e3 eventGUI had a "custom tool bar" inserted here.
    //       We should decide which way it's better.
    viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    /*
		 * "Time "+timeStamp+" "+m_channelName+" "+component+" "+count+"
		 * "+channelEventCount+" " +" "+evtTypeName+"
		 * "+evtCounter.get(evtTypeName)
		 */
    TableViewerColumn tvcol = new TableViewerColumn(viewer, SWT.NONE, 0);
    tvcol.setLabelProvider(new TimeStampLabelProvider());
    TableColumn col = tvcol.getColumn();
    col.setText("Timestamp");
    col.setWidth(180);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 1);
    tvcol.setLabelProvider(new EventSourceLabelProvider());
    col = tvcol.getColumn();
    col.setText("Event source");
    col.setWidth(150);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 2);
    tvcol.setLabelProvider(new CountLabelProvider());
    col = tvcol.getColumn();
    col.setText("# Events in channel");
    col.setWidth(50);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 3);
    tvcol.setLabelProvider(new EventTypeLabelProvider());
    col = tvcol.getColumn();
    col.setText("Event type");
    col.setWidth(150);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 4);
    tvcol.setLabelProvider(new EventTypeCountLabelProvider());
    col = tvcol.getColumn();
    col.setText("# Events this type");
    col.setWidth(50);
    col.setAlignment(SWT.LEFT);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getTable());
    viewer.setContentProvider(new EventListViewContentProvider(em));
    // Attach a selection listener to our event list that will post the selected event for the event details list
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection.size() == 1) {
                selectionService.setSelection(selection.getFirstElement());
            }
        }
    });
    viewer.setInput(new Object());
    hookContextMenu(menuService);
    pel = new PopulateEventList(logger, viewer, new StatusLineWriter(eventBroker), em.getEventQueue(), "NC Events");
    eventListThread = pel.getThreadForEventList();
    eventListThread.start();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Table(org.eclipse.swt.widgets.Table) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) StatusLineWriter(alma.acs.eventbrowser.status.StatusLineWriter) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) PostConstruct(javax.annotation.PostConstruct)

Example 30 with SelectionChangedEvent

use of org.eclipse.jface.viewers.SelectionChangedEvent in project translationstudio8 by heartsome.

the class ConfigConversionDialog method createConvertControl.

/**
	 * 创建文件类型列表
	 * @param title
	 * @param composite
	 * @return ;
	 */
private ComboViewer createConvertControl(String title, Composite composite) {
    Label positiveConvertLabel = new Label(composite, SWT.NONE);
    GridData positiveConvertLabelData = new GridData();
    positiveConvertLabelData.horizontalSpan = 2;
    positiveConvertLabelData.horizontalAlignment = SWT.CENTER;
    positiveConvertLabelData.grabExcessHorizontalSpace = true;
    positiveConvertLabel.setLayoutData(positiveConvertLabelData);
    positiveConvertLabel.setText(title);
    Label suportFormat = new Label(composite, SWT.NONE);
    suportFormat.setText(Messages.getString("dialog.ConfigConversionDialog.suportFormat"));
    ComboViewer supportList = new ComboViewer(composite, SWT.READ_ONLY);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    gridData.grabExcessHorizontalSpace = true;
    supportList.getCombo().setLayoutData(gridData);
    supportList.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection.isEmpty()) {
                okButton.setEnabled(false);
            } else {
                okButton.setEnabled(true);
            }
        }
    });
    return supportList;
}
Also used : ComboViewer(org.eclipse.jface.viewers.ComboViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) ISelection(org.eclipse.jface.viewers.ISelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Aggregations

SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)802 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)754 GridData (org.eclipse.swt.layout.GridData)417 Composite (org.eclipse.swt.widgets.Composite)332 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)303 GridLayout (org.eclipse.swt.layout.GridLayout)245 SelectionEvent (org.eclipse.swt.events.SelectionEvent)187 Label (org.eclipse.swt.widgets.Label)158 TableViewer (org.eclipse.jface.viewers.TableViewer)153 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)147 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)140 Button (org.eclipse.swt.widgets.Button)140 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)126 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)121 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)120 IPropertiesEditionEvent (org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)116 PropertiesEditionEvent (org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)116 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)116 Table (org.eclipse.swt.widgets.Table)93 ISelection (org.eclipse.jface.viewers.ISelection)84