Search in sources :

Example 1 with FieldEditor

use of org.eclipse.jface.preference.FieldEditor in project AutoRefactor by JnRouvignac.

the class WorkspacePreferencePage method createControls.

private Group createControls(final Composite parent, final List<RefactoringRule> allRefactoringRules) {
    fieldEditorParent = new Composite(parent, SWT.FILL);
    fields = new ArrayList<FieldEditor>(1 + allRefactoringRules.size());
    fields.add(new BooleanFieldEditor(DEBUG_MODE_ON.getName(), DEBUG_MODE_ON.getDescription(), fieldEditorParent));
    final Group ruleGroup = new Group(fieldEditorParent, SWT.FILL);
    ruleGroup.setText("Rules by default");
    // All rule checkbox
    toggleAllRules = new Button(ruleGroup, SWT.CHECK | SWT.LEFT);
    toggleAllRules.setFont(ruleGroup.getFont());
    toggleAllRules.setText("Toggle all the rules");
    toggleAllRules.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            boolean isSelected = WorkspacePreferencePage.this.toggleAllRules.getSelection();
            for (BooleanFieldEditor rule : WorkspacePreferencePage.this.rules) {
                ((Button) rule.getDescriptionControl(ruleGroup)).setSelection(isSelected);
            }
        }
    });
    // Add a space
    Composite spacer = new Composite(ruleGroup, SWT.NULL);
    spacer.setLayoutData(new GridData(0, 5));
    rules = new ArrayList<BooleanFieldEditor>(allRefactoringRules.size());
    for (final RefactoringRule refactoringRule : allRefactoringRules) {
        final BooleanFieldEditor booleanFieldEditor = new BooleanFieldEditor(refactoringRule.getClass().getCanonicalName(), refactoringRule.getName(), SWT.WRAP, ruleGroup);
        booleanFieldEditor.getDescriptionControl(ruleGroup).setToolTipText(refactoringRule.getDescription());
        ((Button) booleanFieldEditor.getDescriptionControl(ruleGroup)).addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(final SelectionEvent e) {
                invalidateToggleRules(ruleGroup);
            }
        });
        rules.add(booleanFieldEditor);
    }
    fields.addAll(rules);
    return ruleGroup;
}
Also used : BooleanFieldEditor(org.eclipse.jface.preference.BooleanFieldEditor) FieldEditor(org.eclipse.jface.preference.FieldEditor) Group(org.eclipse.swt.widgets.Group) RefactoringRule(org.autorefactor.refactoring.RefactoringRule) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) BooleanFieldEditor(org.eclipse.jface.preference.BooleanFieldEditor)

Example 2 with FieldEditor

use of org.eclipse.jface.preference.FieldEditor in project AutoRefactor by JnRouvignac.

the class WorkspacePreferencePage method performDefaults.

@Override
protected void performDefaults() {
    if (fields != null) {
        for (final FieldEditor field : fields) {
            field.loadDefault();
        }
    }
    checkState();
    super.performDefaults();
}
Also used : BooleanFieldEditor(org.eclipse.jface.preference.BooleanFieldEditor) FieldEditor(org.eclipse.jface.preference.FieldEditor)

Example 3 with FieldEditor

use of org.eclipse.jface.preference.FieldEditor in project tesb-studio-se by Talend.

the class RunContainerPreferencePage method createPageContents.

/**
     * Create contents of the preference page.
     * 
     * @param parent
     */
@Override
public Control createPageContents(Composite parent) {
    serverFieldEditors = new ArrayList<FieldEditor>();
    optionFieldEditors = new ArrayList<FieldEditor>();
    runtimeEnable = getPreferenceStore().getBoolean(RunContainerPreferenceInitializer.P_ESB_IN_OSGI);
    GridLayout gridLayoutDefault = new GridLayout(1, false);
    Composite body = new Composite(parent, SWT.NONE);
    body.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    body.setLayout(gridLayoutDefault);
    getPreferenceStore().getBoolean(RunContainerPreferenceInitializer.P_ESB_IN_OSGI);
    useOSGiEditor = new BooleanFieldEditor(RunContainerPreferenceInitializer.P_ESB_IN_OSGI, "ESB Studio Runtime - Use Local Talend Runtime (OSGi Container)", body);
    addField(useOSGiEditor);
    Label lblNote = new Label(body, SWT.WRAP);
    lblNote.setText("Note: It will be only taken into account for an ESB Artifact:\n" + "  · A Route (Any Route)\n" + "  · A DataService (SOAP/REST)\n" + "  · A Job contains tRESTClient or tESBConsumer component");
    Group groupServer = new Group(body, SWT.NONE);
    //$NON-NLS-1$
    groupServer.setText(RunContainerMessages.getString("RunContainerPreferencePage.Group1"));
    groupServer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    groupServer.setLayout(new GridLayout(2, false));
    compositeServerBody = new Composite(groupServer, SWT.BORDER);
    compositeServerBody.setLayout(gridLayoutDefault);
    compositeServerBody.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    StringFieldEditor locationEditor = new StringFieldEditor(RunContainerPreferenceInitializer.P_ESB_RUNTIME_LOCATION, RunContainerMessages.getString("RunContainerPreferencePage.Location"), //$NON-NLS-1$
    compositeServerBody);
    addField(locationEditor);
    serverFieldEditors.add(locationEditor);
    StringFieldEditor hostFieldEditor = new StringFieldEditor(RunContainerPreferenceInitializer.P_ESB_RUNTIME_HOST, RunContainerMessages.getString("RunContainerPreferencePage.Host"), compositeServerBody);
    addField(hostFieldEditor);
    // only support local runtime server, if need support remote server ,enable this editor
    hostFieldEditor.setEnabled(false, compositeServerBody);
    StringFieldEditor userFieldEditor = new StringFieldEditor(RunContainerPreferenceInitializer.P_ESB_RUNTIME_USERNAME, RunContainerMessages.getString("RunContainerPreferencePage.Username"), //$NON-NLS-1$
    compositeServerBody);
    addField(userFieldEditor);
    serverFieldEditors.add(userFieldEditor);
    StringFieldEditor passwordFieldEditor = new StringFieldEditor(RunContainerPreferenceInitializer.P_ESB_RUNTIME_PASSWORD, RunContainerMessages.getString("RunContainerPreferencePage.Password"), //$NON-NLS-1$
    compositeServerBody);
    addField(passwordFieldEditor);
    serverFieldEditors.add(passwordFieldEditor);
    StringFieldEditor instanceFieldEditor = new StringFieldEditor(RunContainerPreferenceInitializer.P_ESB_RUNTIME_INSTANCE, RunContainerMessages.getString("RunContainerPreferencePage.Instance"), //$NON-NLS-1$
    compositeServerBody);
    addField(instanceFieldEditor);
    serverFieldEditors.add(instanceFieldEditor);
    IntegerFieldEditor portFieldEditor = new IntegerFieldEditor(RunContainerPreferenceInitializer.P_ESB_RUNTIME_PORT, RunContainerMessages.getString("RunContainerPreferencePage.Port"), //$NON-NLS-1$
    compositeServerBody);
    addField(portFieldEditor);
    serverFieldEditors.add(portFieldEditor);
    StringFieldEditor jmxPortFieldEditor = new StringFieldEditor(RunContainerPreferenceInitializer.P_ESB_RUNTIME_JMX_PORT, RunContainerMessages.getString("RunContainerPreferencePage.JMXPort"), //$NON-NLS-1$
    compositeServerBody);
    addField(jmxPortFieldEditor);
    serverFieldEditors.add(jmxPortFieldEditor);
    Composite compBtn = new Composite(groupServer, SWT.NONE);
    GridData gridDataBtn = new GridData(SWT.LEFT, SWT.FILL, false, true, 1, 1);
    gridDataBtn.widthHint = 100;
    compBtn.setLayoutData(gridDataBtn);
    GridLayout layoutCompBtn = new GridLayout(1, false);
    layoutCompBtn.marginWidth = 0;
    layoutCompBtn.marginHeight = 0;
    compBtn.setLayout(layoutCompBtn);
    buttonAddServer = new Button(compBtn, SWT.NONE);
    buttonAddServer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    buttonAddServer.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            AddRuntimeWizard dirWizard = new AddRuntimeWizard(locationEditor.getStringValue());
            dirWizard.setNeedsProgressMonitor(true);
            WizardDialog wizardDialog = new WizardDialog(getShell(), dirWizard);
            if (wizardDialog.open() == Window.OK) {
                locationEditor.setStringValue(dirWizard.getTarget());
            }
        }
    });
    //$NON-NLS-1$
    buttonAddServer.setText(RunContainerMessages.getString("RunContainerPreferencePage.ServerButton"));
    // Button btnTestConnection = new Button(compBtn, SWT.NONE);
    // btnTestConnection.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    // btnTestConnection.setText("Server Info...");
    buttonInitalizeServer = new Button(compBtn, SWT.NONE);
    buttonInitalizeServer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    //$NON-NLS-1$
    buttonInitalizeServer.setText(RunContainerMessages.getString("RunContainerPreferencePage.InitalizeButton"));
    buttonInitalizeServer.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (initalizeRuntime(locationEditor.getStringValue(), hostFieldEditor.getStringValue())) {
                try {
                    new InitFinishMessageDialog(getShell(), JMXUtil.getBundlesName()).open();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    });
    Group groupOption = new Group(body, SWT.NONE);
    groupOption.setLayout(gridLayoutDefault);
    groupOption.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    //$NON-NLS-1$
    groupOption.setText(RunContainerMessages.getString("RunContainerPreferencePage.Group2"));
    compositeOptionBody = new Composite(groupOption, SWT.NONE);
    compositeOptionBody.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    BooleanFieldEditor filterLogEditor = new BooleanFieldEditor(RunContainerPreferenceInitializer.P_ESB_RUNTIME_SYS_LOG, RunContainerMessages.getString("RunContainerPreferencePage.FilterLogs"), //$NON-NLS-1$
    compositeOptionBody);
    addField(filterLogEditor);
    optionFieldEditors.add(filterLogEditor);
    manager = ProcessManager.getInstance();
    return body;
}
Also used : IntegerFieldEditor(org.eclipse.jface.preference.IntegerFieldEditor) BooleanFieldEditor(org.eclipse.jface.preference.BooleanFieldEditor) FieldEditor(org.eclipse.jface.preference.FieldEditor) StringFieldEditor(org.eclipse.jface.preference.StringFieldEditor) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) InitFinishMessageDialog(org.talend.designer.esb.runcontainer.ui.dialog.InitFinishMessageDialog) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) BooleanFieldEditor(org.eclipse.jface.preference.BooleanFieldEditor) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) StringFieldEditor(org.eclipse.jface.preference.StringFieldEditor) AddRuntimeWizard(org.talend.designer.esb.runcontainer.ui.wizard.AddRuntimeWizard) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IntegerFieldEditor(org.eclipse.jface.preference.IntegerFieldEditor) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 4 with FieldEditor

use of org.eclipse.jface.preference.FieldEditor in project tesb-studio-se by Talend.

the class FieldLayoutPreferencePage method checkState.

/**
     * Recomputes the page's error state by calling <code>isValid</code> for every field editor.
     */
protected void checkState() {
    boolean valid = true;
    m_invalidFieldEditor = null;
    // field editors contain a valid value. So we must check them all
    if (m_fields != null) {
        int size = m_fields.size();
        for (int i = 0; i < size; i++) {
            FieldEditor editor = m_fields.get(i);
            valid = valid && editor.isValid();
            if (!valid) {
                m_invalidFieldEditor = editor;
                break;
            }
        }
    }
    setValid(true);
}
Also used : FieldEditor(org.eclipse.jface.preference.FieldEditor)

Example 5 with FieldEditor

use of org.eclipse.jface.preference.FieldEditor in project tesb-studio-se by Talend.

the class FieldLayoutPreferencePage method dispose.

/**
     * The field editor preference page implementation of an <code>IDialogPage</code> method disposes of this page's
     * controls and images. Subclasses may override to release their own allocated SWT resources, but must call
     * <code>super.dispose</code>.
     */
@Override
public void dispose() {
    super.dispose();
    if (m_fields != null) {
        Iterator<FieldEditor> I = m_fields.iterator();
        while (I.hasNext()) {
            FieldEditor editor = I.next();
            editor.setPage(null);
            editor.setPropertyChangeListener(null);
            editor.setPreferenceStore(null);
        }
    }
}
Also used : FieldEditor(org.eclipse.jface.preference.FieldEditor)

Aggregations

FieldEditor (org.eclipse.jface.preference.FieldEditor)10 BooleanFieldEditor (org.eclipse.jface.preference.BooleanFieldEditor)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2 Group (org.eclipse.swt.widgets.Group)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 RefactoringRule (org.autorefactor.refactoring.RefactoringRule)1 IntegerFieldEditor (org.eclipse.jface.preference.IntegerFieldEditor)1 StringFieldEditor (org.eclipse.jface.preference.StringFieldEditor)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Label (org.eclipse.swt.widgets.Label)1 InitFinishMessageDialog (org.talend.designer.esb.runcontainer.ui.dialog.InitFinishMessageDialog)1 AddRuntimeWizard (org.talend.designer.esb.runcontainer.ui.wizard.AddRuntimeWizard)1