Search in sources :

Example 1 with ChangeNoteTextCommand

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

the class BasicNotePropertyComposite method createTextControl.

/**
     * DOC qwei Comment method "createTextcontrol".
     */
private void createTextControl(Composite parent) {
    //$NON-NLS-1$
    CLabel textLabel = getWidgetFactory().createCLabel(composite, Messages.getString("TextNoteSection.Label"));
    //$NON-NLS-1$
    FormData data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.top = new FormAttachment(colorsAndFontsGroup, 30);
    textLabel.setLayoutData(data);
    //$NON-NLS-1$
    text = getWidgetFactory().createText(composite, "", SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    //$NON-NLS-1$
    data = new FormData();
    data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
    data.right = new FormAttachment(textLabel, 560);
    data.top = new FormAttachment(textLabel, 0, SWT.TOP);
    // 5 lines
    data.height = 5 * text.getLineHeight();
    text.setLayoutData(data);
    text.setForeground(new Color(null, ColorUtils.stringToRGB((String) note.getPropertyValue(EParameterName.NOTETXT_COLOR.getName()))));
    text.setText(note.getText());
    text.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            if (!text.getText().equals(note.getText())) {
                ChangeNoteTextCommand command = new ChangeNoteTextCommand(note, text.getText());
                getCommandStack().execute(command);
            }
        }
    });
    text.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
        // TODO Auto-generated method stub
        }

        @Override
        public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
            // TODO Auto-generated method stub
            if (!text.getText().equals(note.getText())) {
                ChangeNoteTextCommand command = new ChangeNoteTextCommand(note, text.getText());
                getCommandStack().execute(command);
            }
        }
    });
    textChanged();
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) FormData(org.eclipse.swt.layout.FormData) FocusAdapter(org.eclipse.swt.events.FocusAdapter) Color(org.eclipse.swt.graphics.Color) KeyListener(org.eclipse.swt.events.KeyListener) FocusEvent(org.eclipse.swt.events.FocusEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) ChangeNoteTextCommand(org.talend.designer.core.ui.editor.cmd.ChangeNoteTextCommand)

Example 2 with ChangeNoteTextCommand

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

the class TextNotePropertySection method createControls.

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    Composite composite = getWidgetFactory().createFlatFormComposite(parent);
    FormData data;
    //$NON-NLS-1$
    text = getWidgetFactory().createText(composite, "", SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    data = new FormData();
    data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    // 5 lines
    data.height = 5 * text.getLineHeight();
    text.setLayoutData(data);
    //$NON-NLS-1$
    CLabel labelLabel = getWidgetFactory().createCLabel(composite, Messages.getString("TextNoteSection.Label"));
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(text, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(text, 0, SWT.TOP);
    labelLabel.setLayoutData(data);
    text.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            if (!text.getText().equals(note.getText())) {
                ChangeNoteTextCommand command = new ChangeNoteTextCommand(note, text.getText());
                getCommandStack().execute(command);
            }
        }
    });
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) FocusAdapter(org.eclipse.swt.events.FocusAdapter) Composite(org.eclipse.swt.widgets.Composite) FocusEvent(org.eclipse.swt.events.FocusEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) ChangeNoteTextCommand(org.talend.designer.core.ui.editor.cmd.ChangeNoteTextCommand)

Aggregations

CLabel (org.eclipse.swt.custom.CLabel)2 FocusAdapter (org.eclipse.swt.events.FocusAdapter)2 FocusEvent (org.eclipse.swt.events.FocusEvent)2 FormAttachment (org.eclipse.swt.layout.FormAttachment)2 FormData (org.eclipse.swt.layout.FormData)2 ChangeNoteTextCommand (org.talend.designer.core.ui.editor.cmd.ChangeNoteTextCommand)2 KeyListener (org.eclipse.swt.events.KeyListener)1 Color (org.eclipse.swt.graphics.Color)1 Composite (org.eclipse.swt.widgets.Composite)1