org.eclipse.ui.internal.navigator.workingsets.WorkingSetsContentProvider Java Examples

The following examples show how to use org.eclipse.ui.internal.navigator.workingsets.WorkingSetsContentProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorkingSetActionProvider.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public void onExtensionActivation(String aViewerId, String[] theNavigatorExtensionIds, boolean isActive) {

			for (int i = 0; i < theNavigatorExtensionIds.length; i++) {
				if (WorkingSetsContentProvider.EXTENSION_ID.equals(theNavigatorExtensionIds[i])) {
					if (isActive) {
						extensionStateModel = contentService.findStateModel(WorkingSetsContentProvider.EXTENSION_ID);
						workingSetRootModeActionGroup.setStateModel(extensionStateModel);
						extensionStateModel.addPropertyChangeListener(topLevelModeListener);

						if (savedWorkingSet != null) {
							setWorkingSet(savedWorkingSet);
						}
						managerChangeListener.listen();

					} else {
						savedWorkingSet = workingSet;
						setWorkingSet(null);
						viewer.getCommonNavigator().setWorkingSetLabel(null);
						managerChangeListener.ignore();
						workingSetRootModeActionGroup.setShowTopLevelWorkingSets(false);
						extensionStateModel.removePropertyChangeListener(topLevelModeListener);

					}
				}
			}
		}
 
Example #2
Source File: WorkingSetActionProvider.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public void init(ICommonActionExtensionSite aSite) {
	viewer = (CommonViewer) aSite.getStructuredViewer();
	contentService = aSite.getContentService();
	filterService = (NavigatorFilterService) contentService.getFilterService();

	extensionStateModel = contentService.findStateModel(WorkingSetsContentProvider.EXTENSION_ID);

	workingSetActionGroup = new WorkingSetFilterActionGroup(aSite.getViewSite().getShell(), filterChangeListener);
	workingSetRootModeActionGroup = new WorkingSetRootModeActionGroup(viewer, extensionStateModel);

	topLevelModeListener = new IPropertyChangeListener() {
		public void propertyChange(PropertyChangeEvent event) {
			setWorkingSet(workingSet);
			viewer.getFrameList().reset();
		}
	};

	if (contentService.isActive(WorkingSetsContentProvider.EXTENSION_ID)) {
		managerChangeListener.listen();
		extensionStateModel.addPropertyChangeListener(topLevelModeListener);
	}

	contentService.getActivationService().addExtensionActivationListener(activationListener);
}
 
Example #3
Source File: WorkingSetRootModeActionGroup.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Toggle whether top level working sets should be displayed as a group or
 * collapse to just show their contents.
 * 
 * @param showTopLevelWorkingSets
 */
public void setShowTopLevelWorkingSets(boolean showTopLevelWorkingSets) {
	if (actions == null) 
		actions = createActions();

	currentSelection = showTopLevelWorkingSets ? 1 : 0;
	workingSetsAction.setChecked(showTopLevelWorkingSets);
	projectsAction.setChecked(!showTopLevelWorkingSets);

	if (items != null) {
		for (int i = 0; i < items.length; i++) {
			if(items[i] != null && actions[i] != null)
				items[i].setSelection(actions[i].isChecked());
		}
	}
	if (stateModel != null) {
		stateModel.setBooleanProperty(
				WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS,
				showTopLevelWorkingSets);
	}
}
 
Example #4
Source File: WorkingSetRootModeActionGroup.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Toggle whether top level working sets should be displayed as a group or
 * collapse to just show their contents.
 * 
 * @param showTopLevelWorkingSets
 */
public void setShowTopLevelWorkingSets(boolean showTopLevelWorkingSets) {
	if (actions == null) 
		actions = createActions();

	currentSelection = showTopLevelWorkingSets ? 1 : 0;
	workingSetsAction.setChecked(showTopLevelWorkingSets);
	projectsAction.setChecked(!showTopLevelWorkingSets);

	if (items != null) {
		for (int i = 0; i < items.length; i++) {
			if(items[i] != null && actions[i] != null)
				items[i].setSelection(actions[i].isChecked());
		}
	}
	if (stateModel != null) {
		stateModel.setBooleanProperty(
				WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS,
				showTopLevelWorkingSets);
	}
}
 
Example #5
Source File: WorkingSetActionProvider.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public void onExtensionActivation(String aViewerId, String[] theNavigatorExtensionIds, boolean isActive) {

			for (int i = 0; i < theNavigatorExtensionIds.length; i++) {
				if (WorkingSetsContentProvider.EXTENSION_ID.equals(theNavigatorExtensionIds[i])) {
					if (isActive) {
						extensionStateModel = contentService.findStateModel(WorkingSetsContentProvider.EXTENSION_ID);
						workingSetRootModeActionGroup.setStateModel(extensionStateModel);
						extensionStateModel.addPropertyChangeListener(topLevelModeListener);

						if (savedWorkingSet != null) {
							setWorkingSet(savedWorkingSet);
						}
						managerChangeListener.listen();

					} else {
						savedWorkingSet = workingSet;
						setWorkingSet(null);
						viewer.getCommonNavigator().setWorkingSetLabel(null);
						managerChangeListener.ignore();
						workingSetRootModeActionGroup.setShowTopLevelWorkingSets(false);
						extensionStateModel.removePropertyChangeListener(topLevelModeListener);

					}
				}
			}
		}
 
Example #6
Source File: WorkingSetActionProvider.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public void init(ICommonActionExtensionSite aSite) {
	viewer = (CommonViewer) aSite.getStructuredViewer();
	contentService = aSite.getContentService();
	filterService = (NavigatorFilterService) contentService.getFilterService();

	extensionStateModel = contentService.findStateModel(WorkingSetsContentProvider.EXTENSION_ID);

	workingSetActionGroup = new WorkingSetFilterActionGroup(aSite.getViewSite().getShell(), filterChangeListener);
	workingSetRootModeActionGroup = new WorkingSetRootModeActionGroup(viewer, extensionStateModel);

	topLevelModeListener = new IPropertyChangeListener() {
		public void propertyChange(PropertyChangeEvent event) {
			setWorkingSet(workingSet);
			viewer.getFrameList().reset();
		}
	};

	if (contentService.isActive(WorkingSetsContentProvider.EXTENSION_ID)) {
		managerChangeListener.listen();
		extensionStateModel.addPropertyChangeListener(topLevelModeListener);
	}

	contentService.getActivationService().addExtensionActivationListener(activationListener);
}
 
Example #7
Source File: TopLevelProjectsOrWorkingSetChoice.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Starts listening to property changes related to which should be the top-level elements to be shown.
 */
public void init(ICommonContentExtensionSite aConfig, CommonViewer viewer) {
    //if it had something, dispose of its association!
    this.dispose();
    try {
        extensionStateModel = viewer.getNavigatorContentService().findStateModel(
                WorkingSetsContentProvider.EXTENSION_ID);

        extensionStateModel.addPropertyChangeListener(rootModeListener);
    } catch (Exception e) {
        Log.log(e);
    }
    updateRootMode();
}
 
Example #8
Source File: WorkingSetActionProvider.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
	
	if (ignoreFilterChangeEvents)
		return;
	
	IWorkingSet newWorkingSet = (IWorkingSet) event.getNewValue();

	setWorkingSet(newWorkingSet);
	if (newWorkingSet != null) {
		if (!contentService.isActive(WorkingSetsContentProvider.EXTENSION_ID)) {
			contentService.getActivationService().activateExtensions(
					new String[] { WorkingSetsContentProvider.EXTENSION_ID }, false);
			contentService.getActivationService().persistExtensionActivations();
		}
		if (newWorkingSet.isAggregateWorkingSet()) {
			IAggregateWorkingSet agWs = (IAggregateWorkingSet) newWorkingSet;
			IWorkingSet[] comps = agWs.getComponents();
			if (comps.length > 1) {
				viewer.getCommonNavigator().setWorkingSetLabel(
						WorkbenchNavigatorMessages.actions_WorkingSetActionProvider_multipleWorkingSets);
			} else if (comps.length > 0) {
				viewer.getCommonNavigator().setWorkingSetLabel(comps[0].getLabel());
			} else {
				viewer.getCommonNavigator().setWorkingSetLabel(null);
			}
		} else
			viewer.getCommonNavigator().setWorkingSetLabel(workingSet.getLabel());
	} else {
		viewer.getCommonNavigator().setWorkingSetLabel(null);
	}

	viewer.getFrameList().reset();
}
 
Example #9
Source File: WorkingSetRootModeActionGroup.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
	if (stateModel
			.getBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS) != groupWorkingSets) {
		stateModel.setBooleanProperty(
				WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS,
				groupWorkingSets);

		structuredViewer.getControl().setRedraw(false);
		try {
			structuredViewer.refresh();
		} finally {
			structuredViewer.getControl().setRedraw(true);
		}
	}
}
 
Example #10
Source File: WorkingSetActionProvider.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void saveState(IMemento aMemento) {
	super.saveState(aMemento);

	if (aMemento != null) {
		int showWorkingSets = extensionStateModel
				.getBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS) ? 1 : 0;
		aMemento.putInteger(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, showWorkingSets);

		if (workingSet != null) {
			aMemento.putString(TAG_CURRENT_WORKING_SET_NAME, workingSet.getName());
		}
	}

}
 
Example #11
Source File: WorkingSetActionProvider.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void restoreState(final IMemento aMemento) {
	super.restoreState(aMemento);

	// Need to run this async to avoid being reentered when processing a selection change
	viewer.getControl().getShell().getDisplay().asyncExec(new Runnable() {
		public void run() {
			boolean showWorkingSets = true;
			if (aMemento != null) {
				Integer showWorkingSetsInt = aMemento
						.getInteger(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS);
				showWorkingSets = showWorkingSetsInt == null || showWorkingSetsInt.intValue() == 1;
				extensionStateModel.setBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS,
						showWorkingSets);
				workingSetRootModeActionGroup.setShowTopLevelWorkingSets(showWorkingSets);

				String lastWorkingSetName = aMemento.getString(TAG_CURRENT_WORKING_SET_NAME);
				initWorkingSetFilter(lastWorkingSetName);
			} else {
				showWorkingSets = false;

				extensionStateModel.setBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS,
						showWorkingSets);
				workingSetRootModeActionGroup.setShowTopLevelWorkingSets(showWorkingSets);
			}
		}
	});
}
 
Example #12
Source File: WorkingSetActionProvider.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set current active working set.
 * 
 * @param workingSet
 *            working set to be activated, may be <code>null</code>
 */
protected void setWorkingSet(IWorkingSet workingSet) {
	this.workingSet = workingSet;
	emptyWorkingSet = workingSet != null && workingSet.isAggregateWorkingSet() && workingSet.isEmpty();

       ignoreFilterChangeEvents = true;
       try {
       	workingSetActionGroup.setWorkingSet(workingSet);
       } finally {
       	ignoreFilterChangeEvents = false;
      	}		
	
	if (viewer != null) {
		setWorkingSetFilter(workingSet);
		if (workingSet == null || emptyWorkingSet
				|| !extensionStateModel.getBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS)) {
			if (viewer.getInput() != originalViewerInput) {
				viewer.setInput(originalViewerInput);
			} else {
				viewer.refresh();
			}
		} else {
			if (!workingSet.isAggregateWorkingSet()) {
				IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
				viewer.setInput(workingSetManager.createAggregateWorkingSet(
						"", "", new IWorkingSet[] { workingSet })); //$NON-NLS-1$ //$NON-NLS-2$
			} else {
				viewer.setInput(workingSet);
			}
		}
	}
}
 
Example #13
Source File: WorkingSetActionProvider.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
	
	if (ignoreFilterChangeEvents)
		return;
	
	IWorkingSet newWorkingSet = (IWorkingSet) event.getNewValue();

	setWorkingSet(newWorkingSet);
	if (newWorkingSet != null) {
		if (!contentService.isActive(WorkingSetsContentProvider.EXTENSION_ID)) {
			contentService.getActivationService().activateExtensions(
					new String[] { WorkingSetsContentProvider.EXTENSION_ID }, false);
			contentService.getActivationService().persistExtensionActivations();
		}
		if (newWorkingSet.isAggregateWorkingSet()) {
			IAggregateWorkingSet agWs = (IAggregateWorkingSet) newWorkingSet;
			IWorkingSet[] comps = agWs.getComponents();
			if (comps.length > 1) {
				viewer.getCommonNavigator().setWorkingSetLabel(
						WorkbenchNavigatorMessages.actions_WorkingSetActionProvider_multipleWorkingSets);
			} else if (comps.length > 0) {
				viewer.getCommonNavigator().setWorkingSetLabel(comps[0].getLabel());
			} else {
				viewer.getCommonNavigator().setWorkingSetLabel(null);
			}
		} else
			viewer.getCommonNavigator().setWorkingSetLabel(workingSet.getLabel());
	} else {
		viewer.getCommonNavigator().setWorkingSetLabel(null);
	}

	viewer.getFrameList().reset();
}
 
Example #14
Source File: WorkingSetRootModeActionGroup.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
	if (stateModel
			.getBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS) != groupWorkingSets) {
		stateModel.setBooleanProperty(
				WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS,
				groupWorkingSets);

		structuredViewer.getControl().setRedraw(false);
		try {
			structuredViewer.refresh();
		} finally {
			structuredViewer.getControl().setRedraw(true);
		}
	}
}
 
Example #15
Source File: WorkingSetActionProvider.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void saveState(IMemento aMemento) {
	super.saveState(aMemento);

	if (aMemento != null) {
		int showWorkingSets = extensionStateModel
				.getBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS) ? 1 : 0;
		aMemento.putInteger(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, showWorkingSets);

		if (workingSet != null) {
			aMemento.putString(TAG_CURRENT_WORKING_SET_NAME, workingSet.getName());
		}
	}

}
 
Example #16
Source File: WorkingSetActionProvider.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void restoreState(final IMemento aMemento) {
	super.restoreState(aMemento);

	// Need to run this async to avoid being reentered when processing a selection change
	viewer.getControl().getShell().getDisplay().asyncExec(new Runnable() {
		public void run() {
			boolean showWorkingSets = true;
			if (aMemento != null) {
				Integer showWorkingSetsInt = aMemento
						.getInteger(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS);
				showWorkingSets = showWorkingSetsInt == null || showWorkingSetsInt.intValue() == 1;
				extensionStateModel.setBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS,
						showWorkingSets);
				workingSetRootModeActionGroup.setShowTopLevelWorkingSets(showWorkingSets);

				String lastWorkingSetName = aMemento.getString(TAG_CURRENT_WORKING_SET_NAME);
				initWorkingSetFilter(lastWorkingSetName);
			} else {
				showWorkingSets = false;

				extensionStateModel.setBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS,
						showWorkingSets);
				workingSetRootModeActionGroup.setShowTopLevelWorkingSets(showWorkingSets);
			}
		}
	});
}
 
Example #17
Source File: WorkingSetActionProvider.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set current active working set.
 * 
 * @param workingSet
 *            working set to be activated, may be <code>null</code>
 */
protected void setWorkingSet(IWorkingSet workingSet) {
	this.workingSet = workingSet;
	emptyWorkingSet = workingSet != null && workingSet.isAggregateWorkingSet() && workingSet.isEmpty();

       ignoreFilterChangeEvents = true;
       try {
       	workingSetActionGroup.setWorkingSet(workingSet);
       } finally {
       	ignoreFilterChangeEvents = false;
      	}		
	
	if (viewer != null) {
		setWorkingSetFilter(workingSet);
		if (workingSet == null || emptyWorkingSet
				|| !extensionStateModel.getBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS)) {
			if (viewer.getInput() != originalViewerInput) {
				viewer.setInput(originalViewerInput);
			} else {
				viewer.refresh();
			}
		} else {
			if (!workingSet.isAggregateWorkingSet()) {
				IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
				viewer.setInput(workingSetManager.createAggregateWorkingSet(
						"", "", new IWorkingSet[] { workingSet })); //$NON-NLS-1$ //$NON-NLS-2$
			} else {
				viewer.setInput(workingSet);
			}
		}
	}
}