Search in sources :

Example 76 with IDialogSettings

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

the class JobScriptsExportWizardPage method setDefaultDestination.

/**
     * yzhang Comment method "setDefaultDestination".
     */
protected void setDefaultDestination() {
    //$NON-NLS-1$
    String userDir = System.getProperty("user.dir");
    IPath path = new Path(userDir);
    int length = nodes.length;
    //$NON-NLS-1$
    String destinationFile = "";
    if (getDialogSettings() != null) {
        IDialogSettings section = getDialogSettings().getSection(DESTINATION_FILE);
        if (section != null) {
            destinationFile = section.get(DESTINATION_FILE);
        }
    }
    if (destinationFile == null || "".equals(destinationFile)) {
        //$NON-NLS-1$
        if (length == 1) {
            // TODOthis is changed by shenhaize first open ,it show contains in the combo
            path = path.append(getDefaultFileNameWithType());
        } else if (length > 1) {
            // i changed here ..
            path = path.append(getDefaultFileNameWithType());
        }
    } else {
        // path = new Path(destinationFile);
        if (CoreRuntimePlugin.getInstance().getDesignerCoreService().getPreferenceStoreBooleanValue(IRepositoryPrefConstants.USE_EXPORT_SAVE)) {
            path = new Path(destinationFile);
        } else {
            path = path.append(getDefaultFileNameWithType());
        }
    }
    setDestinationValue(path.toOSString());
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ArchiveFileExportOperationFullPath(org.talend.core.ui.export.ArchiveFileExportOperationFullPath) FileSystemExporterFullPath(org.talend.core.ui.export.FileSystemExporterFullPath) IPath(org.eclipse.core.runtime.IPath) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) Point(org.eclipse.swt.graphics.Point)

Example 77 with IDialogSettings

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

the class JavaJobScriptsExportWSWizardPage method initialiseDefaultDialogSettings.

/**
     * this set default dialog settings if none already exists.
     */
private void initialiseDefaultDialogSettings() {
    IDialogSettings dialogSettings = getDialogSettings();
    if (dialogSettings != null) {
        // set default export type according to system properties
        String exportType = dialogSettings.get(STORE_EXPORTTYPE_ID);
        //$NON-NLS-1$
        String defaultExportType = System.getProperty("talend.export.job.default.type");
        if ((exportType == null || exportType.equals("")) && defaultExportType != null && !defaultExportType.equals("")) {
            //$NON-NLS-1$ //$NON-NLS-2$
            dialogSettings.put(STORE_EXPORTTYPE_ID, defaultExportType);
        }
    }
// else ignors it
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings)

Example 78 with IDialogSettings

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

the class JavaJobScriptsExportWSWizardPage method restoreWidgetValuesForPOJO.

protected void restoreWidgetValuesForPOJO() {
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {
        String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
        String fileName = getDefaultFileNameWithType();
        if (!fileName.endsWith(FileConstants.ZIP_FILE_SUFFIX)) {
            fileName = fileName + FileConstants.ZIP_FILE_SUFFIX;
        }
        if (directoryNames != null && directoryNames.length > 0) {
            // destination
            for (int i = 0; i < directoryNames.length; i++) {
                // }
                if (directoryNames[i].toLowerCase().endsWith(FileConstants.ZIP_FILE_SUFFIX)) {
                    //$NON-NLS-1$
                    directoryNames[i] = (directoryNames[i].charAt(0) + "").toUpperCase() + directoryNames[i].substring(1);
                    addDestinationItem(directoryNames[i]);
                }
            }
            //$NON-NLS-1$
            setDestinationValue(directoryNames[0].substring(0, (directoryNames[0].lastIndexOf("\\") + 1)) + fileName);
        } else {
            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));
        zipOption = String.valueOf(chkButton.getSelection());
    // genCodeButton.setSelection(settings.getBoolean(STORE_GENERATECODE_ID));
    }
    launcherCombo.setItems(JobScriptsManager.getLauncher());
    if (JobScriptsManager.getLauncher().length > 0) {
        launcherCombo.select(0);
    }
    if (getProcessItem() != null && contextCombo != null) {
        // don't update the property, this one will be automatically updated if needed when call the getItem()
        // try {
        // process[0].setProcess((ProcessItem) ProxyRepositoryFactory.getInstance().getUptodateProperty(
        // getProcessItem().getProperty()).getItem());
        // } catch (PersistenceException e) {
        // ExceptionHandler.process(e);
        // }
        ProcessItem item = getProcessItem();
        try {
            String id = item.getProperty().getId();
            IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(id);
            item = (ProcessItem) lastVersion.getProperty().getItem();
        } catch (PersistenceException e) {
            throw new RuntimeException(e);
        }
        List<String> contextNames;
        contextNames = ExportJobUtil.getJobContexts(item);
        contextCombo.setItems(contextNames.toArray(new String[contextNames.size()]));
        if (contextNames.size() > 0) {
            contextCombo.select(0);
        }
    }
    if (log4jLevelCombo != null) {
        log4jLevelCombo.setItems(Log4jPrefsSettingManager.getLevel());
        if (Log4jPrefsSettingManager.getLevel().length > 0) {
            log4jLevelCombo.select(2);
        }
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 79 with IDialogSettings

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

the class JavaCamelJobScriptsExportWSWizardPage 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);
        }
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) Widget(org.eclipse.swt.widgets.Widget) Combo(org.eclipse.swt.widgets.Combo)

Example 80 with IDialogSettings

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

the class JavaCamelJobScriptsExportWSWizardPage method restoreWidgetValuesForKar.

private void restoreWidgetValuesForKar() {
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {
        String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
        if (directoryNames != null && directoryNames.length > 0) {
            String fileName = getDefaultFileName().get(0) + '_' + getDefaultFileName().get(1) + getOutputSuffix();
            for (String directoryName : directoryNames) {
                String destination = new Path(directoryName).append(fileName).toOSString();
                addDestinationItem(destination);
                setDestinationValue(destination);
            }
        } else {
            setDefaultDestination();
        }
    } else {
        setDefaultDestination();
    }
}
Also used : Path(org.eclipse.core.runtime.Path) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings)

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