package com.redhat.ceylon.eclipse.code.refactor;

import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

public class InlineInputPage extends UserInputWizardPage {
    public InlineInputPage(String name) {
        super(name);
    }

    /**
     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
     */
    public void createControl(Composite parent) {
        Composite result = new Composite(parent, SWT.NONE);
        setControl(result);
        GridLayout layout = new GridLayout();
        layout.numColumns = 2;
        result.setLayout(layout);
        Label title = new Label(result, SWT.LEFT);  
        title.setText("Inline " + getInlineRefactoring().getCount() + 
                " occurrences of declaration '" + 
                getInlineRefactoring().getDeclaration().getName() + "'.");
        GridData gd2 = new GridData(GridData.FILL_HORIZONTAL);
        gd2.horizontalSpan=2;
        new Label(result, SWT.SEPARATOR|SWT.HORIZONTAL).setLayoutData(gd2);
        GridData gd = new GridData();
        gd.horizontalSpan=2;
        title.setLayoutData(gd);
        final Button checkbox = new Button(result, SWT.CHECK);
        checkbox.setText("Inline all references and delete declaration");
        checkbox.setSelection(true);
        checkbox.setEnabled(getInlineRefactoring().isReference());
        checkbox.addSelectionListener(new SelectionListener() {
            @Override
            public void widgetSelected(SelectionEvent event) {
                getInlineRefactoring().setDelete();
                getInlineRefactoring().setJustOne();
            }
            @Override
            public void widgetDefaultSelected(SelectionEvent event) {}
        });        
    }

    private InlineRefactoring getInlineRefactoring() {
        return (InlineRefactoring) getRefactoring();
    }
}

@@ -560,123 +560,8 @@
  %7D%0A%0A
-    /**%0A     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)%0A     */%0A
     
@@ -602,24 +602,24 @@
 e parent) %7B%0A
+
         Comp
@@ -1336,29 +1336,268 @@
     
-final Button checkbox
+boolean ref = getInlineRefactoring().isReference();%0A        Button radioOne = new Button(result, SWT.RADIO);%0A        radioOne.setText(%22Inline just this reference%22);%0A        radioOne.setSelection(false);%0A        radioOne.setEnabled(ref);%0A        Button radioAll
  = n
@@ -1622,13 +1622,13 @@
 SWT.
-CHECK
+RADIO
 );%0A 
@@ -1630,32 +1630,32 @@
 O);%0A        
-checkbox
+radioAll
 .setText(%22In
@@ -1704,32 +1704,32 @@
 %22);%0A        
-checkbox
+radioAll
 .setSelectio
@@ -1745,24 +1745,24 @@
         
-checkbox
+radioAll
 .setEnab
@@ -1769,67 +1769,22 @@
 led(
-getInlineRefactoring().isReference());%0A        checkbox.add
+ref);%0A        
 Sele
@@ -1796,17 +1796,28 @@
 Listener
-(
+ listener = 
 new Sele
@@ -2144,18 +2144,18 @@
    %7D
-)
 ;
+%0A
         
 %0A   
@@ -2150,16 +2150,56 @@
         
+radioOne.addSelectionListener(listener);
 %0A    %7D%0A%0A

make the option a radio button