Search in sources :

Example 66 with PropertyChangeCommand

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

the class RouteResourceController method createButtonCommand.

/**
     * 
     * @param source
     * @return
     */
private PropertyChangeCommand createButtonCommand(Button button) {
    RouteResourceSelectionDialog dialog = new RouteResourceSelectionDialog(button.getShell());
    selectNodeIfExists(button, dialog);
    if (dialog.open() == Window.OK) {
        IRepositoryViewObject repositoryObject = dialog.getResult().getObject();
        // refreshItemeProperty(repositoryObject);
        final Item item = repositoryObject.getProperty().getItem();
        String id = item.getProperty().getId();
        String paramName = (String) button.getData(PARAMETER_NAME);
        return new PropertyChangeCommand(elem, paramName, id);
    }
    return null;
}
Also used : Item(org.talend.core.model.properties.Item) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RouteResourceSelectionDialog(org.talend.camel.designer.dialog.RouteResourceSelectionDialog)

Example 67 with PropertyChangeCommand

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

the class RestResponseSchemaController method createComboCommand.

@Override
public Command createComboCommand(SelectionEvent event) {
    //Change the body type according to selected return body type
    Command changePropertyCommand = super.createComboCommand(event);
    Object newReturnType = null;
    if (changePropertyCommand != null) {
        newReturnType = ((PropertyChangeCommand) changePropertyCommand).getNewValue();
    }
    if (newReturnType == null) {
        return null;
    }
    //get old metadata column
    List<IMetadataTable> metadataList = ((INode) elem).getMetadataList();
    IMetadataTable oldMetadataTable = null;
    if (metadataList != null && metadataList.size() > 0) {
        oldMetadataTable = metadataList.get(0);
    } else {
        metadataList = new ArrayList<IMetadataTable>();
        ((INode) elem).setMetadataList(metadataList);
    }
    //create new metadata column
    IMetadataTable newMetadataTable = oldMetadataTable == null ? new MetadataTable() : oldMetadataTable.clone();
    List<IMetadataColumn> listColumns = newMetadataTable.getListColumns();
    if (listColumns == null) {
        listColumns = new ArrayList<IMetadataColumn>();
        newMetadataTable.setListColumns(listColumns);
    }
    IMetadataColumn bodyColumn = listColumns.size() > 0 ? listColumns.get(0) : new MetadataColumn();
    bodyColumn.setId("body");
    bodyColumn.setTalendType(newReturnType.toString());
    listColumns.clear();
    listColumns.add(bodyColumn);
    metadataList.clear();
    metadataList.add(newMetadataTable);
    //construct change metadata command
    ChangeMetadataCommand changeMetadataCommand = new ChangeMetadataCommand((INode) elem, null, oldMetadataTable, newMetadataTable);
    //construct compound command by combining above 2 commands
    CompoundCommand compoundCommand = new CompoundCommand();
    compoundCommand.add(changePropertyCommand);
    compoundCommand.add(changeMetadataCommand);
    return compoundCommand;
}
Also used : INode(org.talend.core.model.process.INode) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) ChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) ChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand)

Example 68 with PropertyChangeCommand

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

the class CamelEditorDropTargetListener method createRefreshingPropertiesCommand.

private List<Command> createRefreshingPropertiesCommand(CompoundCommand cc, RepositoryNode selectedNode, Node node) {
    if (selectedNode.getObject().getProperty().getItem() instanceof ProcessItem) {
        ProcessItem processItem = (ProcessItem) selectedNode.getObject().getProperty().getItem();
        // command used to set job
        String value = processItem.getProperty().getId();
        PropertyChangeCommand command4 = new PropertyChangeCommand(node, EParameterName.PROCESS_TYPE_PROCESS.getName(), value);
        cc.add(command4);
        PropertyChangeCommand command5 = new PropertyChangeCommand(node, EParameterName.PROCESS_TYPE_CONTEXT.getName(), processItem.getProcess().getDefaultContext());
        cc.add(command5);
    }
    return null;
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) ProcessItem(org.talend.core.model.properties.ProcessItem)

Aggregations

PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)68 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)8 MetadataTable (org.talend.core.model.metadata.MetadataTable)8 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)8