use of org.eclipse.ui.navigator.CommonNavigator in project tdq-studio-se by Talend.
the class ResourceViewContentProvider method registerMergeRefListener.
/**
* DOC sgandon Comment method "registerMergeRefListgener".
*/
private void registerMergeRefListener() {
if (mergeRefListener == null) {
mergeRefListener = new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (IRepositoryPrefConstants.MERGE_REFERENCE_PROJECT.equals(event.getProperty())) {
try {
ProxyRepositoryFactory.getInstance().initialize();
} catch (PersistenceException e) {
log.error(e, e);
}
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CommonNavigator findView = (CommonNavigator) activePage.findView(DQRespositoryView.ID);
if (findView != null) {
CommonViewer commonViewer = findView.getCommonViewer();
if (commonViewer != null) {
commonViewer.refresh();
}
}
}
}
};
// the merge only for DI repository,need to judge null for other product
IRepositoryService repositoryService = CoreRuntimePlugin.getInstance().getRepositoryService();
if (repositoryService != null) {
IPreferenceStore preferenceStore = repositoryService.getRepositoryPreferenceStore();
preferenceStore.addPropertyChangeListener(mergeRefListener);
}
}
}
use of org.eclipse.ui.navigator.CommonNavigator in project titan.EclipsePlug-ins by eclipse.
the class LogFileContentProvider method getChildren.
@Override
public Object[] getChildren(final Object parentElement) {
Object[] emptyResult = new Object[] {};
if (!(parentElement instanceof IFile)) {
return emptyResult;
}
final IFile logFile = (IFile) parentElement;
if (!logFile.exists()) {
return emptyResult;
}
String fileExtension = logFile.getFileExtension();
if (fileExtension == null || !fileExtension.equals(Constants.LOG_EXTENSION)) {
return emptyResult;
}
try {
Object temp = logFile.getSessionProperty(Constants.EXTRACTION_RUNNING);
if (temp != null && (Boolean) temp) {
return emptyResult;
}
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
TitanLogExceptionHandler.handleException(new UserException(e.getMessage()));
}
if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
handleLogFileChange(logFile);
return emptyResult;
}
try {
final TestCaseExtractor extractor = new TestCaseExtractor();
extractor.extractTestCasesFromIndexedLogFile(logFile);
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart view = activePage.findView("org.eclipse.ui.navigator.ProjectExplorer");
if (view instanceof CommonNavigator) {
CommonViewer viewer = ((CommonNavigator) view).getCommonViewer();
for (TestCase testCase : extractor.getTestCases()) {
viewer.expandToLevel(testCase, AbstractTreeViewer.ALL_LEVELS);
viewer.refresh(testCase, true);
}
}
}
});
return extractor.getTestCases().toArray();
} catch (Exception e) {
LogFileCacheHandler.clearCache(logFile);
ErrorReporter.logExceptionStackTrace(e);
return emptyResult;
}
}
use of org.eclipse.ui.navigator.CommonNavigator in project jbosstools-openshift by jbosstools.
the class OpenShiftUIUtils method getConnectionForExplorerSelection.
/**
* Returns the connection for the given type and current selection in the OpenShift explorer.
*
* @param klass connection type
* @return
*/
public static <T extends IConnection> T getConnectionForExplorerSelection(Class<T> klass) {
ISelection selection = getOpenShiftExplorerSelection();
if (selection != null && !selection.isEmpty()) {
T result = UIUtils.getFirstElement(selection, klass);
IViewPart part = getOpenShiftExplorer();
if (result == null && selection instanceof IStructuredSelection && part instanceof CommonNavigator) {
Object selected = ((IStructuredSelection) selection).getFirstElement();
IContentProvider provider = ((CommonNavigator) part).getCommonViewer().getContentProvider();
if (provider instanceof ITreeContentProvider) {
ITreeContentProvider tree = (ITreeContentProvider) provider;
while (selected != null && result == null) {
result = UIUtils.adapt(selected, klass);
selected = tree.getParent(selected);
}
}
}
return result;
}
return null;
}
use of org.eclipse.ui.navigator.CommonNavigator in project linuxtools by eclipse.
the class EnableConnectionCommandHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof CommonNavigator) {
final CommonViewer viewer = ((CommonNavigator) activePart).getCommonViewer();
final ITreeSelection selection = (ITreeSelection) viewer.getSelection();
for (TreePath treePath : selection.getPaths()) {
final IDockerConnection conn = (IDockerConnection) treePath.getLastSegment();
if (!conn.isOpen()) {
final Job openConnectionJob = new Job(CommandMessages.getFormattedString(// $NON-NLS-1$
"command.enableconnection", conn.getUri())) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
conn.open(true);
Display.getDefault().asyncExec(() -> viewer.refresh(conn));
} catch (DockerException e) {
Activator.logErrorMessage(CommandMessages.getString(// $NON-NLS-1$
"command.enableconnection.failure"), e);
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
};
openConnectionJob.schedule();
}
}
}
return null;
}
use of org.eclipse.ui.navigator.CommonNavigator in project n4js by eclipse.
the class SelectAllProjectExplorerHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == activeWorkbenchWindow) {
return null;
}
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
if (null == activePage) {
return null;
}
IWorkbenchPart activePart = activePage.getActivePart();
if (!(activePart instanceof CommonNavigator)) {
return null;
}
CommonNavigator navigator = (CommonNavigator) activePart;
CommonViewer commonViewer = navigator.getCommonViewer();
Tree navigatorTree = commonViewer.getTree();
List<TreeItem> visibleItems = new ArrayList<>();
collectChildren(navigatorTree.getItems(), visibleItems);
List<Object> visibleData = visibleItems.stream().map(i -> i.getData()).collect(Collectors.toList());
commonViewer.setSelection(new StructuredSelection(visibleData), false);
return null;
}
Aggregations