Search in sources :

Example 56 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project eclipse.platform.text by eclipse.

the class DefaultEncodingSupport method dispose.

/**
 * Disposes this encoding support.
 */
public void dispose() {
    IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES);
    prefs.removePreferenceChangeListener(fPreferenceChangeListener);
    fTextEditor = null;
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Example 57 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.

the class DockerContainersView method createPartControl.

@Override
public void createPartControl(final Composite parent) {
    final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    form = toolkit.createForm(parent);
    form.setText(DVMessages.getString(NoConnectionSelected));
    final Composite container = form.getBody();
    GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).applyTo(container);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(container);
    createTableViewer(container);
    getSite().registerContextMenu(new MenuManager(), null);
    // track selection changes in the Docker Explorer view (only)
    getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(DockerExplorerView.VIEW_ID, this);
    hookContextMenu();
    hookToolBarItems();
    // Look at stored preference to determine if all containers should be
    // shown or just running/paused containers. By default, only show
    // running/paused containers
    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
    boolean showAll = preferences.getBoolean(SHOW_ALL_CONTAINERS_PREFERENCE, true);
    showAllContainers(showAll);
    final ICommandService service = getViewSite().getWorkbenchWindow().getService(ICommandService.class);
    service.getCommand(SHOW_ALL_CONTAINERS_COMMAND_ID).getState(TOGGLE_STATE).setValue(showAll);
    service.refreshElements(SHOW_ALL_CONTAINERS_COMMAND_ID, null);
    boolean filterByLabels = preferences.getBoolean(FILTER_WITH_LABELS_PREFERENCE, false);
    showContainersWithLabels(filterByLabels);
    service.getCommand(FILTER_CONTAINERS_COMMAND_ID).getState(TOGGLE_STATE).setValue(filterByLabels);
    service.refreshElements(FILTER_CONTAINERS_COMMAND_ID, null);
    DockerConnectionManager.getInstance().addConnectionManagerListener(this);
    // On startup, this view might get set up after the Docker Explorer View
    // and so we won't get the notification when it chooses the connection.
    // Find out if it has a selection and set our connection appropriately.
    ISelection selection = getSite().getWorkbenchWindow().getSelectionService().getSelection(DockerExplorerView.VIEW_ID);
    if (selection != null) {
        selectionChanged(null, selection);
        // also notify DockerConnectionWatcher
        DockerConnectionWatcher.getInstance().selectionChanged(null, selection);
    }
}
Also used : FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) MenuManager(org.eclipse.jface.action.MenuManager) ISelection(org.eclipse.jface.viewers.ISelection) ICommandService(org.eclipse.ui.commands.ICommandService)

Example 58 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.

the class DockerContainersView method setLabelFilterIds.

private void setLabelFilterIds() {
    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
    boolean filterLabels = preferences.getBoolean(FILTER_WITH_LABELS_PREFERENCE, Boolean.FALSE);
    if (filterLabels) {
        String filterLabelString = preferences.get(CONTAINER_FILTER_LABELS, // $NON-NLS-1$
        "");
        if (filterLabelString.isEmpty()) {
            containersWithLabelsViewerFilter.setIds(null);
        } else {
            // $NON-NLS-1$
            String[] labels = filterLabelString.split("\u00a0");
            LinkedHashMap<String, String> labelMap = new LinkedHashMap<>();
            for (String label : labels) {
                if (label.length() > 1) {
                    // $NON-NLS-1$
                    String[] tokens = label.split("=");
                    String key = tokens[0];
                    // $NON-NLS-1$
                    String value = "";
                    if (tokens.length > 1)
                        value = tokens[1];
                    labelMap.put(key, value);
                }
            }
            Set<String> filterIds = new HashSet<>();
            try {
                filterIds = ((DockerConnection) connection).getContainerIdsWithLabels(labelMap);
            } catch (DockerException e) {
                Activator.log(e);
            }
            containersWithLabelsViewerFilter.setIds(filterIds);
        }
    }
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) LinkedHashMap(java.util.LinkedHashMap) HashSet(java.util.HashSet)

Example 59 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.

the class DockerContainersView method showAllContainers.

/**
 * Activates {@link HideStoppedContainersViewerFilter} if the given {@code enabled} argument is <code>false</code>, deactivates the filter otherwise.
 * @param enabled the argument to enable/disable the filter.
 */
public void showAllContainers(boolean enabled) {
    if (DockerContainersView.this.viewer == null) {
        return;
    }
    if (!enabled) {
        this.viewer.addFilter(hideStoppedContainersViewerFilter);
    } else {
        final List<ViewerFilter> filters = new ArrayList<>(Arrays.asList(this.viewer.getFilters()));
        // filters
        for (Iterator<ViewerFilter> iterator = filters.iterator(); iterator.hasNext(); ) {
            ViewerFilter viewerFilter = iterator.next();
            if (viewerFilter.equals(hideStoppedContainersViewerFilter)) {
                iterator.remove();
            }
        }
        this.viewer.setFilters(filters.toArray(new ViewerFilter[0]));
    }
    // Save enablement across sessions using a preference variable.
    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
    preferences.putBoolean(SHOW_ALL_CONTAINERS_PREFERENCE, enabled);
    refreshViewTitle();
}
Also used : ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ArrayList(java.util.ArrayList)

Example 60 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.

the class PreferenceInitializer method initializeDefaultPreferences.

@Override
public void initializeDefaultPreferences() {
    IEclipsePreferences prefs = DefaultScope.INSTANCE.getNode(FrameworkUtil.getBundle(this.getClass()).getSymbolicName());
    prefs.put(PreferenceConstants.P_PATH, PreferenceConstants.P_PATH_DEFAULT);
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Aggregations

IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)79 BackingStoreException (org.osgi.service.prefs.BackingStoreException)15 Test (org.junit.Test)11 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)9 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)9 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)6 ProjectScope (org.eclipse.core.resources.ProjectScope)6 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)6 After (org.junit.After)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 Map (java.util.Map)4 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)3 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2