Showing posts with label Eclipse. Show all posts
Showing posts with label Eclipse. Show all posts

Saturday, December 31, 2011

Downloading and installing an old version of the Android Development Toolkit (ADT)

If Eclipse is giving you grief and not allowing you to install an obsolete version of the Android ADT (example: installing ADT 15.0.1 in Eclipse 3.5, since later ADTs require Eclipse 3.6), here are some steps to help you install it:


  1. Head over to http://developer.android.com/sdk/eclipse-adt.html#notes and pick which pick which version you want to use again.
  2. Create your download url: http://dl.google.com/android/ADT-##.#.#.zip. Google uses the version number for the downloads, so if you need 15.0.1, your download would be http://dl.google.com/android/ADT-15.0.1.zip.
  3. Install the new version as an archive (Help --> Install New Software ---> Add --> Archive)
This should get you back to developing!

Thursday, December 23, 2010

Creating a SWT Shell that can be opened from another Java Class using WindowBuilder

WindowBuilder (sometimes called WindowBuilder Pro) is an excellent add-on for Eclipse that allows you to visually build GUIs using SWT, Swing, and a variety of other frameworks including GWT. Google acquired Insantiations, the company that made WindowBuilder, in August of 2010 and recently announced that they are donating the source code and IP of the WindowBuilder project to the Eclipse Foundation. This will likely make WindowBuilder the standard visual GUI creator for those that use Java in the Eclipse IDE.

OK, now you know a little bit about the project. You may have discovered that when using the WindowBuilder wizard to create a new shell, the wizard always creates a shell with a main method. This is very useful for quick, one screen projects, but not for projects that require more than one window.

So, do you want to create a Shell that can be called from inside another class (say, in response to a button click)?

Here are the steps that I used to accomplish the task.



  • Use the SWT WindowBuilder Wizard to make a new shell, name it anything you want (NotMain, in the following case) modify the given code as such:



  • Remove from the main method:

Display display = Display.getDefault();
        Test shell = new Test(display);

  • Cut this code out from the main method:

try {
        shell.open();
        shell.layout();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

  • Change it to:

try
        {
            open();
            layout();
            while (!isDisposed()) 
            {
                if (!display.readAndDispatch()) 
                {
                    display.sleep();
                }
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

  • Place that code directly after

createContents();
in
public NotMain(Display display)
.

  •  Then, completely remove the main method. You should then be able to make all further modifications in the WindowBuilder "Design" window. You can remove the try/catch block, if you feel like it.


You’ll end up with something like this:
import org.eclipse.swt.SWT;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Shell;
    
    public class NotMain extends Shell 
    {
    
        /**
         * Create the shell.
         * @param display
         */
        public NotMain(Display display) 
        {
            super(display, SWT.SHELL_TRIM);
            createContents();
            try
            {
                open();
                layout();
                while (!isDisposed()) 
                {
                    if (!display.readAndDispatch()) 
                    {
                        display.sleep();
                    }
                }
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
    
        }
    
        /**
         * Create contents of the shell.
         */
        protected void createContents() 
        {
            setText("SWT Application");
            setSize(450, 300);
    
        }
    
        @Override
        protected void checkSubclass() 
        {
            // Disable the check that prevents subclassing of SWT components
        }
    
    }

Then, to call this shell from inside of a different class, write:
btn.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                new NotMain(getDisplay());
             }
        });
(where btn is the name of your SWT button)

To change the shell to be application modal to the calling class, change your superclass call in your new shell from:
super(display, SWT.SHELL_TRIM);
to:
super(display, SWT.APPLICATION_MODAL |SWT.SHELL_TRIM);


There you go. Now, get coding!

Tuesday, May 25, 2010

Setting up Pydev in Eclipse for Django development with Python

While researching ways to do Python/Django development using Eclipse, I found this wonderful, though slightly outdated, tutorial video by Nick Vlku that streamlines the process quite well:

As I mentioned, the video is slightly outdated, but very well made. Here are the things that have changed or that I would suggest doing differently than the video:

As I use Ubuntu 10.04, I would suggest installing these packages from the Ubuntu repositories: eclipse-jdt, and eclipse-pde. Without eclipse-pde, you can't install extensions (such as Pydev). You could also simply search for "Eclipse" in the Ubuntu Software Center.

Pydev and the Pydev Extensions have now been merged together as of version 1.5.0, so you now have all of the extra capabilities from Pydev Extensions in the open source Pydev package. Pydev also has a new website- http://pydev.org/.

To add PyDev to Eclipse, Go to Help --> Install New Software.
Then Click on Add in the upper right hand corner and enter PyDev for the name, and http://pydev.org/updates for the location.
Select PyDev for Eclipse, select "Next", agree to terms, and the "Finish".

For Django, To add the Start and Stop Debug server buttons, after right-clicking the Icon bar and choosing "Customize Perspective:, the PyDev Debugger Server buttons were under "Command Groups Availability" -- not "Commands".

You should now have a working PyDev development perspective in Eclipse, including integration with Django. Enjoy!