Java Code Examples for org.eclipse.core.runtime.Platform

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial.extension.ui/src/org/eclipse/acceleo/tutorial/extension/ui/common/.

Source file: GenerateAll.java

  19 
vote

/** 
 * Finds the template in the plug-in. Returns the template plug-in URI.
 * @param bundleID is the plug-in ID
 * @param relativePath is the relative path of the template in the plug-in
 * @return the template URI
 * @throws IOException
 * @generated
 */
@SuppressWarnings("unchecked") private URI getTemplateURI(String bundleID,IPath relativePath) throws IOException {
  Bundle bundle=Platform.getBundle(bundleID);
  if (bundle == null) {
    return URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(),false);
  }
  URL url=bundle.getEntry(relativePath.toString());
  if (url == null && relativePath.segmentCount() > 1) {
    Enumeration<URL> entries=bundle.findEntries("/","*.emtl",true);
    if (entries != null) {
      String[] segmentsRelativePath=relativePath.segments();
      while (url == null && entries.hasMoreElements()) {
        URL entry=entries.nextElement();
        IPath path=new Path(entry.getPath());
        if (path.segmentCount() > relativePath.segmentCount()) {
          path=path.removeFirstSegments(path.segmentCount() - relativePath.segmentCount());
        }
        String[] segmentsPath=path.segments();
        boolean equals=segmentsPath.length == segmentsRelativePath.length;
        for (int i=0; equals && i < segmentsPath.length; i++) {
          equals=segmentsPath[i].equals(segmentsRelativePath[i]);
        }
        if (equals) {
          url=bundle.getEntry(entry.getPath());
        }
      }
    }
  }
  URI result;
  if (url != null) {
    result=URI.createPlatformPluginURI(new Path(bundleID).append(new Path(url.getPath())).toString(),false);
  }
 else {
    result=URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(),false);
  }
  return result;
}
 

Example 2

From project adt-cdt, under directory /com.android.ide.eclipse.adt.cdt/src/com/android/ide/eclipse/adt/cdt/internal/build/.

Source file: NDKCommandLauncher.java

  19 
vote

@Override public Process execute(IPath commandPath,String[] args,String[] env,IPath changeToDirectory,IProgressMonitor monitor) throws CoreException {
  if (Platform.getOS().equals(Platform.OS_WIN32) || Platform.getOS().equals(Platform.OS_MACOSX)) {
    String command=commandPath.toString();
    for (    String arg : args)     command+=" " + arg;
    commandPath=new Path("sh");
    args=new String[]{"-c",command};
  }
  return super.execute(commandPath,args,env,changeToDirectory,monitor);
}
 

Example 3

From project Archimedes, under directory /br.org.archimedes.core/src/br/org/archimedes/rcp/.

Source file: ExtensionLoader.java

  19 
vote

public void loadExtension(ExtensionTagHandler handler){
  IExtensionRegistry registry=Platform.getExtensionRegistry();
  if (registry != null) {
    IExtensionPoint extensionPoint=registry.getExtensionPoint(extensionName);
    if (extensionPoint != null) {
      IExtension[] extensions=extensionPoint.getExtensions();
      for (      IExtension extension : extensions) {
        IConfigurationElement[] configElements=extension.getConfigurationElements();
        for (        IConfigurationElement tag : configElements) {
          try {
            handler.handleTag(tag);
          }
 catch (          CoreException e) {
            e.printStackTrace();
          }
        }
      }
    }
  }
}
 

Example 4

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/.

Source file: AwsClientUtils.java

  19 
vote

/** 
 * Forms a user-agent string for clients to send when making service calls, indicating the name and version of this client.
 * @param pluginName The name of the plugin to use in the user agent string.
 * @param plugin The plugin from which to pull version information.
 * @return A user-agent string indicating what client and version areaccessing AWS.
 */
public String formUserAgentString(String pluginName,Plugin plugin){
  String version="???";
  if (plugin != null) {
    Dictionary headers=plugin.getBundle().getHeaders();
    version=(String)headers.get("Bundle-Version");
  }
  String userAgentValue=pluginName + "/" + version;
  Bundle runtimeCore=Platform.getBundle("org.eclipse.core.runtime");
  if (runtimeCore != null) {
    Dictionary headers=runtimeCore.getHeaders();
    version=(String)headers.get("Bundle-Version");
    userAgentValue+=", Eclipse/" + version;
  }
  return userAgentValue;
}
 

Example 5

From project Bio-PEPA, under directory /uk.ac.ed.inf.common/src/uk/ac/ed/inf/common/launching/.

Source file: LaunchingUtils.java

  19 
vote

/** 
 * Gets the absolute path to this file. It changes location if cygwin is needed.
 * @param file
 * @return
 */
private static String getAbsoluteFilename(IFile file){
  IPath location=file.getLocation();
  if (Platform.getOS().equals(Platform.OS_WIN32)) {
    location=location.setDevice("/cygdrive/c:");
    return location.toString().replaceFirst("/cygdrive/c:","/cygdrive/c");
  }
 else {
    return location.toString();
  }
}
 

Example 6

From project bioclipse.opentox, under directory /plugins/net.bioclipse.opentox/src/net/bioclipse/opentox/.

Source file: ServiceReader.java

  19 
vote

public static List<OpenToxService> readServicesFromExtensionPoints(){
  List<OpenToxService> services=new ArrayList<OpenToxService>();
  IExtensionRegistry registry=Platform.getExtensionRegistry();
  if (registry == null)   throw new UnsupportedOperationException("Extension registry is null. " + "Cannot read tests from EP.");
  IExtensionPoint serviceObjectExtensionPoint=registry.getExtensionPoint("net.bioclipse.opentox");
  IExtension[] serviceObjectExtensions=serviceObjectExtensionPoint.getExtensions();
  for (  IExtension extension : serviceObjectExtensions) {
    for (    IConfigurationElement element : extension.getConfigurationElements()) {
      if (element.getName().equals("service")) {
        String pid=element.getAttribute("id");
        String pname=element.getAttribute("name");
        String purl=element.getAttribute("serviceURL");
        if (purl == null)         purl="";
        String pspql=element.getAttribute("serviceSPARQL");
        if (pspql == null)         pspql="";
        OpenToxService service=new OpenToxService(pname,purl,pspql);
        services.add(service);
        logger.debug("Added OT service from EP: " + service);
      }
    }
  }
  return services;
}
 

Example 7

From project bioclipse.seneca, under directory /plugins/net.bioclipse.seneca/src/net/bioclipse/seneca/.

Source file: Activator.java

  19 
vote

public List<IJudge> getJudgeExtensions(){
  if (judgeExtensions == null) {
    judgeExtensions=new ArrayList<IJudge>();
    IExtensionRegistry registry=Platform.getExtensionRegistry();
    IExtensionPoint extensionPoint=registry.getExtensionPoint("net.bioclipse.seneca.SenecaJudge");
    if (extensionPoint == null) {
      logger.error("Could not find Judge extension Point.");
      return judgeExtensions;
    }
    IExtension[] extensions=extensionPoint.getExtensions();
    for (int i=0; i < extensions.length; i++) {
      IConfigurationElement[] configelements=extensions[i].getConfigurationElements();
      for (int j=0; j < configelements.length; j++) {
        IJudge creator=null;
        try {
          creator=(IJudge)configelements[j].createExecutableExtension("class");
        }
 catch (        Exception e) {
          e.printStackTrace();
          logger.debug("Failed to instantiate factory: " + configelements[j].getAttribute("class") + " in type: "+ extensionPoint.getUniqueIdentifier()+ " in plugin: "+ configelements[j].getDeclaringExtension().getExtensionPointUniqueIdentifier()+ e);
        }
        if (creator != null) {
          judgeExtensions.add(creator);
        }
      }
    }
  }
  return judgeExtensions;
}
 

Example 8

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.spectrum/src/net/bioclipse/spectrum/action/contribution/.

Source file: AddMetadataAction.java

  19 
vote

public AddMetadataAction(SpectrumEditorContributor contributor){
  this.contributor=contributor;
  URL url=Platform.getBundle("net.bioclipse.spectrum").getEntry("/icons/add_metadata.gif");
  ImageDescriptor imageDesc=ImageDescriptor.createFromURL(url);
  this.setImageDescriptor(imageDesc);
}
 

Example 9

From project bioclipse.vscreen, under directory /net.bioclipse.vscreen/src/net/bioclipse/vscreen/business/.

Source file: VScreenManager.java

  19 
vote

/** 
 * @param filterName Name of filter to create
 * @return a new filter with name filterName
 * @throws BioclipseException if no filter with filterName exists or if creation fails
 */
private IScreeningFilter newFilter(String filterName) throws BioclipseException {
  if (!existsFilter(filterName))   throw new BioclipseException("No filter wih name: " + filterName);
  IExtensionRegistry registry=Platform.getExtensionRegistry();
  if (registry == null)   throw new BioclipseException("Eclipse registry=null. Cannot get screeningfilters from EPs.");
  IExtensionPoint serviceObjectExtensionPoint=registry.getExtensionPoint("net.bioclipse.vscreen.filter");
  IExtension[] serviceObjectExtensions=serviceObjectExtensionPoint.getExtensions();
  for (  IExtension extension : serviceObjectExtensions) {
    for (    IConfigurationElement element : extension.getConfigurationElements()) {
      if (element.getName().equals("screeningFilter")) {
        String pname=element.getAttribute("name");
        if (pname.equalsIgnoreCase(filterName)) {
          String pid=element.getAttribute("id");
          String picon=element.getAttribute("icon");
          String pdescription=element.getAttribute("description");
          String pluginID=element.getNamespaceIdentifier();
          Object obj;
          try {
            obj=element.createExecutableExtension("class");
            IScreeningFilter filter=(IScreeningFilter)obj;
            filter.setId(pid);
            filter.setName(pname);
            filter.setIconpath(picon);
            filter.setDescription(pdescription);
            filter.setPlugin(pluginID);
            return filter;
          }
 catch (          CoreException e) {
            LogUtils.handleException(e,logger,net.bioclipse.vscreen.Activator.PLUGIN_ID);
          }
        }
      }
    }
  }
  throw new BioclipseException("Could not find filter named " + filterName);
}
 

Example 10

From project bndtools, under directory /bndtools.core/src/bndtools/builder/.

Source file: BuildListeners.java

  19 
vote

public BuildListeners(){
  IConfigurationElement[] elements=Platform.getExtensionRegistry().getConfigurationElementsFor(Plugin.PLUGIN_ID,"buildListeners");
  listeners=new ArrayList<BuildListener>(elements.length);
  for (  IConfigurationElement elem : elements) {
    try {
      BuildListener listener=(BuildListener)elem.createExecutableExtension("class");
      listeners.add(listener);
    }
 catch (    Exception e) {
      logger.logError("Unable to instantiate build listener: " + elem.getAttribute("name"),e);
    }
  }
  BundleContext context=FrameworkUtil.getBundle(BuildListeners.class).getBundleContext();
  listenerTracker=new ServiceTracker(context,BuildListener.class.getName(),null);
  listenerTracker.open();
}
 

Example 11

From project bpelunit, under directory /tycho/net.bpelunit.framework.client.eclipse/src/net/bpelunit/framework/client/eclipse/.

Source file: ExtensionControl.java

  19 
vote

private static void loadExtensions(String extensionPointID,ELoader loader){
  IExtensionRegistry registry=Platform.getExtensionRegistry();
  IExtensionPoint extensionPoint=registry.getExtensionPoint(extensionPointID);
  IExtension[] extensions=extensionPoint.getExtensions();
  for (  IExtension element : extensions) {
    IConfigurationElement[] elements=element.getConfigurationElements();
    for (    IConfigurationElement element0 : elements) {
      loader.load(element0);
    }
  }
}
 

Example 12

From project BPMN2-Editor-for-Eclipse, under directory /org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/diagram/.

Source file: BpmnToolBehaviourFeature.java

  19 
vote

private void createCustomTasks(List<IPaletteCompartmentEntry> ret,IFeatureProvider featureProvider){
  PaletteCompartmentEntry compartmentEntry;
  compartmentEntry=new PaletteCompartmentEntry("Custom Task",null);
  compartmentEntry.setInitiallyOpen(false);
  ret.add(compartmentEntry);
  IConfigurationElement[] config=Platform.getExtensionRegistry().getConfigurationElementsFor(ICustomTaskEditor.TASK_EDITOR_ID);
  try {
    for (    IConfigurationElement e : config) {
      String name=e.getAttribute("name");
      String id=e.getAttribute("id");
      final Object o=e.createExecutableExtension("createFeature");
      if (o instanceof CustomTaskFeatureContainer) {
        CustomTaskFeatureContainer container=(CustomTaskFeatureContainer)o;
        container.setId(featureProvider,id);
        ICreateFeature cf=container.getCreateFeature(featureProvider);
        ObjectCreationToolEntry objectCreationToolEntry=new ObjectCreationToolEntry(name,cf.getCreateDescription(),cf.getCreateImageId(),cf.getCreateLargeImageId(),cf);
        compartmentEntry.addToolEntry(objectCreationToolEntry);
      }
    }
  }
 catch (  Exception ex) {
    Activator.logError(ex);
  }
}
 

Example 13

From project bundlemaker, under directory /main/org.bundlemaker.core/src/org/bundlemaker/core/internal/extensionpoints/projectcontentprovider/.

Source file: ProjectContentProviderExtension.java

  19 
vote

/** 
 * <p> </p>
 * @return
 * @throws CoreException
 */
public static List<ProjectContentProviderExtension> getAllProjectContentProviderExtension() throws CoreException {
  List<ProjectContentProviderExtension> result=new LinkedList<ProjectContentProviderExtension>();
  IExtensionRegistry reg=Platform.getExtensionRegistry();
  IExtension[] extensions=reg.getExtensionPoint("org.bundlemaker.core.projectcontentprovider").getExtensions();
  for (  IExtension extension : extensions) {
    ProjectContentProviderExtension providerExtension=new ProjectContentProviderExtension();
    providerExtension._extension=extension;
    for (    IConfigurationElement configurationElement : extension.getConfigurationElements()) {
      if (configurationElement.getName().equals("projectContentProvider")) {
        providerExtension._projectContentProviderElement=configurationElement;
        for (        IConfigurationElement child : configurationElement.getChildren()) {
          if (child.getName().equals("jaxbObjectFactory")) {
            providerExtension._jaxbObjectFactoryElement=child;
          }
        }
      }
    }
    result.add(providerExtension);
  }
  return result;
}
 

Example 14

From project ccw, under directory /ccw.core/src/java/ccw/launching/.

Source file: ClojureLaunchDelegate.java

  19 
vote

@Override public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
  List<String> classpath=new ArrayList<String>(Arrays.asList(super.getClasspath(configuration)));
  ClojureProject clojureProject=ClojureCore.getClojureProject(LaunchUtils.getProject(configuration));
  for (  IFolder f : clojureProject.sourceFolders()) {
    String sourcePath=f.getLocation().toOSString();
    while (classpath.contains(sourcePath)) {
      classpath.remove(sourcePath);
    }
    classpath.add(0,sourcePath);
  }
  if (clojureProject.getJavaProject().findElement(new Path("clojure/tools/nrepl")) == null) {
    try {
      File repllib=FileLocator.getBundleFile(Platform.getBundle("org.clojure.tools.nrepl"));
      ArrayList replAdditions=new ArrayList();
      if (repllib.isFile()) {
        replAdditions.add(repllib.getAbsolutePath());
      }
 else {
        replAdditions.add(new File(repllib,"src/main/clojure").getAbsolutePath());
        replAdditions.add(new File(repllib,"target/classes").getAbsolutePath());
      }
      CCWPlugin.log("Adding to project's classpath to support nREPL: " + replAdditions);
      classpath.addAll(replAdditions);
    }
 catch (    IOException e) {
      throw new WorkbenchException("Failed to find nrepl library",e);
    }
  }
  return classpath.toArray(new String[classpath.size()]);
}
 

Example 15

From project ceylon-ide-eclipse, under directory /plugins/com.redhat.ceylon.eclipse.ui/src/com/redhat/ceylon/eclipse/code/hover/.

Source file: DocHover.java

  19 
vote

/** 
 * Loads and returns the Javadoc hover style sheet.
 * @return the style sheet, or <code>null</code> if unable to load
 * @since 3.4
 */
public static String loadStyleSheet(){
  Bundle bundle=Platform.getBundle(JavaPlugin.getPluginId());
  URL styleSheetURL=bundle.getEntry("/JavadocHoverStyleSheet.css");
  if (styleSheetURL != null) {
    BufferedReader reader=null;
    try {
      reader=new BufferedReader(new InputStreamReader(styleSheetURL.openStream()));
      StringBuffer buffer=new StringBuffer(1500);
      String line=reader.readLine();
      while (line != null) {
        buffer.append(line);
        buffer.append('\n');
        line=reader.readLine();
      }
      return buffer.toString();
    }
 catch (    IOException ex) {
      JavaPlugin.log(ex);
      return "";
    }
 finally {
      try {
        if (reader != null)         reader.close();
      }
 catch (      IOException e) {
      }
    }
  }
  return null;
}
 

Example 16

From project CIShell, under directory /clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/.

Source file: DataGUIItem.java

  19 
vote

public static Image getImage(String name,String brandPluginID){
  if (Platform.isRunning()) {
    String imageLocation=String.format("%sicons%s%s",File.separator,File.separator,name);
    ImageDescriptor imageDescriptor=AbstractUIPlugin.imageDescriptorFromPlugin(brandPluginID,imageLocation);
    if (imageDescriptor != null) {
      return imageDescriptor.createImage();
    }
 else {
      String errorMessage=String.format("Could not find the icon '%s' in '%s'. Using the default image instead.",imageLocation,brandPluginID);
      System.err.println(errorMessage);
      return getDefaultImage();
    }
  }
 else {
    String format="Could not obtain the image '%s' in '%s', since the platform was not " + "running (?). Using the default image instead.";
    String errorMessage=String.format(format,name,brandPluginID);
    System.err.println(errorMessage);
    return getDefaultImage();
  }
}
 

Example 17

From project dawn-common, under directory /org.dawb.common.services/src/org/dawb/common/services/.

Source file: ServiceManager.java

  19 
vote

/** 
 * Gets a service given a class, using the workbench if we are not in headless mode, otherwise returns our services providing the class declared for the extension point, also implements the service.
 * @param serviceClass
 * @return
 */
public static Object getService(final Class serviceClass) throws Exception {
  if (PlatformUI.isWorkbenchRunning()) {
    return PlatformUI.getWorkbench().getService(serviceClass);
  }
  if (!OFFLINE_SERVICES.contains(serviceClass))   throw new Exception("Cannot get an implementor for " + serviceClass + " in headless mode!");
  final IConfigurationElement[] ele=Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.ui.services");
  for (  IConfigurationElement i : ele) {
    final Object factory=i.createExecutableExtension("factoryClass");
    if (factory != null && factory.getClass() == serviceClass)     return factory;
  }
  return null;
}
 

Example 18

From project dawn-isenciaui, under directory /com.isencia.passerelle.workbench.model/src/main/java/com/isencia/passerelle/workbench/model/launch/.

Source file: ModelRunner.java

  19 
vote

private void notifyModelChangeStart(){
  try {
    final IConfigurationElement[] ele=Platform.getExtensionRegistry().getConfigurationElementsFor("com.isencia.passerelle.engine.model.listener");
    for (    IConfigurationElement i : ele) {
      final IModelListener l=(IModelListener)i.createExecutableExtension("modelListener");
      l.executionStarted();
    }
  }
 catch (  Exception ne) {
    logger.error("Cannot notify model listeners");
  }
}
 

Example 19

From project dawn-product, under directory /org.dawb.workbench.application/src/org/edna/workbench/application/.

Source file: Application.java

  19 
vote

/** 
 * @param workspacePath
 * @throws Exception if the workspace failed to be set
 */
private void createDawbWorkspace(IApplicationContext context) throws Exception {
  if (context.getArguments().get("data") != null) {
    logger.debug("Using workspace '" + context.getArguments().get("data") + "'");
    return;
  }
  Location instanceLocation=Platform.getInstanceLocation();
  if (instanceLocation.isSet())   return;
  String userHome=System.getProperty("org.dawb.workspace.dir");
  if (userHome == null)   userHome=getESRFBufferLocation();
  if (userHome == null)   userHome=System.getProperty("user.home");
  logger.debug("Using workspace parent folder as '" + userHome + "'");
  final File workspace=new File(userHome + "/dawb_workspace");
  if (!workspace.exists()) {
    if (!workspace.mkdirs()) {
      final String msg="Cannot create workspace in " + workspace.getAbsolutePath() + " not setting workspace";
      throw new Exception(msg);
    }
  }
  workspace.setWritable(true);
  workspace.setReadable(true);
  if (!workspace.canRead() || !workspace.canWrite() || !workspace.canExecute()) {
    final String msg="Not setting workspace to " + workspace.getAbsolutePath() + " due to insufficient permissions.";
    throw new Exception(msg);
  }
  URL url=workspace.toURI().toURL();
  instanceLocation=Platform.getInstanceLocation();
  instanceLocation.set(url,false);
}
 

Example 20

From project dawn-ui, under directory /org.dawb.workbench.plotting/src/org/dawb/workbench/plotting/views/.

Source file: ToolPageView.java

  19 
vote

/** 
 * @param event the event
 */
public void selectionChanged(final SelectionChangedEvent event){
  Object[] listeners=getListeners();
  for (int i=0; i < listeners.length; ++i) {
    final ISelectionChangedListener l=(ISelectionChangedListener)listeners[i];
    Platform.run(new SafeRunnable(){
      public void run(){
        l.selectionChanged(event);
      }
    }
);
  }
}
 

Example 21

From project dawn-workflow, under directory /org.dawb.passerelle.actors/src/org/dawb/passerelle/actors/.

Source file: Activator.java

  19 
vote

public void start(BundleContext context) throws Exception {
  super.start(context);
  System.setProperty("be.isencia.home",ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
  try {
    final Bundle bundle=Platform.getBundle("org.dawb.gda.extensions");
    if (bundle == null)     throw new Exception("Cannot load bundle org.dawb.gda.extensions!");
    bundle.start();
  }
 catch (  Exception e) {
    logger.error("Cannot override plot server in GDA!",e);
  }
  plugin=this;
}
 

Example 22

From project Diver, under directory /ca.uvic.chisel.javasketch/src/ca/uvic/chisel/javasketch/launching/internal/.

Source file: JavaAgentUtil.java

  19 
vote

public static IPath getJavaAgent(ILaunchConfiguration configuration) throws CoreException {
  String os=Platform.getOS();
  String arch=Platform.getOSArch();
  URL fileUrl=null;
  if ("win32".equals(os) && "x86".equals(arch)) {
    fileUrl=SketchPlugin.getDefault().getBundle().getResource("sketch_win32.dll");
  }
 else   if ("win32".equals(os) && ("amd64".equals(arch) || "x86_64".equals(arch))) {
    fileUrl=SketchPlugin.getDefault().getBundle().getResource("sketch_win64.dll");
  }
 else   if ("linux".equals(os)) {
    fileUrl=SketchPlugin.getDefault().getBundle().getResource("libsketch_linux32.so");
  }
 else {
    throw new CoreException(new Status(Status.ERROR,SketchPlugin.PLUGIN_ID,"Unrecognized operating system: " + os + " with architecture "+ arch));
  }
  if (fileUrl == null) {
    throw new CoreException(new Status(Status.ERROR,SketchPlugin.PLUGIN_ID,"Unable to locate tracing library: OS = " + os + " with architecture "+ arch));
  }
  String fileName=null;
  try {
    fileUrl=FileLocator.toFileURL(fileUrl);
    fileName=fileUrl.getFile();
    File file=new File(fileName);
    if (!file.exists()) {
      fileName=null;
    }
 else {
      fileName=file.getCanonicalPath();
    }
    if (fileName != null) {
      IPath filePath=new Path(fileName);
      return filePath;
    }
  }
 catch (  IOException e) {
    throw new CoreException(new Status(Status.ERROR,SketchPlugin.PLUGIN_ID,"Could not locate tracing agent",e));
  }
  throw new CoreException(new Status(Status.ERROR,SketchPlugin.PLUGIN_ID,"Could not locate tracing agent"));
}
 

Example 23

From project droolsjbpm-tools, under directory /drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug/.

Source file: ProcessInstanceViewer.java

  19 
vote

public ProcessInstanceTabItem(CTabFolder folder,String processInstanceId,String processId,List<String> nodeIds,String projectName){
  this.projectName=projectName;
  tabItem=new CTabItem(folder,SWT.NONE);
  ProcessInfo processInfo=DroolsEclipsePlugin.getDefault().getProcessInfo(processId);
  if (processInfo == null) {
    throw new IllegalArgumentException("Could not find process with id " + processId);
  }
  tabItem.setText(processInstanceId + " = " + processInfo.getProcess().getName()+ "["+ processInfo.getProcessId()+ "]");
  Composite composite=new Composite(folder,SWT.NONE);
  composite.setLayout(new FillLayout());
  tabItem.setControl(composite);
  graphicalViewer=new ScrollingGraphicalViewer();
  graphicalViewer.createControl(composite);
  graphicalViewer.getControl().setBackground(ColorConstants.listBackground);
  graphicalViewer.setRootEditPart(new ScalableRootEditPart());
  IJavaProject javaProject=getJavaProject(projectName);
  IExtensionRegistry reg=Platform.getExtensionRegistry();
  IConfigurationElement[] extensions=reg.getConfigurationElementsFor("org.drools.eclipse.processExtension");
  for (  IConfigurationElement element : extensions) {
    try {
      ProcessExtension processExtension=(ProcessExtension)element.createExecutableExtension("className");
      Process process=(Process)processInfo.getProcess();
      if (processExtension.acceptsProcess(process.getType())) {
        ProcessEditPartFactory editPartFactory=processExtension.getProcessEditPartFactory();
        editPartFactory.setProject(javaProject);
        graphicalViewer.setEditPartFactory(editPartFactory);
        ProcessWrapper processWrapper=processExtension.getProcessWrapperBuilder().getProcessWrapper(process,javaProject);
        graphicalViewer.setContents(processWrapper);
        break;
      }
    }
 catch (    CoreException e) {
      DroolsEclipsePlugin.log(e);
    }
  }
  for (  String nodeId : nodeIds) {
    handleNodeInstanceSelection(nodeId);
  }
  folder.setSelection(tabItem);
}
 

Example 24

From project e4-rendering, under directory /com.toedter.e4.demo.contacts.generic/src/com/toedter/e4/demo/contacts/generic/model/internal/.

Source file: VCardContactsRepository.java

  19 
vote

private File[] getContacts() throws Exception {
  File[] localContacts=getLocalContacts();
  if (localContacts.length == 0) {
    IPath path=BundleActivatorImpl.getInstance().getStateLocation();
    byte[] buffer=new byte[8192];
    Bundle bundle=Platform.getBundle("com.toedter.e4.demo.contacts.generic");
    for (Enumeration<?> contacts=getStoredContacts(); contacts.hasMoreElements(); ) {
      String bundlePath=(String)contacts.nextElement();
      if (!bundlePath.endsWith(".vcf")) {
        continue;
      }
      InputStream inputStream=FileLocator.openStream(bundle,new Path(bundlePath),false);
      FileOutputStream outputStream=new FileOutputStream(path.append(bundlePath.substring(bundlePath.indexOf('/') + 1)).toFile());
      int read=inputStream.read(buffer);
      while (read != -1) {
        outputStream.write(buffer,0,read);
        read=inputStream.read(buffer);
      }
      inputStream.close();
      outputStream.close();
    }
    return getLocalContacts();
  }
  return localContacts;
}
 

Example 25

From project eclim, under directory /org.eclim/java/org/eclim/command/.

Source file: ReloadCommand.java

  19 
vote

@Override public Object execute(CommandLine commandLine) throws Exception {
  Bundle system=Platform.getBundle("system.bundle");
  FrameworkWiring framework=(FrameworkWiring)system.adapt(FrameworkWiring.class);
  ArrayList<Bundle> bundles=new ArrayList<Bundle>();
  bundles.add(Platform.getBundle("org.eclim.core"));
  framework.refreshBundles(bundles,new FrameworkListener[0]);
  return Services.getMessage("plugins.reloaded");
}
 

Example 26

From project Eclipse, under directory /com.mobilesorcery.sdk.builder.headless/src/com/mobilesorcery/sdk/builder/app/.

Source file: HeadlessBuild.java

  19 
vote

@Override public Object start(IApplicationContext context) throws Exception {
  String osName=System.getProperty("os.name");
  boolean isMac=osName.startsWith("Mac") || osName.startsWith("Darwin");
  Display dummy=null;
  if (isMac) {
    dummy=PlatformUI.createDisplay();
    Bundle ideBundle=Platform.getBundle("org.eclipse.ui.ide");
    if (ideBundle != null) {
      ideBundle.start();
    }
  }
  CoreMoSyncPlugin.setHeadless(true);
  if (CoreMoSyncPlugin.getDefault().isDebugging()) {
    CoreMoSyncPlugin.trace("*** Started headless build at {0,time}, {0,date}",new Date());
  }
  try {
    context.applicationRunning();
    String[] args=(String[])context.getArguments().get(IApplicationContext.APPLICATION_ARGS);
    BuildRunnable buildRunnable=new BuildRunnable(args);
    buildRunnable.start().join();
    if (buildRunnable.getException() != null) {
      System.err.println(buildRunnable.getException());
      throw buildRunnable.getException();
    }
  }
  finally {
    if (dummy != null) {
      dummy.dispose();
    }
    if (CoreMoSyncPlugin.getDefault().isDebugging()) {
      CoreMoSyncPlugin.trace("*** Stopped headless build at {0,time}, {0,date}",new Date());
    }
  }
  return EXIT_OK;
}
 

Example 27

From project eclipse-instasearch, under directory /instasearch/src/it/unibz/instasearch/prefs/.

Source file: PreferenceInitializer.java

  19 
vote

/** 
 * Get extensions that Eclipse knows of and the default ones
 * @return comma separated string of extensions
 */
public static String getIndexableExtensions(){
  String defaultExtArray[]=DEFAULT_EXTENSIONS.split(",");
  TreeSet<String> extensions=new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
  extensions.addAll(Arrays.asList(defaultExtArray));
  IFileEditorMapping[] allMappings=((EditorRegistry)PlatformUI.getWorkbench().getEditorRegistry()).getUnifiedMappings();
  IContentType text=Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT);
  for (int i=0; i < allMappings.length; i++) {
    if (allMappings[i].getName().equals("*")) {
      String ext=allMappings[i].getExtension();
      IContentType type=Platform.getContentTypeManager().findContentTypeFor("." + ext);
      if (type != null && type.isKindOf(text))       extensions.add(ext);
    }
  }
  IContentType[] types=Platform.getContentTypeManager().getAllContentTypes();
  for (  IContentType type : types) {
    if (type.isKindOf(text)) {
      String exts[]=type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
      extensions.addAll(Arrays.asList(exts));
    }
  }
  return StringUtils.join(extensions.toArray(),",");
}
 

Example 28

From project eclipse-integration-cloudfoundry, under directory /org.cloudfoundry.ide.eclipse.server.core/src/org/cloudfoundry/ide/eclipse/internal/server/core/.

Source file: CloudFoundryBrandingExtensionPoint.java

  19 
vote

private static void readBrandingDefinitions(){
  IExtensionPoint brandingExtPoint=Platform.getExtensionRegistry().getExtensionPoint(POINT_ID);
  if (brandingExtPoint != null) {
    for (    IExtension extension : brandingExtPoint.getExtensions()) {
      for (      IConfigurationElement config : extension.getConfigurationElements()) {
        String serverId=config.getAttribute(ATTR_SERVER_TYPE_ID);
        String name=config.getAttribute(ATTR_NAME);
        if (serverId != null && serverId.trim().length() > 0 && name != null && name.trim().length() > 0) {
          IConfigurationElement[] urls=config.getChildren(ELEM_DEFAULT_URL);
          if (urls != null && urls.length > 0) {
            brandingDefinitions.put(serverId,config);
          }
        }
      }
    }
  }
  read=true;
}
 

Example 29

From project eclipse-integration-commons, under directory /org.springframework.ide.eclipse.uaa/src/org/springframework/ide/eclipse/internal/uaa/monitor/.

Source file: ExtensionIdToBundleMapper.java

  19 
vote

/** 
 * This method walks through the commands registered via the extension registry and creates the  {@link #map}.
 */
protected synchronized void updateCommandToBundleMappings(){
  if (map != null) {
    return;
  }
  map=new HashMap<String,String>();
  IConfigurationElement[] elements=Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointId);
  for (  IConfigurationElement element : elements) {
    map.put(extractId(element),element.getContributor().getName());
  }
}
 

Example 30

From project eclipse-integration-gradle, under directory /org.springsource.ide.eclipse.gradle.core/src/org/springsource/ide/eclipse/gradle/core/dsld/.

Source file: DSLDSupport.java

  19 
vote

/** 
 * @return true only if Greclipse is installed. 
 */
public boolean haveGreclipse(){
  if (haveGreclipse == null) {
    Bundle greclipseCore=Platform.getBundle("org.codehaus.groovy.eclipse.core");
    haveGreclipse=greclipseCore != null;
  }
  return haveGreclipse;
}