Search in sources :

Example 1 with ProjectExplorer

use of org.eclipse.ui.navigator.resources.ProjectExplorer in project n4js by eclipse.

the class WorkingSetManagerBrokerImpl method asyncRefreshCommonViewer.

private void asyncRefreshCommonViewer(final ProjectExplorer explorer, final boolean resetInput) {
    // do deferred initialization
    this.getWorkingSetManagers().stream().filter(m -> (m instanceof IDeferredInitializer)).map(m -> (IDeferredInitializer) m).filter(m -> m.isInitializationRequired()).forEach(m -> {
        m.lateInit();
    });
    final CommonViewer viewer = explorer.getCommonViewer();
    final Display d = getDisplay();
    if (!d.isDisposed()) {
        if (resetInput) {
            d.asyncExec(() -> {
                final WorkingSetManager activeManager = getActiveManager();
                if (activeManager != null)
                    activeManager.discardWorkingSetCaches();
                if (!viewer.getTree().isDisposed())
                    viewer.setInput(viewer.getInput());
            });
        } else {
            d.asyncExec(() -> {
                final WorkingSetManager activeManager = getActiveManager();
                if (activeManager != null)
                    activeManager.discardWorkingSetCaches();
                if (!viewer.getTree().isDisposed())
                    viewer.refresh(true);
            });
        }
    }
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) Diff(org.eclipse.n4js.utils.Diff) Inject(com.google.inject.Inject) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CoreException(org.eclipse.core.runtime.CoreException) N4JSActivator(org.eclipse.n4js.ui.internal.N4JSActivator) Logger(org.apache.log4j.Logger) BackingStoreException(org.osgi.service.prefs.BackingStoreException) IStatus(org.eclipse.core.runtime.IStatus) WorkingSetManagerChangeEvent(org.eclipse.n4js.ui.workingsets.WorkingSetManagerStateChangedListener.WorkingSetManagerChangeEvent) FluentIterable.from(com.google.common.collect.FluentIterable.from) Map(java.util.Map) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) IPartListener2(org.eclipse.ui.IPartListener2) IViewPart(org.eclipse.ui.IViewPart) Objects(com.google.common.base.Objects) ISaveContext(org.eclipse.core.resources.ISaveContext) CommonViewer(org.eclipse.ui.navigator.CommonViewer) StatusHelper(org.eclipse.n4js.utils.StatusHelper) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) Status(org.eclipse.core.runtime.Status) Display(org.eclipse.swt.widgets.Display) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) Platform.isRunning(org.eclipse.core.runtime.Platform.isRunning) Singleton(com.google.inject.Singleton) IWorkbenchPartReference(org.eclipse.ui.IWorkbenchPartReference) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) EXTENSION_POINT_ID(org.eclipse.n4js.ui.workingsets.WorkingSetManager.EXTENSION_POINT_ID) SubMonitor(org.eclipse.core.runtime.SubMonitor) ProjectExplorer(org.eclipse.ui.navigator.resources.ProjectExplorer) Preferences(org.osgi.service.prefs.Preferences) Supplier(com.google.common.base.Supplier) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) OK_STATUS(org.eclipse.core.runtime.Status.OK_STATUS) PlatformUI.getWorkbench(org.eclipse.ui.PlatformUI.getWorkbench) Arrays2(org.eclipse.n4js.utils.collections.Arrays2) AtomicReference(java.util.concurrent.atomic.AtomicReference) Builder(com.google.common.collect.ImmutableMap.Builder) Strings(com.google.common.base.Strings) Platform.getExtensionRegistry(org.eclipse.core.runtime.Platform.getExtensionRegistry) IWorkspace(org.eclipse.core.resources.IWorkspace) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) UIUtils.getDisplay(org.eclipse.n4js.ui.utils.UIUtils.getDisplay) Suppliers.memoize(com.google.common.base.Suppliers.memoize) Collections.emptyMap(java.util.Collections.emptyMap) UIUtils(org.eclipse.n4js.ui.utils.UIUtils) EMFPlugin(org.eclipse.emf.common.EMFPlugin) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Injector(com.google.inject.Injector) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IWorkbench(org.eclipse.ui.IWorkbench) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) CommonViewer(org.eclipse.ui.navigator.CommonViewer) Display(org.eclipse.swt.widgets.Display) UIUtils.getDisplay(org.eclipse.n4js.ui.utils.UIUtils.getDisplay)

Example 2 with ProjectExplorer

use of org.eclipse.ui.navigator.resources.ProjectExplorer in project InformationSystem by ObeoNetwork.

the class DatabaseImportWizard method performFinish.

/* (non-Javadoc)
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
	 */
public boolean performFinish() {
    // First, check if a connection to the database can be established
    if (databaseInfos != null) {
        Connection connection = null;
        DataSource dataSource = databaseInfos.getDataSource();
        if (dataSource != null) {
            try {
                connection = dataSource.getConnection();
            } catch (DataSourceException e) {
                // Unable to connect
                String message = "Unable to connect to database.\n\nReason : " + e.getCause().getMessage();
                MessageDialog.openError(getShell(), "Import database...", message);
                return false;
            } finally {
                JdbcUtils.closeConnection(connection);
            }
        }
    }
    String filename = mainPage.getTxtModelFile().getText();
    boolean result = DatabaseImportHelper.importDatabaseIntoModel(databaseInfos, filename, mainPage.getReferencedFiles());
    if (result == true) {
        MessageDialog.openInformation(getShell(), "Database imported", "The database has been imported.\nThe model file '" + filename + "' has been created.");
        IViewPart explorer = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("org.eclipse.ui.navigator.ProjectExplorer");
        if (explorer != null) {
            if (explorer instanceof ProjectExplorer) {
                ProjectExplorer projectExplorer = (ProjectExplorer) explorer;
                // Create a selection to point on the generated file
                final IFile generatedFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filename));
                projectExplorer.selectReveal(new StructuredSelection(generatedFile));
            }
        }
    } else {
        MessageDialog.openError(getShell(), "Error while importing database", "The database could not be imported.");
    }
    return result;
}
Also used : ProjectExplorer(org.eclipse.ui.navigator.resources.ProjectExplorer) Path(org.eclipse.core.runtime.Path) IViewPart(org.eclipse.ui.IViewPart) IFile(org.eclipse.core.resources.IFile) DataSourceException(org.obeonetwork.dsl.database.reverse.source.DataSourceException) Connection(java.sql.Connection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DataSource(org.obeonetwork.dsl.database.reverse.source.DataSource)

Aggregations

IViewPart (org.eclipse.ui.IViewPart)2 ProjectExplorer (org.eclipse.ui.navigator.resources.ProjectExplorer)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Objects (com.google.common.base.Objects)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Strings (com.google.common.base.Strings)1 Supplier (com.google.common.base.Supplier)1 Suppliers.memoize (com.google.common.base.Suppliers.memoize)1 FluentIterable.from (com.google.common.collect.FluentIterable.from)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Builder (com.google.common.collect.ImmutableMap.Builder)1 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1 Inject (com.google.inject.Inject)1 Injector (com.google.inject.Injector)1 Singleton (com.google.inject.Singleton)1 Connection (java.sql.Connection)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Collections.emptyMap (java.util.Collections.emptyMap)1 Map (java.util.Map)1