/** Selects the displayed repository definition. */ private void selectDisplayedCmrRepositoryDefinition() { List<CmrRepositoryDefinition> repositories = cmrRepositoryManager.getCmrRepositoryDefinitions(); if (CollectionUtils.isNotEmpty(repositories)) { // find first online for (CmrRepositoryDefinition repositoryDefinition : repositories) { if (repositoryDefinition.getOnlineStatus() == OnlineStatus.ONLINE) { displayedCmrRepositoryDefinition = repositoryDefinition; performUpdate(true); selectionProviderAdapter.setSelection( new StructuredSelection(displayedCmrRepositoryDefinition)); return; } } // if no online display first displayedCmrRepositoryDefinition = repositories.get(0); performUpdate(true); selectionProviderAdapter.setSelection( new StructuredSelection(displayedCmrRepositoryDefinition)); } }
/** * Informs that the editing repository for the configuration interface has been changed. * * @param cmrRepositoryDefinition CmrRepositoryDefinition */ public void ciRepositoryDefinitionChange(CmrRepositoryDefinition cmrRepositoryDefinition) { displayedCmrRepositoryDefinition = cmrRepositoryDefinition; performUpdate(true); selectionProviderAdapter.setSelection( new StructuredSelection(displayedCmrRepositoryDefinition)); }
/** {@inheritDoc} */ @Override public void createPartControl(Composite parent) { createViewToolbar(); toolkit = new FormToolkit(parent.getDisplay()); mainComposite = new SashForm(parent, SWT.VERTICAL); GridLayout mainLayout = new GridLayout(1, true); mainLayout.marginWidth = 0; mainLayout.marginHeight = 0; mainComposite.setLayout(mainLayout); mainForm = toolkit.createForm(mainComposite); mainForm.getBody().setLayout(new GridLayout(1, true)); mainForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); createHeadClient(); toolkit.decorateFormHeading(mainForm); int borderStyle = toolkit.getBorderStyle(); toolkit.setBorderStyle(SWT.NULL); Table table = toolkit.createTable(mainForm.getBody(), SWT.V_SCROLL | SWT.H_SCROLL); toolkit.setBorderStyle(borderStyle); tableViewer = new TableViewer(table); // create tree content provider tableViewer.setContentProvider(getContentProvider()); tableViewer.setLabelProvider(getLabelProvider()); ViewerComparator comparator = getViewerComparator(); if (null != comparator) { tableViewer.setComparator(comparator); } ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE); // double-click listener IDoubleClickListener doubleClickListener = getTreeDoubleClickListener(); if (null != doubleClickListener) { tableViewer.addDoubleClickListener(doubleClickListener); } // menu String menuId = getMenuId(); if (null != menuId) { MenuManager menuManager = new MenuManager(); menuManager.setRemoveAllWhenShown(true); getSite().registerContextMenu(menuId, menuManager, tableViewer); Control control = tableViewer.getControl(); Menu menu = menuManager.createContextMenu(control); control.setMenu(menu); } // resizing listener mainComposite.addControlListener( new ControlAdapter() { private boolean verticaLayout; @Override public void controlResized(ControlEvent e) { int width = mainComposite.getBounds().width; int height = mainComposite.getBounds().height; if (width > height && verticaLayout) { verticaLayout = false; mainComposite.setOrientation(SWT.HORIZONTAL); } else if (width < height && !verticaLayout) { verticaLayout = true; mainComposite.setOrientation(SWT.VERTICAL); } mainComposite.layout(); } }); // update all updateFormTitle(); updateFormMenuManager(); updateFormBody(); tableViewer.addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { StructuredSelection ss = (StructuredSelection) tableViewer.getSelection(); if (ss.getFirstElement() instanceof IProfileProvider || ss.getFirstElement() instanceof IEnvironmentProvider) { selectionProviderAdapter.setSelection(ss); } else { // setting selection to the CMR so that we can perform all the necessary // operations selectionProviderAdapter.setSelection( new StructuredSelection(displayedCmrRepositoryDefinition)); } } }); getSite().setSelectionProvider(selectionProviderAdapter); selectionProviderAdapter.setSelection( new StructuredSelection(displayedCmrRepositoryDefinition)); // TODO: This needs to be removed as soon as the configuration interface is fully // functional. UnfinishedWarningUtils.inform( "The configuration interface is not yet connected with the agent instrumentation. You can play around with this preview, but the instrumentations will not be effective.", "UNFINISHED_WARNING_CONFIGURATION_INTERFACE"); }