org.eclipse.linuxtools.lttng.ui.views.latency.dialogs;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
org.eclipse.linuxtools.lttng.ui.views.latency.listeners;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
org.eclipse.linuxtools.lttng.ui.views.latency.model;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
- org.eclipse.linuxtools.lttng.ui.views.project;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
- org.eclipse.linuxtools.lttng.ui.views.project.dialogs;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
- org.eclipse.linuxtools.lttng.ui.views.project.handlers;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
- org.eclipse.linuxtools.lttng.ui.views.project.model;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
org.eclipse.linuxtools.lttng.ui.views.resources;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
org.eclipse.linuxtools.lttng.ui.views.resources.evProcessor;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
org.eclipse.linuxtools.lttng.ui.views.resources.model;x-friends:="org.eclipse.linuxtools.lttng.ui.tests",
perspective.category.name = LTTng
views.category.name = LTTng
-project.view.name = Projects
control.view.name = Control
events.view.name = Events
timeframe.view.name = Time Frame
tracetype.type.kernel = Kernel Trace
#Commands and Menus
-commands.project.category.name = LTTng Project Commands
-commands.project.category.description = LTTng Project Commands
-commands.project.new = New Project
-commands.project.new.description = Create a new LTTng Project
-commands.project.open = Open Project
-commands.project.open.description = Open an LTTng Project
-commands.project.close = Close Project
-commands.project.close.description = Close an LTTng Project
-commands.project.rename = Rename Project
-commands.project.rename.description = Rename an LTTng Project
-commands.project.delete = Delete Project
-commands.project.delete.description = Delete an LTTng Project
-commands.project.refresh = Refresh View
-commands.project.refresh.description = Refresh the Project list
-commands.project.property = P&roperties
-commands.project.property.description = Manage project properties
commands.trace.category.name = LTTng Trace Commands
commands.trace.category.description = LTTng Trace Commands
commands.trace.import = Import Trace
id="org.eclipse.linuxtools.lttng.ui.views.category"
name="%views.category.name">
</category>
- <view
- allowMultiple="false"
- category="org.eclipse.linuxtools.lttng.ui.views.category"
- class="org.eclipse.linuxtools.lttng.ui.views.project.ProjectView"
- icon="icons/eview16/project_view.gif"
- id="org.eclipse.linuxtools.lttng.ui.views.project"
- name="%project.view.name"
- restorable="true">
- </view>
<view
allowMultiple="false"
category="org.eclipse.linuxtools.lttng.ui.views.category"
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Ericsson, Montavista Software
- *
- * 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:
- * Francois Chouinard - Initial API and implementation
- * Yufen Kuo (ykuo@mvista.com) - add support to allow user specify trace library path
- * Yufen Kuo (ykuo@mvista.com) - bug 340341: handle gracefully when native library failed to initialize
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project;
-
-import java.io.FileNotFoundException;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.linuxtools.lttng.core.TraceHelper;
-import org.eclipse.linuxtools.lttng.core.event.LttngEvent;
-import org.eclipse.linuxtools.lttng.core.trace.LTTngExperiment;
-import org.eclipse.linuxtools.lttng.core.trace.LTTngTrace;
-import org.eclipse.linuxtools.lttng.ui.views.project.dialogs.Messages;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.ILTTngProjectTreeNode;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentNode;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectContentProvider;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectLabelProvider;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectRoot;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceNode;
-import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
-import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.ui.views.TmfView;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Tree;
-
-/**
- * <b><u>ProjectView</u></b>
- * <p>
- * The ProjectView keeps track of the LTTng projects in the workspace.
- */
-public class ProjectView extends TmfView {
-
- public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.project"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Main data structures
- // ------------------------------------------------------------------------
-
- private TreeViewer fViewer;
- private LTTngProjectRoot fProjectRoot;
- private LTTngExperiment<LttngEvent> fSelectedExperiment = null;
-
- private IWorkspace fWorkspace;
- private IResourceChangeListener fResourceChangeListener;
-
- // ------------------------------------------------------------------------
- // View refresher
- // ------------------------------------------------------------------------
-
- // Perform updates on the UI thread
- private Runnable fViewRefresher = new Runnable() {
- @Override
- public void run() {
- if ((fViewer != null) && (!fViewer.getTree().isDisposed())) {
- Object[] elements = fViewer.getExpandedElements();
- fViewer.refresh();
- fViewer.setExpandedElements(elements);
- }
- }
- };
-
- public LTTngProjectRoot getRoot() {
- return fProjectRoot;
- }
-
- // ------------------------------------------------------------------------
- // Constructor
- // ------------------------------------------------------------------------
-
- public ProjectView() {
-
- super("ProjectView"); //$NON-NLS-1$
- fProjectRoot = new LTTngProjectRoot(this);
-
- fWorkspace = ResourcesPlugin.getWorkspace();
- fResourceChangeListener = new IResourceChangeListener() {
- @Override
- public void resourceChanged(IResourceChangeEvent event) {
- if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
- fProjectRoot.refreshChildren();
- refresh();
- }
- }
- };
- fWorkspace.addResourceChangeListener(fResourceChangeListener);
- }
-
- public void refresh() {
- Tree tree = fViewer.getTree();
- if (tree != null && !tree.isDisposed())
- tree.getDisplay().asyncExec(fViewRefresher);
- }
-
- public void setSelection(ILTTngProjectTreeNode node) {
- fViewer.setSelection(new StructuredSelection(node), true);
- }
-
- @Override
- public void dispose() {
- fWorkspace.removeResourceChangeListener(fResourceChangeListener);
- }
-
- @Override
- public void createPartControl(Composite parent) {
-
- fViewer = new TreeViewer(parent, SWT.SINGLE);
- fViewer.setContentProvider(new LTTngProjectContentProvider());
- fViewer.setSorter(new ViewerSorter());
- fViewer.setLabelProvider(new LTTngProjectLabelProvider());
- fViewer.setInput(fProjectRoot);
-
- getSite().setSelectionProvider(fViewer);
- hookMouse();
-
- createContextMenu();
- }
-
- // ------------------------------------------------------------------------
- // ViewPart
- // ------------------------------------------------------------------------
-
- @Override
- @SuppressWarnings("nls")
- public String toString() {
- return "[ProjectView]";
- }
-
- // ------------------------------------------------------------------------
- // hookMouse
- // ------------------------------------------------------------------------
-
- private void hookMouse() {
- fViewer.getTree().addMouseListener(new MouseAdapter() {
- @Override
- public void mouseDoubleClick(MouseEvent event) {
- TreeSelection selection = (TreeSelection) fViewer.getSelection();
- Object element = selection.getFirstElement();
- if (element instanceof LTTngExperimentNode) {
- LTTngExperimentNode experiment = (LTTngExperimentNode) element;
- selectExperiment(experiment);
- } else {
- if (element instanceof LTTngTraceNode) {
- LTTngTraceNode trace = (LTTngTraceNode) element;
- selectTrace(trace);
- }
- }
- }
- });
- }
-
- private void selectTrace(LTTngTraceNode traceNode) {
- if (fSelectedExperiment != null) {
- fSelectedExperiment.dispose();
- }
-
- try {
- ITmfTrace[] traces = new ITmfTrace[1];
- IResource res = traceNode.getFolder();
- String location = res.getLocation().toOSString();
- LTTngProjectNode projectNode = traceNode.getProject();
- IProject project = projectNode.getProject();
- String traceLibPath = TraceHelper.getTraceLibDirFromProject(project);
- ITmfTrace trace = new LTTngTrace(location, traceLibPath, waitForCompletion, false);
- traces[0] = trace;
- fSelectedExperiment = new LTTngExperiment<LttngEvent>(LttngEvent.class, traceNode.getName(), traces);
- TmfExperiment.setCurrentExperiment(fSelectedExperiment);
-
- // Make sure the lttng-core, experiment selection context is ready
- // for an event request from any view
-// StateManagerFactory.getExperimentManager().experimentSelected_prep(
-// (TmfExperiment<LttngEvent>) fSelectedExperiment);
-
- broadcast(new TmfExperimentSelectedSignal<LttngEvent>(this, fSelectedExperiment));
- } catch (FileNotFoundException e) {
- return;
- } catch (Exception e) {
- MessageDialog.openError(getViewSite().getShell(), Messages.SelectTrace_ErrorTitle, e.getMessage());
- }
- }
-
- private boolean waitForCompletion = true;
-
- /**
- * @param experiment
- */
- public void selectExperiment(LTTngExperimentNode experiment) {
- String expId = experiment.getName();
- if (fSelectedExperiment != null) {
-// System.out.println(fSelectedExperiment.getName() + ": nbEvents=" + fSelectedExperiment.getNbEvents() +
-// ", nbReads=" + ((LTTngTrace) fSelectedExperiment.getTraces()[0]).nbEventsRead);
- fSelectedExperiment.dispose();
- }
- try {
- LTTngTraceNode[] traceEntries = experiment.getTraces();
- int nbTraces = traceEntries.length;
- ITmfTrace[] traces = new ITmfTrace[nbTraces];
- for (int i = 0; i < nbTraces; i++) {
- IResource res = traceEntries[i].getFolder();
- String location = res.getLocation().toOSString();
- IProject project = res.getProject().getProject();
- String traceLibPath = TraceHelper.getTraceLibDirFromProject(project);
- ITmfTrace trace = new LTTngTrace(location, traceLibPath, waitForCompletion, false);
- traces[i] = trace;
- }
- fSelectedExperiment = new LTTngExperiment<LttngEvent>(LttngEvent.class, expId, traces);
- TmfExperiment.setCurrentExperiment(fSelectedExperiment);
-
- // Make sure the lttng-core, experiment selection context is ready
- // for an event request from any view
-// StateManagerFactory.getExperimentManager().experimentSelected_prep(
-// (TmfExperiment<LttngEvent>) fSelectedExperiment);
-
-// System.out.println(System.currentTimeMillis() + ": Experiment selected");
- broadcast(new TmfExperimentSelectedSignal<LttngEvent>(this, fSelectedExperiment));
- } catch (FileNotFoundException e) {
- return;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- // ------------------------------------------------------------------------
- // createContextMenu
- // ------------------------------------------------------------------------
-
- // Populated from the plug-in
- private void createContextMenu() {
- MenuManager menuManager = new MenuManager("#PopupMenu"); //$NON-NLS-1$
- menuManager.setRemoveAllWhenShown(true);
- Menu menu = menuManager.createContextMenu(fViewer.getControl());
- fViewer.getControl().setMenu(menu);
- getSite().registerContextMenu(menuManager, fViewer);
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentNode;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceNode;
-import org.eclipse.ui.IImportWizard;
-import org.eclipse.ui.IWorkbench;
-
-/**
- * <b><u>AddTraceWizard</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-@Deprecated
-public class AddTraceWizard extends Wizard implements IImportWizard {
-
- private LTTngProjectNode fProject;
- private LTTngExperimentNode fExperiment;
- private AddTraceWizardPage fMainPage;
-
- /**
- * @param project
- */
- public AddTraceWizard(LTTngProjectNode project, LTTngExperimentNode experiment) {
- fProject = project;
- fExperiment = experiment;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
- */
- @Override
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- setWindowTitle(Messages.AddTraceWizard_windowTitle);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.Wizard#addPages()
- */
- @Override
- public void addPages() {
- super.addPages();
- fMainPage = new AddTraceWizardPage(fProject, "Some string"); //$NON-NLS-1$
- addPage(fMainPage);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.Wizard#performFinish()
- */
- @Override
- public boolean performFinish() {
-
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IFolder experimentFolder = fExperiment.getFolder();
-
- LTTngTraceNode[] traces = fMainPage.getSelection();
- for (LTTngTraceNode trace : traces) {
- try {
- IFolder folder = experimentFolder.getFolder(trace.getName());
- IPath location = trace.getFolder().getLocation();
- if (workspace.validateLinkLocation(folder, location).isOK()) {
- folder.createLink(location, IResource.REPLACE, null);
- fExperiment.addTrace(folder);
- }
- else {
- System.out.println(Messages.AddTraceWizard_invalidTraceLocation);
- }
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
-
- return true;
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
-
-import java.util.Vector;
-
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceNode;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-
-/**
- * <b><u>AddTraceWizardPage</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-@Deprecated
-public class AddTraceWizardPage extends WizardPage {
-
- private LTTngProjectNode fProject;
- private CheckboxTableViewer fCheckboxTableViewer;
-
- protected AddTraceWizardPage(LTTngProjectNode project, String pageName) {
- super(pageName);
- setTitle(Messages.AddTraceWizardPage_windowTitle);
- setDescription(Messages.AddTraceWizardPage_description);
- fProject = project;
- }
-
- @Override
- public void createControl(Composite parent) {
- Composite container = new Composite(parent, SWT.NULL);
- container.setLayout(new FormLayout());
- setControl(container);
-
- fCheckboxTableViewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER);
- fCheckboxTableViewer.setContentProvider(new DialogTraceContentProvider());
- fCheckboxTableViewer.setLabelProvider(new DialogTraceLabelProvider());
-
- final Table table = fCheckboxTableViewer.getTable();
- final FormData formData = new FormData();
- formData.bottom = new FormAttachment(100, 0);
- formData.right = new FormAttachment(100, 0);
- formData.top = new FormAttachment(0, 0);
- formData.left = new FormAttachment(0, 0);
- table.setLayoutData(formData);
- table.setHeaderVisible(true);
-
- final TableColumn tableColumn = new TableColumn(table, SWT.NONE);
- tableColumn.setWidth(200);
- tableColumn.setText(Messages.AddTraceWizardPage_columnHeader);
-
- fCheckboxTableViewer.setInput(fProject.getTracesFolder());
- }
-
- public LTTngTraceNode[] getSelection() {
- Vector<LTTngTraceNode> traces = new Vector<LTTngTraceNode>();
- Object[] selection = fCheckboxTableViewer.getCheckedElements();
- for (Object sel : selection) {
- if (sel instanceof LTTngTraceNode)
- traces.add((LTTngTraceNode) sel);
- }
- LTTngTraceNode[] result = new LTTngTraceNode[traces.size()];
- traces.toArray(result);
- return result;
- }
-
-}
+++ /dev/null
-package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
-
-import org.eclipse.osgi.util.NLS;
-
-public class DataTransferMessages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.linuxtools.lttng.ui.views.project.dialogs.messages"; //$NON-NLS-1$
- public static String ImportTraceWizard_LocationError;
- public static String ImportTraceWizard_LocationErrorMsg1;
- public static String ImportTraceWizard_LocationErrorMsg2;
- public static String ImportTraceWizard_LocationErrorMsg3;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, DataTransferMessages.class);
- }
-
- private DataTransferMessages() {
- }
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceFolderNode;
-
-/**
- * <b><u>LTTngTracesContentProvider</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-@Deprecated
-public class DialogTraceContentProvider implements IStructuredContentProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- @Override
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof LTTngTraceFolderNode) {
- LTTngTraceFolderNode folder = (LTTngTraceFolderNode) inputElement;
- return folder.getTraces();
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
-
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceNode;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * <b><u>LTTngTracesLabelProvider</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-@Deprecated
-public class DialogTraceLabelProvider extends LabelProvider implements ITableLabelProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
- */
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- */
- @Override
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof LTTngTraceNode) {
- LTTngTraceNode entry = (LTTngTraceNode) element;
- switch (columnIndex) {
- case 0:
- return entry.getName();
- default:
- return null;
- }
- }
- return null;
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
-
-import java.util.List;
-
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.IImportWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
-
-/**
- * <b><u>ImportTraceWizard</u></b>
- * <p>
- *
- * TODO: Implement me. Please.
- */
-@Deprecated
-@SuppressWarnings("restriction")
-public class ImportTraceWizard extends Wizard implements IImportWizard {
-
- private IWorkbench fWorkbench;
- private IStructuredSelection fSelection;
- private ImportTraceWizardPage fMainPage;
-
- /**
- *
- */
- private final String IMPORT_WIZARD = "LTTngTraceImportWizard"; //$NON-NLS-1$
-
- public ImportTraceWizard() {
- IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
- IDialogSettings section = workbenchSettings.getSection(IMPORT_WIZARD);
- if (section == null) {
- section = workbenchSettings.addNewSection(IMPORT_WIZARD);
- }
-
- setDialogSettings(section);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.wizard.Wizard#addPages()
- */
- @Override
- public void addPages() {
- super.addPages();
- fMainPage = new ImportTraceWizardPage(fWorkbench, fSelection);
- addPage(fMainPage);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
- * org.eclipse.jface.viewers.IStructuredSelection)
- */
- @Override
- @SuppressWarnings("rawtypes")
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- fWorkbench = workbench;
- fSelection = selection;
-
- List selectedResources = IDE.computeSelectedResources(selection);
- if (!selectedResources.isEmpty()) {
- fSelection = new StructuredSelection(selectedResources);
- }
-
- setWindowTitle(""); //$NON-NLS-1$
- setDefaultPageImageDescriptor(IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/importdir_wiz.png")); //$NON-NLS-1$
- setNeedsProgressMonitor(true);
- }
-
- public ImportTraceWizardPage getMainPage() {
- return fMainPage;
- }
-
- /**
- * performFinish is called after the "finish" button is pressed in the
- * import wizard If we return "false", the wizard will not close.
- *
- * We perform here version check on the imported LTTng trace
- *
- */
- @Override
- public boolean performFinish() {
- if (fMainPage.getDestination().equals(fMainPage.getInitialContainerString())) {
- String errMessage[] = { org.eclipse.linuxtools.lttng.ui.views.project.dialogs.DataTransferMessages.ImportTraceWizard_LocationError };
- errMessage = fMainPage.extendErrorMessage(errMessage, ""); //$NON-NLS-1$
- errMessage = fMainPage.extendErrorMessage(errMessage, org.eclipse.linuxtools.lttng.ui.views.project.dialogs.DataTransferMessages.ImportTraceWizard_LocationErrorMsg1 + fMainPage.getInitialContainerString() + "\""); //$NON-NLS-1$
- errMessage = fMainPage.extendErrorMessage(errMessage, org.eclipse.linuxtools.lttng.ui.views.project.dialogs.DataTransferMessages.ImportTraceWizard_LocationErrorMsg2 + fMainPage.getInitialContainerString() + "/MyTrace\""); //$NON-NLS-1$
- errMessage = fMainPage.extendErrorMessage(errMessage, ""); //$NON-NLS-1$
- errMessage = fMainPage.extendErrorMessage(errMessage, org.eclipse.linuxtools.lttng.ui.views.project.dialogs.DataTransferMessages.ImportTraceWizard_LocationErrorMsg3);
- fMainPage.showVersionErrorPopup(errMessage);
- return false;
- }
- return fMainPage.finish();
- }
-
- @Override
- public boolean canFinish() {
- return fMainPage.isSelectedElementsValidLttngTraces();
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Ericsson, MontaVista Software
- *
- * 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:
- * Francois Chouinard - Initial API and implementation
- * Yufen Kuo (ykuo@mvista.com) - add support to allow user specify trace library path
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.linuxtools.lttng.core.TraceHelper;
-import org.eclipse.linuxtools.lttng.core.exceptions.LttngException;
-import org.eclipse.linuxtools.lttng.core.trace.LTTngTraceVersion;
-import org.eclipse.linuxtools.lttng.ui.views.project.handlers.TraceErrorHandler;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.internal.wizards.datatransfer.WizardFileSystemResourceImportPage1;
-
-/**
- * <b><u>ImportTraceWizardPage</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-@Deprecated
-@SuppressWarnings("restriction")
-public class ImportTraceWizardPage extends WizardFileSystemResourceImportPage1 {
-
- private boolean isContainerSet = false;
- private String initialContainerString = ""; //$NON-NLS-1$
- private String selectedSourceDirectory = ""; //$NON-NLS-1$
- private IProject project;
-
- public ImportTraceWizardPage(IWorkbench workbench, IStructuredSelection selection) {
- super(workbench, selection);
-
- project = (IProject) selection.getFirstElement();
- IFolder folder = project.getFolder(LTTngProjectNode.TRACE_FOLDER_NAME);
- if (folder == null) {
- MessageDialog.openError(getShell(), Messages.ImportTrace_ErrorTitle, Messages.ImportTrace_InvalidProject);
- }
- String path = folder.getFullPath().toOSString();
-
- initialContainerString = path;
- setContainerFieldValue(path);
- }
-
- public String getTraceDirectory() {
- String tmpPath = ""; //$NON-NLS-1$
- if ((getSourceDirectory() != null) && (getSourceDirectory().getName() != null)) {
- tmpPath = this.getSourceDirectory().getName().toString();
- }
-
- return tmpPath;
- }
-
- public String getInitialContainerString() {
- return initialContainerString;
- }
-
- public String getTracepath() {
- String tmpPath = ""; //$NON-NLS-1$
- if ((getSourceDirectory() != null) && (getSourceDirectory().getPath() != null)) {
- tmpPath = this.getSourceDirectory().getPath().toString();
- }
-
- return tmpPath;
- }
-
- public String getDestination() {
- String returnPath = null;
-
- if (getContainerFullPath() != null) {
- returnPath = getContainerFullPath().toString();
- }
- return returnPath;
- }
-
- public boolean isSelectedElementsValidLttngTraces() {
- boolean returnedValue = true;
-
- // We don't want to test until something is selected
- if (selectionGroup.getCheckedElementCount() > 0) {
-
- // We don't want to revalidate each time, only want a new directory
- // is selected
- if (!selectedSourceDirectory.equals(getSourceDirectory().getAbsolutePath().toString())) {
- try {
- if (isPathLttngTrace(getSourceDirectory().getAbsolutePath()) == false) {
- returnedValue = false;
- selectedSourceDirectory = ""; //$NON-NLS-1$
-
- String errMessage[] = { Messages.ImportTraceWizardPage_BadTraceVersion + getSourceDirectory().getAbsolutePath() };
- errMessage = extendErrorMessage(errMessage, ""); //$NON-NLS-1$
- errMessage = extendErrorMessage(errMessage, Messages.ImportTraceWizardPage_BadTraceVersionMsg1);
- errMessage = extendErrorMessage(errMessage, Messages.ImportTraceWizardPage_BadTraceVersionMsg2);
- showVersionErrorPopup(errMessage);
- selectionGroup.setAllSelections(false);
- } else {
- selectedSourceDirectory = getSourceDirectory().getAbsolutePath();
-
- if (isContainerSet == false) {
- isContainerSet = true;
-
- if (!getDestination().toString().equals(getInitialContainerString() + "/" + getTraceDirectory())) { //$NON-NLS-1$
- // *** HACK ***
- // Force a sane destination to avoid imported
- // files to end up in the root of the "Traces/"
- // directory
- setContainerFieldValue(getInitialContainerString() + "/" + getTraceDirectory()); //$NON-NLS-1$
- }
- }
- }
- } catch (LttngException e) {
- String[] errorMessages = e.toString().split("\n"); //$NON-NLS-1$
- String exceptionMessage[] = { "Version check failed for the path : ", this.getTracepath(), "", "Returned error was :" }; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
-
- for (int pos = 0; pos < errorMessages.length; pos++) {
- exceptionMessage = extendErrorMessage(exceptionMessage, errorMessages[pos]);
- }
-
- showVersionErrorPopup(exceptionMessage);
- selectionGroup.setAllSelections(false);
- returnedValue = false;
- }
- }
- }
- isContainerSet = false;
-
- return returnedValue;
- }
-
- public boolean isPathLttngTrace(String path) throws LttngException {
-
- boolean returnedValue = true;
- String traceLibPath = TraceHelper.getTraceLibDirFromProject(project);
- // Ask for a LttngTraceVersion for the given path
- LTTngTraceVersion traceVersion = new LTTngTraceVersion(path, traceLibPath);
-
- // If this is not a valid LTTng trace
- if (traceVersion.isValidLttngTrace() == false) {
- returnedValue = false;
- }
-
- return returnedValue;
- }
-
- public String[] extendErrorMessage(String[] oldErrorMessage, String lineToAdd) {
- String tmSwapMessage[] = new String[oldErrorMessage.length + 1];
- for (int pos = 0; pos < oldErrorMessage.length; pos++) {
- tmSwapMessage[pos] = oldErrorMessage[pos];
- }
- tmSwapMessage[oldErrorMessage.length] = lineToAdd;
-
- return tmSwapMessage;
- }
-
- /**
- * This function will show a version error popup that contain the given
- * message.
- *
- */
- public void showVersionErrorPopup(String[] errMessages) {
- TraceErrorHandler errorDialog = new TraceErrorHandler(errMessages);
- try {
- errorDialog.execute(null);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- // // *** HACK HACK AND HACK ***
- // // Everything below is a proof of concept on how we could tweak the
- // import wizard to act according to our plan
- // // Uncomment everything below if you want to test it, but please, does
- // not put any of this into production
- // @SuppressWarnings({ "unchecked", "rawtypes" })
- // @Override
- // public boolean finish() {
- // if (!ensureSourceIsValid()) {
- // return false;
- // }
- // saveWidgetValues();
- //
- // Iterator resourcesEnum = getSelectedResources().iterator();
- // List listRealFiles = new ArrayList();
- //
- // // ****
- // // HACK #1 :
- // // We need to convert everything into java.io.File because
- // ImportOperation does NOT support FileSystemElement
- // while (resourcesEnum.hasNext()) {
- // FileSystemElement tmpFileElement =
- // ((FileSystemElement)resourcesEnum.next());
- // java.io.File tmpRealFile = new
- // java.io.File(tmpFileElement.getFileSystemObject().toString());
- //
- // listRealFiles.add(tmpRealFile);
- // }
- //
- // if (listRealFiles.size() > 0) {
- // // Call import ressources (code is below)
- // return importResources(listRealFiles);
- // }
- //
- // MessageDialog.openInformation(getContainer().getShell(),
- // DataTransferMessages.DataTransfer_information,
- // DataTransferMessages.FileImport_noneSelected);
- // return false;
- // }
- //
- // @Override
- // protected boolean importResources(List fileSystemObjects) {
- // // *** Explanation of the hackssss
- // // We want the import wizard to import everything in the form of :
- // // trace1/ -> tracefiles*
- // //
- // // However, the wizard is too dumb to do the following and will recreate
- // the full architecture the user selected.
- // // So, depending what the user select, we could end up with something
- // like :
- // // home/user/somewhere/trace1/ -> tracefiles*
- // //
- // // Since there is nothing to do with that, we need to change the "source"
- // and the "to-import files" to reflect this.
- // // Basically, from the case above, the "source" should be changed to
- // "trace1/" and "to-import files"
- // // should have the correct parent so the wizard can still find them
- // //
- // // Let's see how fun it is to do with mr. import wizard.
- //
- //
- // List listRealFilesShortPath = new ArrayList();
- // java.io.File newFullSource = getSourceDirectory();
- //
- // // We will loop for every "to-import full path files" we have and
- // recreate "short path" files
- // // Mean, the current path of the file is currently something like :
- // // Path : /home/billybob/mytraces/trace1/metadata_0 Parent : null
- // // And we want something less dumb like :
- // // Path : metadata_0 Parent : /home/billybob/mytraces/trace1/
- // for (int pos=0; pos<fileSystemObjects.size(); pos++) {
- // java.io.File oldFile = (java.io.File)fileSystemObjects.get(pos);
- // java.io.File newShortPathFile = oldFile;
- //
- // // ***
- // // HACK #2 : We need to ajust the source of the files!
- // // Our current source is probably like :
- // // (Source) Path : / (or null?)
- // // (Files) Path : /home/billybob/mytraces/trace1/metadata_0 Parent : null
- // // We want something like :
- // // (Source) Path : /home/billybob/mytraces/trace1/
- // // (Files) Path : metadata_0 Parent : /home/billybob/mytraces/trace1/
- // //
- // // *BUG : However, we might need MULTIPLE sources since we could have
- // MULTIPLE traces selected...
- // // THIS IS NOT HANDLED YET.
- //
- // // Make a new path like -> /home/billybob/mytraces/trace1/
- // String newParent = oldFile.getAbsolutePath().substring(0,
- // oldFile.getAbsolutePath().lastIndexOf("/") );
- //
- // // Create a "short path file" with the good parent from it. This give :
- // // (Files) Path : metadata_0 Parent : /home/billybob/mytraces/trace1/
- // newShortPathFile = new java.io.File(newParent, oldFile.getName() );
- //
- // // Create a new "full source" directory ->
- // /home/billybob/mytraces/trace1/
- // newFullSource = new java.io.File( newParent );
- //
- // // Add our pretty file to the new List
- // listRealFilesShortPath.add(newShortPathFile);
- // }
- //
- // // ***
- // // HACK #3
- // // Now that we have everything, we need to AJUST THE DESTINATION
- // // To do so, we ajust the "ContainerValue" text field.
- // //
- // // Right now we have something like :
- // // Path -> /where/to/import/
- // // (Files) Path : metadata_0 Parent : /home/billybob/mytraces/trace1/
- // // We want something like :
- // // Path -> /where/to/import/trace1/
- // // (Files) Path : metadata_0 Parent : /home/billybob/mytraces/trace1/
- // //
- //
- // // We take the current text field and we add the "full source" name
- // // Note : the "name" is the last directory name so "trace1" is returned
- // for a path like "/home/billybob/mytraces/trace1/"
- // setContainerFieldValue(getContainerFullPath() + "/" +
- // newFullSource.getName());
- //
- // /*
- // System.out.println("\n\n" + getContainerFullPath());
- // System.out.println(newFullSource);
- // System.out.println(FileSystemStructureProvider.INSTANCE);
- // System.out.println(this.getContainer());
- // System.out.println(fileSystemObjects);
- // */
- //
- // // Finally import !!
- // ImportOperation operation = new ImportOperation(getContainerFullPath(),
- // newFullSource, FileSystemStructureProvider.INSTANCE, this,
- // listRealFilesShortPath);
- //
- // operation.setContext(getShell());
- // return executeImportOperation(operation);
- // }
- //
- // // This function test if the selected directory are LTTng traces
- // // This one is made to work with the madness above.
- // public boolean isSelectedElementsValidLttngTraces() {
- // boolean returnedValue = true;
- //
- // String errMessage[] = {
- // "Couldn't get LTTng version number for the path : " };
- //
- // // We don't want to test until something is selected
- // if ( selectionGroup.getCheckedElementCount() > 0 ) {
- // try {
- // List<MinimizedFileSystemElement> selectionList =
- // selectionGroup.getAllWhiteCheckedItems();
- // MinimizedFileSystemElement tmpSelectedElement = null;
- //
- // for ( int x=0; x<selectionList.size(); x++) {
- // tmpSelectedElement = selectionList.get(x);
- //
- // // *** VERIFY ***
- // // Not sure ALL directory are checked.
- // if ( tmpSelectedElement.isDirectory() ) {
- // String tmpPath = tmpSelectedElement.getFileSystemObject().toString();
- // if ( isPathLttngTrace( tmpPath ) == false ) {
- // returnedValue = false;
- // errMessage = extendErrorMessage(errMessage, tmpPath);
- // }
- // }
- // }
- //
- // if ( returnedValue == false ) {
- // errMessage = extendErrorMessage(errMessage, "");
- // errMessage = extendErrorMessage(errMessage,
- // "Verify that the directory is a valid LTTng trace directory.");
- // showVersionErrorPopup(errMessage);
- // selectionGroup.setAllSelections(false);
- // }
- // }
- // catch (LttngException e) {
- // String exceptionMessage[] = { "Version check failed for the path : ",
- // this.getTracepath(), "", "Returned error was :", e.toString() };
- // showVersionErrorPopup(exceptionMessage);
- // selectionGroup.setAllSelections(false);
- // returnedValue = false;
- // }
- // }
- //
- // return returnedValue;
- // }
-
-}
+++ /dev/null
-package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.linuxtools.lttng.ui.views.project.dialogs.messages"; //$NON-NLS-1$
- public static String AddTraceWizard_invalidTraceLocation;
- public static String AddTraceWizard_windowTitle;
- public static String AddTraceWizardPage_columnHeader;
- public static String AddTraceWizardPage_description;
- public static String AddTraceWizardPage_windowTitle;
- public static String ImportTrace_ErrorTitle;
- public static String ImportTrace_InvalidProject;
- public static String ImportTraceWizardPage_BadTraceVersion;
- public static String ImportTraceWizardPage_BadTraceVersionMsg1;
- public static String ImportTraceWizardPage_BadTraceVersionMsg2;
- public static String NewProjectWizard_Description;
- public static String NewProjectWizard_Title;
- public static String NewExperimentDialog_DialogTitle;
- public static String NewExperimentDialog_ExperimentLabel;
- public static String TraceErrorDialog_DalogTitle;
- public static String TraceErrorDialog_DialogMsgLabel;
- public static String TraceLibraryPath_label;
- public static String TraceLibraryPath_browseBtn;
- public static String TraceLibraryPathWizardPage_SpecifiedTraceLibraryLocation_notExists;
- public static String TraceLibraryPathWizardPage_TraceLoaderLibrary_notExists;
- public static String TraceLibraryPathWizardPage_Title;
- public static String TraceLibraryPathWizardPage_Description;
- public static String TraceLibraryPathWizard_Message;
- public static String TraceLibraryPathProperty_Message;
- public static String SelectTrace_ErrorTitle;
- public static String TraceLibraryPath_Note;
- public static String TraceLibraryPath_Message;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
-
-import java.lang.reflect.InvocationTargetException;
-import java.net.URI;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentFolderNode;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.ui.dialogs.SelectionStatusDialog;
-import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
-import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
-import org.eclipse.ui.internal.ide.dialogs.CreateLinkedResourceGroup;
-
-/**
- * NewExperimentDialog
- *
- * This is stripped down version of NewFolderDialog.
- */
-@Deprecated
-@SuppressWarnings("restriction")
-public class NewExperimentDialog extends SelectionStatusDialog {
-
- private Text folderNameField;
- private final IContainer container;
- private boolean firstLinkCheck = true;
- private CreateLinkedResourceGroup linkedResourceGroup;
-
- /**
- * Creates a NewFolderDialog
- *
- * @param parentShell parent of the new dialog
- * @param container parent of the new folder
- */
- public NewExperimentDialog(Shell parentShell, LTTngExperimentFolderNode experimentFolder) {
- super(parentShell);
- this.container = experimentFolder.getFolder();
- setTitle(Messages.NewExperimentDialog_DialogTitle);
- setStatusLineAboveButtons(true);
- }
-
- /**
- * Creates the folder using the name and link target entered by the user.
- * Sets the dialog result to the created folder.
- */
- @Override
- protected void computeResult() {
- }
-
- /**
- * @see org.eclipse.jface.window.Window#create()
- */
- @Override
- public void create() {
- super.create();
- getButton(IDialogConstants.OK_ID).setEnabled(false);
- }
-
- /**
- * Creates the widget for advanced options.
- *
- * @param parent the parent composite
- */
- protected void createLinkResourceGroup(Composite parent) {
- linkedResourceGroup = new CreateLinkedResourceGroup(IResource.FOLDER, new Listener() {
- @Override
- public void handleEvent(Event e) {
- validateLinkedResource();
- firstLinkCheck = false;
- }
- }, new CreateLinkedResourceGroup.IStringValue() {
- @Override
- public void setValue(String string) {
- folderNameField.setText(string);
- }
-
- @Override
- public String getValue() {
- return folderNameField.getText();
- }
-
- @Override
- public IResource getResource() {
- // TODO Auto-generated method stub
- return null;
- }
- });
- }
-
- /*
- * (non-Javadoc) Method declared on Dialog.
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createFolderNameGroup(composite);
- createLinkResourceGroup(composite);
- return composite;
- }
-
- /**
- * Creates the folder name specification controls.
- *
- * @param parent the parent composite
- */
- private void createFolderNameGroup(Composite parent) {
- Font font = parent.getFont();
- Composite folderGroup = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- folderGroup.setLayout(layout);
- folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // new folder label
- Label folderLabel = new Label(folderGroup, SWT.NONE);
- folderLabel.setFont(font);
- folderLabel.setText(Messages.NewExperimentDialog_ExperimentLabel);
-
- // new folder name entry field
- folderNameField = new Text(folderGroup, SWT.BORDER);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
- folderNameField.setLayoutData(data);
- folderNameField.setFont(font);
- folderNameField.addListener(SWT.Modify, new Listener() {
- @Override
- public void handleEvent(Event event) {
- validateLinkedResource();
- }
- });
- }
-
- /**
- * Creates a folder resource handle for the folder with the given name. The
- * folder handle is created relative to the container specified during
- * object creation.
- *
- * @param folderName the name of the folder resource to create a handle for
- * @return the new folder resource handle
- */
- private IFolder createFolderHandle(String folderName) {
- IWorkspaceRoot workspaceRoot = container.getWorkspace().getRoot();
- IPath folderPath = container.getFullPath().append(folderName);
- IFolder folderHandle = workspaceRoot.getFolder(folderPath);
-
- return folderHandle;
- }
-
- /**
- * Creates a new folder with the given name and optionally linking to the
- * specified link target.
- *
- * @param folderName name of the new folder
- * @param linkTarget name of the link target folder. may be null.
- * @return IFolder the new folder
- */
- private IFolder createNewFolder(String folderName, final URI linkTarget) {
- final IFolder folderHandle = createFolderHandle(folderName);
-
- WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
- @Override
- public void execute(IProgressMonitor monitor) throws CoreException {
- try {
- monitor.beginTask(IDEWorkbenchMessages.NewFolderDialog_progress, 2000);
- if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- if (linkTarget == null) {
- folderHandle.create(false, true, monitor);
- } else {
- folderHandle.createLink(linkTarget, IResource.ALLOW_MISSING_LOCAL, monitor);
- }
- if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- } finally {
- monitor.done();
- }
- }
- };
- try {
- PlatformUI.getWorkbench().getProgressService().busyCursorWhile(operation);
- } catch (InterruptedException exception) {
- return null;
- } catch (InvocationTargetException exception) {
- if (exception.getTargetException() instanceof CoreException) {
- ErrorDialog.openError(getShell(), IDEWorkbenchMessages.NewFolderDialog_errorTitle, null,
- ((CoreException) exception.getTargetException()).getStatus());
- } else {
- // CoreExceptions are handled above, but unexpected runtime
- // exceptions and errors may still occur.
- IDEWorkbenchPlugin.log(getClass(), "createNewExperiment", exception.getTargetException()); //$NON-NLS-1$
- MessageDialog.openError(getShell(), IDEWorkbenchMessages.NewFolderDialog_errorTitle,
- NLS.bind(IDEWorkbenchMessages.NewFolderDialog_internalError, exception.getTargetException().getMessage()));
- }
- return null;
- }
- return folderHandle;
- }
-
- /**
- * Update the dialog's status line to reflect the given status. It is safe
- * to call this method before the dialog has been opened.
- */
- @Override
- protected void updateStatus(IStatus status) {
- if (firstLinkCheck && status != null) {
- Status newStatus = new Status(IStatus.OK, status.getPlugin(), status.getCode(), status.getMessage(), status.getException());
- super.updateStatus(newStatus);
- } else {
- super.updateStatus(status);
- }
- }
-
- /**
- * Update the dialog's status line to reflect the given status. It is safe
- * to call this method before the dialog has been opened.
- *
- * @param severity
- * @param message
- */
- private void updateStatus(int severity, String message) {
- updateStatus(new Status(severity, IDEWorkbenchPlugin.IDE_WORKBENCH, severity, message, null));
- }
-
- /**
- * Checks whether the folder name and link location are valid. Disable the
- * OK button if the folder name and link location are valid. a message that
- * indicates the problem otherwise.
- */
- private void validateLinkedResource() {
- boolean valid = validateFolderName();
-
- if (valid) {
- IFolder linkHandle = createFolderHandle(folderNameField.getText());
- IStatus status = linkedResourceGroup.validateLinkLocation(linkHandle);
-
- if (status.getSeverity() != IStatus.ERROR) {
- getOkButton().setEnabled(true);
- } else {
- getOkButton().setEnabled(false);
- }
-
- if (status.isOK() == false) {
- updateStatus(status);
- }
- } else {
- getOkButton().setEnabled(false);
- }
- }
-
- /**
- * Checks if the folder name is valid.
- *
- * @return null if the new folder name is valid. a message that indicates
- * the problem otherwise.
- */
- private boolean validateFolderName() {
- String name = folderNameField.getText();
- IWorkspace workspace = container.getWorkspace();
- IStatus nameStatus = workspace.validateName(name, IResource.FOLDER);
-
- if ("".equals(name)) { //$NON-NLS-1$
- updateStatus(IStatus.ERROR, "Experiment name is empty"); //$NON-NLS-1$
- return false;
- }
- if (nameStatus.isOK() == false) {
- updateStatus(nameStatus);
- return false;
- }
- IPath path = new Path(name);
- if (container.getFolder(path).exists() || container.getFile(path).exists()) {
- updateStatus(IStatus.ERROR, NLS.bind("Experiment already exists", name)); //$NON-NLS-1$
- return false;
- }
- updateStatus(IStatus.OK, ""); //$NON-NLS-1$
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.SelectionStatusDialog#okPressed()
- */
- @Override
- protected void okPressed() {
- URI linkTarget = linkedResourceGroup.getLinkTargetURI();
- IFolder folder = createNewFolder(folderNameField.getText(), linkTarget);
- if (folder == null) {
- return;
- }
-
- setSelectionResult(new IFolder[] { folder });
-
- super.okPressed();
- }
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
-
-import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
-
-/**
- * <b><u>NewProjectMainWizardPage</u></b>
- * <p>
- *
- * TODO: Implement me. Please.
- */
-public class NewLTTngProjectMainWizardPage extends WizardNewProjectCreationPage {
-
- /**
- * @param pageName
- */
- public NewLTTngProjectMainWizardPage(String pageName) {
- super(pageName);
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Ericsson, MontaVista Software
- *
- * 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:
- * Francois Chouinard - Initial API and implementation
- * Yufen Kuo (ykuo@mvista.com) - add support to allow user specify trace library path
- * Francois Chouinard - Rebase on TMF NewProjectWizard
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.linuxtools.lttng.core.LTTngProjectNature;
-import org.eclipse.linuxtools.lttng.core.TraceHelper;
-import org.eclipse.linuxtools.tmf.core.TmfProjectNature;
-import org.eclipse.linuxtools.tmf.ui.project.wizards.NewTmfProjectWizard;
-
-/**
- * <b><u>NewLTTngProjectWizard</u></b>
- * <p>
- */
-public class NewLTTngProjectWizard extends NewTmfProjectWizard {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
- private static final String TRACE_LIBRARY_PATH = "traceLibraryPath"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private TraceLibraryPathWizardPage traceLibraryPathPage;
-
- // ------------------------------------------------------------------------
- // Construction
- // ------------------------------------------------------------------------
-
- public NewLTTngProjectWizard() {
- this(Messages.NewProjectWizard_Title, Messages.NewProjectWizard_Description);
- }
-
- public NewLTTngProjectWizard(String title, String desc) {
- super(title, desc);
- }
-
- // ------------------------------------------------------------------------
- // NewProjectWizard
- // ------------------------------------------------------------------------
-
- @Override
- public void addPages() {
- super.addPages();
- traceLibraryPathPage = new TraceLibraryPathWizardPage(Messages.NewProjectWizard_Title);
- traceLibraryPathPage.setTitle(Messages.TraceLibraryPathWizardPage_Title);
- traceLibraryPathPage.setDescription(Messages.TraceLibraryPathWizardPage_Description);
- addPage(traceLibraryPathPage);
- }
-
- @Override
- public boolean performFinish() {
- // Create the tracing project
- super.performFinish();
-
- // Add the LTTng nature
- try {
- IProjectDescription description = fProject.getDescription();
- description.setNatureIds(new String[] { TmfProjectNature.ID, LTTngProjectNature.ID });
- fProject.setDescription(description, null);
- } catch (CoreException e) {
- }
-
- // Set the library path
- String traceLibraryPath = traceLibraryPathPage.getPath();
- if (traceLibraryPath != null) {
- return TraceHelper.setProjectPreference(fProject, TRACE_LIBRARY_PATH, traceLibraryPath);
- }
-
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- public IProject getProject() {
- return fProject;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009 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:
- * William Bourque - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.SelectionStatusDialog;
-
-public class TraceErrorDialog extends SelectionStatusDialog {
-
- private String[] messages = null;
-
- public TraceErrorDialog(Shell parentShell, String[] newMessages) {
- super(parentShell);
- messages = newMessages;
- setTitle(Messages.TraceErrorDialog_DalogTitle);
- setStatusLineAboveButtons(true);
- }
-
- @Override
- protected void computeResult() {
- }
-
- @Override
- public void create() {
- super.create();
- getButton(IDialogConstants.OK_ID).setEnabled(true);
- getButton(IDialogConstants.OK_ID).setAlignment(GridData.CENTER);
- getButton(IDialogConstants.CANCEL_ID).setVisible(false);
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createFolderNameGroup(composite);
- return composite;
- }
-
- private void createFolderNameGroup(Composite parent) {
- Font font = parent.getFont();
- Composite folderGroup = new Composite(parent, SWT.NONE);
-
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.verticalSpacing = 3;
- folderGroup.setLayout(layout);
- folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Position grid for the messages
- GridData positionningData = new GridData(GridData.FILL_VERTICAL);
-
- // New message label
- Label lblMessage = new Label(folderGroup, SWT.NONE);
- lblMessage.setFont(font);
- lblMessage.setText(Messages.TraceErrorDialog_DialogMsgLabel);
- lblMessage.setLayoutData(positionningData);
-
- // The actual messages
- GC graphicContext = new GC(parent);
- String longuestLine = ""; //$NON-NLS-1$
- int msgSize = 0;
-
- // *** Font and FontData are nowhere near elegant to use.
- Font errorFont = new Font(graphicContext.getDevice(), font.getFontData()[0].getName(), font.getFontData()[0].getHeight(), SWT.ITALIC);
-
- Label[] lblErrorMessages = new Label[messages.length];
- for (int x = 0; x < messages.length; x++) {
- lblErrorMessages[x] = new Label(folderGroup, SWT.NONE);
- lblErrorMessages[x].setFont(errorFont);
-
- lblErrorMessages[x].setForeground(new Color(lblErrorMessages[x].getForeground().getDevice(), 255, 0, 0));
- lblErrorMessages[x].setText(messages[x]);
- lblErrorMessages[x].setLayoutData(positionningData);
-
- if (messages[x].length() > longuestLine.length()) {
- longuestLine = messages[x];
- }
- }
-
- for (int pos = 0; pos < longuestLine.length(); pos++) {
- msgSize += graphicContext.getAdvanceWidth(longuestLine.charAt(pos));
- }
- // Seems we need to count the final \n of the line otherwise we miss
- // some space
- msgSize += graphicContext.getAdvanceWidth('\n');
-
- positionningData.widthHint = msgSize;
- positionningData.grabExcessHorizontalSpace = true;
-
- graphicContext.dispose();
-
- }
-
- @Override
- protected void updateStatus(IStatus status) {
- if (status != null) {
- Status newStatus = new Status(IStatus.OK, status.getPlugin(), status.getCode(), status.getMessage(), status.getException());
- super.updateStatus(newStatus);
- } else {
- super.updateStatus(status);
- }
- }
-
- @Override
- protected void okPressed() {
- super.okPressed();
- }
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2011 MontaVista Software
- *
- * 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:
- * Yufen Kuo (ykuo@mvista.com) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.linuxtools.lttng.core.TraceHelper;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.PropertyPage;
-
-public class TraceLibraryPathPropertyPage extends PropertyPage {
-
- private static final String LTTVTRACEREAD_LOADER_LIBNAME = "lttvtraceread_loader";
- private Button browsePathButton;
- private Text traceLibraryPath;
-
- @Override
- protected Control createContents(Composite parent) {
- Composite client = new Composite(parent, SWT.NONE);
- client.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- GridLayout layout = new GridLayout(3, false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- client.setLayout(layout);
-
- Label label = new Label(client, SWT.NONE);
- label.setText(Messages.TraceLibraryPath_label);
- traceLibraryPath = new Text(client, SWT.BORDER);
- traceLibraryPath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
- false));
- traceLibraryPath.addModifyListener(new ModifyListener() {
-
- @Override
- public void modifyText(ModifyEvent e) {
- setValid(validateInputs());
- }
-
- });
- browsePathButton = new Button(client, SWT.PUSH);
- browsePathButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false,
- false));
- browsePathButton.setText(Messages.TraceLibraryPath_browseBtn);
- browsePathButton.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- String dir = new DirectoryDialog(Display.getDefault()
- .getActiveShell()).open();
- if (dir != null) {
- traceLibraryPath.setText(dir);
- }
-
- }
-
- });
-
- Label noLabel = new Label(client, SWT.NONE);
- noLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
-
- Label descTextLabel = new Label(client, SWT.WRAP);
- descTextLabel.setText(Messages.TraceLibraryPathProperty_Message);
- GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd.widthHint = 400;
- gd.horizontalSpan = 2;
- descTextLabel.setLayoutData(gd);
-
- Label noteBoldLabel = new Label(client, SWT.BOLD);
- noteBoldLabel.setText(Messages.TraceLibraryPath_Note);
- noteBoldLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false,
- false));
- Font font = noteBoldLabel.getFont();
- if (font.getFontData().length > 0)
- noteBoldLabel.setFont(new Font(client.getDisplay(), font
- .getFontData()[0].getName(), font.getFontData()[0]
- .getHeight(), SWT.BOLD));
-
- Label noteTextLabel = new Label(client, SWT.WRAP);
- noteTextLabel.setText(Messages.TraceLibraryPath_Message);
- gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd.widthHint = 400;
- gd.horizontalSpan = 2;
- noteTextLabel.setLayoutData(gd);
-
- performDefaults();
- return client;
- }
-
- public boolean validateInputs() {
- String path = traceLibraryPath.getText();
- if (path != null && !path.trim().isEmpty()) {
- File file = new File(path);
- if (file.exists() && file.isDirectory()) {
- File loaderLib = new File(path,
- System.mapLibraryName(LTTVTRACEREAD_LOADER_LIBNAME));
- if (!loaderLib.exists()) {
- setErrorMessage(Messages.TraceLibraryPathWizardPage_TraceLoaderLibrary_notExists);
- return false;
- }
- } else {
- setErrorMessage(Messages.TraceLibraryPathWizardPage_SpecifiedTraceLibraryLocation_notExists);
- return false;
- }
- }
- setErrorMessage(null);
- return true;
- }
-
- @Override
- protected void performDefaults() {
- IResource resource = (IResource) getElement().getAdapter(
- IResource.class);
- IProject project = resource.getProject();
- if (project != null) {
- String traceLibDir = TraceHelper.getTraceLibDirFromProject(project);
- if (traceLibDir != null) {
- traceLibraryPath.setText(traceLibDir);
- }
- }
- super.performDefaults();
- }
-
- @Override
- public boolean performOk() {
- IResource resource = (IResource) getElement().getAdapter(
- IResource.class);
- IProject project = resource.getProject();
- boolean ok = false;
- if (project != null) {
- String libPath = traceLibraryPath.getText();
- if (libPath == null || libPath.trim().isEmpty())
- ok = TraceHelper.removeProjectPreference(project,
- "traceLibraryPath");
- else
- ok = TraceHelper.setProjectPreference(project,
- "traceLibraryPath", traceLibraryPath.getText());
- }
- return ok && super.performOk();
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2011 MontaVista Software
- *
- * 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:
- * Yufen Kuo (ykuo@mvista.com) - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
-
-import java.io.File;
-
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-public class TraceLibraryPathWizardPage extends WizardPage {
- private static final String LTTVTRACEREAD_LOADER_LIBNAME = "lttvtraceread_loader";
- private Button browsePathButton;
- private Text traceLibraryPath;
-
- protected TraceLibraryPathWizardPage(String pageName) {
- super(pageName);
- }
-
- public void createControl(Composite parent) {
- Composite client = new Composite(parent, SWT.NONE);
- client.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- GridLayout layout = new GridLayout(3, false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- client.setLayout(layout);
-
- Label label = new Label(client, SWT.NONE);
- label.setText(Messages.TraceLibraryPath_label);
- traceLibraryPath = new Text(client, SWT.BORDER);
- traceLibraryPath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- traceLibraryPath.addModifyListener(new ModifyListener() {
-
- @Override
- public void modifyText(ModifyEvent e) {
- boolean valid = validatePage();
- setPageComplete(valid);
- }
-
- });
- browsePathButton = new Button(client, SWT.PUSH);
- browsePathButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
- browsePathButton.setText(Messages.TraceLibraryPath_browseBtn);
- browsePathButton.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- String dir = new DirectoryDialog(Display.getDefault()
- .getActiveShell()).open();
- if (dir != null) {
- traceLibraryPath.setText(dir);
- }
-
- }
-
- });
-
- Label noLabel = new Label(client, SWT.NONE);
- noLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
-
- Label descTextLabel = new Label(client, SWT.WRAP);
- descTextLabel.setText(Messages.TraceLibraryPathWizard_Message);
- GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd.widthHint = 400;
- gd.horizontalSpan = 2;
- descTextLabel.setLayoutData(gd);
-
- Label noteBoldLabel = new Label(client, SWT.BOLD);
- noteBoldLabel.setText(Messages.TraceLibraryPath_Note);
- noteBoldLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
- Font font = noteBoldLabel.getFont();
- if (font.getFontData().length > 0)
- noteBoldLabel.setFont(new Font(client.getDisplay(), font
- .getFontData()[0].getName(), font.getFontData()[0]
- .getHeight(), SWT.BOLD));
-
- Label noteTextLabel = new Label(client, SWT.WRAP);
- noteTextLabel.setText(Messages.TraceLibraryPath_Message);
- gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
- gd.widthHint = 400;
- gd.horizontalSpan = 2;
- noteTextLabel.setLayoutData(gd);
- setControl(client);
-
- }
-
- public String getPath() {
- if (traceLibraryPath != null && !traceLibraryPath.isDisposed()) {
- String path = traceLibraryPath.getText();
- if (path != null && !path.trim().isEmpty())
- return path;
- }
- return null;
- }
-
- private boolean validatePage() {
- String path = getPath();
- if (path != null) {
- File file = new File(path);
- if (file.exists() && file.isDirectory()) {
- File loaderLib = new File(path,
- System.mapLibraryName(LTTVTRACEREAD_LOADER_LIBNAME));
- if (!loaderLib.exists()) {
- setErrorMessage(Messages.TraceLibraryPathWizardPage_TraceLoaderLibrary_notExists);
- return false;
- }
- } else {
- setErrorMessage(Messages.TraceLibraryPathWizardPage_SpecifiedTraceLibraryLocation_notExists);
- return false;
- }
- }
- setErrorMessage(null);
- return true;
-
- }
-
-}
+++ /dev/null
-AddTraceWizard_invalidTraceLocation=Problem
-AddTraceWizard_windowTitle=Adding traces to experiment
-AddTraceWizardPage_columnHeader=Trace
-AddTraceWizardPage_description=Select the traces to add to the experiment
-AddTraceWizardPage_windowTitle=Select traces
-
-ImportTrace_ErrorTitle=Import Trace
-ImportTrace_InvalidProject=Invalid project type
-
-ImportTraceWizardPage_BadTraceVersion=Error: Unrecognized trace version for
-ImportTraceWizardPage_BadTraceVersionMsg1=Verify that the directory is a valid LTTng trace directory.
-ImportTraceWizardPage_BadTraceVersionMsg2=Make sure the top directory is the trace itself and not any of its parent.
-
-NewProjectWizard_Description=Create an LTTng Project
-NewProjectWizard_Title=LTTng Project
-
-NewExperimentDialog_DialogTitle=New Experiment
-NewExperimentDialog_ExperimentLabel= Experiment name:
-
-TraceErrorDialog_DalogTitle=Trace Selection
-TraceErrorDialog_DialogMsgLabel=Error while opening the trace\! Error message:
-
-TraceLibraryPath_label = Trace Library Path:
-TraceLibraryPath_browseBtn = Browse...
-
-TraceLibraryPathWizardPage_SpecifiedTraceLibraryLocation_notExists = Specified trace library directory does not exist!
-TraceLibraryPathWizardPage_TraceLoaderLibrary_notExists = Trace loader library not found at the specified path!
-TraceLibraryPathWizardPage_Title = LTTng Parsing Library
-TraceLibraryPathWizardPage_Description = Specify the directory which contains the LTTng parsing libraries
-TraceLibraryPathWizard_Message = Set this field if you want to dynamically change the parsing libraries your LTTng projects use or if you do not want to set LD_LIBRARY_PATH.\n\n\
- The field is project specific and can be modified at any time from the LTTng project Properties page.\n\
-
-TraceLibraryPathProperty_Message = Set this field if you want to dynamically change the parsing libraries your LTTng projects use or if you do not want to set LD_LIBRARY_PATH.\n\
-
-TraceLibraryPath_Note = Note:
-TraceLibraryPath_Message = If you set this field, the parser library 'liblttvtraceread_loader.so' must be accessible from the path provided.\n\n\
- In addition, the library 'liblttvtraceread_loader.so' must have 'RUNPATH' set with ${ORIGIN} so it can find the dependent libraries. \
- 'RUNPATH' can be set in the makefile or by using the patchelf utility.
-
-SelectTrace_ErrorTitle = Select Trace
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>CloseProjectHandler</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class CloseProjectHandler implements IHandler {
-
- private LTTngProjectNode fProject = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
-
- // Check if we are closing down
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
- return false;
-
- // Check if we are in the Project View
- IWorkbenchPage page = window.getActivePage();
- if (!(page.getActivePart() instanceof ProjectView))
- return false;
-
- // Check if a project is selected
- ISelection selection = page.getSelection(ProjectView.ID);
- if (selection instanceof StructuredSelection) {
- Object element = ((StructuredSelection) selection).getFirstElement();
- fProject = (element instanceof LTTngProjectNode) ? (LTTngProjectNode) element : null;
- }
- return (fProject != null && fProject.isOpen());
- }
-
- // Handled if we are in the ProjectView
- @Override
- public boolean isHandled() {
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- if (fProject != null) {
- fProject.closeProject();
- fProject.refresh();
- }
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.ILTTngProjectTreeNode;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentNode;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>DeleteExperimentHandler</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class DeleteExperimentHandler implements IHandler {
-
- private LTTngExperimentNode fExperiment = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
-
- // Check if we are closing down
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
- return false;
-
- // Check if a trace is selected
- IWorkbenchPage page = window.getActivePage();
- if (!(page.getActivePart() instanceof ProjectView))
- return false;
-
- // Check if a trace is selected
- ISelection selection = page.getSelection(ProjectView.ID);
- if (selection instanceof StructuredSelection) {
- Object element = ((StructuredSelection) selection).getFirstElement();
- fExperiment = (element instanceof LTTngExperimentNode) ? (LTTngExperimentNode) element : null;
- }
-
- return (fExperiment != null);
- }
-
- // Handled if we are in the ProjectView
- @Override
- public boolean isHandled() {
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IFolder folder = fExperiment.getFolder();
- ILTTngProjectTreeNode parent = fExperiment.getParent();
- try {
- parent.removeChild(fExperiment);
- parent.refresh();
- folder.delete(true, true, null);
- } catch (CoreException e) {
- e.printStackTrace();
- }
-
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.ILTTngProjectTreeNode;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>DeleteProjectHandler</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class DeleteProjectHandler implements IHandler {
-
- private LTTngProjectNode fProject = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
-
- // Check if we are closing down
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
- return false;
-
- // Check if we are in the Project View
- IWorkbenchPage page = window.getActivePage();
- if (!(page.getActivePart() instanceof ProjectView))
- return false;
-
- // Check if a project is selected
- ISelection selection = page.getSelection(ProjectView.ID);
- if (selection instanceof StructuredSelection) {
- Object element = ((StructuredSelection) selection).getFirstElement();
- fProject = (element instanceof LTTngProjectNode) ? (LTTngProjectNode) element : null;
- }
- return (fProject != null);
- }
-
- // Handled if we are in the ProjectView
- @Override
- public boolean isHandled() {
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IProject project = fProject.getProject();
- ILTTngProjectTreeNode parent = fProject.getParent();
- try {
- parent.removeChild(fProject);
- parent.refresh();
- project.delete(true, true, null);
- } catch (CoreException e) {
- e.printStackTrace();
- }
-
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.ILTTngProjectTreeNode;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceNode;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>DeleteTraceHandler</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class DeleteTraceHandler implements IHandler {
-
- private LTTngTraceNode fTrace = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
-
- // Check if we are closing down
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
- return false;
-
- // Check if a trace is selected
- IWorkbenchPage page = window.getActivePage();
- if (!(page.getActivePart() instanceof ProjectView))
- return false;
-
- // Check if a trace is selected
- ISelection selection = page.getSelection(ProjectView.ID);
- if (selection instanceof StructuredSelection) {
- Object element = ((StructuredSelection) selection).getFirstElement();
- fTrace = (element instanceof LTTngTraceNode) ? (LTTngTraceNode) element : null;
- }
-
- return (fTrace != null);
- }
-
- // Handled if we are in the ProjectView
- @Override
- public boolean isHandled() {
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IFolder folder = fTrace.getFolder();
- ILTTngProjectTreeNode parent = fTrace.getParent();
- try {
- parent.removeChild(fTrace);
- parent.refresh();
- folder.delete(true, true, null);
- } catch (CoreException e) {
- e.printStackTrace();
- }
-
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView;
-import org.eclipse.linuxtools.lttng.ui.views.project.dialogs.ImportTraceWizard;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.ILTTngProjectTreeNode;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>ImportTraceHandler</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class ImportTraceHandler implements IHandler {
-
- private LTTngProjectNode fProject = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
-
- // Check if we are closing down
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
- return false;
-
- // Check if we are in the Project View
- IWorkbenchPage page = window.getActivePage();
- if (!(page.getActivePart() instanceof ProjectView))
- return false;
-
- // Check if a project is selected
- ISelection selection = page.getSelection(ProjectView.ID);
- if (selection instanceof StructuredSelection) {
- Object element = ((StructuredSelection) selection).getFirstElement();
- if (element instanceof ILTTngProjectTreeNode) {
- ILTTngProjectTreeNode node = (ILTTngProjectTreeNode) element;
- while (node != null && !(node instanceof LTTngProjectNode)) {
- node = node.getParent();
- }
- fProject = (node instanceof LTTngProjectNode) ? (LTTngProjectNode) node : null;
- }
- }
-
- return (fProject != null && fProject.isOpen() && fProject.isLTTngProject());
- }
-
- // Always handled
- @Override
- public boolean isHandled() {
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- // Set the selection to the project
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- ProjectView view = (ProjectView) page.getActivePart();
- view.setSelection(fProject);
-
- // Fire the Import Trace Wizard
- IWorkbench workbench = PlatformUI.getWorkbench();
- Shell shell = workbench.getActiveWorkbenchWindow().getShell();
-
- ImportTraceWizard wizard = new ImportTraceWizard();
- wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(fProject));
- WizardDialog dialog = new WizardDialog(shell, wizard);
- dialog.open();
-
- if (dialog.getReturnCode() == Window.OK && fProject != null) {
- fProject.refreshChildren();
- fProject.refresh();
- }
-
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView;
-import org.eclipse.linuxtools.lttng.ui.views.project.dialogs.NewExperimentDialog;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.ILTTngProjectTreeNode;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentFolderNode;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>NewExperimentHandler</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class NewExperimentHandler implements IHandler {
-
- private LTTngProjectNode fProject = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
-
- // Check if we are closing down
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
- return false;
-
- // Check if we are in the Project View
- IWorkbenchPage page = window.getActivePage();
- if (!(page.getActivePart() instanceof ProjectView))
- return false;
-
- // Check if a project is selected
- ISelection selection = page.getSelection(ProjectView.ID);
- if (selection instanceof StructuredSelection) {
- Object element = ((StructuredSelection) selection).getFirstElement();
- if (element instanceof ILTTngProjectTreeNode) {
- ILTTngProjectTreeNode node = (ILTTngProjectTreeNode) element;
- while (node != null && !(node instanceof LTTngProjectNode)) {
- node = node.getParent();
- }
- fProject = (node instanceof LTTngProjectNode) ? (LTTngProjectNode) node : null;
- }
- }
-
- return (fProject != null && fProject.isOpen() && fProject.isLTTngProject());
- }
-
- // Handled if we are in the ProjectView
- @Override
- public boolean isHandled() {
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- // Open the experiment creation dialog
- LTTngExperimentFolderNode experimentFolder = fProject.getExperimentsFolder();
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- NewExperimentDialog dialog = new NewExperimentDialog(shell, experimentFolder);
- dialog.open();
-
- if (dialog.getReturnCode() == Window.OK) {
- Object[] experiments = dialog.getResult();
- if (experiments[0] instanceof IFolder) {
- experimentFolder.addExperiment((IFolder) experiments[0]);
- }
- }
-
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView;
-import org.eclipse.linuxtools.lttng.ui.views.project.dialogs.NewLTTngProjectWizard;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectRoot;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>NewProjectHandler</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class NewProjectHandler implements IHandler {
-
- private LTTngProjectRoot fProjectRoot = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
-
- // Check if we are closing down
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
- return false;
-
- // Check if we are in the Project View
- IWorkbenchPart part = window.getActivePage().getActivePart();
- if (!(part instanceof ProjectView))
- return false;
-
- fProjectRoot = ((ProjectView) part).getRoot();
-
- return (fProjectRoot != null);
- }
-
- // Always handled
- @Override
- public boolean isHandled() {
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- // Fire the New Project Wizard
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- NewLTTngProjectWizard wizard = new NewLTTngProjectWizard();
- WizardDialog dialog = new WizardDialog(shell, wizard);
- dialog.open();
-
- // Update the project model
- if (dialog.getReturnCode() == Window.OK) {
- IProject project = wizard.getProject();
- if (project != null && fProjectRoot != null) {
- fProjectRoot.refreshChildren();
- fProjectRoot.refresh();
- }
- }
-
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentNode;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>OpenExperimentHandler</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class OpenExperimentHandler implements IHandler {
-
- private LTTngExperimentNode fExperiment = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
- // Check if we are closing down
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
- return false;
-
- // Check if a trace is selected
- IWorkbenchPage page = window.getActivePage();
- if (!(page.getActivePart() instanceof ProjectView))
- return false;
-
- // Check if a trace is selected
- ISelection selection = page.getSelection(ProjectView.ID);
- if (selection instanceof StructuredSelection) {
- Object element = ((StructuredSelection) selection).getFirstElement();
- fExperiment = (element instanceof LTTngExperimentNode) ? (LTTngExperimentNode) element : null;
- }
-
- return (fExperiment != null);
- }
-
- // Handled if we are in the ProjectView
- @Override
- public boolean isHandled() {
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- // Set the selection to the project
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- ProjectView projectView = (ProjectView) page.getActivePart();
-
- if (projectView != null) {
- projectView.selectExperiment(fExperiment);
- }
-
- return null;
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
-
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>OpenProjectHandler</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class OpenProjectHandler implements IHandler {
-
- private LTTngProjectNode fProject = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
-
- // Check if we are closing down
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
- return false;
-
- // Check if we are in the Project View
- IWorkbenchPage page = window.getActivePage();
- if (!(page.getActivePart() instanceof ProjectView))
- return false;
-
- // Check if a project is selected
- ISelection selection = page.getSelection(ProjectView.ID);
- if (selection instanceof StructuredSelection) {
- Object element = ((StructuredSelection) selection).getFirstElement();
- fProject = (element instanceof LTTngProjectNode) ? (LTTngProjectNode) element : null;
- }
- return (fProject != null && !fProject.isOpen());
- }
-
- // Handled if we are in the ProjectView
- @Override
- public boolean isHandled() {
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- if (fProject != null) {
- fProject.openProject();
- fProject.refresh();
- }
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceNode;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>OpenTraceHandler</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class OpenTraceHandler implements IHandler {
-
- private LTTngTraceNode fTrace = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
- return (fTrace != null);
- }
-
- // Handled if we are in the ProjectView
- @Override
- public boolean isHandled() {
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
- mb.setText("Open Trace"); //$NON-NLS-1$
- mb.setMessage("Not implemented yet"); //$NON-NLS-1$
- mb.open();
-
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2011 MontaVista Software
- *
- * 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:
- * Yufen Kuo (ykuo@mvista.com) - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.IShellProvider;
-import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchCommandConstants;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.PropertyDialogAction;
-
-/**
- * <b><u>ProjectPropertyHandler</u></b>
- * <p>
- *
- */
-public class ProjectPropertyHandler implements IHandler {
-
- private IProject project = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
-
- // Check if we are closing down
- IWorkbenchWindow window = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow();
- if (window == null)
- return false;
- project = null;
- // Check if we can find the project model root node
- ISelection selection = window.getActivePage().getSelection(
- ProjectView.ID);
- if (selection instanceof StructuredSelection) {
- Object element = ((StructuredSelection) selection)
- .getFirstElement();
- if (element instanceof LTTngProjectNode) {
- LTTngProjectNode node = (LTTngProjectNode) element;
- if (node != null) {
- project = node.getProject();
- }
-
- }
- }
-
- return (project != null);
- }
-
- // Handled if we are in the ProjectView
- @Override
- public boolean isHandled() {
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- if (project != null) {
- PropertyDialogAction propertyAction = new PropertyDialogAction(
- new IShellProvider() {
- public Shell getShell() {
- return PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell();
- }
- }, new ISelectionProvider() {
- public void addSelectionChangedListener(
- ISelectionChangedListener listener) {
- }
-
- public ISelection getSelection() {
- return new StructuredSelection(project);
- }
-
- public void removeSelectionChangedListener(
- ISelectionChangedListener listener) {
- }
-
- public void setSelection(ISelection selection) {
- }
- });
- propertyAction
- .setActionDefinitionId(IWorkbenchCommandConstants.FILE_PROPERTIES);
- propertyAction.run();
- }
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.ILTTngProjectTreeNode;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectRoot;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>RefreshHandler</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class RefreshHandler implements IHandler {
-
- private LTTngProjectRoot fProjectRoot = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
-
- // Check if we are closing down
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
- return false;
-
- // Check if we can find the project model root node
- ISelection selection = window.getActivePage().getSelection(ProjectView.ID);
- if (selection instanceof StructuredSelection) {
- Object element = ((StructuredSelection) selection).getFirstElement();
- if (element instanceof ILTTngProjectTreeNode) {
- ILTTngProjectTreeNode node = (ILTTngProjectTreeNode) element;
- while (node != null && !(node instanceof LTTngProjectRoot)) {
- node = node.getParent();
- }
- fProjectRoot = (node instanceof LTTngProjectRoot) ? (LTTngProjectRoot) node : null;
- }
- }
-
- return (fProjectRoot != null);
- }
-
- // Handled if we are in the ProjectView
- @Override
- public boolean isHandled() {
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- if (fProjectRoot != null) {
- fProjectRoot.refreshChildren();
- fProjectRoot.refresh();
- }
-
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentNode;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>RenameExperimentHandler</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class RenameExperimentHandler implements IHandler {
-
- private LTTngExperimentNode fExperiment = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
- return (fExperiment != null);
- }
-
- // Handled if we are in the ProjectView
- @Override
- public boolean isHandled() {
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
- mb.setText("Rename Experiment"); //$NON-NLS-1$
- mb.setMessage("Not implemented yet"); //$NON-NLS-1$
- mb.open();
-
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>RenameProjectHandler</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class RenameProjectHandler implements IHandler {
-
- private LTTngProjectNode fProject = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
-
-// // Check if we are closing down
-// IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-// if (window == null)
-// return false;
-//
-// // Check if we are in the Project View
-// IWorkbenchPage page = window.getActivePage();
-// if (!(page.getActivePart() instanceof ProjectView))
-// return false;
-//
-// // Check if a project is selected
-// ISelection selection = page.getSelection(ProjectView.ID);
-// if (selection instanceof StructuredSelection) {
-// Object element = ((StructuredSelection) selection).getFirstElement();
-// fProjectNode = (element instanceof LTTngProjectNode) ? (LTTngProjectNode) element : null;
-// }
-
- return (fProject != null);
- }
-
- // Handled if we are in the ProjectView
- @Override
- public boolean isHandled() {
- return false;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
- mb.setText("Rename Project"); //$NON-NLS-1$
- mb.setMessage("Not implemented yet"); //$NON-NLS-1$
- mb.open();
-
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceNode;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>RenameTraceHandler</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class RenameTraceHandler implements IHandler {
-
- private LTTngTraceNode fTrace = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
- return (fTrace != null);
- }
-
- // Handled if we are in the ProjectView
- @Override
- public boolean isHandled() {
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
- mb.setText("Rename Trace"); //$NON-NLS-1$
- mb.setMessage("Not implemented yet"); //$NON-NLS-1$
- mb.open();
-
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView;
-import org.eclipse.linuxtools.lttng.ui.views.project.dialogs.AddTraceWizard;
-import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentNode;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>SelectTracesHandler</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class SelectTracesHandler implements IHandler {
-
- private LTTngExperimentNode fExperiment = null;
-
- // ------------------------------------------------------------------------
- // Validation
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isEnabled() {
-
- // Check if we are closing down
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
- return false;
-
- // Check if we are in the Project View
- IWorkbenchPage page = window.getActivePage();
- if (!(page.getActivePart() instanceof ProjectView))
- return false;
-
- // Check that an experiment is selected
- ISelection selection = page.getSelection(ProjectView.ID);
- if (selection instanceof StructuredSelection) {
- Object element = ((StructuredSelection) selection).getFirstElement();
- fExperiment = (element instanceof LTTngExperimentNode) ? (LTTngExperimentNode) element : null;
- }
-
- return (fExperiment != null);
- }
-
- // Handled if we are in the ProjectView
- @Override
- public boolean isHandled() {
- return true;
- }
-
- // ------------------------------------------------------------------------
- // Execution
- // ------------------------------------------------------------------------
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- // Open the trace addition wizard
- IWorkbench workbench = PlatformUI.getWorkbench();
- Shell shell = workbench.getActiveWorkbenchWindow().getShell();
-
- AddTraceWizard wizard = new AddTraceWizard(fExperiment.getProject(), fExperiment);
- wizard.init(PlatformUI.getWorkbench(), null);
- WizardDialog dialog = new WizardDialog(shell, wizard);
- dialog.open();
-
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- // ------------------------------------------------------------------------
- // IHandlerListener
- // ------------------------------------------------------------------------
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * William Bourque - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.linuxtools.lttng.ui.views.project.dialogs.TraceErrorDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PlatformUI;
-
-
-public class TraceErrorHandler implements IHandler {
-
- private String[] messages;
-
- public TraceErrorHandler(String[] newMessages) {
- messages = newMessages;
- }
-
- @Override
- public boolean isEnabled() {
- return true;
- }
-
- @Override
- public boolean isHandled() {
- return true;
- }
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbench workbench = PlatformUI.getWorkbench();
- Shell shell = workbench.getActiveWorkbenchWindow().getShell();
-
- TraceErrorDialog dialog = new TraceErrorDialog(shell, messages);
- dialog.open();
-
- return null;
- }
-
- @Override
- public void dispose() {
- }
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- }
-
-}
-
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.model;
-
-import java.util.List;
-
-/**
- * <b><u>ILTTngProjectTreeNode</u></b>
- * <p>
- * TODO: Implement me. Please.
- * TODO: Make ILTTngProjectTreeNode extends IAdaptable
- */
-public interface ILTTngProjectTreeNode {
-
- public String getName();
-
- public ILTTngProjectTreeNode getParent();
-
- public boolean hasChildren();
-
- public List<ILTTngProjectTreeNode> getChildren();
-
- public void removeChild(ILTTngProjectTreeNode child);
-
- public void removeChildren();
-
- public void refreshChildren();
-
- public void refresh();
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.model;
-
-import java.lang.reflect.Array;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * <b><u>LTTngExperimentFolderNode</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class LTTngExperimentFolderNode extends LTTngProjectTreeNode {
-
- private final IFolder fExperimentFolder;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- public LTTngExperimentFolderNode(IFolder folder) {
- this(null, folder);
- }
-
- public LTTngExperimentFolderNode(ILTTngProjectTreeNode parent, IFolder folder) {
- super(parent);
- fExperimentFolder = folder;
- }
-
- // ------------------------------------------------------------------------
- // LTTngProjectTreeNode
- // ------------------------------------------------------------------------
-
- @Override
- public String getName() {
- return fExperimentFolder.getName();
- }
-
- @Override
- public void refreshChildren() {
- try {
- IResource[] resources = fExperimentFolder.members();
- for (IResource resource : resources) {
- if (resource instanceof IFolder) {
- LTTngExperimentNode node = find(resource.getName());
- if (node == null) {
- node = new LTTngExperimentNode(this, (IFolder) resource);
- fChildren.add(node);
- }
- }
- }
- for (ILTTngProjectTreeNode node : fChildren) {
- if (exists(node.getName(), resources)) {
- node.refreshChildren();
- }
- else {
- fChildren.remove(node);
- }
- }
- } catch (CoreException e) {
- }
- }
-
- private LTTngExperimentNode find(String name) {
- for (ILTTngProjectTreeNode node : fChildren) {
- if (node instanceof LTTngExperimentNode && node.getName().equals(name)) {
- return (LTTngExperimentNode) node;
- }
- }
- return null;
- }
-
- private boolean exists(String name, IResource[] resources) {
- for (IResource resource : resources) {
- if (resource.getName().equals(name))
- return true;
- }
- return false;
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /**
- * @return
- */
- public LTTngProjectNode getProject() {
- return (LTTngProjectNode) getParent();
- }
-
- /**
- * @return
- */
- public IFolder getFolder() {
- return fExperimentFolder;
- }
-
- /**
- * @return
- */
- public LTTngExperimentNode[] getExperiments() {
- LTTngExperimentNode[] result = (LTTngExperimentNode[]) Array.newInstance(LTTngExperimentNode.class, fChildren.size());
- return fChildren.toArray(result);
- }
-
- // ------------------------------------------------------------------------
- // Modifiers
- // ------------------------------------------------------------------------
-
-// No longer needed: handled by the IResourceChangeListener in the View
- public void addExperiment(IFolder experiment) {
-// LTTngExperimentNode node = new LTTngExperimentNode(this, experiment);
-// fChildren.add(node);
-// refresh();
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.model;
-
-import java.lang.reflect.Array;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * <b><u>LTTngExperimentNode</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class LTTngExperimentNode extends LTTngProjectTreeNode {
-
- private final IFolder fExperiment;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- public LTTngExperimentNode(IFolder resource) {
- this(null, resource);
- }
-
- public LTTngExperimentNode(ILTTngProjectTreeNode parent, IFolder folder) {
- super(parent);
- fExperiment = folder;
- }
-
- // ------------------------------------------------------------------------
- // LTTngProjectTreeNode
- // ------------------------------------------------------------------------
-
- @Override
- public String getName() {
- return fExperiment.getName();
- }
-
- @Override
- public void refreshChildren() {
- try {
- IResource[] resources = fExperiment.members(0);
- for (IResource resource : resources) {
- LTTngTraceNode node = find(resource.getName());
- if (node == null) {
- node = new LTTngTraceNode(this, (IFolder) resource);
- fChildren.add(node);
- }
- }
- for (ILTTngProjectTreeNode node : fChildren) {
- if (!exists(node.getName(), resources)) {
- fChildren.remove(node);
- }
- }
- } catch (CoreException e) {
- }
- }
-
- private LTTngTraceNode find(String name) {
- for (ILTTngProjectTreeNode node : fChildren) {
- if (node instanceof LTTngTraceNode && node.getName().equals(name)) {
- return (LTTngTraceNode) node;
- }
- }
- return null;
- }
-
- private boolean exists(String name, IResource[] resources) {
- for (IResource resource : resources) {
- if (resource.getName().equals(name))
- return true;
- }
- return false;
- }
-
- // ------------------------------------------------------------------------
- // Modifiers
- // ------------------------------------------------------------------------
-
-// No longer needed: handled by the IResourceChangeListener in the View
- public void addTrace(IFolder trace) {
-// LTTngTraceNode node = new LTTngTraceNode(this, trace);
-// fChildren.add(node);
-// refresh();
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /**
- * @return
- */
- public IFolder getFolder() {
- return fExperiment;
- }
-
- /**
- * @return
- */
- public LTTngTraceNode[] getTraces() {
- LTTngTraceNode[] result = (LTTngTraceNode[]) Array.newInstance(LTTngTraceNode.class, fChildren.size());
- return fChildren.toArray(result);
- }
-
- /**
- * @return
- */
- public LTTngProjectNode getProject() {
- return (LTTngProjectNode) getParent().getParent();
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.model;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * <b><u>LTTngProjectContentProvider</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
- public class LTTngProjectContentProvider implements ITreeContentProvider {
-
- @Override
- public Object[] getChildren(Object parentElement) {
- return ((ILTTngProjectTreeNode) parentElement).getChildren().toArray();
- }
-
- @Override
- public Object getParent(Object element) {
- return ((ILTTngProjectTreeNode) element).getParent();
- }
-
- @Override
- public boolean hasChildren(Object element) {
- return ((ILTTngProjectTreeNode) element).hasChildren();
- }
-
- @Override
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof LTTngProjectRoot) {
- return ((LTTngProjectRoot) inputElement).getChildren().toArray();
- }
- return null;
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.model;
-
-import java.net.URL;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>LTTngProjectLabelProvider</u></b>
- * <p>
- * TODO: Implement me. Please.
- * TODO: Find proper icons for traces and experiments
- */
-public class LTTngProjectLabelProvider implements ILabelProvider {
-
- private final String fTraceIconFile = "icons/obj16/garland16.png"; //$NON-NLS-1$
-// private final String fExperimentIconFile = "icons/obj16/garland16.png"; //$NON-NLS-1$
-
- private final Image fOpenedProjectIcon;
- private final Image fClosedProjectIcon;
- private final Image fFolderIcon;
- private final Image fTraceIcon;
- private final Image fExperimentIcon;
-
- /**
- *
- */
- public LTTngProjectLabelProvider() {
-
- fOpenedProjectIcon = PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT);
- fClosedProjectIcon = PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED);
- fFolderIcon = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
-
- fTraceIcon = loadIcon(fTraceIconFile);
- fExperimentIcon = fFolderIcon; // loadIcon(fExperimentIconFile);
- }
-
- private Image loadIcon(String url) {
- LTTngUiPlugin plugin = LTTngUiPlugin.getDefault();
- Image icon = plugin.getImageRegistry().get(url);
- if (icon == null) {
- URL imageURL = plugin.getBundle().getEntry(url);
- ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL);
- icon = descriptor.createImage();
- plugin.getImageRegistry().put(url, icon);
- }
- return icon;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- @Override
- public Image getImage(Object element) {
-
- if (element instanceof LTTngProjectNode) {
- LTTngProjectNode project = (LTTngProjectNode) element;
- return (project.isOpen()) ? fOpenedProjectIcon : fClosedProjectIcon;
- }
-
- if (element instanceof LTTngTraceFolderNode) {
- return fFolderIcon;
- }
-
- if (element instanceof LTTngTraceNode) {
- return fTraceIcon;
- }
-
- if (element instanceof LTTngExperimentFolderNode) {
- return fFolderIcon;
- }
-
- if (element instanceof LTTngExperimentNode) {
- return fExperimentIcon;
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- @Override
- public String getText(Object element) {
- ILTTngProjectTreeNode node = (ILTTngProjectTreeNode) element;
- String label = node.getName();
- if (node instanceof LTTngTraceFolderNode ||
- node instanceof LTTngExperimentFolderNode ||
- node instanceof LTTngExperimentNode)
- {
- label += " [" + node.getChildren().size() + "]"; //$NON-NLS-1$//$NON-NLS-2$
- }
- return label;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
- */
- @Override
- public void addListener(ILabelProviderListener listener) {
- // TODO Auto-generated method stub
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
- */
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
- */
- @Override
- public boolean isLabelProperty(Object element, String property) {
- // TODO Auto-generated method stub
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
- */
- @Override
- public void removeListener(ILabelProviderListener listener) {
- // TODO Auto-generated method stub
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010, 2011 Ericsson, MontaVista Software
- *
- * 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:
- * Francois Chouinard - Initial API and implementation
- * Yufen Kuo (ykuo@mvista.com) - bug 354541: implement IAdaptable Project->Properties action is enabled when project is selected.
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.linuxtools.lttng.core.LTTngProjectNature;
-
-/**
- * <b><u>LTTngProjectNode</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class LTTngProjectNode extends LTTngProjectTreeNode implements IAdaptable {
-
- public static final String TRACE_FOLDER_NAME = "Traces"; //$NON-NLS-1$
- public static final String EXPER_FOLDER_NAME = "Experiments"; //$NON-NLS-1$
-
- private final IProject fProject;
- private boolean fIsLTTngProject;
- private boolean fIsOpen;
- private LTTngTraceFolderNode fTracesFolder;
- private LTTngExperimentFolderNode fExperimentsFolder;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- public LTTngProjectNode(IProject project) {
- this(null, project);
- }
-
- public LTTngProjectNode(ILTTngProjectTreeNode parent, IProject project) {
- super(parent);
- fProject = project;
- updateState();
- }
-
- // ------------------------------------------------------------------------
- // LTTngProjectTreeNode
- // ------------------------------------------------------------------------
-
- @Override
- public String getName() {
- return fProject.getName();
- }
-
- @Override
- public void refreshChildren() {
-
- if (!(fIsOpen && fIsLTTngProject))
- return;
-
- try {
- IResource[] resources = fProject.members();
- for (IResource resource : resources) {
- if (resource.getType() == IResource.FOLDER) {
- String name = resource.getName();
- if (name.equals(TRACE_FOLDER_NAME) && !isIncluded(true, name, fChildren)) {
- fTracesFolder = new LTTngTraceFolderNode(this, (IFolder) resource);
- fChildren.add(fTracesFolder);
- } else
- if (name.equals(EXPER_FOLDER_NAME) && !isIncluded(false, name, fChildren)) {
- fExperimentsFolder = new LTTngExperimentFolderNode(this, (IFolder) resource);
- fChildren.add(fExperimentsFolder);
- }
- }
- }
- List<ILTTngProjectTreeNode> toRemove = new ArrayList<ILTTngProjectTreeNode>();
- for (ILTTngProjectTreeNode node : fChildren) {
- if (exists(node.getName(), resources)) {
- node.refreshChildren();
- }
- else {
- toRemove.add(node);
- }
- }
- for (ILTTngProjectTreeNode node : toRemove) {
- fChildren.remove(node);
- }
-
- } catch (CoreException e) {
- }
- }
-
- private boolean isIncluded(boolean isTraces, String name, List<ILTTngProjectTreeNode> list) {
- boolean found = false;
- for (ILTTngProjectTreeNode node : list) {
- if (node instanceof LTTngTraceFolderNode && isTraces) {
- found |= node.getName().equals(name);
- } else
- if (node instanceof LTTngExperimentFolderNode && !isTraces) {
- found |= node.getName().equals(name);
- }
- }
- return found;
- }
-
- private boolean exists(String name, IResource[] resources) {
- for (IResource resource : resources) {
- if (resource.getName().equals(name))
- return true;
- }
- return false;
- }
-
- // ------------------------------------------------------------------------
- // Modifiers
- // ------------------------------------------------------------------------
-
- public void openProject() {
- try {
- fProject.open(null);
- updateState();
- refreshChildren();
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
-
- public void closeProject() {
- try {
- fProject.close(null);
- updateState();
- removeChildren();
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
-
- private boolean isLTTngProject(IProject project) {
- boolean result = false;
- if (project != null && project.isAccessible()) {
- try {
- result = project.hasNature(LTTngProjectNature.ID);
- } catch (CoreException e) {
- }
- }
- return result;
- }
-
- public void updateState() {
- fIsOpen = (fProject != null) ? fProject.isAccessible() : false;
- fIsLTTngProject = isLTTngProject(fProject);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /**
- * @return
- */
- public boolean isLTTngProject() {
- return fIsLTTngProject;
- }
-
- /**
- * @return
- */
- public boolean isOpen() {
- return fIsOpen;
- }
-
- /**
- * @return
- */
- public IProject getProject() {
- return fProject;
- }
-
- /**
- * @return
- */
- public LTTngTraceFolderNode getTracesFolder() {
- return fTracesFolder;
- }
-
- /**
- * @return
- */
- public LTTngExperimentFolderNode getExperimentsFolder() {
- return fExperimentsFolder;
- }
-
- /**
- * Returns the adapter
- */
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class adapter) {
- if (adapter == IResource.class) {
- return getProject();
- }
- // Defer to the platform
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView;
-
-/**
- * <b><u>LTTngProjectRoot</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class LTTngProjectRoot extends LTTngProjectTreeNode {
-
- private final ProjectView fView;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- public LTTngProjectRoot(ProjectView view) {
- super(null);
- fView = view;
- refreshChildren();
- }
-
- @Override
- public void refresh() {
- fView.refresh();
- }
-
- // ------------------------------------------------------------------------
- // LTTngProjectTreeNode
- // ------------------------------------------------------------------------
-
- @Override
- public String getName() {
- return null;
- }
-
- @Override
- public void refreshChildren() {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IProject[] projects = root.getProjects();
- for (IProject project : projects) {
- LTTngProjectNode node = find(project.getName());
- if (node == null) {
- node = new LTTngProjectNode(this, project);
- fChildren.add(node);
- } else {
- node.updateState();
- }
- }
- List<ILTTngProjectTreeNode> toRemove = new ArrayList<ILTTngProjectTreeNode>();
- for (ILTTngProjectTreeNode node : fChildren) {
- if (exists(node.getName(), projects)) {
- node.refreshChildren();
- }
- else {
- toRemove.add(node);
- }
- }
- for (ILTTngProjectTreeNode node : toRemove) {
- fChildren.remove(node);
- }
- }
-
- private LTTngProjectNode find(String name) {
- for (ILTTngProjectTreeNode node : fChildren) {
- if (node instanceof LTTngProjectNode && node.getName().equals(name)) {
- return (LTTngProjectNode) node;
- }
- }
- return null;
- }
-
- private boolean exists(String name, IProject[] projects) {
- for (IProject project : projects) {
- if (project.getName().equals(name))
- return true;
- }
- return false;
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * <b><u>LTTngProjectTreeNode</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public abstract class LTTngProjectTreeNode implements ILTTngProjectTreeNode {
-
- protected ILTTngProjectTreeNode fParent = null;
- protected List<ILTTngProjectTreeNode> fChildren = null;
-
- // ------------------------------------------------------------------------
- // Constructor
- // ------------------------------------------------------------------------
-
- public LTTngProjectTreeNode(ILTTngProjectTreeNode parent) {
- fParent = parent;
- fChildren = new ArrayList<ILTTngProjectTreeNode>();
- }
-
- @Override
- public String toString() {
- return getName();
- }
-
- // ------------------------------------------------------------------------
- // ILTTngProjectTreeNode
- // ------------------------------------------------------------------------
-
- @Override
- public ILTTngProjectTreeNode getParent() {
- return fParent;
- }
-
- @Override
- public boolean hasChildren() {
- return fChildren.size() > 0;
- }
-
- @Override
- public List<ILTTngProjectTreeNode> getChildren() {
- return fChildren;
- }
-
- @Override
- public abstract void refreshChildren();
-
- @Override
- public void refresh() {
- fParent.refresh();
- }
-
- @Override
- public void removeChild(ILTTngProjectTreeNode child) {
- for (ILTTngProjectTreeNode node : fChildren) {
- if (node == child) {
- node.removeChildren();
- // We can do it since we are returning right away
- fChildren.remove(node);
- return;
- }
- }
- }
-
- @Override
- public void removeChildren() {
- for (ILTTngProjectTreeNode node : fChildren) {
- node.removeChildren();
- }
- fChildren.clear();
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.model;
-
-import java.lang.reflect.Array;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * <b><u>LTTngTraceFolderNode</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class LTTngTraceFolderNode extends LTTngProjectTreeNode {
-
- private final IFolder fTraceFolder;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- public LTTngTraceFolderNode(IFolder folder) {
- this(null, folder);
- }
-
- public LTTngTraceFolderNode(ILTTngProjectTreeNode parent, IFolder folder) {
- super(parent);
- fTraceFolder = folder;
- }
-
- // ------------------------------------------------------------------------
- // LTTngProjectTreeNode
- // ------------------------------------------------------------------------
-
- @Override
- public String getName() {
- return fTraceFolder.getName();
- }
-
- @Override
- public void refreshChildren() {
- try {
- IResource[] resources = fTraceFolder.members();
- for (IResource resource : resources) {
- if (resource instanceof IFolder) {
- LTTngTraceNode node = find(resource.getName());
- if (node == null) {
- node = new LTTngTraceNode(this, (IFolder) resource);
- fChildren.add(node);
- }
- }
- }
- for (ILTTngProjectTreeNode node : fChildren) {
- if (!exists(node.getName(), resources)) {
- fChildren.remove(node);
- }
- }
- } catch (CoreException e) {
- }
- }
-
- private LTTngTraceNode find(String name) {
- for (ILTTngProjectTreeNode node : fChildren) {
- if (node instanceof LTTngTraceNode && node.getName().equals(name)) {
- return (LTTngTraceNode) node;
- }
- }
- return null;
- }
-
- private boolean exists(String name, IResource[] resources) {
- for (IResource resource : resources) {
- if (resource.getName().equals(name))
- return true;
- }
- return false;
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /**
- * @return
- */
- public LTTngProjectNode getProject() {
- return (LTTngProjectNode) getParent();
- }
-
- /**
- * @return
- */
- public IFolder getFolder() {
- return fTraceFolder;
- }
-
- /**
- * @return
- */
- public LTTngTraceNode[] getTraces() {
- LTTngTraceNode[] result = (LTTngTraceNode[]) Array.newInstance(LTTngTraceNode.class, fChildren.size());
- return fChildren.toArray(result);
- }
-
- // ------------------------------------------------------------------------
- // Modifiers
- // ------------------------------------------------------------------------
-
-// No longer needed: handled by the IResourceChangeListener in the View
- public void addTrace(IFolder trace) {
-// LTTngTraceNode node = new LTTngTraceNode(this, trace);
-// fChildren.add(node);
-// refresh();
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.ui.views.project.model;
-
-import org.eclipse.core.resources.IFolder;
-
-/**
- * <b><u>LTTngTraceNode</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class LTTngTraceNode extends LTTngProjectTreeNode {
-
- private final IFolder fTrace;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- public LTTngTraceNode(IFolder folder) {
- this(null, folder);
- }
-
- public LTTngTraceNode(ILTTngProjectTreeNode parent, IFolder trace) {
- super(parent);
- fTrace = trace;
- }
-
- // ------------------------------------------------------------------------
- // LTTngProjectTreeNode
- // ------------------------------------------------------------------------
-
- @Override
- public String getName() {
- return fTrace.getName();
- }
-
- @Override
- public void refreshChildren() {
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /**
- * @return
- */
- public LTTngProjectNode getProject() {
- ILTTngProjectTreeNode projectNode = null;
- ILTTngProjectTreeNode parent = getParent();
- if (parent instanceof LTTngTraceFolderNode) {
- projectNode = parent.getParent();
- }
- else if (parent instanceof LTTngExperimentNode) {
- projectNode = parent.getParent().getParent();
- }
-
- return (LTTngProjectNode) projectNode;
- }
-
- /**
- * @return
- */
- public IFolder getFolder() {
- return fTrace;
- }
-
-}