org.eclipse.emf.codegen.ui_2.6.0.v20120130-0943

16:43:24.215 INFO  jd.cli.Main - Decompiling org.eclipse.emf.codegen.ui_2.6.0.v20120130-0943.jar
package org.eclipse.emf.codegen.action;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.codegen.jet.JETAddNatureOperation;
import org.eclipse.emf.codegen.presentation.CodeGenUIPlugin;
import org.eclipse.jface.operation.IRunnableWithProgress;

class AddJETNatureAction$1
  implements IRunnableWithProgress
{
  AddJETNatureAction$1(AddJETNatureAction paramAddJETNatureAction) {}
  
  public void run(IProgressMonitor monitor)
  {
    try
    {
      JETAddNatureOperation addNature = new JETAddNatureOperation(this$0.projects);
      addNature.run(monitor);
    }
    catch (CoreException e)
    {
      CodeGenUIPlugin.write(e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.action.AddJETNatureAction.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.action;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.codegen.jet.JETAddNatureOperation;
import org.eclipse.emf.codegen.presentation.CodeGenUIPlugin;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;

public class AddJETNatureAction
  implements IActionDelegate
{
  protected List<IProject> projects;
  
  public AddJETNatureAction()
  {
    projects = new ArrayList();
  }
  
  public void run(IAction action)
  {
    if (action.isEnabled())
    {
      IRunnableWithProgress op = 
        new IRunnableWithProgress()
        {
          public void run(IProgressMonitor monitor)
          {
            try
            {
              JETAddNatureOperation addNature = new JETAddNatureOperation(projects);
              addNature.run(monitor);
            }
            catch (CoreException e)
            {
              CodeGenUIPlugin.write(e);
            }
          }
        };
        try
        {
          ProgressMonitorDialog dialog = 
            new ProgressMonitorDialog(CodeGenUIPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindow().getShell());
          dialog.run(false, true, op);
        }
        catch (Exception e)
        {
          CodeGenUIPlugin.write(e);
        }
      }
    }
    
    public void selectionChanged(IAction action, ISelection selection)
    {
      projects.clear();
      if ((selection instanceof IStructuredSelection)) {
        for (Object object : ((IStructuredSelection)selection).toList()) {
          if ((object instanceof IProject)) {
            projects.add((IProject)object);
          } else if ((object instanceof IJavaProject)) {
            projects.add(((IJavaProject)object).getProject());
          }
        }
      }
    }
  }

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.action.AddJETNatureAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.action;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.codegen.jet.JETCompileTemplateOperation;
import org.eclipse.emf.codegen.jet.JETNature;
import org.eclipse.emf.codegen.presentation.CodeGenUIPlugin;
import org.eclipse.jface.operation.IRunnableWithProgress;

class CompileTemplateAction$1
  implements IRunnableWithProgress
{
  CompileTemplateAction$1(CompileTemplateAction paramCompileTemplateAction) {}
  
  public void run(IProgressMonitor monitor)
  {
    try
    {
      for (Iterator<?> i = this$0.getSelectedObjects().iterator(); i.hasNext();)
      {
        IFile file = (IFile)i.next();
        JETNature jetNature = JETNature.getRuntime(file.getProject());
        if (jetNature != null)
        {
          JETCompileTemplateOperation compileTemplate = 
            new JETCompileTemplateOperation(file.getProject(), jetNature.getTemplateContainers(), Collections.singleton(file));
          compileTemplate.run(monitor);
        }
      }
    }
    catch (Exception e)
    {
      CodeGenUIPlugin.write(e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.action.CompileTemplateAction.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.action;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.codegen.jet.JETCompileTemplateOperation;
import org.eclipse.emf.codegen.jet.JETNature;
import org.eclipse.emf.codegen.presentation.CodeGenUIPlugin;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;

public class CompileTemplateAction
  implements IActionDelegate
{
  protected ISelection selection;
  
  public void run(IAction action)
  {
    if (action.isEnabled())
    {
      IRunnableWithProgress op = 
        new IRunnableWithProgress()
        {
          public void run(IProgressMonitor monitor)
          {
            try
            {
              for (Iterator<?> i = getSelectedObjects().iterator(); i.hasNext();)
              {
                IFile file = (IFile)i.next();
                JETNature jetNature = JETNature.getRuntime(file.getProject());
                if (jetNature != null)
                {
                  JETCompileTemplateOperation compileTemplate = 
                    new JETCompileTemplateOperation(file.getProject(), jetNature.getTemplateContainers(), Collections.singleton(file));
                  compileTemplate.run(monitor);
                }
              }
            }
            catch (Exception e)
            {
              CodeGenUIPlugin.write(e);
            }
          }
        };
        try
        {
          ProgressMonitorDialog dialog = 
            new ProgressMonitorDialog(CodeGenUIPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindow().getShell());
          dialog.run(false, true, op);
        }
        catch (Exception e)
        {
          CodeGenUIPlugin.write(e);
        }
      }
    }
    
    public void selectionChanged(IAction action, ISelection selection)
    {
      this.selection = selection;
      setActionState(action);
    }
    
    protected void setActionState(IAction action)
    {
      action.setEnabled(true);
    }
    
    protected List<?> getSelectedObjects()
    {
      return 
        (selection instanceof IStructuredSelection) ? 
        ((IStructuredSelection)selection).toList() : 
        Collections.EMPTY_LIST;
    }
    
    protected boolean isSupportedAction(Object object)
    {
      return ((object instanceof IFile)) && (((IFile)object).isAccessible());
    }
  }

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.action.CompileTemplateAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.presentation;

import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.ResourceBundle;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.codegen.jet.JETException;
import org.eclipse.emf.common.ui.dialogs.DiagnosticDialog;
import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.Bundle;

public class CodeGenUIPlugin
  extends AbstractUIPlugin
{
  private static CodeGenUIPlugin plugin;
  
  public static CodeGenUIPlugin getPlugin()
  {
    return plugin;
  }
  
  public CodeGenUIPlugin()
  {
    plugin = this;
  }
  
  public String getString(String key)
  {
    return Platform.getResourceBundle(plugin.getBundle()).getString(key);
  }
  
  public ImageDescriptor getImage(String key)
  {
    try
    {
      return ImageDescriptor.createFromURL(new URL(getBundle().getEntry("/") + "icons/" + key + ".gif"));
    }
    catch (MalformedURLException exception)
    {
      write(exception);
    }
    return null;
  }
  
  public String getString(String key, Object[] objects)
  {
    return MessageFormat.format(getString(key), objects);
  }
  
  public static void write(Exception exception)
  {
    DiagnosticDialog.open(
      getPlugin().getWorkbench().getActiveWorkbenchWindow().getShell(), 
      getPlugin().getString("_UI_JETProblem_title"), 
      (exception instanceof JETException) ? 
      getPlugin().getString("_UI_JETCompileProblem_message") : 
      null, 
      BasicDiagnostic.toDiagnostic(exception));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.presentation.CodeGenUIPlugin
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.presentation;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.codegen.jet.JETAddNatureOperation;
import org.eclipse.ui.actions.WorkspaceModifyOperation;

class ConvertToJETProjectWizard$1
  extends WorkspaceModifyOperation
{
  ConvertToJETProjectWizard$1(ConvertToJETProjectWizard paramConvertToJETProjectWizard) {}
  
  public void execute(IProgressMonitor monitor)
  {
    try
    {
      JETAddNatureOperation addNature = new JETAddNatureOperation(this$0.projectsToConvert);
      addNature.run(monitor);
    }
    catch (CoreException e)
    {
      CodeGenUIPlugin.write(e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.presentation.ConvertToJETProjectWizard.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.presentation;

import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbench;

class ConvertToJETProjectWizard$ConversionPage$1
  extends LabelProvider
{
  ConvertToJETProjectWizard$ConversionPage$1(ConvertToJETProjectWizard.ConversionPage paramConversionPage) {}
  
  public Image getImage(Object o)
  {
    return access$0this$1).workbench.getSharedImages().getImage("IMG_OBJ_PROJECT");
  }
  
  public String getText(Object o)
  {
    return ((IProject)o).getName();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.presentation.ConvertToJETProjectWizard.ConversionPage.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.presentation;

import java.util.Arrays;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;

class ConvertToJETProjectWizard$ConversionPage$2
  implements ICheckStateListener
{
  ConvertToJETProjectWizard$ConversionPage$2(ConvertToJETProjectWizard.ConversionPage paramConversionPage, CheckboxTableViewer paramCheckboxTableViewer) {}
  
  public void checkStateChanged(CheckStateChangedEvent event)
  {
    access$0this$1).projectsToConvert.clear();
    
    List<IProject> list = Arrays.asList(val$projectsCheckboxTableViewer.getCheckedElements());
    access$0this$1).projectsToConvert.addAll(list);
    this$1.setPageComplete(this$1.isPageComplete());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.presentation.ConvertToJETProjectWizard.ConversionPage.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.presentation;

import java.util.List;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class ConvertToJETProjectWizard$ConversionPage$3
  extends SelectionAdapter
{
  ConvertToJETProjectWizard$ConversionPage$3(ConvertToJETProjectWizard.ConversionPage paramConversionPage, List paramList, CheckboxTableViewer paramCheckboxTableViewer) {}
  
  public void widgetSelected(SelectionEvent event)
  {
    access$0this$1).projectsToConvert.addAll(val$projects);
    val$projectsCheckboxTableViewer.setCheckedElements(val$projects.toArray());
    this$1.setPageComplete(this$1.isPageComplete());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.presentation.ConvertToJETProjectWizard.ConversionPage.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.presentation;

import java.util.List;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class ConvertToJETProjectWizard$ConversionPage$4
  extends SelectionAdapter
{
  ConvertToJETProjectWizard$ConversionPage$4(ConvertToJETProjectWizard.ConversionPage paramConversionPage, CheckboxTableViewer paramCheckboxTableViewer) {}
  
  public void widgetSelected(SelectionEvent event)
  {
    val$projectsCheckboxTableViewer.setCheckedElements(new Object[0]);
    access$0this$1).projectsToConvert.clear();
    this$1.setPageComplete(this$1.isPageComplete());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.presentation.ConvertToJETProjectWizard.ConversionPage.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.presentation;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.codegen.jet.JETNature;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbench;

public class ConvertToJETProjectWizard$ConversionPage
  extends WizardPage
{
  public ConvertToJETProjectWizard$ConversionPage(ConvertToJETProjectWizard paramConvertToJETProjectWizard)
  {
    super("JETConversionPage");
    
    setTitle(CodeGenUIPlugin.getPlugin().getString("_UI_JETConvertProject_label"));
    paramConvertToJETProjectWizard.setDefaultPageImageDescriptor(CodeGenUIPlugin.getPlugin().getImage("full/wizban/ConvertToJETProjectWizard"));
    setDescription(CodeGenUIPlugin.getPlugin().getString("_UI_JETConvertProject_message"));
  }
  
  public boolean isPageComplete()
  {
    return !this$0.projectsToConvert.isEmpty();
  }
  
  public void createControl(Composite parent)
  {
    Composite composite = new Composite(parent, 0);
    
    FormLayout layout = new FormLayout();
    marginTop = 10;
    marginLeft = 10;
    marginRight = 10;
    spacing = 10;
    composite.setLayout(layout);
    
    GridData data = new GridData();
    verticalAlignment = 4;
    grabExcessVerticalSpace = true;
    horizontalAlignment = 4;
    composite.setLayoutData(data);
    
    Label projectsLabel = new Label(composite, 16384);
    projectsLabel.setText(CodeGenUIPlugin.getPlugin().getString("_UI_Projects_label"));
    
    FormData data = new FormData();
    left = new FormAttachment(0);
    projectsLabel.setLayoutData(data);
    
    Table projectsTable = new Table(composite, 2080);
    
    FormData data = new FormData(-1, 250);
    top = new FormAttachment(projectsLabel, 5);
    bottom = new FormAttachment(100);
    left = new FormAttachment(0);
    right = new FormAttachment(100);
    height = 90;
    projectsTable.setLayoutData(data);
    
    Composite selectionComposite = new Composite(composite, 0);
    
    FormData data = new FormData();
    top = new FormAttachment(projectsLabel, 0, 16777216);
    right = new FormAttachment(100);
    selectionComposite.setLayoutData(data);
    
    RowLayout layout = new RowLayout();
    justify = true;
    pack = true;
    spacing = 15;
    marginBottom = (marginTop = 0);
    marginLeft = (marginRight = 0);
    selectionComposite.setLayout(layout);
    
    Button selectAllButton = new Button(selectionComposite, 8);
    selectAllButton.setText(CodeGenUIPlugin.getPlugin().getString("_UI_SelectAll_label"));
    
    Button deselectAllButton = new Button(selectionComposite, 8);
    deselectAllButton.setText(CodeGenUIPlugin.getPlugin().getString("_UI_DeselectAll_label"));
    
    final CheckboxTableViewer projectsCheckboxTableViewer = new CheckboxTableViewer(projectsTable);
    
    TableLayout layout = new TableLayout();
    TableColumn projectColumn = new TableColumn(projectsTable, 0);
    layout.addColumnData(new ColumnWeightData(1, true));
    projectColumn.setResizable(true);
    projectsTable.setLayout(layout);
    
    projectsCheckboxTableViewer.setColumnProperties(new String[] { "a" });
    projectsCheckboxTableViewer.setContentProvider(new ArrayContentProvider());
    projectsCheckboxTableViewer.setLabelProvider(
      new LabelProvider()
      {
        public Image getImage(Object o)
        {
          return this$0.workbench.getSharedImages().getImage("IMG_OBJ_PROJECT");
        }
        
        public String getText(Object o)
        {
          return ((IProject)o).getName();
        }
      });
    projectsCheckboxTableViewer.addCheckStateListener(
      new ICheckStateListener()
      {
        public void checkStateChanged(CheckStateChangedEvent event)
        {
          this$0.projectsToConvert.clear();
          
          List<IProject> list = Arrays.asList(projectsCheckboxTableViewer.getCheckedElements());
          this$0.projectsToConvert.addAll(list);
          setPageComplete(isPageComplete());
        }
      });
    final List<IProject> projects = new ArrayList(Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects()));
    for (Iterator<IProject> i = projects.iterator(); i.hasNext();)
    {
      IProject project = (IProject)i.next();
      boolean isJavaProject = false;
      try
      {
        isJavaProject = project.getNature("org.eclipse.jdt.core.javanature") != null;
      }
      catch (CoreException localCoreException) {}
      if ((!project.isOpen()) || (JETNature.getRuntime(project) != null) || (!isJavaProject)) {
        i.remove();
      }
    }
    projectsCheckboxTableViewer.setInput(projects.toArray());
    projectsCheckboxTableViewer.setCheckedElements(this$0.projectsToConvert.toArray());
    
    selectAllButton.addSelectionListener(
      new SelectionAdapter()
      {
        public void widgetSelected(SelectionEvent event)
        {
          this$0.projectsToConvert.addAll(projects);
          projectsCheckboxTableViewer.setCheckedElements(projects.toArray());
          setPageComplete(isPageComplete());
        }
      });
    deselectAllButton.addSelectionListener(
      new SelectionAdapter()
      {
        public void widgetSelected(SelectionEvent event)
        {
          projectsCheckboxTableViewer.setCheckedElements(new Object[0]);
          this$0.projectsToConvert.clear();
          setPageComplete(isPageComplete());
        }
      });
    setControl(composite);
    
    setPageComplete(isPageComplete());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.presentation.ConvertToJETProjectWizard.ConversionPage
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.presentation;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.codegen.jet.JETAddNatureOperation;
import org.eclipse.emf.codegen.jet.JETNature;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.actions.WorkspaceModifyOperation;

public class ConvertToJETProjectWizard
  extends Wizard
  implements INewWizard
{
  protected IWorkbench workbench;
  protected List<IProject> projectsToConvert = new ArrayList();
  protected ConversionPage conversionPage;
  
  public ConvertToJETProjectWizard()
  {
    setWindowTitle(CodeGenUIPlugin.getPlugin().getString("_UI_JETConvertProject_label"));
    setNeedsProgressMonitor(true);
  }
  
  public void init(IWorkbench workbench, IStructuredSelection selection)
  {
    this.workbench = workbench;
    for (Object object : selection.toList()) {
      if ((object instanceof IProject))
      {
        IProject project = (IProject)object;
        if ((project.isOpen()) && (JETNature.getRuntime(project) == null)) {
          projectsToConvert.add(project);
        }
      }
    }
  }
  
  public void addPages()
  {
    super.addPages();
    conversionPage = new ConversionPage();
    addPage(conversionPage);
  }
  
  public boolean performFinish()
  {
    IRunnableWithProgress operation = 
      new WorkspaceModifyOperation()
      {
        public void execute(IProgressMonitor monitor)
        {
          try
          {
            JETAddNatureOperation addNature = new JETAddNatureOperation(projectsToConvert);
            addNature.run(monitor);
          }
          catch (CoreException e)
          {
            CodeGenUIPlugin.write(e);
          }
        }
      };
      try
      {
        getContainer().run(false, true, operation);
      }
      catch (InterruptedException exception)
      {
        CodeGenUIPlugin.write(exception);
      }
      catch (InvocationTargetException exception)
      {
        CodeGenUIPlugin.write(exception);
      }
      return true;
    }
    
    public class ConversionPage
      extends WizardPage
    {
      public ConversionPage()
      {
        super();
        
        setTitle(CodeGenUIPlugin.getPlugin().getString("_UI_JETConvertProject_label"));
        setDefaultPageImageDescriptor(CodeGenUIPlugin.getPlugin().getImage("full/wizban/ConvertToJETProjectWizard"));
        setDescription(CodeGenUIPlugin.getPlugin().getString("_UI_JETConvertProject_message"));
      }
      
      public boolean isPageComplete()
      {
        return !projectsToConvert.isEmpty();
      }
      
      public void createControl(Composite parent)
      {
        Composite composite = new Composite(parent, 0);
        
        FormLayout layout = new FormLayout();
        marginTop = 10;
        marginLeft = 10;
        marginRight = 10;
        spacing = 10;
        composite.setLayout(layout);
        
        GridData data = new GridData();
        verticalAlignment = 4;
        grabExcessVerticalSpace = true;
        horizontalAlignment = 4;
        composite.setLayoutData(data);
        
        Label projectsLabel = new Label(composite, 16384);
        projectsLabel.setText(CodeGenUIPlugin.getPlugin().getString("_UI_Projects_label"));
        
        FormData data = new FormData();
        left = new FormAttachment(0);
        projectsLabel.setLayoutData(data);
        
        Table projectsTable = new Table(composite, 2080);
        
        FormData data = new FormData(-1, 250);
        top = new FormAttachment(projectsLabel, 5);
        bottom = new FormAttachment(100);
        left = new FormAttachment(0);
        right = new FormAttachment(100);
        height = 90;
        projectsTable.setLayoutData(data);
        
        Composite selectionComposite = new Composite(composite, 0);
        
        FormData data = new FormData();
        top = new FormAttachment(projectsLabel, 0, 16777216);
        right = new FormAttachment(100);
        selectionComposite.setLayoutData(data);
        
        RowLayout layout = new RowLayout();
        justify = true;
        pack = true;
        spacing = 15;
        marginBottom = (marginTop = 0);
        marginLeft = (marginRight = 0);
        selectionComposite.setLayout(layout);
        
        Button selectAllButton = new Button(selectionComposite, 8);
        selectAllButton.setText(CodeGenUIPlugin.getPlugin().getString("_UI_SelectAll_label"));
        
        Button deselectAllButton = new Button(selectionComposite, 8);
        deselectAllButton.setText(CodeGenUIPlugin.getPlugin().getString("_UI_DeselectAll_label"));
        
        final CheckboxTableViewer projectsCheckboxTableViewer = new CheckboxTableViewer(projectsTable);
        
        TableLayout layout = new TableLayout();
        TableColumn projectColumn = new TableColumn(projectsTable, 0);
        layout.addColumnData(new ColumnWeightData(1, true));
        projectColumn.setResizable(true);
        projectsTable.setLayout(layout);
        
        projectsCheckboxTableViewer.setColumnProperties(new String[] { "a" });
        projectsCheckboxTableViewer.setContentProvider(new ArrayContentProvider());
        projectsCheckboxTableViewer.setLabelProvider(
          new LabelProvider()
          {
            public Image getImage(Object o)
            {
              return workbench.getSharedImages().getImage("IMG_OBJ_PROJECT");
            }
            
            public String getText(Object o)
            {
              return ((IProject)o).getName();
            }
          });
        projectsCheckboxTableViewer.addCheckStateListener(
          new ICheckStateListener()
          {
            public void checkStateChanged(CheckStateChangedEvent event)
            {
              projectsToConvert.clear();
              
              List<IProject> list = Arrays.asList(projectsCheckboxTableViewer.getCheckedElements());
              projectsToConvert.addAll(list);
              setPageComplete(isPageComplete());
            }
          });
        final List<IProject> projects = new ArrayList(Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects()));
        for (Iterator<IProject> i = projects.iterator(); i.hasNext();)
        {
          IProject project = (IProject)i.next();
          boolean isJavaProject = false;
          try
          {
            isJavaProject = project.getNature("org.eclipse.jdt.core.javanature") != null;
          }
          catch (CoreException localCoreException) {}
          if ((!project.isOpen()) || (JETNature.getRuntime(project) != null) || (!isJavaProject)) {
            i.remove();
          }
        }
        projectsCheckboxTableViewer.setInput(projects.toArray());
        projectsCheckboxTableViewer.setCheckedElements(projectsToConvert.toArray());
        
        selectAllButton.addSelectionListener(
          new SelectionAdapter()
          {
            public void widgetSelected(SelectionEvent event)
            {
              projectsToConvert.addAll(projects);
              projectsCheckboxTableViewer.setCheckedElements(projects.toArray());
              setPageComplete(isPageComplete());
            }
          });
        deselectAllButton.addSelectionListener(
          new SelectionAdapter()
          {
            public void widgetSelected(SelectionEvent event)
            {
              projectsCheckboxTableViewer.setCheckedElements(new Object[0]);
              projectsToConvert.clear();
              setPageComplete(isPageComplete());
            }
          });
        setControl(composite);
        
        setPageComplete(isPageComplete());
      }
    }
  }

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.presentation.ConvertToJETProjectWizard
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.presentation;

import java.util.List;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.codegen.jet.IJETNature;
import org.eclipse.emf.codegen.jet.JETNature;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.PropertyPage;

public class JETPropertyPage
  extends PropertyPage
  implements Listener
{
  protected IProject project;
  protected Text templateContainerField;
  protected Text javaSourceField;
  protected List<Object> oldTemplateContainers;
  protected List<Object> oldTemplateSourceContainers;
  protected List<Object> newTemplateContainers;
  protected List<Object> newTemplateSourceContainers;
  protected IContainer oldJavaSoureContainer;
  protected IContainer newJavaSourceContainer;
  
  protected Control createContents(Composite parent)
  {
    Control control = null;
    
    project = getJETProject();
    if (project != null)
    {
      IJETNature jetNature = JETNature.getRuntime(project);
      if (jetNature != null)
      {
        Composite containerGroup = new Composite(parent, 0);
        GridLayout layout = new GridLayout();
        numColumns = 2;
        containerGroup.setLayout(layout);
        containerGroup.setLayoutData(new GridData(768));
        
        Label templateContainerLabel = new Label(containerGroup, 32);
        templateContainerLabel.setText(CodeGenUIPlugin.getPlugin().getString("_UI_TemplateContainer_label"));
        
        templateContainerField = new Text(containerGroup, 2048);
        GridData data = new GridData(768);
        templateContainerField.setLayoutData(data);
        
        oldTemplateContainers = jetNature.getTemplateContainers();
        oldTemplateSourceContainers = jetNature.getTemplateSourceContainers();
        templateContainerField.setText(JETNature.getContainers(project, oldTemplateContainers, oldTemplateSourceContainers));
        templateContainerField.addListener(24, this);
        
        Label sourceContainerLabel = new Label(containerGroup, 32);
        sourceContainerLabel.setText(CodeGenUIPlugin.getPlugin().getString("_UI_SourceContainer_label"));
        
        javaSourceField = new Text(containerGroup, 2048);
        data = new GridData(768);
        javaSourceField.setLayoutData(data);
        
        oldJavaSoureContainer = jetNature.getJavaSourceContainer();
        javaSourceField.setText(oldJavaSoureContainer.getProjectRelativePath().toString());
        javaSourceField.addListener(24, this);
        
        control = containerGroup;
      }
      else
      {
        Label closedProjectLabel = new Label(parent, 0);
        closedProjectLabel.setText(CodeGenUIPlugin.getPlugin().getString("_UI_WebSettingsNotAvaiable_message"));
        control = closedProjectLabel;
      }
    }
    return control;
  }
  
  protected IProject getJETProject()
  {
    Object element = getElement();
    if ((element instanceof IProject)) {
      return isJETProject((IProject)element) ? (IProject)element : null;
    }
    if ((element instanceof IJavaProject)) {
      return isJETProject(((IJavaProject)element).getProject()) ? ((IJavaProject)element).getProject() : null;
    }
    return null;
  }
  
  protected static boolean isJETProject(IProject project)
  {
    try
    {
      return project.hasNature("org.eclipse.emf.codegen.jet.IJETNature");
    }
    catch (CoreException e)
    {
      CodeGenUIPlugin.write(e);
    }
    return false;
  }
  
  public void handleEvent(Event event)
  {
    if (widget == templateContainerField)
    {
      IJETNature jetNature = JETNature.getRuntime(project);
      if (jetNature != null) {
        try
        {
          newTemplateContainers = JETNature.getContainers(getJETProject(), templateContainerField.getText());
          newTemplateSourceContainers = JETNature.getContainers(getJETProject(), templateContainerField.getText(), true);
          
          setErrorMessage(null);
        }
        catch (Exception exception)
        {
          setErrorMessage(
            CodeGenUIPlugin.getPlugin().getString(
            "_UI_CannotSetTemplateContainer_message", new String[] { exception.getLocalizedMessage() }));
        }
      }
    }
    if (widget == javaSourceField)
    {
      IJETNature jetNature = JETNature.getRuntime(project);
      if (jetNature != null)
      {
        newJavaSourceContainer = JETNature.getContainer(getJETProject(), javaSourceField.getText());
        if (newJavaSourceContainer.exists()) {
          setErrorMessage(null);
        } else {
          setErrorMessage(
            CodeGenUIPlugin.getPlugin().getString(
            "_UI_ContainerDoesNotExist_message", new String[] { newJavaSourceContainer.toString() }));
        }
      }
    }
  }
  
  public boolean performOk()
  {
    performApply();
    return super.performOk();
  }
  
  protected void performApply()
  {
    IJETNature jetNature = JETNature.getRuntime(project);
    if (jetNature != null)
    {
      if (newTemplateContainers != null) {
        jetNature.setTemplateContainers(
          newTemplateContainers, newTemplateSourceContainers == null ? newTemplateContainers : newTemplateSourceContainers);
      }
      if (newJavaSourceContainer != null) {
        jetNature.setJavaSourceContainer(newJavaSourceContainer);
      }
    }
  }
  
  protected void performDefaults()
  {
    IJETNature jetNature = JETNature.getRuntime(project);
    if (jetNature != null) {
      try
      {
        ((JETNature)jetNature).setDefaults(new NullProgressMonitor());
      }
      catch (CoreException e)
      {
        CodeGenUIPlugin.write(e);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.presentation.JETPropertyPage
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
1

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd