Search in sources :

Example 1 with SystemTapView

use of org.eclipse.linuxtools.internal.callgraph.core.SystemTapView in project linuxtools by eclipse.

the class SystemTapOptionsTab method createParserOption.

private void createParserOption(Composite parserTop) {
    Composite browseTop = new Composite(parserTop, SWT.NONE);
    browseTop.setLayout(new GridLayout(1, false));
    GridData browseData = new GridData(GridData.FILL_HORIZONTAL);
    browseTop.setLayoutData(browseData);
    Label suppFileLabel = new Label(browseTop, SWT.NONE);
    // $NON-NLS-1$
    suppFileLabel.setText("Parser");
    parser = new Text(browseTop, SWT.BORDER);
    parser.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    parser.addModifyListener(modifyListener);
    Button parserButton = createPushButton(browseTop, "Find parsers", // $NON-NLS-1$
    null);
    parserButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
        ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new ListLabelProvider());
        // $NON-NLS-1$
        dialog.setTitle("Select parser");
        // $NON-NLS-1$
        dialog.setMessage("Select parser to use.");
        IExtensionRegistry reg = Platform.getExtensionRegistry();
        IConfigurationElement[] extensions = reg.getConfigurationElementsFor(PluginConstants.PARSER_RESOURCE, PluginConstants.PARSER_NAME);
        dialog.setElements(extensions);
        if (dialog.open() == IDialogConstants.OK_ID) {
            String arg = getUsefulLabel(dialog.getFirstResult());
            parser.setText(arg);
        }
    }));
    viewer = new Text(browseTop, SWT.BORDER);
    viewer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    viewer.addModifyListener(modifyListener);
    Button viewerButton = createPushButton(browseTop, "Find viewers", // $NON-NLS-1$
    null);
    viewerButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
        ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new ListLabelProvider());
        // $NON-NLS-1$
        dialog.setTitle("Select viewer");
        // $NON-NLS-1$
        dialog.setMessage("Select viewer to use.");
        IExtensionRegistry reg = Platform.getExtensionRegistry();
        IConfigurationElement[] extensions = reg.getConfigurationElementsFor(PluginConstants.VIEW_RESOURCE, PluginConstants.VIEW_NAME);
        ArrayList<IConfigurationElement> ext = new ArrayList<>();
        for (IConfigurationElement el : extensions) {
            if (// $NON-NLS-1$
            !el.getNamespaceIdentifier().contains("org.eclipse.linuxtools"))
                continue;
            // org.eclipse.linuxtools, then see if the class extends SystemTapView
            try {
                if (el.createExecutableExtension(PluginConstants.ATTR_CLASS) instanceof SystemTapView) {
                    ext.add(el);
                }
            } catch (CoreException e1) {
            }
        }
        dialog.setElements(ext.toArray());
        if (dialog.open() == IDialogConstants.OK_ID) {
            String arg = getUsefulLabel(dialog.getFirstResult());
            viewer.setText(arg);
        }
    }));
}
Also used : CLaunchConfigurationTab(org.eclipse.cdt.launch.ui.CLaunchConfigurationTab) LaunchConfigurationConstants(org.eclipse.linuxtools.internal.callgraph.core.LaunchConfigurationConstants) CoreException(org.eclipse.core.runtime.CoreException) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IPath(org.eclipse.core.runtime.IPath) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) Composite(org.eclipse.swt.widgets.Composite) ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) IExtension(org.eclipse.core.runtime.IExtension) SystemTapView(org.eclipse.linuxtools.internal.callgraph.core.SystemTapView) CDebugUtils(org.eclipse.cdt.debug.core.CDebugUtils) Text(org.eclipse.swt.widgets.Text) Button(org.eclipse.swt.widgets.Button) PlatformUI(org.eclipse.ui.PlatformUI) ICElement(org.eclipse.cdt.core.model.ICElement) IBinary(org.eclipse.cdt.core.model.IBinary) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) Window(org.eclipse.jface.window.Window) SWT(org.eclipse.swt.SWT) Label(org.eclipse.swt.widgets.Label) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) PluginConstants(org.eclipse.linuxtools.internal.callgraph.core.PluginConstants) SelectionListener(org.eclipse.swt.events.SelectionListener) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) TabFolder(org.eclipse.swt.widgets.TabFolder) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) Image(org.eclipse.swt.graphics.Image) Spinner(org.eclipse.swt.widgets.Spinner) FocusListener(org.eclipse.swt.events.FocusListener) ArrayList(java.util.ArrayList) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) TwoPaneElementSelector(org.eclipse.ui.dialogs.TwoPaneElementSelector) IWorkspace(org.eclipse.core.resources.IWorkspace) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) GridData(org.eclipse.swt.layout.GridData) ICProject(org.eclipse.cdt.core.model.ICProject) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) TabItem(org.eclipse.swt.widgets.TabItem) Shell(org.eclipse.swt.widgets.Shell) FileDialog(org.eclipse.swt.widgets.FileDialog) ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) File(java.io.File) CElementLabelProvider(org.eclipse.cdt.ui.CElementLabelProvider) ICDTLaunchConfigurationConstants(org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants) ModifyListener(org.eclipse.swt.events.ModifyListener) IResource(org.eclipse.core.resources.IResource) Platform(org.eclipse.core.runtime.Platform) LabelProvider(org.eclipse.jface.viewers.LabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) SystemTapView(org.eclipse.linuxtools.internal.callgraph.core.SystemTapView) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) Text(org.eclipse.swt.widgets.Text) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) GridLayout(org.eclipse.swt.layout.GridLayout) CoreException(org.eclipse.core.runtime.CoreException) Button(org.eclipse.swt.widgets.Button) ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog) GridData(org.eclipse.swt.layout.GridData) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Aggregations

File (java.io.File)1 ArrayList (java.util.ArrayList)1 IBinary (org.eclipse.cdt.core.model.IBinary)1 ICElement (org.eclipse.cdt.core.model.ICElement)1 ICProject (org.eclipse.cdt.core.model.ICProject)1 CDebugUtils (org.eclipse.cdt.debug.core.CDebugUtils)1 ICDTLaunchConfigurationConstants (org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants)1 CLaunchConfigurationTab (org.eclipse.cdt.launch.ui.CLaunchConfigurationTab)1 CElementLabelProvider (org.eclipse.cdt.ui.CElementLabelProvider)1 IResource (org.eclipse.core.resources.IResource)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 ResourcesPlugin (org.eclipse.core.resources.ResourcesPlugin)1 CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtension (org.eclipse.core.runtime.IExtension)1 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)1 IPath (org.eclipse.core.runtime.IPath)1 Platform (org.eclipse.core.runtime.Platform)1 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)1