Search in sources :

Example 31 with SelectionChangedEvent

use of org.eclipse.jface.viewers.SelectionChangedEvent in project translationstudio8 by heartsome.

the class ConversionWizardPage method createConversionOptionsGroup.

/**
	 * 转换选项组
	 * @param contents
	 *            ;
	 */
private void createConversionOptionsGroup(Composite contents) {
    Group options = new Group(contents, SWT.NONE);
    //$NON-NLS-1$
    options.setText(Messages.getString("wizard.ConversionWizardPage.options"));
    options.setLayout(new GridLayout(1, false));
    options.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    /* 如果已经存在,是否要替换 */
    final Button btnReplaceTarget = new Button(options, SWT.CHECK);
    //$NON-NLS-1$
    btnReplaceTarget.setText(Messages.getString("wizard.ConversionWizardPage.btnReplaceTarget"));
    btnReplaceTarget.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnReplaceTarget.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            isReplaceTarget = btnReplaceTarget.getSelection();
            for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
                conversionConfigBean.setReplaceTarget(btnReplaceTarget.getSelection());
            }
            validate();
        }
    });
    final Button btnOpenPreTrans = new Button(options, SWT.CHECK);
    btnOpenPreTrans.setText(Messages.getString("wizard.ConversionWizardPage.btnOpenPreTrans"));
    btnOpenPreTrans.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnOpenPreTrans.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            isOpenPreTrans = btnOpenPreTrans.getSelection();
        }
    });
    Composite composite = new Composite(options, SWT.NONE);
    GridLayout gd = new GridLayout(1, false);
    gd.marginWidth = 0;
    gd.marginHeight = 0;
    composite.setLayout(gd);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    Label tgtLangLbl = new Label(composite, SWT.NONE);
    tgtLangLbl.setText(Messages.getString("wizard.ConversionWizardPage.tgtLangLbl"));
    tgtLangViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    Table tgtLangTable = tgtLangViewer.getTable();
    GridData gdTgtLangTable = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gdTgtLangTable.heightHint = 80;
    tgtLangTable.setLayoutData(gdTgtLangTable);
    tgtLangViewer.setLabelProvider(new LanguageLabelProvider());
    tgtLangViewer.setContentProvider(new ArrayContentProvider());
    tgtLangViewer.setInput(conversionConfigBeans.get(0).getTgtLangList());
    tgtLangViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            @SuppressWarnings("unchecked") List<Language> selectedList = sel.toList();
            for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
                conversionConfigBean.setHasSelTgtLangList(selectedList);
            }
            validate();
        }
    });
    tgtLangViewer.getTable().select(0);
    IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings();
    btnReplaceTarget.setSelection(dialogSettings.getBoolean(REPLACE_TARGET));
    btnOpenPreTrans.setSelection(dialogSettings.getBoolean(OPEN_PRE_TRANS));
    this.isOpenPreTrans = btnOpenPreTrans.getSelection();
    isReplaceTarget = btnReplaceTarget.getSelection();
    for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
        conversionConfigBean.setReplaceTarget(isReplaceTarget);
    }
    validate();
}
Also used : Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) LanguageLabelProvider(net.heartsome.cat.ts.ui.composite.LanguageLabelProvider) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) 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) ConversionConfigBean(net.heartsome.cat.convert.ui.model.ConversionConfigBean) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) WritableList(org.eclipse.core.databinding.observable.list.WritableList) List(java.util.List) ArrayList(java.util.ArrayList) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 32 with SelectionChangedEvent

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

the class AzureNewDockerConfigPage method updateDockerSubscriptionComboBox.

private void updateDockerSubscriptionComboBox(Composite mainContainer) {
    dockerSubscriptionComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection.size() > 0) {
                AzureDockerSubscription currentSubscription = (AzureDockerSubscription) selection.getFirstElement();
                dockerSubscriptionIdTextField.setText(currentSubscription != null ? currentSubscription.id : "");
                wizard.setSubscription(currentSubscription);
                errDispatcher.removeMessage("dockerSubscriptionCombo", dockerSubscriptionCombo);
                updateDockerLocationComboBox(mainContainer, currentSubscription);
                updateDockerHostSelectRGComboBox(mainContainer, currentSubscription);
                String region = (String) dockerLocationComboBox.getText();
                Region regionObj = Region.findByLabelOrName(region);
                updateDockerSelectVnetComboBox(mainContainer, currentSubscription, regionObj != null ? regionObj.name() : region);
                updateDockerSelectStorageComboBox(mainContainer, currentSubscription);
                setPageComplete(doValidate());
            } else {
                errDispatcher.addMessage("dockerSubscriptionCombo", "No active subscriptions found", null, IMessageProvider.ERROR, dockerSubscriptionCombo);
                setPageComplete(false);
            }
        }
    });
    dockerSubscriptionComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    dockerSubscriptionComboViewer.setInput(dockerManager.getSubscriptionsList());
    if (dockerManager.getSubscriptionsList() != null && dockerManager.getSubscriptionsList().size() > 0) {
        dockerSubscriptionCombo.select(0);
        dockerSubscriptionIdTextField.setText(((AzureDockerSubscription) ((StructuredSelection) dockerSubscriptionComboViewer.getSelection()).getFirstElement()).id);
        wizard.setSubscription((AzureDockerSubscription) ((StructuredSelection) dockerSubscriptionComboViewer.getSelection()).getFirstElement());
    }
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) AzureDockerSubscription(com.microsoft.azure.docker.model.AzureDockerSubscription) Region(com.microsoft.azure.management.resources.fluentcore.arm.Region) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 33 with SelectionChangedEvent

use of org.eclipse.jface.viewers.SelectionChangedEvent in project cubrid-manager by CUBRID.

the class RecentlyUsedSQLComposite method createHistoryTable.

/**
	 * createHistoryTable
	 * @param bottomSash
	 */
public void createHistoryTable(SashForm bottomSash) {
    sqlHistoryTable = new TableViewer(bottomSash, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
    sqlHistoryTable.getTable().setHeaderVisible(true);
    sqlHistoryTable.getTable().setLinesVisible(true);
    //		final TableViewerColumn columnNO = new TableViewerColumn(
    //				sqlHistoryTable, SWT.CENTER);
    //		columnNO.getColumn().setWidth(40);
    //		columnNO.getColumn().setText("NO");
    final TableViewerColumn columnRunTime = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
    columnRunTime.getColumn().setWidth(155);
    columnRunTime.getColumn().setText(Messages.recentlyUsedSQLColumnRunTime);
    columnRunTime.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean asc = true;

        @Override
        public void widgetSelected(SelectionEvent e) {
            sqlHistoryTable.setSorter(asc ? Sorter.EXECUTETIME_ASC : Sorter.EXECUTETIME_DESC);
            sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
            asc = !asc;
        }
    });
    final TableViewerColumn columnSQL = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
    columnSQL.getColumn().setWidth(250);
    columnSQL.getColumn().setText(Messages.recentlyUsedSQLColumn);
    columnSQL.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean asc = true;

        @Override
        public void widgetSelected(SelectionEvent e) {
            sqlHistoryTable.setSorter(asc ? Sorter.SQL_ASC : Sorter.SQL_DEC);
            sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
            asc = !asc;
        }
    });
    final TableViewerColumn columnElapseTime = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
    columnElapseTime.getColumn().setWidth(100);
    columnElapseTime.getColumn().setText(Messages.recentlyUsedSQLColumnElapseTime);
    columnElapseTime.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean asc = true;

        @Override
        public void widgetSelected(SelectionEvent e) {
            sqlHistoryTable.setSorter(asc ? Sorter.ELAPSETIME_ASC : Sorter.ELAPSETIME_DESC);
            sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
            asc = !asc;
        }
    });
    final TableViewerColumn columnInfo = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
    columnInfo.getColumn().setWidth(300);
    columnInfo.getColumn().setText(Messages.recentlyUsedSQLColumnLOG);
    columnInfo.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean asc = true;

        @Override
        public void widgetSelected(SelectionEvent e) {
            sqlHistoryTable.setSorter(asc ? Sorter.LOG_ASC : Sorter.LOG_DESC);
            sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
            asc = !asc;
        }
    });
    sqlHistoryTable.setContentProvider(new HistorySQLContentProvider());
    provider = new HistorySQLLabelProvider();
    sqlHistoryTable.setLabelProvider(provider);
    sqlHistoryTable.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(final SelectionChangedEvent event) {
            SQLHistoryDetail history = (SQLHistoryDetail) sqlHistoryTable.getElementAt(sqlHistoryTable.getTable().getSelectionIndex());
            if (history != null) {
                logMessageArea.setText(history.getExecuteInfo() + StringUtil.NEWLINE + history.getSql());
            }
        }
    });
    sqlHistoryTable.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            SQLHistoryDetail history = (SQLHistoryDetail) selection.getFirstElement();
            logMessageArea.setText(history.getExecuteInfo() + StringUtil.NEWLINE + StringUtil.NEWLINE + history.getSql());
            int start = editor.getAllQueries().length();
            editor.setQuery(StringUtil.NEWLINE + history.getSql(), true, false, false);
            int end = start + history.getSql().length();
            // "/n" take a postion ,so both start and end should + 1
            editor.setSelection(start + 1, end + 1);
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 34 with SelectionChangedEvent

use of org.eclipse.jface.viewers.SelectionChangedEvent in project cubrid-manager by CUBRID.

the class LayoutManager method fireSelectionChanged.

/**
	 * 
	 * Fire selection change event
	 * 
	 * @param selection the ISelection object
	 */
public void fireSelectionChanged(ISelection selection) {
    SelectionChangedEvent event = new SelectionChangedEvent(getSelectionProvider(), selection);
    selectionChanged(event);
}
Also used : SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 35 with SelectionChangedEvent

use of org.eclipse.jface.viewers.SelectionChangedEvent in project dbeaver by serge-rider.

the class ViewValuePanel method createContents.

@Override
public Control createContents(IResultSetPresentation presentation, Composite parent) {
    this.presentation = presentation;
    viewPlaceholder = new Composite(parent, SWT.NONE);
    viewPlaceholder.setLayout(new FillLayout());
    viewPlaceholder.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            if (viewPlaceholder.getChildren().length == 0) {
                String hidePanelCmd = ActionUtils.findCommandDescription(ResultSetCommandHandler.CMD_TOGGLE_PANELS, ViewValuePanel.this.presentation.getController().getSite(), true);
                UIUtils.drawMessageOverControl(viewPlaceholder, e, "Select a cell to view/edit value", 0);
                UIUtils.drawMessageOverControl(viewPlaceholder, e, "Press " + hidePanelCmd + " to hide this panel", 20);
            }
        }
    });
    if (this.presentation instanceof ISelectionProvider) {
        final ISelectionProvider selectionProvider = (ISelectionProvider) this.presentation;
        final ISelectionChangedListener selectionListener = new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                if (ViewValuePanel.this.presentation.getController().getVisiblePanel() == ViewValuePanel.this) {
                    refreshValue(false);
                }
            }
        };
        selectionProvider.addSelectionChangedListener(selectionListener);
        viewPlaceholder.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                selectionProvider.removeSelectionChangedListener(selectionListener);
            }
        });
    }
    return viewPlaceholder;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) PaintListener(org.eclipse.swt.events.PaintListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FillLayout(org.eclipse.swt.layout.FillLayout) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Aggregations

SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)802 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)754 GridData (org.eclipse.swt.layout.GridData)417 Composite (org.eclipse.swt.widgets.Composite)332 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)303 GridLayout (org.eclipse.swt.layout.GridLayout)245 SelectionEvent (org.eclipse.swt.events.SelectionEvent)187 Label (org.eclipse.swt.widgets.Label)158 TableViewer (org.eclipse.jface.viewers.TableViewer)153 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)147 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)140 Button (org.eclipse.swt.widgets.Button)140 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)126 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)121 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)120 IPropertiesEditionEvent (org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)116 PropertiesEditionEvent (org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)116 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)116 Table (org.eclipse.swt.widgets.Table)93 ISelection (org.eclipse.jface.viewers.ISelection)84