Search in sources :

Example 26 with IDialogSettings

use of org.eclipse.jface.dialogs.IDialogSettings in project tdi-studio-se by Talend.

the class JavaJobScriptsExportWizardPage method internalSaveWidgetValues.

/**
     * Hook method for saving widget values for restoration by the next instance of this class.
     */
@Override
protected void internalSaveWidgetValues() {
    // update directory names history
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {
        String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
        if (directoryNames == null) {
            directoryNames = new String[0];
        }
        directoryNames = addToHistory(directoryNames, getDestinationValue());
        settings.put(STORE_DESTINATION_NAMES_ID, directoryNames);
        settings.put(STORE_SHELL_LAUNCHER_ID, shellLauncherButton.getSelection());
        settings.put(STORE_JOB_ID, jobItemButton.getSelection());
        settings.put(STORE_SOURCE_ID, jobScriptButton.getSelection());
        settings.put(STORE_CONTEXT_ID, contextButton.getSelection());
        settings.put(APPLY_TO_CHILDREN_ID, applyToChildrenButton.getSelection());
        settings.put(EXTRACT_ZIP_FILE, chkButton.getSelection());
    // settings.put(STORE_GENERATECODE_ID, genCodeButton.getSelection());
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings)

Example 27 with IDialogSettings

use of org.eclipse.jface.dialogs.IDialogSettings in project tdi-studio-se by Talend.

the class JavaJobScriptsExportWizardPage method restoreWidgetValues.

/**
     * Hook method for restoring widget values to the values that they held last time this wizard was used to
     * completion.
     */
@Override
protected void restoreWidgetValues() {
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {
        String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
        if (directoryNames != null && directoryNames.length > 0) {
            for (String directoryName : directoryNames) {
                addDestinationItem(directoryName);
            }
        }
        setDefaultDestination();
        shellLauncherButton.setSelection(settings.getBoolean(STORE_SHELL_LAUNCHER_ID));
        jobItemButton.setSelection(settings.getBoolean(STORE_JOB_ID));
        jobScriptButton.setSelection(settings.getBoolean(STORE_SOURCE_ID));
        contextButton.setSelection(settings.getBoolean(STORE_CONTEXT_ID));
        applyToChildrenButton.setSelection(settings.getBoolean(APPLY_TO_CHILDREN_ID));
        chkButton.setSelection(settings.getBoolean(EXTRACT_ZIP_FILE));
    // genCodeButton.setSelection(settings.getBoolean(STORE_GENERATECODE_ID));
    }
    launcherCombo.setItems(JobScriptsManager.getLauncher());
    if (JobScriptsManager.getLauncher().length > 0) {
        launcherCombo.select(0);
    }
    try {
        setProcessItem((ProcessItem) ProxyRepositoryFactory.getInstance().getUptodateProperty(getProcessItem().getProperty()).getItem());
    } catch (PersistenceException e) {
        e.printStackTrace();
    }
    List<String> contextNames = ExportJobUtil.getJobContexts(getProcessItem());
    contextCombo.setItems(contextNames.toArray(new String[contextNames.size()]));
    if (contextNames.size() > 0) {
        contextCombo.select(0);
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 28 with IDialogSettings

use of org.eclipse.jface.dialogs.IDialogSettings in project tdi-studio-se by Talend.

the class JavaJobScriptsExportWSWizardPage method restoreWidgetValuesForESB.

protected void restoreWidgetValuesForESB() {
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {
        String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
        if (directoryNames != null && directoryNames.length > 0) {
            String fileName = getDefaultFileNameWithType();
            // destination
            for (int i = 0; i < directoryNames.length; i++) {
                if (directoryNames[i].toLowerCase().endsWith(FileConstants.ESB_FILE_SUFFIX)) {
                    //$NON-NLS-1$
                    directoryNames[i] = (directoryNames[i].charAt(0) + "").toUpperCase() + directoryNames[i].substring(1);
                    addDestinationItem(directoryNames[i]);
                }
            }
            File dest = new File(new File(directoryNames[0]).getParentFile(), fileName);
            setDestinationValue(dest.getAbsolutePath());
        } else {
            setDefaultDestination();
        }
        IDialogSettings section = getDialogSettings().getSection(DESTINATION_FILE);
        if (section == null) {
            section = getDialogSettings().addNewSection(DESTINATION_FILE);
        }
        if (jobScriptButton != null && !jobScriptButton.isDisposed()) {
            jobScriptButton.setSelection(settings.getBoolean(STORE_SOURCE_ID));
        }
        if (contextButton != null && !contextButton.isDisposed()) {
            contextButton.setSelection(settings.getBoolean(STORE_CONTEXT_ID));
        }
        if (applyToChildrenButton != null && !applyToChildrenButton.isDisposed()) {
            applyToChildrenButton.setSelection(settings.getBoolean(APPLY_TO_CHILDREN_ID));
        }
        if (jobItemButton != null && !jobItemButton.isDisposed()) {
            jobItemButton.setSelection(settings.getBoolean(STORE_JOB_ID));
        }
        if (section.get(ESB_EXPORT_TYPE) != null) {
            esbTypeCombo.setText(section.get(ESB_EXPORT_TYPE));
            if (section.get(ESB_SERVICE_NAME) != null) {
                esbServiceName.setText(section.get(ESB_SERVICE_NAME));
            }
            if (section.get(ESB_CATEGORY) != null) {
                esbCategory.setText(section.get(ESB_CATEGORY));
            }
            if (section.get(QUERY_MESSAGE_NAME) != null) {
                esbQueueMessageName.setText(section.get(QUERY_MESSAGE_NAME));
            }
        }
    }
    if (getProcessItem() != null && contextCombo != null) {
        try {
            setProcessItem((ProcessItem) ProxyRepositoryFactory.getInstance().getUptodateProperty(getProcessItem().getProperty()).getItem());
        } catch (PersistenceException e) {
            e.printStackTrace();
        }
        List<String> contextNames = ExportJobUtil.getJobContexts(getProcessItem());
        contextCombo.setItems(contextNames.toArray(new String[contextNames.size()]));
        if (contextNames.size() > 0) {
            contextCombo.select(0);
        }
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) PersistenceException(org.talend.commons.exception.PersistenceException) File(java.io.File)

Example 29 with IDialogSettings

use of org.eclipse.jface.dialogs.IDialogSettings in project tdi-studio-se by Talend.

the class JavaJobScriptsExportWSWizardPage method handleEvent.

@Override
public void handleEvent(Event e) {
    super.handleEvent(e);
    Widget source = e.widget;
    if (source instanceof Combo) {
        String destination = ((Combo) source).getText();
        if (getDialogSettings() != null) {
            IDialogSettings section = getDialogSettings().getSection(DESTINATION_FILE);
            if (section == null) {
                section = getDialogSettings().addNewSection(DESTINATION_FILE);
            }
            section.put(DESTINATION_FILE, destination);
        }
        if (destination != null) {
            if (!destination.endsWith(getOutputSuffix())) {
                destination += getOutputSuffix();
            }
        }
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) Widget(org.eclipse.swt.widgets.Widget) Combo(org.eclipse.swt.widgets.Combo)

Example 30 with IDialogSettings

use of org.eclipse.jface.dialogs.IDialogSettings in project tdi-studio-se by Talend.

the class JavaPublishOnSpagoExportWizardPage method restoreWidgetValues.

/**
     * Hook method for restoring widget values to the values that they held last time this wizard was used to
     * completion.
     */
protected void restoreWidgetValues() {
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {
        // String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
        // if (directoryNames != null) {
        // // destination
        // setDestinationValue(directoryNames[0]);
        // for (int i = 0; i < directoryNames.length; i++) {
        // addDestinationItem(directoryNames[i]);
        // }
        // }
        // shellLauncherButton.setSelection(settings.getBoolean(STORE_SHELL_LAUNCHER_ID));
        // systemRoutineButton.setSelection(settings.getBoolean(STORE_SYSTEM_ROUTINE_ID));
        // userRoutineButton.setSelection(settings.getBoolean(STORE_USER_ROUTINE_ID));
        // modelButton.setSelection(settings.getBoolean(STORE_MODEL_ID));
        // jobButton.setSelection(settings.getBoolean(STORE_JOB_ID));
        // sourceButton.setSelection(settings.getBoolean(STORE_SOURCE_ID));
        contextButton.setSelection(settings.getBoolean(STORE_CONTEXT_ID));
    // genCodeButton.setSelection(settings.getBoolean(STORE_GENERATECODE_ID));
    }
    // }
    if (process.length > 0) {
        try {
            process[0].setProcess((ProcessItem) ProxyRepositoryFactory.getInstance().getUptodateProperty(process[0].getItem().getProperty()).getItem());
        } catch (PersistenceException e) {
            e.printStackTrace();
        }
        if (manager == null) {
            manager = new JobJavaScriptsManager(getExportChoiceMap(), contextCombo.getText(), //$NON-NLS-1$
            "all", //$NON-NLS-1$
            IProcessor.NO_STATISTICS, IProcessor.NO_TRACES);
        }
        List<String> contextNames = manager.getJobContextsComboValue((ProcessItem) process[0].getItem());
        contextCombo.setItems(contextNames.toArray(new String[contextNames.size()]));
        if (contextNames.size() > 0) {
            contextCombo.select(0);
        }
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) PersistenceException(org.talend.commons.exception.PersistenceException)

Aggregations

IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)81 File (java.io.File)9 ArrayList (java.util.ArrayList)6 PersistenceException (org.talend.commons.exception.PersistenceException)6 Point (org.eclipse.swt.graphics.Point)5 Path (org.eclipse.core.runtime.Path)4 MenuItem (org.eclipse.swt.widgets.MenuItem)4 IPath (org.eclipse.core.runtime.IPath)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 GridData (org.eclipse.swt.layout.GridData)3 Combo (org.eclipse.swt.widgets.Combo)3 Composite (org.eclipse.swt.widgets.Composite)3 FileDialog (org.eclipse.swt.widgets.FileDialog)3 Widget (org.eclipse.swt.widgets.Widget)3 LocalFile (org.eclipse.core.internal.filesystem.local.LocalFile)2 IFile (org.eclipse.core.resources.IFile)2 CoreException (org.eclipse.core.runtime.CoreException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)2 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2