Search in sources :

Example 1 with LabelFieldEditor

use of org.talend.commons.ui.swt.advanced.dataeditor.LabelFieldEditor in project tesb-studio-se by Talend.

the class EsbSoapServicePreferencePage method createFieldEditors.

@Override
protected void createFieldEditors() {
    LabelFieldEditor separator = new //$NON-NLS-1$
    LabelFieldEditor(//$NON-NLS-1$
    "", //$NON-NLS-1$
    getFieldEditorParent()) {

        private Label label = null;

        @Override
        public Label getLabelControl(Composite parent) {
            if (label == null) {
                label = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
            }
            return label;
        }

        ;

        @Override
        protected void doFillIntoGrid(Composite parent, int numColumns) {
            super.doFillIntoGrid(parent, numColumns);
            Object layoutData = label.getLayoutData();
            if (layoutData instanceof GridData) {
                ((GridData) layoutData).grabExcessHorizontalSpace = true;
            }
        }
    };
    addField(separator);
    addField(new CheckBoxFieldEditor(ENABLE_WSDL_VALIDATION, Messages.EsbSoapServicePreferencePage_enableWsdlValidation, getFieldEditorParent()));
}
Also used : LabelFieldEditor(org.talend.commons.ui.swt.advanced.dataeditor.LabelFieldEditor) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) CheckBoxFieldEditor(org.talend.commons.ui.swt.preferences.CheckBoxFieldEditor)

Example 2 with LabelFieldEditor

use of org.talend.commons.ui.swt.advanced.dataeditor.LabelFieldEditor in project tdi-studio-se by Talend.

the class I18nPreferencePage method createFieldEditors.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
     */
@Override
protected void createFieldEditors() {
    // Adds a combo for language selection.
    //$NON-NLS-1$
    String spanish = "Español";
    byte[] utf8Bytes;
    try {
        //$NON-NLS-1$
        utf8Bytes = spanish.getBytes("UTF8");
        //$NON-NLS-1$
        spanish = new String(utf8Bytes, "UTF8");
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        //$NON-NLS-1$
        spanish = "Spanish";
    }
    //$NON-NLS-1$
    String russian = "Русский";
    try {
        //$NON-NLS-1$
        utf8Bytes = russian.getBytes("UTF8");
        //$NON-NLS-1$
        russian = new String(utf8Bytes, "UTF8");
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        //$NON-NLS-1$
        russian = "Russian";
    }
    //$NON-NLS-1$
    String greek = "Ελληνικά";
    try {
        //$NON-NLS-1$
        utf8Bytes = greek.getBytes("UTF8");
        //$NON-NLS-1$
        greek = new String(utf8Bytes, "UTF8");
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        //$NON-NLS-1$
        greek = "Greek";
    }
    //$NON-NLS-1$
    String arabic = "العربيه";
    try {
        //$NON-NLS-1$
        utf8Bytes = arabic.getBytes("UTF8");
        //$NON-NLS-1$
        arabic = new String(utf8Bytes, "UTF8");
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        //$NON-NLS-1$
        arabic = "Arabic";
    }
    //$NON-NLS-1$
    String serbian = "Српски";
    try {
        //$NON-NLS-1$
        utf8Bytes = serbian.getBytes("UTF8");
        //$NON-NLS-1$
        serbian = new String(utf8Bytes, "UTF8");
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        //$NON-NLS-1$
        serbian = "Serbian";
    }
    String[][] entryNamesAndValues = { { Locale.ENGLISH.getDisplayLanguage(Locale.ENGLISH), Locale.ENGLISH.getLanguage() }, { Locale.FRENCH.getDisplayLanguage(Locale.FRENCH), Locale.FRENCH.getLanguage() }, { Locale.CHINESE.getDisplayLanguage(Locale.CHINESE), "zh_CN" }, { Locale.GERMAN.getDisplayLanguage(Locale.GERMAN), Locale.GERMAN.getLanguage() }, { Locale.JAPANESE.getDisplayLanguage(Locale.JAPANESE), Locale.JAPANESE.getLanguage() }, { Locale.ITALIAN.getDisplayLanguage(Locale.ITALIAN), Locale.ITALIAN.getLanguage() }, //$NON-NLS-1$ //$NON-NLS-2$ 
    { "Brasil", "pt_BR" }, //$NON-NLS-1$ //$NON-NLS-2$ 
    { spanish, "es" }, //$NON-NLS-1$ //$NON-NLS-2$ 
    { russian, "ru" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
    { Locale.KOREA.getDisplayLanguage(Locale.KOREA), "kr" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
    { "Turkish", "tr" }, { greek, "el" }, { "Hrvatski", "hr" }, { arabic, "ar" }, { serbian, "sr" }, { "Polski", "pl" }, { "Romanian", "ro" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ // /$NON-NLS-7$ 
    { "Netherlands", "nl" } };
    languageSelectionEditor = new OneLineComboFieldEditor(ITalendCorePrefConstants.LANGUAGE_SELECTOR, Messages.getString("I18nPreferencePage.needRestart"), entryNamesAndValues, //$NON-NLS-1$
    getFieldEditorParent());
    addField(languageSelectionEditor);
    Composite composite = getFieldEditorParent();
    LabelFieldEditor importAll = new //$NON-NLS-1$
    LabelFieldEditor(//$NON-NLS-1$
    Messages.getString("I18nPreferencePage.translationInformation"), composite);
    addField(importAll);
    Button allUpdate = new Button(composite, SWT.FLAT);
    //$NON-NLS-1$
    allUpdate.setText(Messages.getString("I18nPreferencePage.importBabili"));
    allUpdate.setLayoutData(new GridData());
    allUpdate.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // import all update from Babili
            // select the .zip file
            FileDialog fd = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OPEN);
            //$NON-NLS-1$
            fd.setText("Open");
            //$NON-NLS-1$
            fd.setFilterPath("C:" + fs);
            //$NON-NLS-1$
            String[] filterExtensions = { "*.zip" };
            fd.setFilterExtensions(filterExtensions);
            String selected = fd.open();
            if (selected != null) {
                isBabiliButtonClicked = true;
                runProgressMonitorDialog(selected);
                if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), //$NON-NLS-1$
                Messages.getString("I18nPreferencePage.restart"), Messages.getString("I18nPreferencePage.restartButton"))) {
                    PlatformUI.getWorkbench().restart();
                }
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // Nothing to do
        }
    });
    // added by nma
    Button restoredefault = new Button(composite, SWT.FLAT);
    //$NON-NLS-1$
    restoredefault.setText("Restore Defaults");
    restoredefault.setLayoutData(new GridData());
    restoredefault.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // Nothing to do
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            isBabiliButtonClicked = true;
            //$NON-NLS-1$
            runProgressMonitorDialog(Messages.getString("I18nPreferencePage.restoreDefault"));
            if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("I18nPreferencePage.restart"), Messages.getString("I18nPreferencePage.restartButton"))) {
                PlatformUI.getWorkbench().restart();
            }
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) OneLineComboFieldEditor(org.talend.commons.ui.utils.workbench.preferences.OneLineComboFieldEditor) UnsupportedEncodingException(java.io.UnsupportedEncodingException) LabelFieldEditor(org.talend.commons.ui.swt.advanced.dataeditor.LabelFieldEditor) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FileDialog(org.eclipse.swt.widgets.FileDialog) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

GridData (org.eclipse.swt.layout.GridData)2 Composite (org.eclipse.swt.widgets.Composite)2 LabelFieldEditor (org.talend.commons.ui.swt.advanced.dataeditor.LabelFieldEditor)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 Button (org.eclipse.swt.widgets.Button)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1 Label (org.eclipse.swt.widgets.Label)1 CheckBoxFieldEditor (org.talend.commons.ui.swt.preferences.CheckBoxFieldEditor)1 OneLineComboFieldEditor (org.talend.commons.ui.utils.workbench.preferences.OneLineComboFieldEditor)1