blob: 998ff93add79358f25a45ea2ca1dd206099cd250 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009 Sybase, Inc. and others
*
* All rights reserved. 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/
*
* Contributors: Ingres - initial API and implementation
* brianf - a few tweaks
******************************************************************************/
package org.eclipse.datatools.enablement.rcp;
import java.net.URL;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.application.IWorkbenchConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
import org.eclipse.ui.internal.ide.undo.WorkspaceUndoMonitor;
import org.osgi.framework.Bundle;
public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
private static final String PERSPECTIVE_ID = "org.eclipse.datatools.enablement.rcp.perspective";
private transient WorkspaceUndoMonitor workspaceUndoMonitor;
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
return new ApplicationWorkbenchWindowAdvisor(configurer);
}
public String getInitialWindowPerspectiveId() {
return PERSPECTIVE_ID;
}
public void initialize(IWorkbenchConfigurer configurer) {
super.initialize(configurer);
// make sure we always save and restore workspace state
configurer.setSaveAndRestore(true);
final String ICONS_PATH = "icons/full/";
final String PATH_OBJECT = ICONS_PATH + "obj16/";
Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH);
declareWorkbenchImage(configurer, ideBundle,
IDE.SharedImages.IMG_OBJ_PROJECT, PATH_OBJECT + "prj_obj.gif",
true);
declareWorkbenchImage(configurer, ideBundle,
IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT
+ "cprj_obj.gif", true);
// initialize the workspace undo monitor
workspaceUndoMonitor = WorkspaceUndoMonitor.getInstance();
}
private void declareWorkbenchImage(IWorkbenchConfigurer configurer_p,
Bundle ideBundle, String symbolicName, String path, boolean shared) {
URL url = ideBundle.getEntry(path);
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
configurer_p.declareImage(symbolicName, desc, shared);
}
@Override
public IAdaptable getDefaultPageInput() {
return ResourcesPlugin.getWorkspace().getRoot();
}
@Override
public void postShutdown() {
if (workspaceUndoMonitor != null) {
workspaceUndoMonitor.shutdown();
workspaceUndoMonitor = null;
}
}
}