Esempio n. 1
0
  public boolean performOk() {
    if (fFileInfo != null && (fFileInfo instanceof IExtendedFileInfo)) {
      long permissions = fPermissionsGroup.getPermissions();
      IExtendedFileInfo extendedInfo = (IExtendedFileInfo) fFileInfo;
      if (permissions != extendedInfo.getPermissions()) {
        // the permissions have been modified
        extendedInfo.setPermissions(permissions);

        IFileStore fileStore = Utils.getFileStore(getElement());
        if (fileStore != null) {
          try {
            fileStore.putInfo(
                fFileInfo, IExtendedFileInfo.SET_PERMISSIONS, new NullProgressMonitor());
          } catch (CoreException e) {
            UIUtils.showErrorMessage(Messages.FileInfoPropertyPage_ErrorStoreInfo, e);
          }
        }
      }
    }

    return super.performOk();
  }
Esempio n. 2
0
  /* (non-Javadoc)
   * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
   */
  @Override
  protected Control createContents(Composite parent) {
    // first try to adapt to IFileStore directly
    final IFileStore fileStore = Utils.getFileStore(getElement());
    if (fileStore == null) {
      Label label = new Label(parent, SWT.NONE);
      label.setText(IDEWorkbenchMessages.ResourceInfoPage_noResource);
      return label;
    }
    try {
      if (getElement().getAdapter(File.class) != null) {
        fFileInfo = fileStore.fetchInfo(EFS.NONE, new NullProgressMonitor());
      } else {
        final IFileInfo[] result = new IFileInfo[1];
        ProgressMonitorDialog dlg = new ProgressMonitorDialog(parent.getShell());
        try {
          dlg.run(
              true,
              true,
              new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor)
                    throws InvocationTargetException, InterruptedException {
                  try {
                    result[0] = fileStore.fetchInfo(IExtendedFileStore.DETAILED, monitor);
                  } catch (CoreException e) {
                    throw new InvocationTargetException(e, e.getLocalizedMessage());
                  } finally {
                    monitor.done();
                  }
                }
              });
        } catch (InvocationTargetException e) {
          throw (CoreException) e.getTargetException();
        } catch (InterruptedException e) {
          e.getCause();
        }
        fFileInfo = result[0];
      }
    } catch (CoreException e) {
      UIUtils.showErrorMessage(Messages.FileInfoPropertyPage_FailedToFetchInfo, e);
    }
    if (fFileInfo == null) {
      Label label = new Label(parent, SWT.NONE);
      label.setText(IDEWorkbenchMessages.ResourceInfoPage_noResource);
      return label;
    }

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(GridLayoutFactory.swtDefaults().margins(0, 0).create());
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    Composite basicInfo = createBasicInfoGroup(composite, fileStore, fFileInfo);
    basicInfo.setLayoutData(GridDataFactory.fillDefaults().create());

    Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    Composite state = createStateGroup(composite, fileStore, fFileInfo);
    state.setLayoutData(GridDataFactory.fillDefaults().create());

    if (fFileInfo instanceof IExtendedFileInfo) {
      IExtendedFileInfo extendedInfo = (IExtendedFileInfo) fFileInfo;
      Composite owner = createOwnerGroup(composite, extendedInfo);
      owner.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(0, 10).create());

      Composite permissions = createPermissionsGroup(composite, extendedInfo);
      permissions.setLayoutData(
          GridDataFactory.fillDefaults().grab(true, false).indent(0, 5).create());
    }

    /* TODO
    new Label(composite, SWT.NONE); // a vertical spacer
    encodingEditor = new EncodingFieldEditor("",
    		fileInfo.isDirectory() ? IDEWorkbenchMessages.ResourceInfo_fileEncodingTitle : IDEWorkbenchMessages.WorkbenchPreference_encoding,
    		composite);
    encodingEditor.setPreferenceStore(null);
    encodingEditor.setPage(this);
    encodingEditor.load();

    encodingEditor.setPropertyChangeListener(new IPropertyChangeListener() {
    	public void propertyChange(PropertyChangeEvent event) {
    		if (event.getProperty().equals(FieldEditor.IS_VALID)) {
    			setValid(encodingEditor.isValid());
    		}
    	}
    });

    if (fileInfo.isDirectory()) {
    	lineDelimiterEditor = new LineDelimiterEditor(composite, resource.getProject());
    	lineDelimiterEditor.doLoad();
    }
    */

    Dialog.applyDialogFont(composite);

    return composite;
  }