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;
}
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);
}
}
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);
}
}
}
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();
}
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);
}
Aggregations