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;
}
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;
}
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();
}
}
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();
}
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();
}
}
});
}
Aggregations