oberhack    2004/02/13 03:45:34

  Modified:    ide/org.apache.avalon.ide.eclipse.ui plugin.xml
  Added:       
ide/org.apache.avalon.ide.eclipse.ui/src/org/apache/avalon/ide/eclipse/merlin/ui/tools
                        ImageViewerEditor.java
               ide/org.apache.avalon.ide.eclipse.ui/icons sample.gif
  Log:
  merlin 3.2.5 update
  
  Revision  Changes    Path
  1.4       +16 -1     avalon-sandbox/ide/org.apache.avalon.ide.eclipse.ui/plugin.xml
  
  Index: plugin.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/ide/org.apache.avalon.ide.eclipse.ui/plugin.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- plugin.xml        26 Jan 2004 15:56:44 -0000      1.3
  +++ plugin.xml        13 Feb 2004 11:45:34 -0000      1.4
  @@ -21,6 +21,10 @@
         <import plugin="org.junit"/>
         <import plugin="org.apache.avalon.MerlinDeveloperCore"/>
         <import plugin="org.apache.avalon.MerlinDeveloperLaunch"/>
  +      <import plugin="org.eclipse.jface.text"/>
  +      <import plugin="org.eclipse.ui.workbench.texteditor"/>
  +      <import plugin="org.eclipse.ui.editors"/>
  +     
      </requires>
   
   
  @@ -46,5 +50,16 @@
               
id="org.apache.avalon.ide.eclipse.merlin.wizards.newMerlinNatureWizard2">
         </wizard>
      </extension>
  -
  +   
  +   <extension
  +         point="org.eclipse.ui.editors">
  +      <editor
  +            name="Image Viewer"
  +            extensions="jpg, gif"
  +            icon="icons/sample.gif"
  +            class="org.apache.avalon.ide.eclipse.merlin.ui.tools.ImageViewerEditor"
  +            id="Viewer.editors.XMLEditor">
  +      </editor>
  +   </extension>
  +      
   </plugin>
  
  
  
  1.1                  
avalon-sandbox/ide/org.apache.avalon.ide.eclipse.ui/src/org/apache/avalon/ide/eclipse/merlin/ui/tools/ImageViewerEditor.java
  
  Index: ImageViewerEditor.java
  ===================================================================
  package org.apache.avalon.ide.eclipse.merlin.ui.tools;
  
  import org.eclipse.core.runtime.IProgressMonitor;
  import org.eclipse.swt.SWT;
  import org.eclipse.swt.custom.ScrolledComposite;
  import org.eclipse.swt.events.SelectionAdapter;
  import org.eclipse.swt.events.SelectionEvent;
  import org.eclipse.swt.graphics.Color;
  import org.eclipse.swt.graphics.Image;
  import org.eclipse.swt.layout.FillLayout;
  import org.eclipse.swt.layout.GridData;
  import org.eclipse.swt.layout.GridLayout;
  import org.eclipse.swt.widgets.Button;
  import org.eclipse.swt.widgets.Combo;
  import org.eclipse.swt.widgets.Composite;
  import org.eclipse.swt.widgets.Display;
  import org.eclipse.swt.widgets.Label;
  import org.eclipse.ui.IEditorInput;
  import org.eclipse.ui.IEditorSite;
  import org.eclipse.ui.PartInitException;
  import org.eclipse.ui.part.EditorPart;
  import org.eclipse.ui.part.FileEditorInput;
  public class ImageViewerEditor extends EditorPart
  {
  
      private Label imageLabel;
      private FileEditorInput input;
      private Image originalImage;
      private double factor;
      private Composite cImage;
  
      public ImageViewerEditor()
      {
          super();
      }
      public void dispose()
      {
  
          if (originalImage != null)
          {
              originalImage.dispose();
          }
      }
      /*
         * (non-Javadoc)
         * 
         * @see 
org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
         */
      public void doSave(IProgressMonitor pMonitor)
      {}
      /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.ui.part.EditorPart#doSaveAs()
         */
      public void doSaveAs()
      {
          // TODO Auto-generated method stub
  
      }
      /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,
         *      org.eclipse.ui.IEditorInput)
         */
      public void init(IEditorSite pSite, IEditorInput pInput) throws PartInitException
      {
          input = (FileEditorInput) pInput;
          this.setSite(pSite);
          this.setInput(pInput);
  
      }
      /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.ui.part.EditorPart#isDirty()
         */
      public boolean isDirty()
      {
          // TODO Auto-generated method stub
          return false;
      }
      /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
         */
      public boolean isSaveAsAllowed()
      {
          // TODO Auto-generated method stub
          return false;
      }
      /*
         * (non-Javadoc)
         * 
         * @see 
org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
         */
      public void createPartControl(Composite pParent)
      {
  
          pParent.setLayoutData(new FillLayout());
  
          Composite cMain = new Composite(pParent, SWT.NONE);
          cMain.setLayoutData(new GridData(GridData.FILL_BOTH));
          cMain.setLayout(new GridLayout());
  
          // Bar composite
          {
              final Composite composite = new Composite(cMain, SWT.BORDER);
              composite.setBackground(new Color(null, 192, 192, 192));
              final GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
              gridData.heightHint = 30;
              composite.setLayoutData(gridData);
              final GridLayout gridLayout = new GridLayout();
              gridLayout.numColumns = 8;
              composite.setLayout(gridLayout);
              {
                  final Label label = new Label(composite, SWT.NONE);
                  label.setBackground(new Color(null, 192, 192, 192));
                  label.setText("Zoom");
              }
              {
                  final Combo combo = new Combo(composite, SWT.NONE);
                  combo.addSelectionListener(new SelectionAdapter()
                  {
                      public void widgetSelected(SelectionEvent e)
                      {
                          int f = Integer.parseInt(((Combo) e.getSource()).getText());
                          factor = f / 100.0;
                          showImage(factor);
                          cImage.setSize(cImage.computeSize(SWT.DEFAULT, SWT.DEFAULT));
                      }
                  });
  
                  final GridData gridData_1 = new GridData();
                  gridData_1.widthHint = 40;
                  combo.setLayoutData(gridData_1);
                  combo.setItems(
                      new String[] { "50", "60", "70", "80", "90", "100", "110", 
"120", "150" });
                  combo.setText("100");
                  factor = 1;
              }
              {
                  final Button button = new Button(composite, SWT.NONE);
                  button.setText("in");
              }
              {
                  final Button button = new Button(composite, SWT.NONE);
                  button.setText("out");
              }
              {
                  final Label label = new Label(composite, SWT.RIGHT);
                  final GridData gridData_1 = new 
GridData(GridData.HORIZONTAL_ALIGN_END);
                  gridData_1.widthHint = 80;
                  label.setLayoutData(gridData_1);
                  label.setBackground(new Color(null, 192, 192, 192));
                  label.setText("image size:");
              }
              {
                  final Label label = new Label(composite, SWT.NONE);
                  final GridData gridData_1 = new GridData();
                  gridData_1.widthHint = 30;
                  label.setLayoutData(gridData_1);
                  label.setBackground(new Color(null, 192, 192, 192));
                  label.setText("0");
              }
              {
                  final Label label = new Label(composite, SWT.NONE);
                  final GridData gridData_1 = new GridData();
                  gridData_1.widthHint = 30;
                  label.setLayoutData(gridData_1);
                  label.setBackground(new Color(null, 192, 192, 192));
                  label.setText("0");
              }
          }
  
          // Scroll area
          {
              Composite cScroll = new Composite(cMain, SWT.NONE);
              final GridData gridData = new GridData(GridData.FILL_BOTH);
              cScroll.setLayoutData(gridData);
              cScroll.setLayout(new FillLayout());
              ScrolledComposite sc =
                  new ScrolledComposite(cScroll, SWT.H_SCROLL | SWT.V_SCROLL | 
SWT.BORDER);
              sc.setAlwaysShowScrollBars(true);
              // image composite
              cImage = new Composite(sc, SWT.NONE);
              sc.setContent(cImage);
              cImage.setLayout(new FillLayout());
  
              // create image
              imageLabel = new Label(cImage, SWT.NONE);
              String location = input.getFile().getLocation().toString();
              originalImage = new Image(Display.getDefault(), location);
              showImage(factor);
              cImage.setSize(cImage.computeSize(SWT.DEFAULT, SWT.DEFAULT));
          }
      }
  
      /**
         * @param pFactor
         */
      protected void showImage(double pFactor)
      {
          Image tmp = imageLabel.getImage();
          if (tmp != null)
          {
              tmp.dispose();
          }
          int width = originalImage.getBounds().width;
          int height = originalImage.getBounds().height;
  
          Image scaled =
              new Image(
                  Display.getDefault(),
                  originalImage.getImageData().scaledTo(
                      (int) (width * pFactor),
                      (int) (height * pFactor)));
  
          imageLabel.setImage(scaled);
  
      }
      /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
         */
      public void setFocus()
      {
          // TODO Auto-generated method stub
  
      }
  
  }
  
  
  
  1.1                  
avalon-sandbox/ide/org.apache.avalon.ide.eclipse.ui/icons/sample.gif
  
        <<Binary file>>
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to