Package org.eclipse.core.runtime.content

Examples of org.eclipse.core.runtime.content.IContentType


    IContentDescription contentDescription = null;
    try {
      contentDescription = ((IFile) file).getContentDescription();
      if (contentDescription != null) {
        IContentType contentType = contentDescription.getContentType();
        return contentDescription != null && contentType.isKindOf(getXMLContentType());
      }
    }
    catch (CoreException e) {
      Logger.logException(e);
    }
View Full Code Here


      final IPaletteContext paletteContext) {

    final IFile file = paletteContext.getFile();
    if (file != null) {
          final IContentTypeManager typeManager = Platform.getContentTypeManager();
          final IContentType contentType =
              typeManager.findContentTypeFor(file.getName());
         
          if (contentType != null)
          {
              return new TagRegistryIdentifier(file.getProject(), contentType);
View Full Code Here

    }
    registerTagsFromTagRegistry()
  }

  private boolean isJSP(final TagRegistryIdentifier tagRegistryId) {
    final IContentType ct = tagRegistryId.getContentType();
    if (JSPUtil.isJSPContentType(ct.getId()))
      return true;
    return false;
  }
View Full Code Here

  private String[] calculateParentContentTypeIds(String contentTypeId) {

    Set parentTypes = new HashSet();

    IContentTypeManager ctManager = Platform.getContentTypeManager();
    IContentType ct = ctManager.getContentType(contentTypeId);
    String id = contentTypeId;

    while (ct != null && id != null) {

      parentTypes.add(id);
      ct = ctManager.getContentType(id);
      if (ct != null) {
        IContentType baseType = ct.getBaseType();
        id = (baseType != null) ? baseType.getId() : null;
      }
    }
    return (String[]) parentTypes.toArray(new String[parentTypes.size()]);
  }
View Full Code Here

    String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET);
    return charSet;
  }

  public void createXMLDocument(String xmlFileName) throws Exception {
    IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(xmlFileName);
    String charset = null;
    if (contentType != null) {
      charset = contentType.getDefaultCharset();
    }
    ByteArrayOutputStream outputStream = createXMLDocument(xmlFileName, charset);

    File file = new File(xmlFileName);
    FileOutputStream fos = new FileOutputStream(file);
View Full Code Here

      model.arguments.put(DeModelConfig.LOAD_ARCHITECTURE, architecture.toString());
      model.arguments.put(DeModelConfig.LOAD_DEPLOY, deploy.toString());

    }

    final IContentType vdmrtFileContentType = Platform.getContentTypeManager().getContentType(IDebugConstants.VDMRT_CONTENT_TYPE_ID);

    try
    {
      if (!configuration.getAttribute(IDebugConstants.VDM_LAUNCH_CONFIG_PRE_CHECKS, true))// vdmProject.hasPrechecks())
      {
        model.arguments.put(DeModelConfig.LOAD_SETTING_DISABLE_PRE, "true");
      }
      if (!configuration.getAttribute(IDebugConstants.VDM_LAUNCH_CONFIG_POST_CHECKS, true))// vdmProject.hasPostchecks())
      {
        model.arguments.put(DeModelConfig.LOAD_SETTING_DISABLE_POST, "true");
      }
      if (!configuration.getAttribute(IDebugConstants.VDM_LAUNCH_CONFIG_INV_CHECKS, true))// vdmProject.hasInvchecks())
      {
        model.arguments.put(DeModelConfig.LOAD_SETTING_DISABLE_INV, "true");
      }
      if (!configuration.getAttribute(IDebugConstants.VDM_LAUNCH_CONFIG_DTC_CHECKS, true))// vdmProject.hasDynamictypechecks())
      {
        model.arguments.put(DeModelConfig.LOAD_SETTING_DISABLE_DYNAMIC_TC, "true");
      }
      if (!configuration.getAttribute(IDebugConstants.VDM_LAUNCH_CONFIG_MEASURE_CHECKS, true))// vdmProject.hasMeasurechecks())
      {
        model.arguments.put(DeModelConfig.LOAD_SETTING_DISABLE_MEASURE, "true");
      }
      if (!configuration.getAttribute(IDebugConstants.VDM_LAUNCH_CONFIG_LOG_RT, true))// vdmProject.hasMeasurechecks())
      {
        model.arguments.put(DeModelConfig.LOAD_SETTING_DISABLE_RT_LOG, "true");
      }
      if (!configuration.getAttribute(IDebugConstants.VDM_LAUNCH_CONFIG_GENERATE_COVERAGE, true))// vdmProject.hasMeasurechecks())
      {
        model.arguments.put(DeModelConfig.LOAD_SETTING_DISABLE_COVERAGE, "true");
      }

      project2.accept(new IResourceVisitor()
      {

        public boolean visit(IResource resource) throws CoreException
        {
          if (resource instanceof IFile
              && resource.getFileExtension() != null
              && resource.getFileExtension().equals(DeModelConfig.LOAD_LINK))
          {
            model.arguments.put(DeModelConfig.LOAD_LINK, resource.getLocation().toFile().getAbsolutePath());
          }
          return true;
        }
      });

      p.getVdmModelFolder().accept(new IResourceVisitor()
      {

        public boolean visit(IResource resource) throws CoreException
        {
          if (vdmrtFileContentType.isAssociatedWith(resource.getName()))
          {
            model.addSpecFile(resource.getLocation().toFile());
          }
          return true;
        }
View Full Code Here

              final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();

              Display.getDefault().asyncExec(new Runnable() {
                public void run() {
                  try {
                    IContentType contentType = iFile.getContentDescription().getContentType();
                    IEditorRegistry editorRegistry = workbench.getEditorRegistry();
                    String fileName = iFile.getName();
                    IEditorDescriptor descriptor = editorRegistry.getDefaultEditor(fileName, contentType);
                    String editorId;
                    if (descriptor != null) {
View Full Code Here

       * (non-Javadoc)
       *
       * @see org.eclipse.swt.events.KeyAdapter#keyReleased(org.eclipse.swt.events.KeyEvent)
       */
      public void keyReleased(KeyEvent e) {
        IContentType contentType = getSelectedContentType();
        String charset = contentType.getDefaultCharset();
        if (charset == null) {
          charset = ""; //$NON-NLS-1$
        }
        setButton.setEnabled(!charset.equals(charsetField.getText()));
      }
View Full Code Here

         *
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        public void widgetSelected(SelectionEvent e) {
          Shell shell = composite.getShell();
          IContentType selectedContentType = getSelectedContentType();
          FileExtensionDialog dialog = new FileExtensionDialog(shell);
          if (dialog.open() == Window.OK) {
            String name = dialog.getName();
            String extension = dialog.getExtension();
            try {
              if (name.equals("*")) { //$NON-NLS-1$
                selectedContentType.addFileSpec(extension,
                    IContentType.FILE_EXTENSION_SPEC);
              } else {
                selectedContentType
                    .addFileSpec(
                        name
                            + (extension.length() > 0 ? ('.' + extension)
                                : ""), //$NON-NLS-1$
                        IContentType.FILE_NAME_SPEC);
              }
            } catch (CoreException ex) {
              StatusUtil.handleStatus(ex.getStatus(),
                  StatusManager.SHOW, shell);
              WorkbenchPlugin.log(ex);
            } finally {
              fileAssociationViewer.setInput(selectedContentType);
            }
          }
        }
      });

      removeButton = new Button(buttonArea, SWT.PUSH);
      removeButton.setEnabled(false);
      removeButton
          .setText(WorkbenchMessages.ContentTypes_fileAssociationsRemoveLabel);
      setButtonLayoutData(removeButton);
      removeButton.addSelectionListener(new SelectionAdapter() {
        /*
         * (non-Javadoc)
         *
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        public void widgetSelected(SelectionEvent event) {
          IContentType contentType = getSelectedContentType();
          Spec[] specs = getSelectedSpecs();
          MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID,
              0, new IStatus[0],
              WorkbenchMessages.ContentTypes_errorDialogMessage,
              null);
          for (int i = 0; i < specs.length; i++) {
            Spec spec = specs[i];
            try {
              if (spec.name != null) {
                contentType.removeFileSpec(spec.name,
                    IContentType.FILE_NAME_SPEC);
              } else if (spec.ext != null) {
                contentType.removeFileSpec(spec.ext,
                    IContentType.FILE_EXTENSION_SPEC);
              }
            } catch (CoreException e) {
              result.add(e.getStatus());
            }
View Full Code Here

             * (non-Javadoc)
             *
             * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
             */
            public void selectionChanged(SelectionChangedEvent event) {
              IContentType contentType = (IContentType) ((IStructuredSelection) event
                  .getSelection()).getFirstElement();
              fileAssociationViewer.setInput(contentType);

              if (contentType != null) {
                String charset = contentType
                    .getDefaultCharset();
                if (charset == null) {
                  charset = ""; //$NON-NLS-1$
                }
                charsetField.setText(charset);
View Full Code Here

TOP

Related Classes of org.eclipse.core.runtime.content.IContentType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.