Search in sources :

Example 21 with IDialogSettings

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

the class FindDialog method addHistory.

/**
     * Adds the search text to history.
     * 
     * @param searchText The search text.
     */
private void addHistory(String searchText) {
    if (searchText.isEmpty()) {
        return;
    }
    IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings(getClass().getName());
    String[] items = dialogSettings.getArray(FIND_HISTORY_KEY);
    if (items == null) {
        items = new String[] { searchText };
    } else {
        List<String> list = new ArrayList<String>();
        Collections.addAll(list, items);
        if (list.contains(searchText)) {
            list.remove(searchText);
        }
        Collections.reverse(list);
        list.add(searchText);
        Collections.reverse(list);
        items = list.toArray(new String[0]);
    }
    dialogSettings.put(FIND_HISTORY_KEY, items);
    findText.setItems(items);
    findText.select(0);
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) ArrayList(java.util.ArrayList)

Example 22 with IDialogSettings

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

the class Activator method getDialogSettings.

/**
     * Gets the dialog settings.
     * 
     * @param sectionName The sectionName
     * 
     * @return The dialog settings
     */
public IDialogSettings getDialogSettings(String sectionName) {
    IDialogSettings settings = getDialogSettings();
    IDialogSettings section = settings.getSection(sectionName);
    if (section == null) {
        section = settings.addNewSection(sectionName);
    }
    return section;
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings)

Example 23 with IDialogSettings

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

the class GenerateDocAsHTMLWizardPage 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 24 with IDialogSettings

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

the class GenerateDocAsHTMLWizardPage method saveLastDirectoryName.

/**
     * Save the last directoryName path .
     * 
     * @param runnable
     */
private void saveLastDirectoryName(ArchiveFileExportOperationFullPath runnable) {
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {
        String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
        if (directoryNames != null) {
            boolean isExist = false;
            for (String directoryName : directoryNames) {
                if (directoryName.equals(runnable.getDestinationFilename())) {
                    isExist = true;
                }
            }
            if (!isExist) {
                String[] newDirectoryNames = Arrays.copyOf(directoryNames, directoryNames.length + 1);
                newDirectoryNames[newDirectoryNames.length - 1] = runnable.getDestinationFilename();
                settings.put(STORE_DESTINATION_NAMES_ID, newDirectoryNames);
            }
        } else {
            settings.put(STORE_DESTINATION_NAMES_ID, new String[] { runnable.getDestinationFilename() });
        }
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings)

Example 25 with IDialogSettings

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

the class OverviewSection method getDialogSettings.

/**
     * Gets the dialog settings for the tree expansion state.
     * 
     * @return The dialog settings
     */
private IDialogSettings getDialogSettings() {
    String id = sectionName;
    IActiveJvm jvm = getJvm();
    if (jvm != null) {
        id += jvm.getPid();
    }
    IDialogSettings settings = Activator.getDefault().getDialogSettings();
    IDialogSettings section = settings.getSection(id);
    if (section == null) {
        section = settings.addNewSection(id);
    }
    return section;
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) 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