Search in sources :

Example 11 with ComboViewer

use of org.eclipse.jface.viewers.ComboViewer 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;
}
Also used : ComboViewer(org.eclipse.jface.viewers.ComboViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) ISelection(org.eclipse.jface.viewers.ISelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 12 with ComboViewer

use of org.eclipse.jface.viewers.ComboViewer in project azure-tools-for-java by Microsoft.

the class SettingsStep method createSettingsPanel.

private void createSettingsPanel(Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    GridData gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    gridData.verticalAlignment = GridData.BEGINNING;
    gridData.grabExcessHorizontalSpace = true;
    composite.setLayout(gridLayout);
    composite.setLayoutData(gridData);
    resourceGrpLabel = new Label(composite, SWT.LEFT);
    resourceGrpLabel.setText("Resource group:");
    final Composite container = new Composite(composite, SWT.NONE);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    gridData.verticalAlignment = GridData.BEGINNING;
    // gridData.grabExcessHorizontalSpace = true;
    gridData.widthHint = 250;
    container.setLayout(gridLayout);
    container.setLayoutData(gridData);
    createNewRadioButton = new Button(container, SWT.RADIO);
    createNewRadioButton.setText("Create new");
    resourceGrpField = new Text(container, SWT.LEFT | SWT.BORDER);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
    resourceGrpField.setLayoutData(gridData);
    useExistingRadioButton = new Button(container, SWT.RADIO);
    useExistingRadioButton.setText("Use existing");
    resourceGrpCombo = new Combo(container, SWT.READ_ONLY);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
    resourceGrpCombo.setLayoutData(gridData);
    resourceGroupViewer = new ComboViewer(resourceGrpCombo);
    resourceGroupViewer.setContentProvider(ArrayContentProvider.getInstance());
    SelectionListener updateListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            handleResourceGroup();
        }
    };
    createNewRadioButton.addSelectionListener(updateListener);
    useExistingRadioButton.addSelectionListener(updateListener);
    createNewRadioButton.setSelection(true);
    handleResourceGroup();
    storageAccountLabel = new Label(composite, SWT.LEFT);
    storageAccountLabel.setText("Storage account:");
    storageComboBox = new Combo(composite, SWT.READ_ONLY);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
    storageComboBox.setLayoutData(gridData);
    networkLabel = new Label(composite, SWT.LEFT);
    networkLabel.setText("Virtual Network:");
    networkComboBox = new Combo(composite, SWT.READ_ONLY);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
    networkComboBox.setLayoutData(gridData);
    subnetLabel = new Label(composite, SWT.LEFT);
    subnetLabel.setText("Subnet:");
    subnetComboBox = new Combo(composite, SWT.READ_ONLY);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
    subnetComboBox.setLayoutData(gridData);
    pipLabel = new Label(composite, SWT.LEFT);
    pipLabel.setText("Public IP address:");
    pipCombo = new Combo(composite, SWT.READ_ONLY);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
    pipCombo.setLayoutData(gridData);
    nsgLabel = new Label(composite, SWT.LEFT);
    nsgLabel.setText("Network security group (firewall):");
    nsgCombo = new Combo(composite, SWT.READ_ONLY);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
    nsgCombo.setLayoutData(gridData);
    availabilityLabel = new Label(composite, SWT.LEFT);
    availabilityLabel.setText("Availability set:");
    availabilityCombo = new Combo(composite, SWT.READ_ONLY);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
    availabilityCombo.setLayoutData(gridData);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) ComboViewer(org.eclipse.jface.viewers.ComboViewer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 13 with ComboViewer

use of org.eclipse.jface.viewers.ComboViewer in project azure-tools-for-java by Microsoft.

the class CreateArmStorageAccountForm method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    setTitle("Create New Storage Account");
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "com.microsoft.azuretools.azureexplorer.storage_account_dialog");
    Composite container = new Composite(parent, SWT.FILL);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    gridLayout.marginBottom = 10;
    container.setLayout(gridLayout);
    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = SWT.FILL;
    //		gridData.widthHint = 250;
    container.setLayoutData(gridData);
    nameLabel = new Label(container, SWT.LEFT);
    nameLabel.setText("Name:");
    nameTextField = new Text(container, SWT.LEFT | SWT.BORDER);
    //        gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
    nameTextField.setLayoutData(gridDataForText(180));
    subscriptionLabel = new Label(container, SWT.LEFT);
    subscriptionLabel.setText("Subscription:");
    subscriptionComboBox = new Combo(container, SWT.READ_ONLY);
    subscriptionComboBox.setLayoutData(gridDataForText(180));
    resourceGroupLabel = new Label(container, SWT.LEFT);
    resourceGroupLabel.setText("Resource group:");
    gridData = new GridData();
    gridData.verticalAlignment = SWT.TOP;
    resourceGroupLabel.setLayoutData(gridData);
    final Composite composite = new Composite(container, SWT.NONE);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    gridData.verticalAlignment = GridData.BEGINNING;
    gridData.grabExcessHorizontalSpace = true;
    //        gridData.widthHint = 250;
    composite.setLayout(gridLayout);
    composite.setLayoutData(gridData);
    createNewRadioButton = new Button(composite, SWT.RADIO);
    createNewRadioButton.setText("Create new");
    createNewRadioButton.setSelection(true);
    resourceGrpField = new Text(composite, SWT.LEFT | SWT.BORDER);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
    resourceGrpField.setLayoutData(gridData);
    useExistingRadioButton = new Button(composite, SWT.RADIO);
    useExistingRadioButton.setText("Use existing");
    resourceGrpCombo = new Combo(composite, SWT.READ_ONLY);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
    resourceGrpCombo.setLayoutData(gridData);
    resourceGroupViewer = new ComboViewer(resourceGrpCombo);
    resourceGroupViewer.setContentProvider(ArrayContentProvider.getInstance());
    SelectionListener updateListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            updateResourceGroup();
        }
    };
    createNewRadioButton.addSelectionListener(updateListener);
    useExistingRadioButton.addSelectionListener(updateListener);
    updateResourceGroup();
    regionLabel = new Label(container, SWT.LEFT);
    regionLabel.setText("Region:");
    regionComboBox = new Combo(container, SWT.READ_ONLY);
    regionComboBox.setLayoutData(gridDataForText(180));
    kindLabel = new Label(container, SWT.LEFT);
    kindLabel.setText("Account kind:");
    kindCombo = new Combo(container, SWT.READ_ONLY);
    kindCombo.setLayoutData(gridDataForText(180));
    performanceLabel = new Label(container, SWT.LEFT);
    performanceLabel.setText("Performance:");
    performanceCombo = new Combo(container, SWT.READ_ONLY);
    performanceCombo.setLayoutData(gridDataForText(180));
    replicationLabel = new Label(container, SWT.LEFT);
    replicationLabel.setText("Replication:");
    replicationComboBox = new Combo(container, SWT.READ_ONLY);
    replicationComboBox.setLayoutData(gridDataForText(180));
    if (subscription == null) {
        // not showing access tier with general purpose storage account which is used when creating vm
        accessTierLabel = new Label(container, SWT.LEFT);
        accessTierLabel.setText("Access Tier:");
        accessTierComboBox = new Combo(container, SWT.READ_ONLY);
        accessTierComboBox.setLayoutData(gridDataForText(180));
        for (AccessTier type : AccessTier.values()) {
            accessTierComboBox.add(type.toString());
            accessTierComboBox.setData(type.toString(), type);
        }
        accessTierComboBox.select(0);
    }
    pricingLabel = new Link(container, SWT.LEFT);
    pricingLabel.setText(PRICING_LINK);
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    pricingLabel.setLayoutData(gridData);
    pricingLabel.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            try {
                PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(event.text));
            } catch (Exception ex) {
                /*
					 * only logging the error in log file
					 * not showing anything to end user
					 */
                Activator.getDefault().log("Error occurred while opening link in default browser.", ex);
            }
        }
    });
    nameTextField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent modifyEvent) {
            validateEmptyFields();
        }
    });
    regionComboBox.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            validateEmptyFields();
        }
    });
    resourceGrpField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent modifyEvent) {
            validateEmptyFields();
        }
    });
    resourceGrpCombo.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            validateEmptyFields();
        }
    });
    fillFields();
    return super.createDialogArea(parent);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) AccessTier(com.microsoft.azure.management.storage.AccessTier) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) URL(java.net.URL) InvocationTargetException(java.lang.reflect.InvocationTargetException) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Link(org.eclipse.swt.widgets.Link) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 14 with ComboViewer

use of org.eclipse.jface.viewers.ComboViewer in project eclipse.platform.text by eclipse.

the class AnnotationsConfigurationBlock method createControl.

@Override
public Control createControl(Composite parent) {
    PixelConverter pixelConverter = new PixelConverter(parent);
    Composite composite = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    Label label = new Label(composite, SWT.LEFT);
    label.setText(TextEditorMessages.AnnotationsConfigurationBlock_annotationPresentationOptions);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 2;
    label.setLayoutData(gd);
    Composite editorComposite = new Composite(composite, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    editorComposite.setLayout(layout);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
    gd.horizontalSpan = 2;
    editorComposite.setLayoutData(gd);
    fAnnotationTypeViewer = new TableViewer(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    fAnnotationTypeViewer.setLabelProvider(new ItemLabelProvider());
    fAnnotationTypeViewer.setContentProvider(new ItemContentProvider());
    gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
    gd.heightHint = pixelConverter.convertHeightInCharsToPixels(20);
    fAnnotationTypeViewer.getControl().setLayoutData(gd);
    Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    optionsComposite.setLayout(layout);
    optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    label = new Label(optionsComposite, SWT.LEFT);
    label.setText(TextEditorMessages.AnnotationsConfigurationBlock_labels_showIn);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    label.setLayoutData(gd);
    fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
    fShowInVerticalRulerCheckBox.setText(TextEditorMessages.AnnotationsConfigurationBlock_showInVerticalRuler);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 20;
    fShowInVerticalRulerCheckBox.setLayoutData(gd);
    fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
    fShowInOverviewRulerCheckBox.setText(TextEditorMessages.AnnotationsConfigurationBlock_showInOverviewRuler);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 20;
    fShowInOverviewRulerCheckBox.setLayoutData(gd);
    fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
    fShowInTextCheckBox.setText(TextEditorMessages.AnnotationsConfigurationBlock_showInText);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalIndent = 20;
    fShowInTextCheckBox.setLayoutData(gd);
    fDecorationViewer = new ComboViewer(optionsComposite, SWT.READ_ONLY);
    fDecorationViewer.setContentProvider(new ArrayContentProvider());
    fDecorationViewer.setLabelProvider(new ArrayLabelProvider());
    fDecorationViewer.setComparator(new ViewerComparator(Collator.getInstance()));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    fDecorationViewer.getControl().setLayoutData(gd);
    fDecorationViewer.setInput(new Object[] { HIGHLIGHT, SQUIGGLES, BOX, DASHED_BOX, UNDERLINE, PROBLEM_UNDERLINE, IBEAM });
    fDecorationViewer.getCombo().setVisibleItemCount(fDecorationViewer.getCombo().getItemCount());
    label = new Label(optionsComposite, SWT.LEFT);
    label.setText(TextEditorMessages.AnnotationsConfigurationBlock_color);
    gd = new GridData();
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalIndent = 20;
    label.setLayoutData(gd);
    fAnnotationForegroundColorEditor = new ColorSelector(optionsComposite);
    Button foregroundColorButton = fAnnotationForegroundColorEditor.getButton();
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    foregroundColorButton.setLayoutData(gd);
    addFiller(optionsComposite);
    fIsNextPreviousTargetCheckBox = new Button(optionsComposite, SWT.CHECK);
    fIsNextPreviousTargetCheckBox.setText(TextEditorMessages.AnnotationsConfigurationBlock_isNavigationTarget);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 0;
    fIsNextPreviousTargetCheckBox.setLayoutData(gd);
    fAnnotationTypeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            handleAnnotationListSelection();
        }
    });
    fShowInTextCheckBox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListItem item = getSelectedItem();
            final boolean value = fShowInTextCheckBox.getSelection();
            if (value) {
                // enable whatever is in the combo
                String[] decoration = (String[]) ((IStructuredSelection) fDecorationViewer.getSelection()).getFirstElement();
                if (HIGHLIGHT.equals(decoration))
                    fStore.setValue(item.highlightKey, true);
                else
                    fStore.setValue(item.textKey, true);
            } else {
                // disable both
                if (item.textKey != null)
                    fStore.setValue(item.textKey, false);
                if (item.highlightKey != null)
                    fStore.setValue(item.highlightKey, false);
            }
            fStore.setValue(item.textKey, value);
            updateDecorationViewer(item, false);
            fAnnotationTypeViewer.refresh(item);
        }
    });
    fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListItem item = getSelectedItem();
            fStore.setValue(item.overviewRulerKey, fShowInOverviewRulerCheckBox.getSelection());
            fAnnotationTypeViewer.refresh(item);
        }
    });
    fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListItem item = getSelectedItem();
            fStore.setValue(item.verticalRulerKey, fShowInVerticalRulerCheckBox.getSelection());
            fAnnotationTypeViewer.refresh(item);
        }
    });
    fIsNextPreviousTargetCheckBox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListItem item = getSelectedItem();
            fStore.setValue(item.isNextPreviousNavigationKey, fIsNextPreviousTargetCheckBox.getSelection());
            fAnnotationTypeViewer.refresh(item);
        }
    });
    foregroundColorButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListItem item = getSelectedItem();
            PreferenceConverter.setValue(fStore, item.colorKey, fAnnotationForegroundColorEditor.getColorValue());
            fAnnotationTypeViewer.refresh(item);
        }
    });
    fDecorationViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            String[] decoration = (String[]) ((IStructuredSelection) fDecorationViewer.getSelection()).getFirstElement();
            ListItem item = getSelectedItem();
            if (fShowInTextCheckBox.getSelection()) {
                if (HIGHLIGHT.equals(decoration)) {
                    fStore.setValue(item.highlightKey, true);
                    if (item.textKey != null) {
                        fStore.setValue(item.textKey, false);
                        if (item.textStyleKey != null)
                            fStore.setValue(item.textStyleKey, AnnotationPreference.STYLE_NONE);
                    }
                } else {
                    if (item.highlightKey != null)
                        fStore.setValue(item.highlightKey, false);
                    if (item.textKey != null) {
                        fStore.setValue(item.textKey, true);
                        if (item.textStyleKey != null)
                            fStore.setValue(item.textStyleKey, decoration[1]);
                    }
                }
            }
            fAnnotationTypeViewer.refresh(item);
        }
    });
    composite.layout();
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ComboViewer(org.eclipse.jface.viewers.ComboViewer) PixelConverter(org.eclipse.jface.layout.PixelConverter) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ColorSelector(org.eclipse.jface.preference.ColorSelector) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 15 with ComboViewer

use of org.eclipse.jface.viewers.ComboViewer in project eclipse.platform.text by eclipse.

the class SpellingConfigurationBlock method createProviderViewer.

private ComboViewer createProviderViewer() {
    /* list viewer */
    final ComboViewer viewer = new ComboViewer(fProviderCombo);
    viewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public void dispose() {
        }

        @Override
        public void inputChanged(Viewer v, Object oldInput, Object newInput) {
        }

        @Override
        public Object[] getElements(Object inputElement) {
            return fProviderDescriptors.values().toArray();
        }
    });
    viewer.setLabelProvider(new LabelProvider() {

        @Override
        public Image getImage(Object element) {
            return null;
        }

        @Override
        public String getText(Object element) {
            return ((SpellingEngineDescriptor) element).getLabel();
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            if (sel.isEmpty())
                return;
            if (fCurrentBlock != null && fStatusMonitor.getStatus() != null && fStatusMonitor.getStatus().matches(IStatus.ERROR))
                if (isPerformRevert()) {
                    ISafeRunnable runnable = new ISafeRunnable() {

                        @Override
                        public void run() throws Exception {
                            fCurrentBlock.performRevert();
                        }

                        @Override
                        public void handleException(Throwable x) {
                        }
                    };
                    SafeRunner.run(runnable);
                } else {
                    revertSelection();
                    return;
                }
            fStore.setValue(SpellingService.PREFERENCE_SPELLING_ENGINE, ((SpellingEngineDescriptor) sel.getFirstElement()).getId());
            updateListDependencies();
        }

        private boolean isPerformRevert() {
            Shell shell = viewer.getControl().getShell();
            MessageDialog dialog = new MessageDialog(shell, TextEditorMessages.SpellingConfigurationBlock_error_title, null, TextEditorMessages.SpellingConfigurationBlock_error_message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1);
            return dialog.open() == 0;
        }

        private void revertSelection() {
            try {
                viewer.removeSelectionChangedListener(this);
                SpellingEngineDescriptor desc = EditorsUI.getSpellingService().getActiveSpellingEngineDescriptor(fStore);
                if (desc != null)
                    viewer.setSelection(new StructuredSelection(desc), true);
            } finally {
                viewer.addSelectionChangedListener(this);
            }
        }
    });
    viewer.setInput(fProviderDescriptors);
    viewer.refresh();
    return viewer;
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Image(org.eclipse.swt.graphics.Image) SpellingEngineDescriptor(org.eclipse.ui.texteditor.spelling.SpellingEngineDescriptor) Shell(org.eclipse.swt.widgets.Shell) ComboViewer(org.eclipse.jface.viewers.ComboViewer) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Aggregations

ComboViewer (org.eclipse.jface.viewers.ComboViewer)46 Label (org.eclipse.swt.widgets.Label)33 GridData (org.eclipse.swt.layout.GridData)30 Composite (org.eclipse.swt.widgets.Composite)30 Combo (org.eclipse.swt.widgets.Combo)26 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)22 Button (org.eclipse.swt.widgets.Button)22 GridLayout (org.eclipse.swt.layout.GridLayout)21 Text (org.eclipse.swt.widgets.Text)21 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)18 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)18 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)17 SelectionEvent (org.eclipse.swt.events.SelectionEvent)15 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)13 LabelProvider (org.eclipse.jface.viewers.LabelProvider)12 Point (org.eclipse.swt.graphics.Point)11 Group (org.eclipse.swt.widgets.Group)11 Control (org.eclipse.swt.widgets.Control)10 ISelection (org.eclipse.jface.viewers.ISelection)8 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8