/** Constructs the import trace package wizard */
 public ImportTracePackageWizard() {
   IDialogSettings workbenchSettings = Activator.getDefault().getDialogSettings();
   IDialogSettings section = workbenchSettings.getSection(STORE_IMPORT_TRACE_PKG_WIZARD);
   if (section == null) {
     section = workbenchSettings.addNewSection(STORE_IMPORT_TRACE_PKG_WIZARD);
   }
   setDialogSettings(section);
 }
Esempio n. 2
0
 /**
  * Get the events table for an experiment. If all traces in the experiment are of the same type,
  * use the extension point specified event table
  *
  * @param experiment the experiment
  * @param parent the parent Composite
  * @param cacheSize the event table cache size
  * @return an events table of the appropriate type
  */
 private static TmfEventsTable getExperimentEventsTable(
     final TmfExperiment experiment, final Composite parent, final int cacheSize) {
   TmfEventsTable eventsTable = null;
   String commonTraceType = null;
   try {
     for (final ITmfTrace trace : experiment.getTraces()) {
       final IResource resource = trace.getResource();
       if (resource == null) {
         return null;
       }
       final String traceType = resource.getPersistentProperty(TmfCommonConstants.TRACETYPE);
       if ((commonTraceType != null) && !commonTraceType.equals(traceType)) {
         return null;
       }
       commonTraceType = traceType;
     }
     if (commonTraceType == null) {
       return null;
     }
     if (commonTraceType.startsWith(CustomTxtTrace.class.getCanonicalName())) {
       return new CustomEventsTable(
           ((CustomTxtTrace) experiment.getTraces()[0]).getDefinition(), parent, cacheSize);
     }
     if (commonTraceType.startsWith(CustomXmlTrace.class.getCanonicalName())) {
       return new CustomEventsTable(
           ((CustomXmlTrace) experiment.getTraces()[0]).getDefinition(), parent, cacheSize);
     }
     for (final IConfigurationElement ce :
         TmfTraceTypeUIUtils.getTypeUIElements(TraceElementType.TRACE)) {
       if (ce.getAttribute(TmfTraceTypeUIUtils.TRACETYPE_ATTR).equals(commonTraceType)) {
         final IConfigurationElement[] eventsTableTypeCE =
             ce.getChildren(TmfTraceTypeUIUtils.EVENTS_TABLE_TYPE_ELEM);
         if (eventsTableTypeCE.length != 1) {
           break;
         }
         final String eventsTableType =
             eventsTableTypeCE[0].getAttribute(TmfTraceTypeUIUtils.CLASS_ATTR);
         if ((eventsTableType == null) || (eventsTableType.length() == 0)) {
           break;
         }
         final Bundle bundle = Platform.getBundle(ce.getContributor().getName());
         final Class<?> c = bundle.loadClass(eventsTableType);
         final Class<?>[] constructorArgs = new Class[] {Composite.class, int.class};
         final Constructor<?> constructor = c.getConstructor(constructorArgs);
         final Object[] args = new Object[] {parent, cacheSize};
         eventsTable = (TmfEventsTable) constructor.newInstance(args);
         break;
       }
     }
   } catch (final CoreException e) {
     Activator.getDefault()
         .logError("Error getting TmfEventsTable for experiment", e); // $NON-NLS-1$
   } catch (final InvalidRegistryObjectException e) {
     Activator.getDefault()
         .logError("Error getting TmfEventsTable for experiment", e); // $NON-NLS-1$
   } catch (final SecurityException e) {
     Activator.getDefault()
         .logError("Error getting TmfEventsTable for experiment", e); // $NON-NLS-1$
   } catch (final IllegalArgumentException e) {
     Activator.getDefault()
         .logError("Error getting TmfEventsTable for experiment", e); // $NON-NLS-1$
   } catch (final ClassNotFoundException e) {
     Activator.getDefault()
         .logError("Error getting TmfEventsTable for experiment", e); // $NON-NLS-1$
   } catch (final NoSuchMethodException e) {
     Activator.getDefault()
         .logError("Error getting TmfEventsTable for experiment", e); // $NON-NLS-1$
   } catch (final InstantiationException e) {
     Activator.getDefault()
         .logError("Error getting TmfEventsTable for experiment", e); // $NON-NLS-1$
   } catch (final IllegalAccessException e) {
     Activator.getDefault()
         .logError("Error getting TmfEventsTable for experiment", e); // $NON-NLS-1$
   } catch (final InvocationTargetException e) {
     Activator.getDefault()
         .logError("Error getting TmfEventsTable for experiment", e); // $NON-NLS-1$
   }
   return eventsTable;
 }
Esempio n. 3
0
 @Override
 public void init(final IEditorSite site, IEditorInput input) throws PartInitException {
   IFileEditorInput fileEditorInput;
   if (input instanceof TmfEditorInput) {
     fFile = ((TmfEditorInput) input).getFile();
     fTrace = ((TmfEditorInput) input).getTrace();
     /* change the input to a FileEditorInput to allow open handlers to find this editor */
     fileEditorInput = new FileEditorInput(fFile);
   } else if (input instanceof IFileEditorInput) {
     fileEditorInput = (IFileEditorInput) input;
     fFile = fileEditorInput.getFile();
     if (fFile == null) {
       throw new PartInitException("Invalid IFileEditorInput: " + fileEditorInput); // $NON-NLS-1$
     }
     try {
       final String traceTypeId = fFile.getPersistentProperty(TmfCommonConstants.TRACETYPE);
       if (traceTypeId == null) {
         throw new PartInitException(Messages.TmfOpenTraceHelper_NoTraceType);
       }
       if (traceTypeId.equals(TmfExperiment.class.getCanonicalName())) {
         // Special case: experiment bookmark resource
         final TmfProjectElement project = TmfProjectRegistry.getProject(fFile.getProject(), true);
         if (project == null) {
           throw new PartInitException(Messages.TmfOpenTraceHelper_NoTraceType);
         }
         for (final TmfExperimentElement experimentElement :
             project.getExperimentsFolder().getExperiments()) {
           if (experimentElement.getResource().equals(fFile.getParent())) {
             setPartName(experimentElement.getName());
             super.setSite(site);
             super.setInput(fileEditorInput);
             TmfOpenTraceHelper.reopenTraceFromElement(experimentElement, this);
             return;
           }
         }
       } else if (traceTypeId.equals(TmfTrace.class.getCanonicalName())) {
         // Special case: trace bookmark resource
         final TmfProjectElement project = TmfProjectRegistry.getProject(fFile.getProject(), true);
         for (final TmfTraceElement traceElement : project.getTracesFolder().getTraces()) {
           if (traceElement.getResource().equals(fFile.getParent())) {
             setPartName(traceElement.getName());
             super.setSite(site);
             super.setInput(fileEditorInput);
             TmfOpenTraceHelper.reopenTraceFromElement(traceElement, this);
             return;
           }
         }
       } else {
         final TmfProjectElement project = TmfProjectRegistry.getProject(fFile.getProject(), true);
         for (final TmfTraceElement traceElement : project.getTracesFolder().getTraces()) {
           if (traceElement.getResource().equals(fFile)) {
             setPartName(traceElement.getName());
             super.setSite(site);
             super.setInput(fileEditorInput);
             TmfOpenTraceHelper.reopenTraceFromElement(traceElement, this);
             return;
           }
         }
       }
     } catch (final PartInitException e) {
       throw e;
     } catch (final InvalidRegistryObjectException e) {
       Activator.getDefault().logError("Error initializing TmfEventsEditor", e); // $NON-NLS-1$
     } catch (final CoreException e) {
       Activator.getDefault().logError("Error initializing TmfEventsEditor", e); // $NON-NLS-1$
     }
   } else {
     throw new PartInitException("Invalid IEditorInput: " + input.getClass()); // $NON-NLS-1$
   }
   if (fTrace == null) {
     throw new PartInitException("Invalid IEditorInput: " + fFile.getName()); // $NON-NLS-1$
   }
   super.setSite(site);
   super.setInput(fileEditorInput);
 }