Search in sources :

Example 16 with ControlAdapter

use of org.eclipse.swt.events.ControlAdapter in project dbeaver by serge-rider.

the class ViewerColumnController method recreateColumns.

private void recreateColumns(boolean pack) {
    final Control control = viewer.getControl();
    control.setRedraw(false);
    isInitializing = true;
    try {
        boolean needRefresh = false;
        for (ColumnInfo columnInfo : columns) {
            if (columnInfo.column != null) {
                columnInfo.column.dispose();
                columnInfo.column = null;
                needRefresh = true;
            }
        }
        createVisibleColumns();
        if (pack && !isAllSized()) {
            repackColumns();
            control.addControlListener(new ControlAdapter() {

                @Override
                public void controlResized(ControlEvent e) {
                    control.removeControlListener(this);
                    repackColumns();
                }
            });
        }
        if (needRefresh) {
            viewer.refresh();
            for (ColumnInfo columnInfo : getVisibleColumns()) {
                if (columnInfo.column instanceof TreeColumn) {
                    ((TreeColumn) columnInfo.column).pack();
                } else {
                    ((TableColumn) columnInfo.column).pack();
                }
            }
        }
    } finally {
        control.setRedraw(true);
        isInitializing = false;
    }
}
Also used : ControlAdapter(org.eclipse.swt.events.ControlAdapter) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 17 with ControlAdapter

use of org.eclipse.swt.events.ControlAdapter in project dbeaver by serge-rider.

the class DataTransferPagePipes method createControl.

@Override
public void createControl(Composite parent) {
    initializeDialogUnits(parent);
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    consumersTable = new TableViewer(composite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
    consumersTable.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
    consumersTable.getTable().setLinesVisible(true);
    consumersTable.setContentProvider(new IStructuredContentProvider() {

        @Override
        public void dispose() {
        }

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

        @Override
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof Collection) {
                return ((Collection<?>) inputElement).toArray();
            }
            return new Object[0];
        }
    });
    CellLabelProvider labelProvider = new CellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            TransferTarget element = (TransferTarget) cell.getElement();
            if (cell.getColumnIndex() == 0) {
                if (element.processor != null) {
                    cell.setImage(DBeaverIcons.getImage(element.processor.getIcon()));
                    cell.setText(element.processor.getName());
                } else {
                    cell.setImage(DBeaverIcons.getImage(element.consumer.getIcon()));
                    cell.setText(element.consumer.getName());
                }
            } else {
                if (element.processor != null) {
                    cell.setText(element.processor.getDescription());
                } else {
                    cell.setText(element.consumer.getDescription());
                }
            }
        }
    };
    {
        TableViewerColumn columnName = new TableViewerColumn(consumersTable, SWT.LEFT);
        columnName.setLabelProvider(labelProvider);
        columnName.getColumn().setText(CoreMessages.data_transfer_wizard_init_column_exported);
        TableViewerColumn columnDesc = new TableViewerColumn(consumersTable, SWT.LEFT);
        columnDesc.setLabelProvider(labelProvider);
        columnDesc.getColumn().setText(CoreMessages.data_transfer_wizard_init_column_description);
    }
    loadConsumers();
    consumersTable.getTable().addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final IStructuredSelection selection = (IStructuredSelection) consumersTable.getSelection();
            TransferTarget target;
            if (!selection.isEmpty()) {
                target = (TransferTarget) selection.getFirstElement();
            } else {
                target = null;
            }
            if (target == null) {
                getWizard().getSettings().selectConsumer(null, null);
            } else {
                getWizard().getSettings().selectConsumer(target.consumer, target.processor);
            }
            updatePageCompletion();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
            if (isPageComplete()) {
                getWizard().getContainer().showPage(getWizard().getNextPage(DataTransferPagePipes.this));
            }
        }
    });
    consumersTable.getTable().addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            UIUtils.packColumns(consumersTable.getTable());
            UIUtils.maxTableColumnsWidth(consumersTable.getTable());
            consumersTable.getTable().removeControlListener(this);
        }
    });
    setControl(composite);
    DataTransferNodeDescriptor consumer = getWizard().getSettings().getConsumer();
    DataTransferProcessorDescriptor processor = getWizard().getSettings().getProcessor();
    if (consumer != null) {
        Collection<TransferTarget> targets = (Collection<TransferTarget>) consumersTable.getInput();
        for (TransferTarget target : targets) {
            if (target.consumer == consumer && target.processor == processor) {
                consumersTable.setSelection(new StructuredSelection(target));
                break;
            }
        }
    }
    updatePageCompletion();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) DataTransferProcessorDescriptor(org.jkiss.dbeaver.registry.transfer.DataTransferProcessorDescriptor) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Collection(java.util.Collection) DataTransferNodeDescriptor(org.jkiss.dbeaver.registry.transfer.DataTransferNodeDescriptor) ControlEvent(org.eclipse.swt.events.ControlEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 18 with ControlAdapter

use of org.eclipse.swt.events.ControlAdapter in project cubrid-manager by CUBRID.

the class ShardEnvStatusView method createPartControl.

/**
	 * Create the page content
	 * 
	 * @param parent
	 *            the parent composite
	 */
public void createPartControl(Composite parent) {
    composite = new Composite(parent, SWT.NONE);
    composite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    composite.setLayout(new FillLayout());
    createTable();
    // makeActions();
    composite.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent event) {
            updateTableLayout();
        }
    });
    new StatusUpdate().start();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) FillLayout(org.eclipse.swt.layout.FillLayout) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 19 with ControlAdapter

use of org.eclipse.swt.events.ControlAdapter in project cubrid-manager by CUBRID.

the class BrokerEnvStatusView method createPartControl.

/**
	 * Create the page content
	 *
	 * @param parent the parent composite
	 */
public void createPartControl(Composite parent) {
    composite = new Composite(parent, SWT.NONE);
    composite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    composite.setLayout(new FillLayout());
    createTable();
    makeActions();
    composite.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent event) {
            updateTableLayout();
        }
    });
    new StatusUpdate().start();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) FillLayout(org.eclipse.swt.layout.FillLayout) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 20 with ControlAdapter

use of org.eclipse.swt.events.ControlAdapter in project MonjaDB by Kanatoko.

the class MJavaScriptView method init2.

//--------------------------------------------------------------------------------
public void init2() {
    parent.setLayout(new FormLayout());
    sashForm = new SashForm(parent, SWT.SMOOTH | SWT.VERTICAL);
    FormData fd_sashForm1 = new FormData();
    fd_sashForm1.top = new FormAttachment(0, 1);
    fd_sashForm1.left = new FormAttachment(0, 1);
    fd_sashForm1.right = new FormAttachment(100, -1);
    fd_sashForm1.bottom = new FormAttachment(100, -1);
    sashForm.setLayoutData(fd_sashForm1);
    text1 = new Text(sashForm, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    text1.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            onSashResize();
        }
    });
    text1.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            executeAction.setEnabled(dataManager.isConnected() && text1.getText().length() > 0);
        }
    });
    FormData fd_text = new FormData();
    fd_text.top = new FormAttachment(0, 1);
    fd_text.left = new FormAttachment(0, 1);
    fd_text.bottom = new FormAttachment(100, -1);
    fd_text.right = new FormAttachment(100, -1);
    text1.setLayoutData(fd_text);
    text2 = new Text(sashForm, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    FormData fd_text2 = new FormData();
    fd_text2.top = new FormAttachment(0, 1);
    fd_text2.left = new FormAttachment(0, 1);
    fd_text2.bottom = new FormAttachment(100, -1);
    fd_text2.right = new FormAttachment(100, -1);
    text2.setLayoutData(fd_text2);
    executeAction = new Action() {

        public void run() {
            //-----------
            onExecute();
        }
    };
    //-----------
    executeAction.setToolTipText("Execute JavaScript 'eval()' on MongoDB Server");
    executeAction.setText("Execute");
    initAction(executeAction, "database_go.png", null);
    executeAction.setEnabled(false);
    clearAction = new Action() {

        public void run() {
            //-----------
            text1.setText("");
            text2.setText("");
        }
    };
    //-----------
    clearAction.setToolTipText("Clear");
    clearAction.setText("Clear");
    initAction(clearAction, "bullet_delete.png", null);
    clearAction.setEnabled(true);
    if (prop.containsKey(JAVASCRIPT_COMPOSITE_WEIGHT)) {
        (new Thread() {

            public void run() {
                MSystemUtil.sleep(0);
                shell.getDisplay().asyncExec(new Runnable() {

                    public void run() {
                        //----
                        sashForm.setWeights(prop.getIntArrayProperty(JAVASCRIPT_COMPOSITE_WEIGHT));
                    }
                });
            //----
            }
        }).start();
    } else {
        sashForm.setWeights(new int[] { 70, 30 });
    }
    initializedTime = System.currentTimeMillis();
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Action(org.eclipse.jface.action.Action) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ModifyListener(org.eclipse.swt.events.ModifyListener) ControlEvent(org.eclipse.swt.events.ControlEvent)

Aggregations

ControlAdapter (org.eclipse.swt.events.ControlAdapter)28 ControlEvent (org.eclipse.swt.events.ControlEvent)28 Composite (org.eclipse.swt.widgets.Composite)16 SelectionEvent (org.eclipse.swt.events.SelectionEvent)12 GridLayout (org.eclipse.swt.layout.GridLayout)11 Point (org.eclipse.swt.graphics.Point)9 GridData (org.eclipse.swt.layout.GridData)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 Rectangle (org.eclipse.swt.graphics.Rectangle)7 TableColumn (org.eclipse.swt.widgets.TableColumn)7 ModifyEvent (org.eclipse.swt.events.ModifyEvent)6 Button (org.eclipse.swt.widgets.Button)6 ModifyListener (org.eclipse.swt.events.ModifyListener)5 FillLayout (org.eclipse.swt.layout.FillLayout)5 Label (org.eclipse.swt.widgets.Label)5 Table (org.eclipse.swt.widgets.Table)5 SashForm (org.eclipse.swt.custom.SashForm)4 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)4 Event (org.eclipse.swt.widgets.Event)4 Listener (org.eclipse.swt.widgets.Listener)4