Search in sources :

Example 11 with PropertyChangeCommand

use of org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand in project tdi-studio-se by Talend.

the class ComponentListController method createCommand.

private Command createCommand(SelectionEvent selectionEvent) {
    Collection<String> elementsName = hashCurControls.keySet();
    for (String name : elementsName) {
        Object o = hashCurControls.get(name);
        if (o instanceof Control) {
            Control ctrl = (Control) o;
            if (ctrl == null) {
                hashCurControls.remove(name);
                return null;
            }
            if (ctrl.equals(selectionEvent.getSource()) && ctrl instanceof CCombo) {
                boolean isDisposed = ((CCombo) ctrl).isDisposed();
                if (!isDisposed && (!elem.getPropertyValue(name).equals(((CCombo) ctrl).getText()))) {
                    //$NON-NLS-1$
                    String value = new String("");
                    List<? extends IElementParameter> elementParametersWithChildrens = elem.getElementParametersWithChildrens();
                    for (int i = 0; i < elementParametersWithChildrens.size(); i++) {
                        IElementParameter param = elementParametersWithChildrens.get(i);
                        if (getParameterName(param).equals(name)) {
                            for (int j = 0; j < param.getListItemsValue().length; j++) {
                                if (((CCombo) ctrl).getText().equals(param.getListItemsDisplayName()[j])) {
                                    value = (String) param.getListItemsValue()[j];
                                }
                            }
                        }
                    }
                    return new PropertyChangeCommand(elem, name, value);
                }
            }
        }
    }
    return null;
}
Also used : Control(org.eclipse.swt.widgets.Control) CCombo(org.eclipse.swt.custom.CCombo) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IElementParameter(org.talend.core.model.process.IElementParameter) Point(org.eclipse.swt.graphics.Point)

Example 12 with PropertyChangeCommand

use of org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand in project tdi-studio-se by Talend.

the class ColorController method createCommand.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createCommand()
     */
private Command createCommand(SelectionEvent event) {
    Control ctrl = (Control) event.getSource();
    if (ctrl instanceof Button) {
        String paramName = (String) ctrl.getData(PARAMETER_NAME);
        if (paramName != null) {
            ColorDialog colorDialog = new ColorDialog(ctrl.getShell());
            colorDialog.setRGB(ColorUtils.parseStringToRGB((String) elem.getPropertyValue(paramName)));
            RGB rgb = colorDialog.open();
            if (rgb != null) {
                setButtonColor((Button) ctrl, rgb);
                Command cmd;
                cmd = new PropertyChangeCommand(elem, paramName, ColorUtils.getRGBValue(rgb));
                return cmd;
            }
        }
    }
    return null;
}
Also used : Control(org.eclipse.swt.widgets.Control) ColorDialog(org.eclipse.swt.widgets.ColorDialog) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Button(org.eclipse.swt.widgets.Button) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) RGB(org.eclipse.swt.graphics.RGB)

Example 13 with PropertyChangeCommand

use of org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand in project tdi-studio-se by Talend.

the class BasicNotePropertyComposite method updateFontFamily.

/**
     * Update font family property
     */
protected void updateFontFamily() {
    // Update model in response to user
    if (fontFamilyCombo.getText() != null || !fontFamilyCombo.getText().equals("")) {
        //$NON-NLS-1$
        String value = fontFamilyCombo.getText();
        Command cmd = new PropertyChangeCommand(note, EParameterName.NOTE_FONT.getName(), value);
        getCommandStack().execute(cmd);
        note.refresh();
        textChanged();
    }
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) ChangeNoteOpacityCommand(org.talend.designer.core.ui.editor.cmd.ChangeNoteOpacityCommand) ChangeNoteTextCommand(org.talend.designer.core.ui.editor.cmd.ChangeNoteTextCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)

Example 14 with PropertyChangeCommand

use of org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand in project tdi-studio-se by Talend.

the class BasicNotePropertyComposite method updateFontBold.

private void updateFontBold() {
    Boolean value = fontBoldButton.getSelection();
    Command cmd = new PropertyChangeCommand(note, EParameterName.FONT_BOLD.getName(), value);
    getCommandStack().execute(cmd);
    note.refresh();
    textChanged();
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) ChangeNoteOpacityCommand(org.talend.designer.core.ui.editor.cmd.ChangeNoteOpacityCommand) ChangeNoteTextCommand(org.talend.designer.core.ui.editor.cmd.ChangeNoteTextCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)

Example 15 with PropertyChangeCommand

use of org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand in project tdi-studio-se by Talend.

the class BasicNotePropertyComposite method addListener.

private void addListener() {
    leftBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Boolean value = leftBtn.getSelection();
            if (value) {
                Command cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_LEFT.getName(), value);
                getCommandStack().execute(cmd);
                if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_RIGHT.getName())) {
                    cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_RIGHT.getName(), !value);
                    getCommandStack().execute(cmd);
                }
                if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_CENTER.getName())) {
                    cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_CENTER.getName(), !value);
                    getCommandStack().execute(cmd);
                }
                note.refresh();
            }
        }
    });
    rightBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Boolean value = rightBtn.getSelection();
            if (value) {
                Command cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_RIGHT.getName(), value);
                getCommandStack().execute(cmd);
                if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_LEFT.getName())) {
                    cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_LEFT.getName(), !value);
                    getCommandStack().execute(cmd);
                }
                if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_CENTER.getName())) {
                    cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_CENTER.getName(), !value);
                    getCommandStack().execute(cmd);
                }
                note.refresh();
            }
        }
    });
    centreBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Boolean value = centreBtn.getSelection();
            if (value) {
                Command cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_CENTER.getName(), value);
                getCommandStack().execute(cmd);
                if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_LEFT.getName())) {
                    cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_LEFT.getName(), !value);
                    getCommandStack().execute(cmd);
                }
                if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_RIGHT.getName())) {
                    cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_RIGHT.getName(), !value);
                    getCommandStack().execute(cmd);
                }
                note.refresh();
            }
        }
    });
    topBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Boolean value = topBtn.getSelection();
            if (value) {
                Command cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_TOP.getName(), value);
                getCommandStack().execute(cmd);
                if ((Boolean) note.getPropertyValue(EParameterName.NOTELABEL_CENTER.getName())) {
                    cmd = new PropertyChangeCommand(note, EParameterName.NOTELABEL_CENTER.getName(), !value);
                    getCommandStack().execute(cmd);
                }
                if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_BOTTOM.getName())) {
                    cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_BOTTOM.getName(), !value);
                    getCommandStack().execute(cmd);
                }
                note.refresh();
            }
        }
    });
    bottomBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Boolean value = bottomBtn.getSelection();
            if (value) {
                Command cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_BOTTOM.getName(), value);
                getCommandStack().execute(cmd);
                if ((Boolean) note.getPropertyValue(EParameterName.NOTELABEL_CENTER.getName())) {
                    cmd = new PropertyChangeCommand(note, EParameterName.NOTELABEL_CENTER.getName(), !value);
                    getCommandStack().execute(cmd);
                }
                if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_TOP.getName())) {
                    cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_TOP.getName(), !value);
                    getCommandStack().execute(cmd);
                }
                note.refresh();
            }
        }
    });
    centreLabelBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Boolean value = centreLabelBtn.getSelection();
            if (value) {
                Command cmd = new PropertyChangeCommand(note, EParameterName.NOTELABEL_CENTER.getName(), value);
                getCommandStack().execute(cmd);
                if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_BOTTOM.getName())) {
                    cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_BOTTOM.getName(), !value);
                    getCommandStack().execute(cmd);
                }
                if ((Boolean) note.getPropertyValue(EParameterName.NOTETXT_TOP.getName())) {
                    cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_TOP.getName(), !value);
                    getCommandStack().execute(cmd);
                }
                note.refresh();
            }
        }
    });
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) ChangeNoteOpacityCommand(org.talend.designer.core.ui.editor.cmd.ChangeNoteOpacityCommand) ChangeNoteTextCommand(org.talend.designer.core.ui.editor.cmd.ChangeNoteTextCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)69 IElementParameter (org.talend.core.model.process.IElementParameter)34 Command (org.eclipse.gef.commands.Command)24 Point (org.eclipse.swt.graphics.Point)18 INode (org.talend.core.model.process.INode)18 Node (org.talend.designer.core.ui.editor.nodes.Node)18 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)16 Control (org.eclipse.swt.widgets.Control)14 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)13 RepositoryNode (org.talend.repository.model.RepositoryNode)12 CCombo (org.eclipse.swt.custom.CCombo)11 IConnection (org.talend.core.model.process.IConnection)11 ConnectionItem (org.talend.core.model.properties.ConnectionItem)11 ArrayList (java.util.ArrayList)10 List (java.util.List)10 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)10 Item (org.talend.core.model.properties.Item)10 Button (org.eclipse.swt.widgets.Button)9 Text (org.eclipse.swt.widgets.Text)8 MetadataTable (org.talend.core.model.metadata.MetadataTable)8