Search in sources :

Example 1 with IPreferenceChangeListener

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

the class DefaultEncodingSupport method initialize.

/**
 * Associates this encoding support to the given text editor and initializes this encoding.
 *
 * @param textEditor the editor
 */
public void initialize(StatusTextEditor textEditor) {
    fTextEditor = textEditor;
    IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES);
    fPreferenceChangeListener = new IPreferenceChangeListener() {

        @Override
        public void preferenceChange(PreferenceChangeEvent event) {
            if (ResourcesPlugin.PREF_ENCODING.equals(event.getKey())) {
                Runnable runnable = new Runnable() {

                    @Override
                    public void run() {
                        // null means: use default
                        setEncoding(null, false);
                    }
                };
                if (Display.getCurrent() != null)
                    runnable.run();
                else {
                    // Post runnable into UI thread
                    Shell shell;
                    if (fTextEditor != null)
                        shell = fTextEditor.getSite().getShell();
                    else
                        shell = getActiveWorkbenchShell();
                    Display display;
                    if (shell != null)
                        display = shell.getDisplay();
                    else
                        display = Display.getDefault();
                    display.asyncExec(runnable);
                }
            }
        }
    };
    prefs.addPreferenceChangeListener(fPreferenceChangeListener);
}
Also used : PreferenceChangeEvent(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent) IPreferenceChangeListener(org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener) Shell(org.eclipse.swt.widgets.Shell) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Display(org.eclipse.swt.widgets.Display)

Example 2 with IPreferenceChangeListener

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

the class GitSelectRepositoryPage method createControl.

@Override
public void createControl(Composite parent) {
    Composite main = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).applyTo(main);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
    // use a filtered tree
    FilteredTree tree = new FilteredTree(main, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, new PatternFilter(), true);
    tv = tree.getViewer();
    GridDataFactory.fillDefaults().grab(true, true).applyTo(tree);
    tv.setContentProvider(new RepositoriesViewContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            Object[] elements = super.getElements(inputElement);
            if (allowBare) {
                return elements;
            }
            List<Object> result = new ArrayList<>();
            for (Object element : elements) {
                if (element instanceof RepositoryTreeNode) {
                    RepositoryTreeNode node = (RepositoryTreeNode) element;
                    if (node.getRepository() != null && !node.getRepository().isBare()) {
                        result.add(element);
                    }
                }
            }
            bareMsg.setVisible(result.size() != elements.length);
            return result.toArray();
        }

        // we never show children, only the Repository nodes
        @Override
        public Object[] getChildren(Object parentElement) {
            return null;
        }

        @Override
        public boolean hasChildren(Object element) {
            return false;
        }
    });
    tv.setLabelProvider(new RepositoriesViewLabelProvider());
    Composite tb = new Composite(main, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(tb);
    GridDataFactory.fillDefaults().grab(false, true).applyTo(tb);
    addRepo = new Button(tb, SWT.PUSH);
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.BEGINNING).applyTo(addRepo);
    addRepo.setText(UIText.GitSelectRepositoryPage_AddButton);
    addRepo.setToolTipText(UIText.GitSelectRepositoryPage_AddTooltip);
    addRepo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            List<String> configuredDirs = util.getConfiguredRepositories();
            RepositorySearchWizard wizard = new RepositorySearchWizard(configuredDirs, allowBare);
            WizardDialog dlg = new WizardDialog(getShell(), wizard);
            if (dlg.open() == Window.OK && !wizard.getDirectories().isEmpty()) {
                Set<String> dirs = wizard.getDirectories();
                for (String dir : dirs) {
                    File gitDir = FileUtils.canonicalize(new File(dir));
                    GerritUtil.tryToAutoConfigureForGerrit(gitDir);
                    util.addConfiguredRepository(gitDir);
                }
                checkPage();
            }
        }
    });
    if (!allowBare) {
        bareMsg = new Composite(main, SWT.NONE);
        bareMsg.setLayout(new RowLayout());
        bareMsg.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
        Label imageLabel = new Label(bareMsg, SWT.NONE);
        imageLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO));
        Label textLabel = new Label(bareMsg, SWT.WRAP);
        textLabel.setText(UIText.GitSelectRepositoryPage_BareRepositoriesHidden);
        bareMsg.setVisible(false);
    }
    tv.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            checkPage();
        }
    });
    tv.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            checkPage();
            if (isPageComplete())
                getContainer().showPage(getNextPage());
        }
    });
    tv.setInput(util.getConfiguredRepositories());
    configChangeListener = new IPreferenceChangeListener() {

        @Override
        public void preferenceChange(PreferenceChangeEvent event) {
            if (RepositoryUtil.PREFS_DIRECTORIES_REL.equals(event.getKey())) {
                Display display = tv.getControl().getDisplay();
                display.asyncExec(() -> {
                    if (!tv.getControl().isDisposed()) {
                        refreshRepositoryList();
                        checkPage();
                    }
                });
            }
        }
    };
    util.getPreferences().addPreferenceChangeListener(configChangeListener);
    // we need to select at least a repository to become complete
    setPageComplete(false);
    Dialog.applyDialogFont(main);
    setControl(main);
}
Also used : PatternFilter(org.eclipse.ui.dialogs.PatternFilter) Set(java.util.Set) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FilteredTree(org.eclipse.ui.dialogs.FilteredTree) RepositoriesViewLabelProvider(org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider) RepositoriesViewContentProvider(org.eclipse.egit.ui.internal.repository.RepositoriesViewContentProvider) RepositorySearchWizard(org.eclipse.egit.ui.internal.repository.RepositorySearchWizard) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) PreferenceChangeEvent(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent) IPreferenceChangeListener(org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) WizardDialog(org.eclipse.jface.wizard.WizardDialog) File(java.io.File) Display(org.eclipse.swt.widgets.Display)

Example 3 with IPreferenceChangeListener

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

the class RebaseInteractiveView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    GridLayoutFactory.fillDefaults().applyTo(parent);
    final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    parent.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            toolkit.dispose();
        }
    });
    form = createForm(parent, toolkit);
    createCommandToolBar(form, toolkit);
    planTreeViewer = createPlanTreeViewer(form.getBody(), toolkit);
    planLayout = new PlanLayout();
    planTreeViewer.getTree().getParent().setLayout(planLayout);
    createColumns(planLayout);
    createStepActionToolBar(toolkit);
    createPopupMenu(planTreeViewer);
    setupListeners();
    createLocalDragandDrop();
    planTreeViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            PlanElement element = (PlanElement) ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (element == null)
                return;
            RepositoryCommit commit = loadCommit(element.getCommit());
            if (commit != null)
                CommitEditor.openQuiet(commit);
        }

        private RepositoryCommit loadCommit(AbbreviatedObjectId abbreviatedObjectId) {
            if (abbreviatedObjectId != null) {
                try (RevWalk walk = new RevWalk(RebaseInteractiveView.this.currentRepository)) {
                    Collection<ObjectId> resolved = walk.getObjectReader().resolve(abbreviatedObjectId);
                    if (resolved.size() == 1) {
                        RevCommit commit = walk.parseCommit(resolved.iterator().next());
                        return new RepositoryCommit(RebaseInteractiveView.this.currentRepository, commit);
                    }
                } catch (IOException e) {
                    return null;
                }
            }
            return null;
        }
    });
    prefListener = new IPreferenceChangeListener() {

        @Override
        public void preferenceChange(PreferenceChangeEvent event) {
            if (!RepositoryUtil.PREFS_DIRECTORIES_REL.equals(event.getKey())) {
                return;
            }
            final Repository repo = currentRepository;
            if (repo == null)
                return;
            if (Activator.getDefault().getRepositoryUtil().contains(repo))
                return;
            // Unselect repository as it has been removed
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    currentRepository = null;
                    showRepository(null);
                }
            });
        }
    };
    InstanceScope.INSTANCE.getNode(org.eclipse.egit.core.Activator.getPluginId()).addPreferenceChangeListener(prefListener);
    uiPrefsListener = new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            String property = event.getProperty();
            if (UIPreferences.DATE_FORMAT.equals(property) || UIPreferences.DATE_FORMAT_CHOICE.equals(property) || UIPreferences.RESOURCEHISTORY_SHOW_RELATIVE_DATE.equals(property)) {
                refresh();
            }
        }
    };
    Activator.getDefault().getPreferenceStore().addPropertyChangeListener(uiPrefsListener);
    IActionBars actionBars = getViewSite().getActionBars();
    IToolBarManager toolbar = actionBars.getToolBarManager();
    listenOnRepositoryViewSelection = RebaseInteractivePreferences.isReactOnSelection();
    // link with selection
    Action linkSelectionAction = new BooleanPrefAction((IPersistentPreferenceStore) Activator.getDefault().getPreferenceStore(), UIPreferences.REBASE_INTERACTIVE_SYNC_SELECTION, UIText.InteractiveRebaseView_LinkSelection) {

        @Override
        public void apply(boolean value) {
            listenOnRepositoryViewSelection = value;
        }
    };
    linkSelectionAction.setImageDescriptor(UIIcons.ELCL16_SYNCED);
    toolbar.add(linkSelectionAction);
    switchRepositoriesAction = new RepositoryToolbarAction(false, () -> currentRepository, repo -> setInput(new StructuredSelection(repo)));
    toolbar.add(switchRepositoriesAction);
    UIUtils.notifySelectionChangedWithCurrentSelection(selectionChangedListener, getSite());
    getSite().setSelectionProvider(new RepositorySelectionProvider(planTreeViewer, () -> currentRepository));
}
Also used : AdapterUtils(org.eclipse.egit.core.AdapterUtils) UIPreferences(org.eclipse.egit.ui.UIPreferences) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) DND(org.eclipse.swt.dnd.DND) CommitEditor(org.eclipse.egit.ui.internal.commit.CommitEditor) RepositoryState(org.eclipse.jgit.lib.RepositoryState) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) RevWalk(org.eclipse.jgit.revwalk.RevWalk) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) ProcessStepsRebaseCommand(org.eclipse.egit.ui.internal.commands.shared.ProcessStepsRebaseCommand) Composite(org.eclipse.swt.widgets.Composite) PartInitException(org.eclipse.ui.PartInitException) PreferenceBasedDateFormatter(org.eclipse.egit.ui.internal.PreferenceBasedDateFormatter) KeyEvent(org.eclipse.swt.events.KeyEvent) KeyAdapter(org.eclipse.swt.events.KeyAdapter) IEditorPart(org.eclipse.ui.IEditorPart) AbortRebaseCommand(org.eclipse.egit.ui.internal.commands.shared.AbortRebaseCommand) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Separator(org.eclipse.jface.action.Separator) IEditorInput(org.eclipse.ui.IEditorInput) PlatformUI(org.eclipse.ui.PlatformUI) MenuManager(org.eclipse.jface.action.MenuManager) ToolItem(org.eclipse.swt.widgets.ToolItem) AbstractRebaseCommandHandler(org.eclipse.egit.ui.internal.commands.shared.AbstractRebaseCommandHandler) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) Transfer(org.eclipse.swt.dnd.Transfer) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) UIText(org.eclipse.egit.ui.internal.UIText) PreferenceChangeEvent(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent) SWT(org.eclipse.swt.SWT) BooleanPrefAction(org.eclipse.egit.ui.internal.actions.BooleanPrefAction) ElementType(org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.ElementType) RepositorySelectionProvider(org.eclipse.egit.ui.internal.selection.RepositorySelectionProvider) ViewPart(org.eclipse.ui.part.ViewPart) RevCommit(org.eclipse.jgit.revwalk.RevCommit) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Format(org.eclipse.jgit.util.GitDateFormatter.Format) JFaceResources(org.eclipse.jface.resource.JFaceResources) RebaseInteractivePlan(org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) IFileEditorInput(org.eclipse.ui.IFileEditorInput) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) PlanElement(org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.PlanElement) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) Font(org.eclipse.swt.graphics.Font) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IPreferenceChangeListener(org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) IViewSite(org.eclipse.ui.IViewSite) IOException(java.io.IOException) ExecutionException(org.eclipse.core.commands.ExecutionException) IActionBars(org.eclipse.ui.IActionBars) CommonUtils(org.eclipse.egit.ui.internal.CommonUtils) Form(org.eclipse.ui.forms.widgets.Form) RepositoryToolbarAction(org.eclipse.egit.ui.internal.components.RepositoryMenuUtil.RepositoryToolbarAction) ToolTip(org.eclipse.jface.window.ToolTip) Repository(org.eclipse.jgit.lib.Repository) ElementAction(org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.ElementAction) DisposeEvent(org.eclipse.swt.events.DisposeEvent) DisposeListener(org.eclipse.swt.events.DisposeListener) IAction(org.eclipse.jface.action.IAction) ToolBar(org.eclipse.swt.widgets.ToolBar) IToolBarManager(org.eclipse.jface.action.IToolBarManager) SWTKeySupport(org.eclipse.jface.bindings.keys.SWTKeySupport) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) GC(org.eclipse.swt.graphics.GC) ISelectionListener(org.eclipse.ui.ISelectionListener) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) RepositoryCommit(org.eclipse.egit.ui.internal.commit.RepositoryCommit) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) Collection(java.util.Collection) GitDateFormatter(org.eclipse.jgit.util.GitDateFormatter) Display(org.eclipse.swt.widgets.Display) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) AbbreviatedObjectId(org.eclipse.jgit.lib.AbbreviatedObjectId) List(java.util.List) Tree(org.eclipse.swt.widgets.Tree) ISelection(org.eclipse.jface.viewers.ISelection) TreeViewer(org.eclipse.jface.viewers.TreeViewer) UIIcons(org.eclipse.egit.ui.internal.UIIcons) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ISelectionService(org.eclipse.ui.ISelectionService) RepositoryMapping(org.eclipse.egit.core.project.RepositoryMapping) RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) Activator(org.eclipse.egit.ui.Activator) Image(org.eclipse.swt.graphics.Image) RepositoryUtil(org.eclipse.egit.core.RepositoryUtil) IPersistentPreferenceStore(org.eclipse.jface.preference.IPersistentPreferenceStore) ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ContinueRebaseCommand(org.eclipse.egit.ui.internal.commands.shared.ContinueRebaseCommand) IWorkbenchActionConstants(org.eclipse.ui.IWorkbenchActionConstants) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Action(org.eclipse.jface.action.Action) TreeItem(org.eclipse.swt.widgets.TreeItem) ObjectId(org.eclipse.jgit.lib.ObjectId) IResource(org.eclipse.core.resources.IResource) UIUtils(org.eclipse.egit.ui.UIUtils) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) LocalResourceManager(org.eclipse.jface.resource.LocalResourceManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) RepositoriesView(org.eclipse.egit.ui.internal.repository.RepositoriesView) Control(org.eclipse.swt.widgets.Control) SkipRebaseCommand(org.eclipse.egit.ui.internal.commands.shared.SkipRebaseCommand) DisposeListener(org.eclipse.swt.events.DisposeListener) BooleanPrefAction(org.eclipse.egit.ui.internal.actions.BooleanPrefAction) RepositoryToolbarAction(org.eclipse.egit.ui.internal.components.RepositoryMenuUtil.RepositoryToolbarAction) ElementAction(org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.ElementAction) IAction(org.eclipse.jface.action.IAction) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) Action(org.eclipse.jface.action.Action) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositorySelectionProvider(org.eclipse.egit.ui.internal.selection.RepositorySelectionProvider) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DisposeEvent(org.eclipse.swt.events.DisposeEvent) PlanElement(org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.PlanElement) AbbreviatedObjectId(org.eclipse.jgit.lib.AbbreviatedObjectId) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) IActionBars(org.eclipse.ui.IActionBars) RevCommit(org.eclipse.jgit.revwalk.RevCommit) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) RepositoryToolbarAction(org.eclipse.egit.ui.internal.components.RepositoryMenuUtil.RepositoryToolbarAction) PreferenceChangeEvent(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent) IPreferenceChangeListener(org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IOException(java.io.IOException) RevWalk(org.eclipse.jgit.revwalk.RevWalk) RepositoryCommit(org.eclipse.egit.ui.internal.commit.RepositoryCommit) Repository(org.eclipse.jgit.lib.Repository) IToolBarManager(org.eclipse.jface.action.IToolBarManager) Collection(java.util.Collection) BooleanPrefAction(org.eclipse.egit.ui.internal.actions.BooleanPrefAction)

Example 4 with IPreferenceChangeListener

use of org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener in project titan.EclipsePlug-ins by eclipse.

the class ExcludedResourceFilter method checkIsActive.

private static void checkIsActive() {
    final IEclipsePreferences rootNode = (IEclipsePreferences) Platform.getPreferencesService().getRootNode().node(InstanceScope.SCOPE).node(NAVIGATOR_QUALIFIER);
    rootNode.addPreferenceChangeListener(new IPreferenceChangeListener() {

        @Override
        public void preferenceChange(final PreferenceChangeEvent event) {
            if (FILTER_ACTIVATION_KEY.equals(event.getKey())) {
                final String temp = Platform.getPreferencesService().getString(NAVIGATOR_QUALIFIER, FILTER_ACTIVATION_KEY, "", null);
                isActive = temp.indexOf(FILTER_ID) != -1;
                isActiveSet = true;
            }
        }
    });
    final String temp = Platform.getPreferencesService().getString(NAVIGATOR_QUALIFIER, FILTER_ACTIVATION_KEY, "", null);
    isActive = temp.indexOf(FILTER_ID) != -1;
    isActiveSet = true;
}
Also used : PreferenceChangeEvent(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent) IPreferenceChangeListener(org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Example 5 with IPreferenceChangeListener

use of org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener in project titan.EclipsePlug-ins by eclipse.

the class WorkingDirectoryFilter method checkIsActive.

private static void checkIsActive() {
    final IEclipsePreferences rootNode = (IEclipsePreferences) Platform.getPreferencesService().getRootNode().node(InstanceScope.SCOPE).node(NAVIGATOR_QUALIFIER);
    rootNode.addPreferenceChangeListener(new IPreferenceChangeListener() {

        @Override
        public void preferenceChange(final PreferenceChangeEvent event) {
            if (FILTER_ACTIVATION_KEY.equals(event.getKey())) {
                final String temp = Platform.getPreferencesService().getString(NAVIGATOR_QUALIFIER, FILTER_ACTIVATION_KEY, "", null);
                isActive = temp.indexOf(FILTER_ID) != -1;
                isActiveSet = true;
            }
        }
    });
    final String temp = Platform.getPreferencesService().getString(NAVIGATOR_QUALIFIER, FILTER_ACTIVATION_KEY, "", null);
    isActive = temp.indexOf(FILTER_ID) != -1;
    isActiveSet = true;
}
Also used : PreferenceChangeEvent(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent) IPreferenceChangeListener(org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Aggregations

IPreferenceChangeListener (org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener)5 PreferenceChangeEvent (org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)5 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)3 Display (org.eclipse.swt.widgets.Display)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 RepositoryTreeNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)2 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)2 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Composite (org.eclipse.swt.widgets.Composite)2 File (java.io.File)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 Set (java.util.Set)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IResource (org.eclipse.core.resources.IResource)1