/** * Open the filter editor on a given selection of the list. * * @param selection the selection */ private void openFilterEditor(ISelection selection) { if (selection instanceof IStructuredSelection) { Object selectedElement = ((IStructuredSelection) selection).getFirstElement(); if (selectedElement instanceof IFilter) { try { IFilter aFilterDef = (IFilter) selectedElement; if (!PluginFilterEditors.hasEditor(aFilterDef)) { return; } IFilterEditor editableFilter = PluginFilterEditors.getNewEditor(aFilterDef); editableFilter.setInputProject(mProjectConfig.getProject()); editableFilter.setFilterData(aFilterDef.getFilterData()); if (Window.OK == editableFilter.openEditor(getShell())) { aFilterDef.setFilterData(editableFilter.getFilterData()); mFilterList.refresh(); } } catch (CheckstylePluginException ex) { CheckstyleUIPlugin.errorDialog(getShell(), ex, true); } } } }
/** * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged * (org.eclipse.jface.viewers.SelectionChangedEvent) */ public void selectionChanged(SelectionChangedEvent event) { Object source = event.getSource(); if (source == mFilterList) { ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { Object selectedElement = ((IStructuredSelection) selection).getFirstElement(); if (selectedElement instanceof IFilter) { IFilter filterDef = (IFilter) selectedElement; mTxtFilterDescription.setText(filterDef.getDescription()); // activate edit button mBtnEditFilter.setEnabled(PluginFilterEditors.hasEditor(filterDef)); } } } }