use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.
the class DockerImagesView method showAllImages.
/**
* Activates {@link HideDanglingImagesFilter} and
* {@link HideIntermediateImagesFilter} 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 showAllImages(boolean enabled) {
if (!enabled) {
this.viewer.addFilter(hideDanglingImagesFilter);
this.viewer.addFilter(hideIntermediateImagesFilter);
} 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(hideDanglingImagesFilter) || viewerFilter.equals(hideIntermediateImagesFilter)) {
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_IMAGES_PREFERENCE, enabled);
refreshViewTitle();
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.
the class DockerImagesView 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);
// track selection changes in the Docker Explorer view (only)
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(DockerExplorerView.VIEW_ID, this);
hookContextMenu();
// Look at stored preference to determine if all images should be
// shown or just top-level images. By default, only show
// top-level images.
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
boolean showAll = preferences.getBoolean(SHOW_ALL_IMAGES_PREFERENCE, false);
showAllImages(showAll);
final ICommandService service = getViewSite().getWorkbenchWindow().getService(ICommandService.class);
service.getCommand(SHOW_ALL_IMAGES_COMMAND_ID).getState(TOGGLE_STATE).setValue(showAll);
service.refreshElements(SHOW_ALL_IMAGES_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 ConfigureLabelsPage method setDefaultValues.
private void setDefaultValues() {
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
// $NON-NLS-1$
String filterLabelString = preferences.get(CONTAINER_FILTER_LABELS, "");
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);
}
}
model.setLabelVariables(labelMap);
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project knime-core by knime.
the class ExtensibleUtilityFactoryTest method testGetRendererFamily.
/**
* Checks if the creation of actual renderer (via the family) works correct.
*/
@Test
public void testGetRendererFamily() {
DataValueRendererFamily family = StringCell.TYPE.getRenderer(new DataColumnSpecCreator("Test", StringCell.TYPE).createSpec());
assertThat("Wrong number of renderers in family", family.getRendererDescriptions().length, is(2));
IEclipsePreferences corePrefs = InstanceScope.INSTANCE.getNode(FrameworkUtil.getBundle(DataValueRendererFactory.class).getSymbolicName());
DataValueRendererFactory rendererFactory = new DoubleGrayValueRenderer.Factory();
corePrefs.put(ExtensibleUtilityFactory.getPreferenceKey(DoubleValue.class), rendererFactory.getId());
DataColumnSpec colSpec = new DataColumnSpecCreator("Test", DoubleCell.TYPE).createSpec();
family = DoubleCell.TYPE.getRenderer(colSpec);
assertThat("Wrong preferred renderer in family list at position 0", family.getRendererDescriptions()[0], is(rendererFactory.createRenderer(colSpec).getDescription()));
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project knime-core by knime.
the class ExtensibleUtilityFactoryTest method testPreferredRenderer.
/**
* Checks if the preferred renderer is correctly read from the preferences.
*/
@Test
public void testPreferredRenderer() {
ExtensibleUtilityFactory utilityFactory = TestDataValue.UTILITY;
IEclipsePreferences corePrefs = InstanceScope.INSTANCE.getNode(FrameworkUtil.getBundle(DataValueRendererFactory.class).getSymbolicName());
DataValueRendererFactory rendererFactory = new TestValueRenderer.Factory();
corePrefs.put(ExtensibleUtilityFactory.getPreferenceKey(TestDataValue.class), rendererFactory.getId());
assertThat("Unexpected preferred renderer", utilityFactory.getPreferredRenderer(), is(rendererFactory));
rendererFactory = new StringValueRenderer.Factory();
corePrefs.put(ExtensibleUtilityFactory.getPreferenceKey(TestDataValue.class), rendererFactory.getId());
assertThat("Unexpected preferred renderer after preference change", utilityFactory.getPreferredRenderer(), is(rendererFactory));
DataValueRendererFactory invalidRendererFactory = new MultiLineStringValueRenderer.Factory();
corePrefs.put(ExtensibleUtilityFactory.getPreferenceKey(TestDataValue.class), invalidRendererFactory.getId());
assertThat("Unexpected preferred renderer after trying to set invalid preferred renderer", utilityFactory.getPreferredRenderer(), is(IsNull.nullValue()));
}
Aggregations