Search in sources :

Example 1 with LanguageConfigurationInfoWidget

use of org.eclipse.tm4e.languageconfiguration.internal.widgets.LanguageConfigurationInfoWidget in project tm4e by eclipse.

the class SelectLanguageConfigurationWizardPage method createBody.

protected void createBody(Composite ancestor) {
    Composite parent = new Composite(ancestor, SWT.NONE);
    parent.setFont(parent.getFont());
    parent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    parent.setLayout(new GridLayout(2, false));
    fileText = createText(parent, LanguageConfigurationMessages.SelectLanguageConfigurationWizardPage_file);
    fileText.addListener(SWT.Modify, this);
    Composite buttons = new Composite(parent, SWT.NONE);
    buttons.setLayout(new GridLayout(2, false));
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    gd.horizontalAlignment = SWT.RIGHT;
    buttons.setLayoutData(gd);
    infoWidget = new LanguageConfigurationInfoWidget(parent, SWT.NONE);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    infoWidget.setLayoutData(data);
    browseFileSystemButton = new Button(buttons, SWT.NONE);
    browseFileSystemButton.setText(LanguageConfigurationMessages.SelectLanguageConfigurationWizardPage_browse_fileSystem);
    browseFileSystemButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(parent.getShell());
            dialog.setFilterExtensions(TEXTMATE_EXTENSIONS);
            dialog.setFilterPath(fileText.getText());
            String result = dialog.open();
            if (result != null && result.length() > 0) {
                fileText.setText(result);
            }
        }
    });
    browseWorkspaceButton = new Button(buttons, SWT.NONE);
    browseWorkspaceButton.setText(LanguageConfigurationMessages.SelectLanguageConfigurationWizardPage_browse_workspace);
    browseWorkspaceButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ResourceSelectionDialog dialog = new ResourceSelectionDialog(browseWorkspaceButton.getShell(), ResourcesPlugin.getWorkspace().getRoot(), LanguageConfigurationMessages.SelectLanguageConfigurationWizardPage_workspace_description);
            dialog.setTitle(LanguageConfigurationMessages.SelectLanguageConfigurationWizardPage_workspace_title);
            int returnCode = dialog.open();
            Object[] results = dialog.getResult();
            if (returnCode == 0 && results.length > 0) {
                fileText.setText(((IResource) results[0]).getFullPath().makeRelative().toString());
            }
        }
    });
    contentTypeText = createText(parent, LanguageConfigurationMessages.SelectLanguageConfigurationWizardPage_contentType);
    contentTypeText.addListener(SWT.Modify, this);
    createContentTypeTreeViewer(parent);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ResourceSelectionDialog(org.eclipse.ui.dialogs.ResourceSelectionDialog) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LanguageConfigurationInfoWidget(org.eclipse.tm4e.languageconfiguration.internal.widgets.LanguageConfigurationInfoWidget) FileDialog(org.eclipse.swt.widgets.FileDialog) IResource(org.eclipse.core.resources.IResource)

Aggregations

IResource (org.eclipse.core.resources.IResource)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1 LanguageConfigurationInfoWidget (org.eclipse.tm4e.languageconfiguration.internal.widgets.LanguageConfigurationInfoWidget)1 ResourceSelectionDialog (org.eclipse.ui.dialogs.ResourceSelectionDialog)1