blob: ab7a1d5c75d04ec6574ee50901d1bae7d3ee684b [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009, 2010 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.equinox.p2.examples.rcp.cloud.p2;
import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery;
import org.eclipse.equinox.p2.examples.rcp.cloud.Activator;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.ui.Policy;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.graphics.Point;
/**
* CloudPolicy defines the RCP Cloud Example policies for the p2 UI. The policy
* is registered as an OSGi service when the example bundle starts.
*
* @since 3.5
*/
public class CloudPolicy extends Policy {
public void updateForPreferences() {
IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();
setRepositoriesVisible(prefs
.getBoolean(PreferenceConstants.REPOSITORIES_VISIBLE));
setRestartPolicy(prefs.getInt(PreferenceConstants.RESTART_POLICY));
setShowLatestVersionsOnly(prefs
.getBoolean(PreferenceConstants.SHOW_LATEST_VERSION_ONLY));
setGroupByCategory(prefs
.getBoolean(PreferenceConstants.AVAILABLE_GROUP_BY_CATEGORY));
setShowDrilldownRequirements(prefs
.getBoolean(PreferenceConstants.SHOW_DRILLDOWN_REQUIREMENTS));
setFilterOnEnv(prefs.getBoolean(PreferenceConstants.FILTER_ON_ENV));
setUpdateWizardStyle(prefs.getInt(PreferenceConstants.UPDATE_WIZARD_STYLE));
int preferredWidth = prefs.getInt(PreferenceConstants.UPDATE_DETAILS_WIDTH);
int preferredHeight = prefs.getInt(PreferenceConstants.UPDATE_DETAILS_HEIGHT);
setUpdateDetailsPreferredSize(new Point(preferredWidth, preferredHeight));
if (prefs.getBoolean(PreferenceConstants.AVAILABLE_SHOW_ALL_BUNDLES))
setVisibleAvailableIUQuery(QueryUtil.ALL_UNITS);
else
setVisibleAvailableIUQuery(QueryUtil.createIUGroupQuery());
if (prefs.getBoolean(PreferenceConstants.INSTALLED_SHOW_ALL_BUNDLES))
setVisibleAvailableIUQuery(QueryUtil.ALL_UNITS);
else
setVisibleAvailableIUQuery(new UserVisibleRootQuery());
}
}