Search in sources :

Example 1 with PropertyChangeEvent

use of org.eclipse.jface.util.PropertyChangeEvent in project dbeaver by serge-rider.

the class SpreadsheetPresentation method createPresentation.

@Override
public void createPresentation(@NotNull IResultSetController controller, @NotNull Composite parent) {
    super.createPresentation(controller, parent);
    this.boldFont = UIUtils.makeBoldFont(parent.getFont());
    this.italicFont = UIUtils.modifyFont(parent.getFont(), SWT.ITALIC);
    this.foregroundNull = parent.getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
    this.spreadsheet = new Spreadsheet(parent, SWT.MULTI | SWT.VIRTUAL | SWT.H_SCROLL | SWT.V_SCROLL, controller.getSite(), this, new ContentProvider(), new GridLabelProvider());
    this.spreadsheet.setLayoutData(new GridData(GridData.FILL_BOTH));
    this.spreadsheet.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (e.detail != SWT.DRAG && e.detail != SWT.DROP_DOWN) {
                updateGridCursor((GridCell) e.data);
            }
            fireSelectionChanged(new SpreadsheetSelectionImpl());
        }
    });
    spreadsheet.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
            SpreadsheetPresentation.this.controller.updateEditControls();
        }

        @Override
        public void focusLost(FocusEvent e) {
            SpreadsheetPresentation.this.controller.updateEditControls();
        }
    });
    this.themeManager = controller.getSite().getWorkbenchWindow().getWorkbench().getThemeManager();
    this.themeChangeListener = new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().startsWith(ThemeConstants.RESULTS_PROP_PREFIX)) {
                applyThemeSettings();
            }
        }
    };
    this.themeManager.addPropertyChangeListener(themeChangeListener);
    applyThemeSettings();
    this.spreadsheet.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            dispose();
        }
    });
    trackPresentationControl();
    UIUtils.enableHostEditorKeyBindingsSupport(controller.getSite(), spreadsheet);
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) IGridContentProvider(org.jkiss.dbeaver.ui.controls.lightgrid.IGridContentProvider) GridCell(org.jkiss.dbeaver.ui.controls.lightgrid.GridCell) IGridLabelProvider(org.jkiss.dbeaver.ui.controls.lightgrid.IGridLabelProvider) GridData(org.eclipse.swt.layout.GridData)

Example 2 with PropertyChangeEvent

use of org.eclipse.jface.util.PropertyChangeEvent in project dbeaver by serge-rider.

the class PrefPageConnectionTypes method createContents.

@Override
protected Control createContents(final Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 1, 5);
    {
        typeTable = new Table(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
        typeTable.setLayoutData(new GridData(GridData.FILL_BOTH));
        UIUtils.createTableColumn(typeTable, SWT.LEFT, "Name");
        UIUtils.createTableColumn(typeTable, SWT.LEFT, "Description");
        typeTable.setHeaderVisible(true);
        typeTable.setLayoutData(new GridData(GridData.FILL_BOTH));
        typeTable.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                showSelectedType(getSelectedType());
            }
        });
        ToolBar toolbar = new ToolBar(composite, SWT.FLAT | SWT.HORIZONTAL);
        final ToolItem newButton = new ToolItem(toolbar, SWT.NONE);
        newButton.setImage(DBeaverIcons.getImage(UIIcon.ROW_ADD));
        deleteButton = new ToolItem(toolbar, SWT.NONE);
        deleteButton.setImage(DBeaverIcons.getImage(UIIcon.ROW_DELETE));
        newButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                String name;
                for (int i = 1; ; i++) {
                    name = "Type" + i;
                    boolean hasName = false;
                    for (DBPConnectionType type : changedInfo.keySet()) {
                        if (type.getName().equals(name)) {
                            hasName = true;
                            break;
                        }
                    }
                    if (!hasName) {
                        break;
                    }
                }
                DBPConnectionType newType = new DBPConnectionType(SecurityUtils.generateUniqueId(), name, "255,255,255", "New type", true, false);
                addTypeToTable(newType, newType);
                typeTable.select(typeTable.getItemCount() - 1);
                typeTable.showSelection();
                showSelectedType(newType);
            }
        });
        this.deleteButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                DBPConnectionType connectionType = getSelectedType();
                if (!UIUtils.confirmAction(getShell(), "Delete connection type", "Are you sure you want to delete connection type '" + connectionType.getName() + "'?\n" + "All connections of this type will be reset to default type (" + DBPConnectionType.DEFAULT_TYPE.getName() + ")")) {
                    return;
                }
                changedInfo.remove(connectionType);
                int index = typeTable.getSelectionIndex();
                typeTable.remove(index);
                if (index > 0)
                    index--;
                typeTable.select(index);
                showSelectedType(getSelectedType());
            }
        });
    }
    {
        Group groupSettings = UIUtils.createControlGroup(composite, "Settings", 2, GridData.VERTICAL_ALIGN_BEGINNING, 300);
        groupSettings.setLayoutData(new GridData(GridData.FILL_BOTH));
        typeName = UIUtils.createLabelText(groupSettings, "Name", null);
        typeName.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                getSelectedType().setName(typeName.getText());
                updateTableInfo();
            }
        });
        typeDescription = UIUtils.createLabelText(groupSettings, "Description", null);
        typeDescription.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                getSelectedType().setDescription(typeDescription.getText());
                updateTableInfo();
            }
        });
        {
            UIUtils.createControlLabel(groupSettings, "Color");
            //                Composite colorGroup = UIUtils.createPlaceholder(groupSettings, 2, 5);
            //                colorGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            colorPicker = new ColorSelector(groupSettings);
            //                colorPicker.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            colorPicker.addListener(new IPropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent event) {
                    getSelectedType().setColor(StringConverter.asString(colorPicker.getColorValue()));
                    updateTableInfo();
                }
            });
        /*
                Button pickerButton = new Button(colorGroup, SWT.PUSH);
                pickerButton.setText("...");
                pickerButton.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e)
                    {
                        DBPConnectionType connectionType = getSelectedType();
                        ColorDialog colorDialog = new ColorDialog(parent.getShell());
                        colorDialog.setRGB(StringConverter.asRGB(connectionType.getColor()));
                        RGB rgb = colorDialog.open();
                        if (rgb != null) {
                            Color color = null;
                            int count = colorPicker.getItemCount();
                            for (int i = 0; i < count; i++) {
                                Color item = colorPicker.getColorItem(i);
                                if (item != null && item.getRGB().equals(rgb)) {
                                    color = item;
                                    break;
                                }
                            }
                            if (color == null) {
                                color = new Color(colorPicker.getDisplay(), rgb);
                                colorPicker.addColor(color);
                            }
                            colorPicker.select(color);
                            getSelectedType().setColor(StringConverter.asString(color.getRGB()));
                            updateTableInfo();
                        }
                    }
                });
*/
        }
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        autocommitCheck = UIUtils.createCheckbox(groupSettings, "Auto-commit by default", false);
        autocommitCheck.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                getSelectedType().setAutocommit(autocommitCheck.getSelection());
            }
        });
        autocommitCheck.setLayoutData(gd);
        confirmCheck = UIUtils.createCheckbox(groupSettings, "Confirm SQL execution", false);
        confirmCheck.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                getSelectedType().setConfirmExecute(confirmCheck.getSelection());
            }
        });
        confirmCheck.setLayoutData(gd);
    }
    performDefaults();
    return composite;
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) DBPConnectionType(org.jkiss.dbeaver.model.connection.DBPConnectionType) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) GridData(org.eclipse.swt.layout.GridData) ColorSelector(org.eclipse.jface.preference.ColorSelector)

Example 3 with PropertyChangeEvent

use of org.eclipse.jface.util.PropertyChangeEvent in project translationstudio8 by heartsome.

the class PluginConfigManageDialog method createShortcutKeyGoup.

/**
	 * 创建快捷键面板
	 * @param tparent
	 *            ;
	 */
private void createShortcutKeyGoup(Composite tparent) {
    Group group = new Group(tparent, SWT.None);
    group.setText(Messages.getString("dialog.PluginConfigManageDialog.group"));
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(group);
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(group);
    Label keyLbl = new Label(group, SWT.NONE);
    keyLbl.setText(Messages.getString("dialog.PluginConfigManageDialog.keyLbl"));
    keyTxt = new Text(group, SWT.BORDER);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(keyTxt);
    fKeySequenceText = new KeySequenceText(keyTxt);
    fKeySequenceText.setKeyStrokeLimit(4);
    fKeySequenceText.addPropertyChangeListener(new IPropertyChangeListener() {

        public final void propertyChange(final PropertyChangeEvent event) {
            if (!event.getOldValue().equals(event.getNewValue())) {
                final KeySequence keySequence = fKeySequenceText.getKeySequence();
                if (!keySequence.isComplete()) {
                    return;
                }
                keyTxt.setSelection(keyTxt.getTextLimit());
            }
        }
    });
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) Group(org.eclipse.swt.widgets.Group) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Label(org.eclipse.swt.widgets.Label) KeySequenceText(org.eclipse.jface.bindings.keys.KeySequenceText) Text(org.eclipse.swt.widgets.Text) KeySequenceText(org.eclipse.jface.bindings.keys.KeySequenceText) KeySequence(org.eclipse.jface.bindings.keys.KeySequence)

Example 4 with PropertyChangeEvent

use of org.eclipse.jface.util.PropertyChangeEvent in project tdi-studio-se by Talend.

the class DragAndDrogDialog method createDialogArea.

/*
     * (non-Javadoc) Method declared on Dialog.
     */
protected Control createDialogArea(Composite parent) {
    // create composite
    Composite composite = (Composite) super.createDialogArea(parent);
    // composite.setLayout(new GridLayout());
    // String[][] namevalues = new String[][] { { "Create as sub-element of target node", CREATE_AS_SUBELEMENT },
    // { "Create as attribute of target node", CREATE_AS_ATTRIBUTE }, { "Add linker to target node", CREATE_AS_TEXT
    // } };
    String[][] namevalues = null;
    if (hasChildren) {
        namevalues = new String[][] { { "Create as sub-element of target node", CREATE_AS_SUBELEMENT }, { "Create as attribute of target node", CREATE_AS_ATTRIBUTE } };
    } else {
        namevalues = new String[][] { { "Create as sub-element of target node", CREATE_AS_SUBELEMENT }, { "Create as attribute of target node", CREATE_AS_ATTRIBUTE }, { "Add linker to target node", CREATE_AS_TEXT } };
    }
    RadioGroupFieldEditor rgfe = new RadioGroupFieldEditor("", "Select the operation:", 1, namevalues, composite, true);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 12;
    composite.setLayout(layout);
    rgfe.setPropertyChangeListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            value = event.getNewValue().toString();
        }
    });
    applyDialogFont(composite);
    return composite;
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) RadioGroupFieldEditor(org.eclipse.jface.preference.RadioGroupFieldEditor) GridLayout(org.eclipse.swt.layout.GridLayout) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Composite(org.eclipse.swt.widgets.Composite)

Example 5 with PropertyChangeEvent

use of org.eclipse.jface.util.PropertyChangeEvent in project cubrid-manager by CUBRID.

the class ChartCompositePart method createSeriesList.

/**
	 * Create the sub composite of Series selection combo and its related
	 * properties such as check and color
	 *
	 * @param composite the parent composite
	 */
private void createSeriesList(Composite composite) {
    Composite comp = new Composite(composite, SWT.NONE);
    GridLayout layout = new GridLayout(3, false);
    comp.setLayout(layout);
    comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    combo = new Combo(comp, SWT.DROP_DOWN);
    for (Map.Entry<String, String> entry : valueMap.entrySet()) {
        combo.add(entry.getKey());
    }
    combo.setLayout(new GridLayout());
    combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    combo.addSelectionListener(new SelectionAdapter() {

        /**
			 * Sent when selection occurs in the control.
			 *
			 * @param event an event containing information about the selection
			 */
        public void widgetSelected(SelectionEvent event) {
            widgetDefaultSelected(event);
        }

        /**
			 * Sent when default selection occurs in the control.
			 *
			 * @param event an event containing information about the default
			 *        selection
			 */
        public void widgetDefaultSelected(SelectionEvent event) {
            String selectedItem = combo.getItem(combo.getSelectionIndex());
            boolean checked = settingMap.get(selectedItem).isChecked();
            RGB rgb = settingMap.get(selectedItem).getSeriesRgb();
            checkBtn.setSelection(checked);
            colorField.getColorSelector().setColorValue(rgb);
        }
    });
    checkBtn = new Button(comp, SWT.CHECK);
    checkBtn.setText(Messages.seriesSelectCheckBtn);
    checkBtn.addSelectionListener(new SelectionAdapter() {

        /**
			 * Sent when selection occurs in the control.
			 *
			 * @param event an event containing information about the selection
			 */
        public void widgetSelected(SelectionEvent event) {
            widgetDefaultSelected(event);
        }

        /**
			 * Sent when default selection occurs in the control.
			 *
			 * @param event an event containing information about the default
			 *        selection
			 */
        public void widgetDefaultSelected(SelectionEvent event) {
            handleUpdateSettingChange();
        }
    });
    Composite selComp = new Composite(comp, SWT.NONE);
    colorField = new ColorFieldEditor(Messages.seriesSelectColorBtnName, Messages.seriesSelectColorBtnLbl, selComp);
    colorField.getColorSelector().addListener(new IPropertyChangeListener() {

        /**
			 * Notification that a property has changed.
			 *
			 * @param event the property change event object describing which
			 *        property changed and how
			 */
        public void propertyChange(PropertyChangeEvent event) {
            handleUpdateSettingChange();
        }
    });
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Composite(org.eclipse.swt.widgets.Composite) ChartComposite(org.jfree.experimental.chart.swt.ChartComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Combo(org.eclipse.swt.widgets.Combo) RGB(org.eclipse.swt.graphics.RGB) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ColorFieldEditor(org.eclipse.jface.preference.ColorFieldEditor) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Map(java.util.Map) TreeMap(java.util.TreeMap)

Aggregations

IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)13 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)13 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 ColorSelector (org.eclipse.jface.preference.ColorSelector)3 Composite (org.eclipse.swt.widgets.Composite)3 Iterator (java.util.Iterator)2 KeySequence (org.eclipse.jface.bindings.keys.KeySequence)2 RadioGroupFieldEditor (org.eclipse.jface.preference.RadioGroupFieldEditor)2 BindingElement (org.eclipse.ui.internal.keys.model.BindingElement)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)1 IAction (org.eclipse.jface.action.IAction)1 Binding (org.eclipse.jface.bindings.Binding)1 KeySequenceText (org.eclipse.jface.bindings.keys.KeySequenceText)1