コード例 #1
0
 public ContentImageFileBasePage() {
   super(
       ContentImageFileBasePage.class.getName(),
       Messages.getString(
           "org.nightlabs.eclipse.ui.fckeditor.file.image.ContentImageFileBasePage.pageTitle"),
       null); //$NON-NLS-1$
 }
コード例 #2
0
 /* (non-Javadoc)
  * @see org.nightlabs.eclipse.ui.fckeditor.file.ContentFileBasePage#applySourceFile()
  */
 @Override
 protected void applySourceFile() {
   super.applySourceFile();
   if (getSourceFile() != null && imageLabel != null) {
     imageLabel.setImage(null);
     if (previewImage != null) {
       previewImage.dispose();
       previewImage = null;
     }
     try {
       ImageData id = ImageUtil.loadImage(getSourceFile(), new NullProgressMonitor());
       // ImageData id = new ImageData(new FileInputStream(getSourceFile()));
       float m = Math.max(id.width / 200f, id.height / 200f);
       int width = Math.round(id.width / m);
       int height = Math.round(id.height / m);
       previewImage = new Image(getShell().getDisplay(), id.scaledTo(width, height));
       imageLabel.setImage(previewImage);
       if (!disposeListenerRegistered) {
         getShell().addDisposeListener(this);
         disposeListenerRegistered = true;
       }
     } catch (Exception e) {
       Activator.err("Error loading image preview", e); // $NON-NLS-1$
       previewImage = null;
       imageLabel.setText(
           Messages.getString(
               "org.nightlabs.eclipse.ui.fckeditor.file.image.ContentImageFileBasePage.previewLoadingErrorText")); //$NON-NLS-1$
     }
   }
 }
コード例 #3
0
 /* (non-Javadoc)
  * @see org.nightlabs.eclipse.ui.fckeditor.file.ContentFileBasePage#createCustomControls(org.eclipse.swt.widgets.Composite)
  */
 @Override
 protected void createCustomControls(Composite parent) {
   Label l = new Label(parent, SWT.NONE);
   l.setText(
       Messages.getString(
           "org.nightlabs.eclipse.ui.fckeditor.file.image.ContentImageFileBasePage.previewLabelText")); //$NON-NLS-1$
   l.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
   imageLabel = new Label(parent, SWT.NONE);
   //		GridData gd = new GridData();
   //		gd.widthHint = 200;
   //		gd.heightHint = 200;
   //		gd.horizontalSpan = 2;
   //		imageLabel.setLayoutData(gd);
 }
コード例 #4
0
  protected List<IAction> getActions(final IFCKEditorContentFile file) {
    final String extension = ContentTypeUtil.getFileExtension(file);
    List<IAction> actions = new ArrayList<IAction>();
    actions.add(
        new Action(
            Messages.getString(
                "org.nightlabs.eclipse.ui.fckeditor.file.FileList.openFileActionText")) { //$NON-NLS-1$
          @Override
          public boolean isEnabled() {
            return Desktop.isDesktopSupported() && extension != null;
          }

          @Override
          public void runWithEvent(Event event) {
            try {
              final File tmpFile = File.createTempFile(file.getName(), extension);
              tmpFile.deleteOnExit();
              FileOutputStream out = new FileOutputStream(tmpFile);
              try {
                out.write(file.getData());
              } finally {
                out.close();
              }
              Desktop.getDesktop().open(tmpFile);
            } catch (Throwable ex) {
              String msg =
                  String.format(
                      Messages.getString(
                          "org.nightlabs.eclipse.ui.fckeditor.file.FileList.appLaunchError"),
                      ex.getLocalizedMessage()); // $NON-NLS-1$
              Activator.err(msg, ex);
              MessageDialog.openError(
                  getShell(),
                  Messages.getString("org.nightlabs.eclipse.ui.fckeditor.file.FileList.errorTitle"),
                  msg); //$NON-NLS-1$
            }
          }
        });
    return actions;
  }