use of org.eclipse.jface.viewers.ISelectionChangedListener 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;
}
use of org.eclipse.jface.viewers.ISelectionChangedListener 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);
}
});
}
use of org.eclipse.jface.viewers.ISelectionChangedListener 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);
}
use of org.eclipse.jface.viewers.ISelectionChangedListener 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();
}
use of org.eclipse.jface.viewers.ISelectionChangedListener 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;
}
Aggregations