コード例 #1
0
 private void createOptionalDependenciesButton(Composite container) {
   if (isEditable()) {
     fIncludeOptionalButton = new Button(container, SWT.CHECK);
     fIncludeOptionalButton.setText(PDEUIMessages.PluginSection_includeOptional);
     // initialize value
     IEditorInput input = getPage().getEditorInput();
     if (input instanceof IFileEditorInput) {
       IFile file = ((IFileEditorInput) input).getFile();
       try {
         fIncludeOptionalButton.setSelection(
             "true".equals(file.getPersistentProperty(OPTIONAL_PROPERTY))); // $NON-NLS-1$
       } catch (CoreException e) {
       }
     }
     // create listener to save value when the checkbox is changed
     fIncludeOptionalButton.addSelectionListener(
         new SelectionAdapter() {
           public void widgetSelected(SelectionEvent e) {
             IEditorInput input = getPage().getEditorInput();
             if (input instanceof IFileEditorInput) {
               IFile file = ((IFileEditorInput) input).getFile();
               try {
                 file.setPersistentProperty(
                     OPTIONAL_PROPERTY,
                     fIncludeOptionalButton.getSelection() ? "true" : null); // $NON-NLS-1$
               } catch (CoreException e1) {
               }
             }
           }
         });
   }
 }
コード例 #2
0
ファイル: EditorUtil.java プロジェクト: shahidminhas/abc
  public static IEditorDescriptor getEditorDescription(IFile file) {
    IEditorRegistry editorReg = PlatformUI.getWorkbench().getEditorRegistry();

    IEditorDescriptor selectedDescriptor = null;

    String defaultEditorID = null;
    try {
      defaultEditorID = file.getPersistentProperty(IDE.EDITOR_KEY);
    } catch (CoreException e) {
    }
    if (defaultEditorID != null) selectedDescriptor = editorReg.findEditor(defaultEditorID);

    if (selectedDescriptor == null) {

      /*
      JastAddModel model = JastAddModelProvider.getModel(file);
      if (model != null) {
      */
      IEditorDescriptor[] descriptors = editorReg.getEditors(file.getName());
      for (IEditorDescriptor descriptor : descriptors)
        if (descriptor.getId().equals(JastAddJEditor.EDITOR_ID)) selectedDescriptor = descriptor;
      if (selectedDescriptor == null && descriptors.length > 0) selectedDescriptor = descriptors[0];
      // }
    }
    return selectedDescriptor;
  }
コード例 #3
0
  /**
   * Returns the value of the provided property for the provided file.
   *
   * @param file the file to operate on.
   * @param property the property to check.
   * @return the found value of the property.
   */
  private static String getPropertyValue(final IFile file, final String property) {
    String temp = null;
    try {
      temp = file.getPersistentProperty(new QualifiedName(QUALIFIER, property));
    } catch (CoreException e) {
      ErrorReporter.logExceptionStackTrace(
          "While getting property `" + property + "' of `" + file.getName() + "'", e);
    }

    if (!TRUE_STRING.equals(temp)) {
      temp = FALSE_STRING;
    }

    return temp;
  }
コード例 #4
0
ファイル: ExecutionArguments.java プロジェクト: aptana/rdt
  public static ExecutionArguments getExecutionArguments(IFile rubyScriptFile) {
    try {
      String executionArgumentsPersistableFormat =
          rubyScriptFile.getPersistentProperty(EXECUTION_ARGUMENTS_PROPERTY);
      ExecutionArguments executionArguments = new ExecutionArguments();

      if (executionArgumentsPersistableFormat != null) {
        int argBreakIndex = executionArgumentsPersistableFormat.indexOf(ARGUMENT_SEPARATOR);
        executionArguments.setInterpreterArguments(
            executionArgumentsPersistableFormat.substring(0, argBreakIndex));
        executionArguments.setRubyFileArguments(
            executionArgumentsPersistableFormat.substring(
                argBreakIndex + ARGUMENT_SEPARATOR.length()));
      }

      return executionArguments;
    } catch (CoreException e) {
    }

    return null;
  }
コード例 #5
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);
 }