From: Alexandre Montplaisir Date: Thu, 25 Sep 2014 20:33:30 +0000 (-0400) Subject: rcp: Rename plugins to org.eclipse.tracecompass X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;ds=sidebyside;h=9d26aebf874e0f2523551b7f947d14c10462f611;p=deliverable%2Ftracecompass.git rcp: Rename plugins to org.eclipse.tracecompass Change-Id: I29f43aa20166dd5a6af4cd5660eb0b430fd3a9c3 Signed-off-by: Alexandre Montplaisir --- diff --git a/org.eclipse.tracecompass.rcp.ui/META-INF/MANIFEST.MF b/org.eclipse.tracecompass.rcp.ui/META-INF/MANIFEST.MF index 8b01efc4c3..117208cc24 100644 --- a/org.eclipse.tracecompass.rcp.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.tracecompass.rcp.ui/META-INF/MANIFEST.MF @@ -5,7 +5,7 @@ Bundle-Vendor: %Bundle-Vendor Bundle-Version: 1.1.0.qualifier Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.tracecompass.rcp.ui;singleton:=true -Bundle-Activator: org.eclipse.linuxtools.internal.tracing.rcp.ui.TracingRcpPlugin +Bundle-Activator: org.eclipse.tracecompass.internal.tracing.rcp.ui.TracingRcpPlugin Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Require-Bundle: org.eclipse.core.commands, @@ -18,6 +18,6 @@ Require-Bundle: org.eclipse.core.commands, org.eclipse.tracecompass.tmf.core;bundle-version="2.0.0", org.eclipse.update.configurator;bundle-version="3.3.200", org.eclipse.equinox.p2.ui.sdk -Export-Package: org.eclipse.linuxtools.internal.tracing.rcp.ui;x-internal:=true, - org.eclipse.linuxtools.internal.tracing.rcp.ui.cli;x-internal:=true, - org.eclipse.linuxtools.internal.tracing.rcp.ui.messages;x-internal:=true +Export-Package: org.eclipse.tracecompass.internal.tracing.rcp.ui;x-internal:=true, + org.eclipse.tracecompass.internal.tracing.rcp.ui.cli;x-internal:=true, + org.eclipse.tracecompass.internal.tracing.rcp.ui.messages;x-internal:=true diff --git a/org.eclipse.tracecompass.rcp.ui/plugin.xml b/org.eclipse.tracecompass.rcp.ui/plugin.xml index 68a762bc3a..83c305a0fd 100644 --- a/org.eclipse.tracecompass.rcp.ui/plugin.xml +++ b/org.eclipse.tracecompass.rcp.ui/plugin.xml @@ -6,7 +6,7 @@ point="org.eclipse.core.runtime.applications"> org.eclipse.linuxtools.tracing.rcp.product + class="org.eclipse.tracecompass.internal.tracing.rcp.ui.Application"> diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/Application.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/Application.java deleted file mode 100644 index 7145cdb5b8..0000000000 --- a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/Application.java +++ /dev/null @@ -1,103 +0,0 @@ -/********************************************************************** - * Copyright (c) 2013 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Bernd Hufmann - Initial API and implementation - **********************************************************************/ -package org.eclipse.linuxtools.internal.tracing.rcp.ui; - -import java.io.File; -import java.net.URL; -import java.text.MessageFormat; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.equinox.app.IApplication; -import org.eclipse.equinox.app.IApplicationContext; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.linuxtools.internal.tracing.rcp.ui.messages.Messages; -import org.eclipse.osgi.service.datalocation.Location; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.PlatformUI; - -/** - * This class controls all aspects of the application's execution - * @author Bernd Hufmann - */ -public class Application implements IApplication { - - private Location fInstanceLoc = null; - - @Override - public Object start(IApplicationContext context) throws Exception { - Display display = PlatformUI.createDisplay(); - try { - // fetch the Location that we will be modifying - fInstanceLoc = Platform.getInstanceLocation(); - - // -data @noDefault in .ini allows us to set the workspace here. - // If the user wants to change the location then he has to change - // @noDefault to a specific location or remove -data @noDefault for - // default location - if (!fInstanceLoc.allowsDefault() && !fInstanceLoc.isSet()) { - File workspaceRoot = new File(TracingRcpPlugin.getWorkspaceRoot()); - - if (!workspaceRoot.exists()) { - MessageDialog.openError(display.getActiveShell(), - Messages.Application_WorkspaceCreationError, - MessageFormat.format(Messages.Application_WorkspaceRootNotExistError, new Object[] { TracingRcpPlugin.getWorkspaceRoot() })); - return IApplication.EXIT_OK; - } - - if (!workspaceRoot.canWrite()) { - MessageDialog.openError(display.getActiveShell(), - Messages.Application_WorkspaceCreationError, - MessageFormat.format(Messages.Application_WorkspaceRootPermissionError, new Object[] { TracingRcpPlugin.getWorkspaceRoot() })); - return IApplication.EXIT_OK; - } - - String workspace = TracingRcpPlugin.getWorkspaceRoot() + File.separator + TracingRcpPlugin.WORKSPACE_NAME; - // set location to workspace - fInstanceLoc.set(new URL("file", null, workspace), false); //$NON-NLS-1$ - } - - if (!fInstanceLoc.lock()) { - MessageDialog.openError(display.getActiveShell(), - Messages.Application_WorkspaceCreationError, - MessageFormat.format(Messages.Application_WorkspaceInUseError, new Object[] { fInstanceLoc.getURL().getPath() })); - return IApplication.EXIT_OK; - } - - int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); - if (returnCode == PlatformUI.RETURN_RESTART) { - return IApplication.EXIT_RESTART; - } - return IApplication.EXIT_OK; - } finally { - display.dispose(); - } - } - - @Override - public void stop() { - if (!PlatformUI.isWorkbenchRunning()) { - return; - } - final IWorkbench workbench = PlatformUI.getWorkbench(); - final Display display = workbench.getDisplay(); - fInstanceLoc.release(); - display.syncExec(new Runnable() { - @Override - public void run() { - if (!display.isDisposed()) { - workbench.close(); - } - } - }); - } -} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/ApplicationActionBarAdvisor.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/ApplicationActionBarAdvisor.java deleted file mode 100644 index 1e3806a9ec..0000000000 --- a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/ApplicationActionBarAdvisor.java +++ /dev/null @@ -1,38 +0,0 @@ -/********************************************************************** - * Copyright (c) 2013 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Bernd Hufmann - Initial API and implementation - **********************************************************************/ -package org.eclipse.linuxtools.internal.tracing.rcp.ui; - -import org.eclipse.ui.application.ActionBarAdvisor; -import org.eclipse.ui.application.IActionBarConfigurer; - -/** - * ActionBarAdvisor implementation of the LTTng RCP. - * - * @author Bernd Hufmann - * - */ -public class ApplicationActionBarAdvisor extends ActionBarAdvisor { - - // ------------------------------------------------------------------------ - // Constructor(s) - // ------------------------------------------------------------------------ - /** - * Default constructor - * - * @param configurer - * - An action bar configure instance - */ - public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { - super(configurer); - } - -} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/ApplicationWorkbenchAdvisor.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/ApplicationWorkbenchAdvisor.java deleted file mode 100644 index 5673f8c102..0000000000 --- a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/ApplicationWorkbenchAdvisor.java +++ /dev/null @@ -1,239 +0,0 @@ -/********************************************************************** - * Copyright (c) 2013 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Bernd Hufmann - Initial API and implementation - **********************************************************************/ -package org.eclipse.linuxtools.internal.tracing.rcp.ui; - -import java.lang.reflect.InvocationTargetException; -import java.net.URL; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.linuxtools.internal.tracing.rcp.ui.messages.Messages; -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.IDEInternalWorkbenchImages; -import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; -import org.osgi.framework.Bundle; - - -/** - * WorkbenchAdvisor implementation of the LTTng RCP. - * - * @author Bernd Hufmann - */ -@SuppressWarnings("restriction") -public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { - - // ------------------------------------------------------------------------ - // Constants - // ------------------------------------------------------------------------ - // The default perspective - private static final String PERSPECTIVE_ID = "org.eclipse.linuxtools.tmf.ui.perspective"; //$NON-NLS-1$ - - private final static String ICONS_PATH = "$nl$/icons/full/"; //$NON-NLS-1$ - private final static String PATH_ELOCALTOOL = ICONS_PATH + "elcl16/"; //$NON-NLS-1$ - private final static String PATH_DLOCALTOOL = ICONS_PATH + "dlcl16/"; //$NON-NLS-1$ - private final static String PATH_ETOOL = ICONS_PATH + "etool16/"; //$NON-NLS-1$ - private final static String PATH_DTOOL = ICONS_PATH + "dtool16/"; //$NON-NLS-1$ - private final static String PATH_OBJECT = ICONS_PATH + "obj16/"; //$NON-NLS-1$ - private final static String PATH_WIZBAN = ICONS_PATH + "wizban/";//$NON-NLS-1$ - - // ------------------------------------------------------------------------ - // Operations - // ------------------------------------------------------------------------ - @Override - public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { - return new ApplicationWorkbenchWindowAdvisor(configurer); - } - - @Override - public void initialize(IWorkbenchConfigurer configurer) { - configurer.setSaveAndRestore(true); - declareWorkbenchImages(); - } - - @Override - public String getInitialWindowPerspectiveId() { - return PERSPECTIVE_ID; - } - - @Override - public IAdaptable getDefaultPageInput() { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - return workspace.getRoot(); - } - - @Override - public void preStartup() { - IDE.registerAdapters(); - } - - @Override - public void postShutdown() { - // Save workspace - final MultiStatus status = new MultiStatus(TracingRcpPlugin.PLUGIN_ID, 1, Messages.Application_WorkspaceSavingError, null); - try { - IRunnableWithProgress runnable = new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) { - try { - IWorkspace ws = ResourcesPlugin.getWorkspace(); - status.merge(ws.save(true, monitor)); - } catch (CoreException e) { - status.merge(e.getStatus()); - } - } - }; - new ProgressMonitorDialog(null).run(true, true, runnable); - } catch (InvocationTargetException e) { - status.merge(new Status(IStatus.ERROR, TracingRcpPlugin.PLUGIN_ID, Messages.Application_InternalError, e.getTargetException())); - } catch (InterruptedException e) { - status.merge(Status.CANCEL_STATUS); - } - if (!status.isOK()) { - ErrorDialog.openError(null, Messages.Application_WorkspaceSavingError, null, status, IStatus.ERROR | IStatus.WARNING); - TracingRcpPlugin.getDefault().getLog().log(status); - } - } - - // ------------------------------------------------------------------------ - // Helper methods - // ------------------------------------------------------------------------ - private void declareWorkbenchImages() { - - Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH); - - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC, - PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_HOVER, - PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_DISABLED, - PATH_DTOOL + "build_exec.gif", false); //$NON-NLS-1$ - - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC, - PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_HOVER, - PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_DISABLED, - PATH_DTOOL + "search_src.gif", false); //$NON-NLS-1$ - - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_NEXT_NAV, PATH_ETOOL - + "next_nav.gif", false); //$NON-NLS-1$ - - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_PREVIOUS_NAV, - PATH_ETOOL + "prev_nav.gif", false); //$NON-NLS-1$ - - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWPRJ_WIZ, - PATH_WIZBAN + "newprj_wiz.png", false); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFOLDER_WIZ, - PATH_WIZBAN + "newfolder_wiz.png", false); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFILE_WIZ, - PATH_WIZBAN + "newfile_wiz.png", false); //$NON-NLS-1$ - - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTDIR_WIZ, - PATH_WIZBAN + "importdir_wiz.png", false); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTZIP_WIZ, - PATH_WIZBAN + "importzip_wiz.png", false); //$NON-NLS-1$ - - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTDIR_WIZ, - PATH_WIZBAN + "exportdir_wiz.png", false); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTZIP_WIZ, - PATH_WIZBAN + "exportzip_wiz.png", false); //$NON-NLS-1$ - - declareWorkbenchImage(ideBundle, - IDEInternalWorkbenchImages.IMG_WIZBAN_RESOURCEWORKINGSET_WIZ, PATH_WIZBAN - + "workset_wiz.png", false); //$NON-NLS-1$ - - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLGBAN_SAVEAS_DLG, - PATH_WIZBAN + "saveas_wiz.png", false); //$NON-NLS-1$ - - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG, - PATH_WIZBAN + "quick_fix.png", false); //$NON-NLS-1$ - - declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT, PATH_OBJECT - + "prj_obj.gif", true); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT - + "cprj_obj.gif", true); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OPEN_MARKER, PATH_ELOCALTOOL - + "gotoobj_tsk.gif", true); //$NON-NLS-1$ - - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ELCL_QUICK_FIX_ENABLED, - PATH_ELOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$ - - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLCL_QUICK_FIX_DISABLED, - PATH_DLOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$ - - declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_TASK_TSK, PATH_OBJECT - + "taskmrk_tsk.gif", true); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_BKMRK_TSK, PATH_OBJECT - + "bkmrk_tsk.gif", true); //$NON-NLS-1$ - - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_COMPLETE_TSK, - PATH_OBJECT + "complete_tsk.gif", true); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_INCOMPLETE_TSK, - PATH_OBJECT + "incomplete_tsk.gif", true); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM, - PATH_OBJECT + "welcome_item.gif", true); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER, - PATH_OBJECT + "welcome_banner.gif", true); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_ERROR_PATH, - PATH_OBJECT + "error_tsk.gif", true); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WARNING_PATH, - PATH_OBJECT + "warn_tsk.gif", true); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_INFO_PATH, PATH_OBJECT - + "info_tsk.gif", true); //$NON-NLS-1$ - - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_LCL_FLAT_LAYOUT, - PATH_ELOCALTOOL + "flatLayout.gif", true); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_LCL_HIERARCHICAL_LAYOUT, - PATH_ELOCALTOOL + "hierarchicalLayout.gif", true); //$NON-NLS-1$ - declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEM_CATEGORY, - PATH_ETOOL + "problem_category.gif", true); //$NON-NLS-1$ - } - - /** - * Declares an IDE-specific workbench image. - * - * Declares all IDE-specific workbench images. This includes both "shared" - * images (named in ( @link IDE.SharedImages} ) and internal images (named in - * {@link org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages}). - * - * @param symbolicName - * the symbolic name of the image - * @param path - * the path of the image file; this path is relative to the base - * of the IDE plug-in - * @param shared - * true if this is a shared image, and - * false if this is not a shared image - */ - private void declareWorkbenchImage(Bundle ideBundle, String symbolicName, String path, boolean shared) { - URL url = FileLocator.find(ideBundle, new Path(path), null); - ImageDescriptor desc = ImageDescriptor.createFromURL(url); - getWorkbenchConfigurer().declareImage(symbolicName, desc, shared); - } -} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/ApplicationWorkbenchWindowAdvisor.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/ApplicationWorkbenchWindowAdvisor.java deleted file mode 100644 index 1bc5b0d0d3..0000000000 --- a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/ApplicationWorkbenchWindowAdvisor.java +++ /dev/null @@ -1,165 +0,0 @@ -/********************************************************************** - * Copyright (c) 2013, 2014 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Bernd Hufmann - Initial API and implementation - **********************************************************************/ -package org.eclipse.linuxtools.internal.tracing.rcp.ui; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.linuxtools.internal.tracing.rcp.ui.cli.CliParser; -import org.eclipse.tracecompass.tmf.core.TmfCommonConstants; -import org.eclipse.tracecompass.tmf.ui.project.model.TmfOpenTraceHelper; -import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry; -import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder; -import org.eclipse.ui.IPerspectiveDescriptor; -import org.eclipse.ui.IPerspectiveListener; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.application.ActionBarAdvisor; -import org.eclipse.ui.application.IActionBarConfigurer; -import org.eclipse.ui.application.IWorkbenchWindowConfigurer; -import org.eclipse.ui.application.WorkbenchWindowAdvisor; - -/** - * The WorkbenchAdvisor implementation of the LTTng RCP. - * - * @author Bernd Hufmann - */ -public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { - - // ------------------------------------------------------------------------ - // Constants - // ------------------------------------------------------------------------ - @SuppressWarnings("nls") - private static final String[] UNWANTED_ACTION_SET = { - "org.eclipse.search.searchActionSet", - "org.eclipse.rse.core.search.searchActionSet", - "org.eclipse.debug.ui.launchActionSet", - "org.eclipse.debug.ui.debugActionSet", - "org.eclipse.debug.ui.breakpointActionSet", - "org.eclipse.team.ui", - "org.eclipse.ui.externaltools.ExternalToolsSet", -// "org.eclipse.update.ui.softwareUpdates", -// "org.eclipse.ui.edit.text.actionSet.navigation", -// "org.eclipse.ui.actionSet.keyBindings", -// "org.eclipse.ui.edit.text.actionSet.navigation", - "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo", -// "org.eclipse.ui.edit.text.actionSet.annotationNavigation", -// "org.eclipse.ui.NavigateActionSet", -// "org.eclipse.jdt.ui.JavaActionSet", -// "org.eclipse.jdt.ui.A_OpenActionSet", -// "org.eclipse.jdt.ui.text.java.actionSet.presentation", -// "org.eclipse.jdt.ui.JavaElementCreationActionSet", -// "org.eclipse.jdt.ui.CodingActionSet", -// "org.eclipse.jdt.ui.SearchActionSet", -// "org.eclipse.jdt.debug.ui.JDTDebugActionSet", - "org.eclipse.ui.edit.text.actionSet.openExternalFile", -// "org.eclipse.debug.ui.profileActionSet" - }; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - /** - * Standard constructor - * - * @param configurer - * - the workbench window configurer - */ - public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { - super(configurer); - } - - // ------------------------------------------------------------------------ - // Operations - // ------------------------------------------------------------------------ - @Override - public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { - return new ApplicationActionBarAdvisor(configurer); - } - - @Override - public void preWindowOpen() { - IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); - configurer.setShowCoolBar(false); - configurer.setShowStatusLine(true); - configurer.setShowProgressIndicator(true); - } - - @Override - public void postWindowCreate() { - super.postWindowOpen(); - TracingRcpPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new PerspectiveListener()); - IProject defaultProject = createDefaultProject(); - hideActionSets(); - openTraceIfNecessary(defaultProject); - } - - - - private static void openTraceIfNecessary(IProject project) { - String traceToOpen = TracingRcpPlugin.getDefault().getCli().getArgument(CliParser.OPEN_FILE_LOCATION); - if (traceToOpen != null) { - try { - TmfTraceFolder destinationFolder = TmfProjectRegistry.getProject(project, true).getTracesFolder(); - TmfOpenTraceHelper.openTraceFromPath(destinationFolder, traceToOpen, TracingRcpPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell()); - } catch (CoreException e) { - TracingRcpPlugin.getDefault().logError(e.getMessage()); - } - - } - } - - // ------------------------------------------------------------------------ - // Helper methods - // ------------------------------------------------------------------------ - - /** - * Hides the unwanted action sets - */ - private static void hideActionSets() { - - IWorkbenchPage page = TracingRcpPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(); - - for (int i = 0; i < UNWANTED_ACTION_SET.length; i++) { - page.hideActionSet(UNWANTED_ACTION_SET[i]); - } - } - - private static IProject createDefaultProject() { - return TmfProjectRegistry.createProject(TmfCommonConstants.DEFAULT_TRACE_PROJECT_NAME, null, new NullProgressMonitor()); - } - - /** - * A perspective listener implementation - * - * @author Bernd Hufmann - */ - public class PerspectiveListener implements IPerspectiveListener { - - /** - * Default Constructor - */ - public PerspectiveListener() { - } - - @Override - public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) { - createDefaultProject(); - hideActionSets(); - } - - @Override - public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) { - } - } - -} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/TracingRcpPlugin.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/TracingRcpPlugin.java deleted file mode 100644 index 1c1f3fea77..0000000000 --- a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/TracingRcpPlugin.java +++ /dev/null @@ -1,167 +0,0 @@ -/********************************************************************** - * Copyright (c) 2013, 2014 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Bernd Hufmann - Initial API and implementation - * Matthew Khouzam - Implementation of File->Open - **********************************************************************/ -package org.eclipse.linuxtools.internal.tracing.rcp.ui; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.linuxtools.internal.tracing.rcp.ui.cli.TracingRCPCliException; -import org.eclipse.linuxtools.internal.tracing.rcp.ui.cli.CliParser; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle. - * - * @author Bernd Hufmann - */ -public class TracingRcpPlugin extends AbstractUIPlugin { - - // ------------------------------------------------------------------------ - // Constants - // ------------------------------------------------------------------------ - /** - * The plug-in ID - */ - public static final String PLUGIN_ID = "org.eclipse.linuxtools.tracing.rcp.ui"; //$NON-NLS-1$ - - /** - * The default workspace name - */ - public static final String WORKSPACE_NAME = ".traceviewer"; //$NON-NLS-1$ - - // ------------------------------------------------------------------------ - // Attributes - // ------------------------------------------------------------------------ - - // The shared instance - private static TracingRcpPlugin fPlugin; - private static CliParser fCli; - - // ------------------------------------------------------------------------ - // Constructor(s) - // ------------------------------------------------------------------------ - /** - * The default constructor - */ - public TracingRcpPlugin() { - } - - // ------------------------------------------------------------------------ - // Accessors - // ------------------------------------------------------------------------ - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static TracingRcpPlugin getDefault() { - return fPlugin; - } - - /** - * Gets the tracing workspace root directory. By default it uses the user's - * home directory. This value can be overwritten by using the global - * TRACING_RCP_ROOT environment variable. - * - * @return the tracing workspace root directory - */ - public static String getWorkspaceRoot() { - /* Look for the environment variable in the global environment variables */ - String workspaceRoot = System.getenv().get("TRACING_RCP_ROOT"); //$NON-NLS-1$ - if (workspaceRoot == null) { - /* Use the user's home directory */ - workspaceRoot = System.getProperty("user.home"); //$NON-NLS-1$ - } - return workspaceRoot; - } - - // ------------------------------------------------------------------------ - // Operation - // ------------------------------------------------------------------------ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - fPlugin = this; - String args[] = Platform.getCommandLineArgs(); - fCli = null; - try { - fCli = new CliParser(args); - } catch (TracingRCPCliException e) { - logError(e.getMessage()); - } - } - - @Override - public void stop(BundleContext context) throws Exception { - fPlugin = null; - super.stop(context); - } - - /** - * Gets the command line parser - * - * @return the command line parser - */ - public CliParser getCli() { - return fCli; - } - - /** - * Returns an image descriptor for the image file at the given plug-in - * relative path - * - * @param path - * the path - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(String path) { - return imageDescriptorFromPlugin(PLUGIN_ID, path); - } - - /** - * Log an error - * - * @param message - * the error message to log - */ - public void logError(String message) { - getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message)); - } - - /** - * Log an error - * - * @param message - * the error message to log - * @param e - * the exception to log - */ - public void logError(String message, Exception e) { - getDefault().getLog().log( - new Status(IStatus.ERROR, PLUGIN_ID, message, e)); - } - - /** - * Log a warning - * - * @param message - * the warning message to log - */ - public void logWarning(String message) { - getDefault().getLog().log( - new Status(IStatus.WARNING, PLUGIN_ID, message)); - } - -} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/cli/CliParser.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/cli/CliParser.java deleted file mode 100644 index f1e6977f0a..0000000000 --- a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/cli/CliParser.java +++ /dev/null @@ -1,75 +0,0 @@ -/********************************************************************** - * Copyright (c) 2013, 2014 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Matthew Khouzam- Initial API and implementation - **********************************************************************/ - -package org.eclipse.linuxtools.internal.tracing.rcp.ui.cli; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.linuxtools.internal.tracing.rcp.ui.messages.Messages; - -/** - * Command line parser - * - * @author Matthew Khouzam - */ -public class CliParser { - - private static final String NOUI_ARG = "--NOUI"; //$NON-NLS-1$ - - private static final String OPEN_ARG = "--open"; //$NON-NLS-1$ - - private final Map params = new HashMap<>(); - - /** Open key */ - public static final String OPEN_FILE_LOCATION = ".,-=open=-,."; //$NON-NLS-1$ - /** No ui key */ - public static final String NO_UI = ".,-=noui=-,."; //$NON-NLS-1$ - - /** - * Constructor - * - * @param args - * the command line arguments - * @throws TracingRCPCliException - * an error occurred parsing the cli - */ - public CliParser(final String[] args) throws TracingRCPCliException { - for (int i = 0; i < args.length; i++) { - if (args[i].equals(OPEN_ARG)) { - put(OPEN_FILE_LOCATION, args, i); - // skip since we have two args - i++; - } - else if (args[i].equals(NOUI_ARG)) { - params.put(NO_UI, new String()); - } - } - } - - private void put(String key, String[] args, int pos) throws TracingRCPCliException { - if (args.length <= pos) { - throw new TracingRCPCliException(Messages.CliParser_MalformedCommand + ':' + ' ' + args[pos]); - } - params.put(key, args[pos + 1]); - } - - /** - * Get a parameter from the parsed command line - * @param key OPEN_FILE_LOCATION or NO_UI - * @return the value of the parameter, can be null - */ - public String getArgument(String key) { - return params.get(key); - } - -} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/cli/TracingRCPCliException.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/cli/TracingRCPCliException.java deleted file mode 100644 index 8c20e1bdc2..0000000000 --- a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/cli/TracingRCPCliException.java +++ /dev/null @@ -1,40 +0,0 @@ -/********************************************************************** - * Copyright (c) 2013 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Matthew Khouzam- Initial API and implementation - **********************************************************************/ - -package org.eclipse.linuxtools.internal.tracing.rcp.ui.cli; - -/** - * Command line exceptions. - * - * @author Matthew Khouzam - */ -public class TracingRCPCliException extends Exception { - - /** - * Serial UID - */ - private static final long serialVersionUID = -844846299720475123L; - - /** - * Constructs a new exception with the specified detail message. The cause - * is not initialized, and may subsequently be initialized by a call to - * {@link #initCause}. - * - * @param message - * the detail message. The detail message is saved for later - * retrieval by the {@link #getMessage()} method. - */ - public TracingRCPCliException(String message) { - super(message); - } - -} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/messages/Messages.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/messages/Messages.java deleted file mode 100644 index 06b5d266ef..0000000000 --- a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/messages/Messages.java +++ /dev/null @@ -1,49 +0,0 @@ -/********************************************************************** - * Copyright (c) 2013 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Bernd Hufmann - Initial API and implementation - **********************************************************************/ -package org.eclipse.linuxtools.internal.tracing.rcp.ui.messages; - -import org.eclipse.osgi.util.NLS; - -/** - * Messages file for the tracing RCP. - * - * @author Bernd Hufmann - */ -public class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.tracing.rcp.ui.messages.messages"; //$NON-NLS-1$ - - /** Error title for error during workspace creation */ - public static String Application_WorkspaceCreationError; - /** Error message if workspace root doesn't exist */ - public static String Application_WorkspaceRootNotExistError; - /** Error message if workspace root is write protected */ - public static String Application_WorkspaceRootPermissionError; - /** Error message if workspace is already in use */ - public static String Application_WorkspaceInUseError; - /** Error message if workspace can't be saved during shutdown */ - public static String Application_WorkspaceSavingError; - /** Error message for internal errors */ - public static String Application_InternalError; - - /** Malformed command */ - public static String CliParser_MalformedCommand; - /** Unkown command */ - public static String CliParser_UnknownCommand; - - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - } -} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/messages/messages.properties b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/messages/messages.properties deleted file mode 100644 index e10d1cd0c4..0000000000 --- a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/linuxtools/internal/tracing/rcp/ui/messages/messages.properties +++ /dev/null @@ -1,19 +0,0 @@ -############################################################################### -# Copyright (c) 2013 Ericsson. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Bernd Hufmann - initial API and implementation -############################################################################### -Application_WorkspaceCreationError=Workspace Creation Error -Application_WorkspaceRootNotExistError=Workspace root {0} doesn't exists.\n\nPlease create the workspace root. -Application_WorkspaceRootPermissionError=No permission to create workspace in workspace root {0}\n\nPlease change permission of the workspace root. -Application_WorkspaceInUseError=Could not launch the application because the associated workspace is currently in use. \n\n{0} -Application_InternalError=Internal Error -Application_WorkspaceSavingError=Problem saving workspace -CliParser_MalformedCommand=malformed command -CliParser_UnknownCommand=unknown command diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/Application.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/Application.java new file mode 100644 index 0000000000..6bcdd32636 --- /dev/null +++ b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/Application.java @@ -0,0 +1,103 @@ +/********************************************************************** + * Copyright (c) 2013 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bernd Hufmann - Initial API and implementation + **********************************************************************/ +package org.eclipse.tracecompass.internal.tracing.rcp.ui; + +import java.io.File; +import java.net.URL; +import java.text.MessageFormat; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.equinox.app.IApplication; +import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.osgi.service.datalocation.Location; +import org.eclipse.swt.widgets.Display; +import org.eclipse.tracecompass.internal.tracing.rcp.ui.messages.Messages; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; + +/** + * This class controls all aspects of the application's execution + * @author Bernd Hufmann + */ +public class Application implements IApplication { + + private Location fInstanceLoc = null; + + @Override + public Object start(IApplicationContext context) throws Exception { + Display display = PlatformUI.createDisplay(); + try { + // fetch the Location that we will be modifying + fInstanceLoc = Platform.getInstanceLocation(); + + // -data @noDefault in .ini allows us to set the workspace here. + // If the user wants to change the location then he has to change + // @noDefault to a specific location or remove -data @noDefault for + // default location + if (!fInstanceLoc.allowsDefault() && !fInstanceLoc.isSet()) { + File workspaceRoot = new File(TracingRcpPlugin.getWorkspaceRoot()); + + if (!workspaceRoot.exists()) { + MessageDialog.openError(display.getActiveShell(), + Messages.Application_WorkspaceCreationError, + MessageFormat.format(Messages.Application_WorkspaceRootNotExistError, new Object[] { TracingRcpPlugin.getWorkspaceRoot() })); + return IApplication.EXIT_OK; + } + + if (!workspaceRoot.canWrite()) { + MessageDialog.openError(display.getActiveShell(), + Messages.Application_WorkspaceCreationError, + MessageFormat.format(Messages.Application_WorkspaceRootPermissionError, new Object[] { TracingRcpPlugin.getWorkspaceRoot() })); + return IApplication.EXIT_OK; + } + + String workspace = TracingRcpPlugin.getWorkspaceRoot() + File.separator + TracingRcpPlugin.WORKSPACE_NAME; + // set location to workspace + fInstanceLoc.set(new URL("file", null, workspace), false); //$NON-NLS-1$ + } + + if (!fInstanceLoc.lock()) { + MessageDialog.openError(display.getActiveShell(), + Messages.Application_WorkspaceCreationError, + MessageFormat.format(Messages.Application_WorkspaceInUseError, new Object[] { fInstanceLoc.getURL().getPath() })); + return IApplication.EXIT_OK; + } + + int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); + if (returnCode == PlatformUI.RETURN_RESTART) { + return IApplication.EXIT_RESTART; + } + return IApplication.EXIT_OK; + } finally { + display.dispose(); + } + } + + @Override + public void stop() { + if (!PlatformUI.isWorkbenchRunning()) { + return; + } + final IWorkbench workbench = PlatformUI.getWorkbench(); + final Display display = workbench.getDisplay(); + fInstanceLoc.release(); + display.syncExec(new Runnable() { + @Override + public void run() { + if (!display.isDisposed()) { + workbench.close(); + } + } + }); + } +} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/ApplicationActionBarAdvisor.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/ApplicationActionBarAdvisor.java new file mode 100644 index 0000000000..b5843a4127 --- /dev/null +++ b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/ApplicationActionBarAdvisor.java @@ -0,0 +1,38 @@ +/********************************************************************** + * Copyright (c) 2013 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bernd Hufmann - Initial API and implementation + **********************************************************************/ +package org.eclipse.tracecompass.internal.tracing.rcp.ui; + +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; + +/** + * ActionBarAdvisor implementation of the LTTng RCP. + * + * @author Bernd Hufmann + * + */ +public class ApplicationActionBarAdvisor extends ActionBarAdvisor { + + // ------------------------------------------------------------------------ + // Constructor(s) + // ------------------------------------------------------------------------ + /** + * Default constructor + * + * @param configurer + * - An action bar configure instance + */ + public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { + super(configurer); + } + +} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/ApplicationWorkbenchAdvisor.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/ApplicationWorkbenchAdvisor.java new file mode 100644 index 0000000000..55bfea8ffb --- /dev/null +++ b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/ApplicationWorkbenchAdvisor.java @@ -0,0 +1,239 @@ +/********************************************************************** + * Copyright (c) 2013 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bernd Hufmann - Initial API and implementation + **********************************************************************/ +package org.eclipse.tracecompass.internal.tracing.rcp.ui; + +import java.lang.reflect.InvocationTargetException; +import java.net.URL; + +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.tracecompass.internal.tracing.rcp.ui.messages.Messages; +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.IDEInternalWorkbenchImages; +import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; +import org.osgi.framework.Bundle; + + +/** + * WorkbenchAdvisor implementation of the LTTng RCP. + * + * @author Bernd Hufmann + */ +@SuppressWarnings("restriction") +public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + // The default perspective + private static final String PERSPECTIVE_ID = "org.eclipse.linuxtools.tmf.ui.perspective"; //$NON-NLS-1$ + + private final static String ICONS_PATH = "$nl$/icons/full/"; //$NON-NLS-1$ + private final static String PATH_ELOCALTOOL = ICONS_PATH + "elcl16/"; //$NON-NLS-1$ + private final static String PATH_DLOCALTOOL = ICONS_PATH + "dlcl16/"; //$NON-NLS-1$ + private final static String PATH_ETOOL = ICONS_PATH + "etool16/"; //$NON-NLS-1$ + private final static String PATH_DTOOL = ICONS_PATH + "dtool16/"; //$NON-NLS-1$ + private final static String PATH_OBJECT = ICONS_PATH + "obj16/"; //$NON-NLS-1$ + private final static String PATH_WIZBAN = ICONS_PATH + "wizban/";//$NON-NLS-1$ + + // ------------------------------------------------------------------------ + // Operations + // ------------------------------------------------------------------------ + @Override + public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + return new ApplicationWorkbenchWindowAdvisor(configurer); + } + + @Override + public void initialize(IWorkbenchConfigurer configurer) { + configurer.setSaveAndRestore(true); + declareWorkbenchImages(); + } + + @Override + public String getInitialWindowPerspectiveId() { + return PERSPECTIVE_ID; + } + + @Override + public IAdaptable getDefaultPageInput() { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + return workspace.getRoot(); + } + + @Override + public void preStartup() { + IDE.registerAdapters(); + } + + @Override + public void postShutdown() { + // Save workspace + final MultiStatus status = new MultiStatus(TracingRcpPlugin.PLUGIN_ID, 1, Messages.Application_WorkspaceSavingError, null); + try { + IRunnableWithProgress runnable = new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) { + try { + IWorkspace ws = ResourcesPlugin.getWorkspace(); + status.merge(ws.save(true, monitor)); + } catch (CoreException e) { + status.merge(e.getStatus()); + } + } + }; + new ProgressMonitorDialog(null).run(true, true, runnable); + } catch (InvocationTargetException e) { + status.merge(new Status(IStatus.ERROR, TracingRcpPlugin.PLUGIN_ID, Messages.Application_InternalError, e.getTargetException())); + } catch (InterruptedException e) { + status.merge(Status.CANCEL_STATUS); + } + if (!status.isOK()) { + ErrorDialog.openError(null, Messages.Application_WorkspaceSavingError, null, status, IStatus.ERROR | IStatus.WARNING); + TracingRcpPlugin.getDefault().getLog().log(status); + } + } + + // ------------------------------------------------------------------------ + // Helper methods + // ------------------------------------------------------------------------ + private void declareWorkbenchImages() { + + Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH); + + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC, + PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_HOVER, + PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_DISABLED, + PATH_DTOOL + "build_exec.gif", false); //$NON-NLS-1$ + + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC, + PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_HOVER, + PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_DISABLED, + PATH_DTOOL + "search_src.gif", false); //$NON-NLS-1$ + + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_NEXT_NAV, PATH_ETOOL + + "next_nav.gif", false); //$NON-NLS-1$ + + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_PREVIOUS_NAV, + PATH_ETOOL + "prev_nav.gif", false); //$NON-NLS-1$ + + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWPRJ_WIZ, + PATH_WIZBAN + "newprj_wiz.png", false); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFOLDER_WIZ, + PATH_WIZBAN + "newfolder_wiz.png", false); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFILE_WIZ, + PATH_WIZBAN + "newfile_wiz.png", false); //$NON-NLS-1$ + + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTDIR_WIZ, + PATH_WIZBAN + "importdir_wiz.png", false); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTZIP_WIZ, + PATH_WIZBAN + "importzip_wiz.png", false); //$NON-NLS-1$ + + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTDIR_WIZ, + PATH_WIZBAN + "exportdir_wiz.png", false); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTZIP_WIZ, + PATH_WIZBAN + "exportzip_wiz.png", false); //$NON-NLS-1$ + + declareWorkbenchImage(ideBundle, + IDEInternalWorkbenchImages.IMG_WIZBAN_RESOURCEWORKINGSET_WIZ, PATH_WIZBAN + + "workset_wiz.png", false); //$NON-NLS-1$ + + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLGBAN_SAVEAS_DLG, + PATH_WIZBAN + "saveas_wiz.png", false); //$NON-NLS-1$ + + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG, + PATH_WIZBAN + "quick_fix.png", false); //$NON-NLS-1$ + + declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT, PATH_OBJECT + + "prj_obj.gif", true); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT + + "cprj_obj.gif", true); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OPEN_MARKER, PATH_ELOCALTOOL + + "gotoobj_tsk.gif", true); //$NON-NLS-1$ + + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ELCL_QUICK_FIX_ENABLED, + PATH_ELOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$ + + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLCL_QUICK_FIX_DISABLED, + PATH_DLOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$ + + declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_TASK_TSK, PATH_OBJECT + + "taskmrk_tsk.gif", true); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_BKMRK_TSK, PATH_OBJECT + + "bkmrk_tsk.gif", true); //$NON-NLS-1$ + + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_COMPLETE_TSK, + PATH_OBJECT + "complete_tsk.gif", true); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_INCOMPLETE_TSK, + PATH_OBJECT + "incomplete_tsk.gif", true); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM, + PATH_OBJECT + "welcome_item.gif", true); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER, + PATH_OBJECT + "welcome_banner.gif", true); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_ERROR_PATH, + PATH_OBJECT + "error_tsk.gif", true); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WARNING_PATH, + PATH_OBJECT + "warn_tsk.gif", true); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_INFO_PATH, PATH_OBJECT + + "info_tsk.gif", true); //$NON-NLS-1$ + + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_LCL_FLAT_LAYOUT, + PATH_ELOCALTOOL + "flatLayout.gif", true); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_LCL_HIERARCHICAL_LAYOUT, + PATH_ELOCALTOOL + "hierarchicalLayout.gif", true); //$NON-NLS-1$ + declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEM_CATEGORY, + PATH_ETOOL + "problem_category.gif", true); //$NON-NLS-1$ + } + + /** + * Declares an IDE-specific workbench image. + * + * Declares all IDE-specific workbench images. This includes both "shared" + * images (named in ( @link IDE.SharedImages} ) and internal images (named in + * {@link org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages}). + * + * @param symbolicName + * the symbolic name of the image + * @param path + * the path of the image file; this path is relative to the base + * of the IDE plug-in + * @param shared + * true if this is a shared image, and + * false if this is not a shared image + */ + private void declareWorkbenchImage(Bundle ideBundle, String symbolicName, String path, boolean shared) { + URL url = FileLocator.find(ideBundle, new Path(path), null); + ImageDescriptor desc = ImageDescriptor.createFromURL(url); + getWorkbenchConfigurer().declareImage(symbolicName, desc, shared); + } +} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/ApplicationWorkbenchWindowAdvisor.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/ApplicationWorkbenchWindowAdvisor.java new file mode 100644 index 0000000000..c0d0f6749e --- /dev/null +++ b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/ApplicationWorkbenchWindowAdvisor.java @@ -0,0 +1,165 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bernd Hufmann - Initial API and implementation + **********************************************************************/ +package org.eclipse.tracecompass.internal.tracing.rcp.ui; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.tracecompass.internal.tracing.rcp.ui.cli.CliParser; +import org.eclipse.tracecompass.tmf.core.TmfCommonConstants; +import org.eclipse.tracecompass.tmf.ui.project.model.TmfOpenTraceHelper; +import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry; +import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder; +import org.eclipse.ui.IPerspectiveDescriptor; +import org.eclipse.ui.IPerspectiveListener; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; + +/** + * The WorkbenchAdvisor implementation of the LTTng RCP. + * + * @author Bernd Hufmann + */ +public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + @SuppressWarnings("nls") + private static final String[] UNWANTED_ACTION_SET = { + "org.eclipse.search.searchActionSet", + "org.eclipse.rse.core.search.searchActionSet", + "org.eclipse.debug.ui.launchActionSet", + "org.eclipse.debug.ui.debugActionSet", + "org.eclipse.debug.ui.breakpointActionSet", + "org.eclipse.team.ui", + "org.eclipse.ui.externaltools.ExternalToolsSet", +// "org.eclipse.update.ui.softwareUpdates", +// "org.eclipse.ui.edit.text.actionSet.navigation", +// "org.eclipse.ui.actionSet.keyBindings", +// "org.eclipse.ui.edit.text.actionSet.navigation", + "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo", +// "org.eclipse.ui.edit.text.actionSet.annotationNavigation", +// "org.eclipse.ui.NavigateActionSet", +// "org.eclipse.jdt.ui.JavaActionSet", +// "org.eclipse.jdt.ui.A_OpenActionSet", +// "org.eclipse.jdt.ui.text.java.actionSet.presentation", +// "org.eclipse.jdt.ui.JavaElementCreationActionSet", +// "org.eclipse.jdt.ui.CodingActionSet", +// "org.eclipse.jdt.ui.SearchActionSet", +// "org.eclipse.jdt.debug.ui.JDTDebugActionSet", + "org.eclipse.ui.edit.text.actionSet.openExternalFile", +// "org.eclipse.debug.ui.profileActionSet" + }; + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + /** + * Standard constructor + * + * @param configurer + * - the workbench window configurer + */ + public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + super(configurer); + } + + // ------------------------------------------------------------------------ + // Operations + // ------------------------------------------------------------------------ + @Override + public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { + return new ApplicationActionBarAdvisor(configurer); + } + + @Override + public void preWindowOpen() { + IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); + configurer.setShowCoolBar(false); + configurer.setShowStatusLine(true); + configurer.setShowProgressIndicator(true); + } + + @Override + public void postWindowCreate() { + super.postWindowOpen(); + TracingRcpPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new PerspectiveListener()); + IProject defaultProject = createDefaultProject(); + hideActionSets(); + openTraceIfNecessary(defaultProject); + } + + + + private static void openTraceIfNecessary(IProject project) { + String traceToOpen = TracingRcpPlugin.getDefault().getCli().getArgument(CliParser.OPEN_FILE_LOCATION); + if (traceToOpen != null) { + try { + TmfTraceFolder destinationFolder = TmfProjectRegistry.getProject(project, true).getTracesFolder(); + TmfOpenTraceHelper.openTraceFromPath(destinationFolder, traceToOpen, TracingRcpPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell()); + } catch (CoreException e) { + TracingRcpPlugin.getDefault().logError(e.getMessage()); + } + + } + } + + // ------------------------------------------------------------------------ + // Helper methods + // ------------------------------------------------------------------------ + + /** + * Hides the unwanted action sets + */ + private static void hideActionSets() { + + IWorkbenchPage page = TracingRcpPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(); + + for (int i = 0; i < UNWANTED_ACTION_SET.length; i++) { + page.hideActionSet(UNWANTED_ACTION_SET[i]); + } + } + + private static IProject createDefaultProject() { + return TmfProjectRegistry.createProject(TmfCommonConstants.DEFAULT_TRACE_PROJECT_NAME, null, new NullProgressMonitor()); + } + + /** + * A perspective listener implementation + * + * @author Bernd Hufmann + */ + public class PerspectiveListener implements IPerspectiveListener { + + /** + * Default Constructor + */ + public PerspectiveListener() { + } + + @Override + public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) { + createDefaultProject(); + hideActionSets(); + } + + @Override + public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) { + } + } + +} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/TracingRcpPlugin.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/TracingRcpPlugin.java new file mode 100644 index 0000000000..8886756e60 --- /dev/null +++ b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/TracingRcpPlugin.java @@ -0,0 +1,167 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bernd Hufmann - Initial API and implementation + * Matthew Khouzam - Implementation of File->Open + **********************************************************************/ +package org.eclipse.tracecompass.internal.tracing.rcp.ui; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.tracecompass.internal.tracing.rcp.ui.cli.CliParser; +import org.eclipse.tracecompass.internal.tracing.rcp.ui.cli.TracingRCPCliException; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle. + * + * @author Bernd Hufmann + */ +public class TracingRcpPlugin extends AbstractUIPlugin { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + /** + * The plug-in ID + */ + public static final String PLUGIN_ID = "org.eclipse.linuxtools.tracing.rcp.ui"; //$NON-NLS-1$ + + /** + * The default workspace name + */ + public static final String WORKSPACE_NAME = ".traceviewer"; //$NON-NLS-1$ + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + // The shared instance + private static TracingRcpPlugin fPlugin; + private static CliParser fCli; + + // ------------------------------------------------------------------------ + // Constructor(s) + // ------------------------------------------------------------------------ + /** + * The default constructor + */ + public TracingRcpPlugin() { + } + + // ------------------------------------------------------------------------ + // Accessors + // ------------------------------------------------------------------------ + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static TracingRcpPlugin getDefault() { + return fPlugin; + } + + /** + * Gets the tracing workspace root directory. By default it uses the user's + * home directory. This value can be overwritten by using the global + * TRACING_RCP_ROOT environment variable. + * + * @return the tracing workspace root directory + */ + public static String getWorkspaceRoot() { + /* Look for the environment variable in the global environment variables */ + String workspaceRoot = System.getenv().get("TRACING_RCP_ROOT"); //$NON-NLS-1$ + if (workspaceRoot == null) { + /* Use the user's home directory */ + workspaceRoot = System.getProperty("user.home"); //$NON-NLS-1$ + } + return workspaceRoot; + } + + // ------------------------------------------------------------------------ + // Operation + // ------------------------------------------------------------------------ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + fPlugin = this; + String args[] = Platform.getCommandLineArgs(); + fCli = null; + try { + fCli = new CliParser(args); + } catch (TracingRCPCliException e) { + logError(e.getMessage()); + } + } + + @Override + public void stop(BundleContext context) throws Exception { + fPlugin = null; + super.stop(context); + } + + /** + * Gets the command line parser + * + * @return the command line parser + */ + public CliParser getCli() { + return fCli; + } + + /** + * Returns an image descriptor for the image file at the given plug-in + * relative path + * + * @param path + * the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } + + /** + * Log an error + * + * @param message + * the error message to log + */ + public void logError(String message) { + getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message)); + } + + /** + * Log an error + * + * @param message + * the error message to log + * @param e + * the exception to log + */ + public void logError(String message, Exception e) { + getDefault().getLog().log( + new Status(IStatus.ERROR, PLUGIN_ID, message, e)); + } + + /** + * Log a warning + * + * @param message + * the warning message to log + */ + public void logWarning(String message) { + getDefault().getLog().log( + new Status(IStatus.WARNING, PLUGIN_ID, message)); + } + +} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/cli/CliParser.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/cli/CliParser.java new file mode 100644 index 0000000000..2b20ba8f06 --- /dev/null +++ b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/cli/CliParser.java @@ -0,0 +1,75 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthew Khouzam- Initial API and implementation + **********************************************************************/ + +package org.eclipse.tracecompass.internal.tracing.rcp.ui.cli; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.tracecompass.internal.tracing.rcp.ui.messages.Messages; + +/** + * Command line parser + * + * @author Matthew Khouzam + */ +public class CliParser { + + private static final String NOUI_ARG = "--NOUI"; //$NON-NLS-1$ + + private static final String OPEN_ARG = "--open"; //$NON-NLS-1$ + + private final Map params = new HashMap<>(); + + /** Open key */ + public static final String OPEN_FILE_LOCATION = ".,-=open=-,."; //$NON-NLS-1$ + /** No ui key */ + public static final String NO_UI = ".,-=noui=-,."; //$NON-NLS-1$ + + /** + * Constructor + * + * @param args + * the command line arguments + * @throws TracingRCPCliException + * an error occurred parsing the cli + */ + public CliParser(final String[] args) throws TracingRCPCliException { + for (int i = 0; i < args.length; i++) { + if (args[i].equals(OPEN_ARG)) { + put(OPEN_FILE_LOCATION, args, i); + // skip since we have two args + i++; + } + else if (args[i].equals(NOUI_ARG)) { + params.put(NO_UI, new String()); + } + } + } + + private void put(String key, String[] args, int pos) throws TracingRCPCliException { + if (args.length <= pos) { + throw new TracingRCPCliException(Messages.CliParser_MalformedCommand + ':' + ' ' + args[pos]); + } + params.put(key, args[pos + 1]); + } + + /** + * Get a parameter from the parsed command line + * @param key OPEN_FILE_LOCATION or NO_UI + * @return the value of the parameter, can be null + */ + public String getArgument(String key) { + return params.get(key); + } + +} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/cli/TracingRCPCliException.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/cli/TracingRCPCliException.java new file mode 100644 index 0000000000..26741a8506 --- /dev/null +++ b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/cli/TracingRCPCliException.java @@ -0,0 +1,40 @@ +/********************************************************************** + * Copyright (c) 2013 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthew Khouzam- Initial API and implementation + **********************************************************************/ + +package org.eclipse.tracecompass.internal.tracing.rcp.ui.cli; + +/** + * Command line exceptions. + * + * @author Matthew Khouzam + */ +public class TracingRCPCliException extends Exception { + + /** + * Serial UID + */ + private static final long serialVersionUID = -844846299720475123L; + + /** + * Constructs a new exception with the specified detail message. The cause + * is not initialized, and may subsequently be initialized by a call to + * {@link #initCause}. + * + * @param message + * the detail message. The detail message is saved for later + * retrieval by the {@link #getMessage()} method. + */ + public TracingRCPCliException(String message) { + super(message); + } + +} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/messages/Messages.java b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/messages/Messages.java new file mode 100644 index 0000000000..894ad3fcfe --- /dev/null +++ b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/messages/Messages.java @@ -0,0 +1,49 @@ +/********************************************************************** + * Copyright (c) 2013 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bernd Hufmann - Initial API and implementation + **********************************************************************/ +package org.eclipse.tracecompass.internal.tracing.rcp.ui.messages; + +import org.eclipse.osgi.util.NLS; + +/** + * Messages file for the tracing RCP. + * + * @author Bernd Hufmann + */ +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.tracing.rcp.ui.messages.messages"; //$NON-NLS-1$ + + /** Error title for error during workspace creation */ + public static String Application_WorkspaceCreationError; + /** Error message if workspace root doesn't exist */ + public static String Application_WorkspaceRootNotExistError; + /** Error message if workspace root is write protected */ + public static String Application_WorkspaceRootPermissionError; + /** Error message if workspace is already in use */ + public static String Application_WorkspaceInUseError; + /** Error message if workspace can't be saved during shutdown */ + public static String Application_WorkspaceSavingError; + /** Error message for internal errors */ + public static String Application_InternalError; + + /** Malformed command */ + public static String CliParser_MalformedCommand; + /** Unkown command */ + public static String CliParser_UnknownCommand; + + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/messages/messages.properties b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/messages/messages.properties new file mode 100644 index 0000000000..e10d1cd0c4 --- /dev/null +++ b/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/messages/messages.properties @@ -0,0 +1,19 @@ +############################################################################### +# Copyright (c) 2013 Ericsson. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Bernd Hufmann - initial API and implementation +############################################################################### +Application_WorkspaceCreationError=Workspace Creation Error +Application_WorkspaceRootNotExistError=Workspace root {0} doesn't exists.\n\nPlease create the workspace root. +Application_WorkspaceRootPermissionError=No permission to create workspace in workspace root {0}\n\nPlease change permission of the workspace root. +Application_WorkspaceInUseError=Could not launch the application because the associated workspace is currently in use. \n\n{0} +Application_InternalError=Internal Error +Application_WorkspaceSavingError=Problem saving workspace +CliParser_MalformedCommand=malformed command +CliParser_UnknownCommand=unknown command diff --git a/pom.xml b/pom.xml index 7bcb4f8be3..d0ea5a1d7a 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ tracingRcp - org.eclipse.linuxtools.tracing.rcp.product + org.eclipse.tracecompass.rcp.product