org.eclipse.emf.codegen.ecore.ui_2.7.0.v20120130-0943

16:43:22.181 INFO  jd.cli.Main - Decompiling org.eclipse.emf.codegen.ecore.ui_2.7.0.v20120130-0943.jar
package org.eclipse.emf.codegen.ecore.genmodel.action;

import java.util.Collection;
import java.util.Iterator;
import org.eclipse.emf.codegen.ecore.genmodel.provider.GenModelEditPlugin;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.edit.command.CommandParameter;
import org.eclipse.emf.edit.command.CreateChildCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.ui.action.StaticSelectionCommandAction;
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IEditorPart;

public class CreateChildAction
  extends StaticSelectionCommandAction
{
  protected CommandParameter newChildDescriptor;
  
  public CreateChildAction(IEditorPart editorPart, ISelection selection, CommandParameter newChildDescriptor)
  {
    super(editorPart);
    this.newChildDescriptor = newChildDescriptor;
    configureAction(selection);
  }
  
  protected ImageDescriptor getDefaultImageDescriptor()
  {
    return ExtendedImageRegistry.INSTANCE.getImageDescriptor(GenModelEditPlugin.INSTANCE.getImage("CreateChild"));
  }
  
  protected Command createActionCommand(EditingDomain editingDomain, Collection<?> collection)
  {
    if (collection.size() == 1) {
      return CreateChildCommand.create(editingDomain, collection.iterator().next(), newChildDescriptor, collection);
    }
    return UnexecutableCommand.INSTANCE;
  }
}

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

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class GenerateHandler$GenModelGenerationDialog$1
  implements Listener
{
  GenerateHandler$GenModelGenerationDialog$1(GenerateHandler.GenModelGenerationDialog paramGenModelGenerationDialog) {}
  
  public void handleEvent(Event event)
  {
    GenerateHandler.GenModelGenerationDialog.access$0(this$1, 14);
    this$1.close();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.ecore.genmodel.handler.GenerateHandler.GenModelGenerationDialog.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.ecore.genmodel.handler;

import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;

class GenerateHandler$GenModelGenerationDialog$2
  implements Listener
{
  GenerateHandler$GenModelGenerationDialog$2(GenerateHandler.GenModelGenerationDialog paramGenModelGenerationDialog) {}
  
  public void handleEvent(Event event)
  {
    if (this$1.genModelTable.getSelectionCount() == 1)
    {
      if (type == 8)
      {
        Boolean select = null;
        TableColumn[] tableColumns = this$1.genModelTable.getColumns();
        for (int i = 1; i < tableColumns.length; i++) {
          select = this$1.checkBoxColumnHeaderSelected(tableColumns[i], this$1.genModelTable.getSelectionIndex(), select);
        }
        this$1.updateButtons(select);
      }
      TableItem tableItem = this$1.genModelTable.getSelection()[0];
      this$1.selectionChanged((GenModel)tableItem.getData());
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.ecore.genmodel.handler.GenerateHandler.GenModelGenerationDialog.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.ecore.genmodel.handler;

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;

class GenerateHandler$GenModelGenerationDialog$3
  implements Listener
{
  GenerateHandler$GenModelGenerationDialog$3(GenerateHandler.GenModelGenerationDialog paramGenModelGenerationDialog) {}
  
  public void handleEvent(Event event)
  {
    Boolean select = null;
    TableColumn[] tableColumns = this$1.genModelTable.getColumns();
    for (int i = 1; i < tableColumns.length; i++) {
      select = this$1.checkBoxColumnHeaderSelected(tableColumns[i], -1, select);
    }
    this$1.updateButtons(select);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.ecore.genmodel.handler.GenerateHandler.GenModelGenerationDialog.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.ecore.genmodel.handler;

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.TableColumn;

class GenerateHandler$GenModelGenerationDialog$4
  implements Listener
{
  GenerateHandler$GenModelGenerationDialog$4(GenerateHandler.GenModelGenerationDialog paramGenModelGenerationDialog) {}
  
  public void handleEvent(Event event)
  {
    TableColumn tableColumn = (TableColumn)widget;
    Boolean select = this$1.checkBoxColumnHeaderSelected(tableColumn, -1, null);
    this$1.updateButtons(select);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.ecore.genmodel.handler.GenerateHandler.GenModelGenerationDialog.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.ecore.genmodel.handler;

import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class GenerateHandler$GenModelGenerationDialog$5
  implements Listener
{
  GenerateHandler$GenModelGenerationDialog$5(GenerateHandler.GenModelGenerationDialog paramGenModelGenerationDialog) {}
  
  public void handleEvent(Event event)
  {
    this$1.updateButtons(Boolean.valueOf(((Button)widget).getSelection()));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.ecore.genmodel.handler.GenerateHandler.GenModelGenerationDialog.5
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.ecore.genmodel.handler;

import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.provider.GenModelEditPlugin;

 enum GenerateHandler$GenModelGenerationDialog$ProjectType$1
{
  GenerateHandler$GenModelGenerationDialog$ProjectType$1()
  {
    super(paramString, paramInt, null);
  }
  
  public String getID()
  {
    return "org.eclipse.emf.codegen.ecore.genmodel.generator.ModelProject";
  }
  
  public String getLabel()
  {
    return GenModelEditPlugin.INSTANCE.getString("_UI_Model_title");
  }
  
  public boolean canGenerate(GenModel genModel)
  {
    return genModel.canGenerate();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.ecore.genmodel.handler.GenerateHandler.GenModelGenerationDialog.ProjectType.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.ecore.genmodel.handler;

import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.provider.GenModelEditPlugin;

 enum GenerateHandler$GenModelGenerationDialog$ProjectType$2
{
  GenerateHandler$GenModelGenerationDialog$ProjectType$2()
  {
    super(paramString, paramInt, null);
  }
  
  public String getID()
  {
    return "org.eclipse.emf.codegen.ecore.genmodel.generator.EditProject";
  }
  
  public String getLabel()
  {
    return GenModelEditPlugin.INSTANCE.getString("_UI_Edit_title");
  }
  
  public boolean canGenerate(GenModel genModel)
  {
    return genModel.canGenerateEdit();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.ecore.genmodel.handler.GenerateHandler.GenModelGenerationDialog.ProjectType.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.ecore.genmodel.handler;

import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.provider.GenModelEditPlugin;

 enum GenerateHandler$GenModelGenerationDialog$ProjectType$3
{
  GenerateHandler$GenModelGenerationDialog$ProjectType$3()
  {
    super(paramString, paramInt, null);
  }
  
  public String getID()
  {
    return "org.eclipse.emf.codegen.ecore.genmodel.generator.EditorProject";
  }
  
  public String getLabel()
  {
    return GenModelEditPlugin.INSTANCE.getString("_UI_Editor_title");
  }
  
  public boolean canGenerate(GenModel genModel)
  {
    return genModel.canGenerateEditor();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.ecore.genmodel.handler.GenerateHandler.GenModelGenerationDialog.ProjectType.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.ecore.genmodel.handler;

import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.provider.GenModelEditPlugin;

 enum GenerateHandler$GenModelGenerationDialog$ProjectType$4
{
  GenerateHandler$GenModelGenerationDialog$ProjectType$4()
  {
    super(paramString, paramInt, null);
  }
  
  public String getID()
  {
    return "org.eclipse.emf.codegen.ecore.genmodel.generator.TestsProject";
  }
  
  public String getLabel()
  {
    return GenModelEditPlugin.INSTANCE.getString("_UI_Tests_title");
  }
  
  public boolean canGenerate(GenModel genModel)
  {
    return genModel.canGenerateTests();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.ecore.genmodel.handler.GenerateHandler.GenModelGenerationDialog.ProjectType.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.ecore.genmodel.handler;

import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.provider.GenModelEditPlugin;

public enum GenerateHandler$GenModelGenerationDialog$ProjectType
{
  MODEL,  EDIT,  EDITOR,  TESTS;
  
  public abstract boolean canGenerate(GenModel paramGenModel);
  
  public abstract String getID();
  
  public abstract String getLabel();
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.ecore.genmodel.handler.GenerateHandler.GenModelGenerationDialog.ProjectType
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.ecore.genmodel.handler;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.codegen.ecore.generator.Generator;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
import org.eclipse.emf.codegen.ecore.genmodel.provider.GenModelEditPlugin;
import org.eclipse.emf.codegen.ecore.genmodel.util.GenModelUtil;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.custom.ViewForm;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;

public class GenerateHandler$GenModelGenerationDialog
  extends TrayDialog
{
  protected List<GenModel> genModels;
  protected List<Object[]> generatorAndArgumentsList;
  
  protected static abstract enum ProjectType
  {
    MODEL,  EDIT,  EDITOR,  TESTS;
    
    public abstract boolean canGenerate(GenModel paramGenModel);
    
    public abstract String getID();
    
    public abstract String getLabel();
  }
  
  protected boolean startWithProjectSelected = true;
  protected Point size;
  protected Point location;
  protected Table genModelTable;
  protected CLabel genModelLabel;
  protected boolean showBackButton = false;
  
  public GenerateHandler$GenModelGenerationDialog(Shell shell, List<GenModel> genModels)
  {
    super(shell);
    this.genModels = genModels;
    setShellStyle(getShellStyle() | 0x10 | 0x400);
  }
  
  public boolean isShowBackButton()
  {
    return showBackButton;
  }
  
  public void setShowBackButton(boolean showBackButton)
  {
    this.showBackButton = showBackButton;
  }
  
  public List<Object[]> getGeneratorAndArgumentsList()
  {
    if (generatorAndArgumentsList == null) {
      generatorAndArgumentsList = new ArrayList();
    }
    return generatorAndArgumentsList;
  }
  
  public void initialize(Point size, Point location)
  {
    this.size = size;
    this.location = location;
  }
  
  public Point getSize()
  {
    return size;
  }
  
  public Point getLocation()
  {
    return location;
  }
  
  protected void configureShell(Shell newShell)
  {
    super.configureShell(newShell);
    newShell.setText(GenModelEditPlugin.INSTANCE.getString("_UI_GenModelGenerationDialog_title"));
  }
  
  public void create()
  {
    super.create();
    if (size != null)
    {
      Point shellSize = getShell().computeSize(-1, -1);
      getShell().setSize(Math.max(x, size.x), size.y);
    }
    if (location != null) {
      getShell().setLocation(location);
    }
    if (genModelTable.getSelectionCount() == 0)
    {
      genModelTable.select(0);
      selectionChanged((GenModel)genModelTable.getItem(0).getData());
    }
  }
  
  protected Control createDialogArea(Composite parent)
  {
    Composite composite = (Composite)super.createDialogArea(parent);
    createControls(composite);
    refresh();
    return composite;
  }
  
  protected void createControls(Composite parent)
  {
    createTable(parent);
    createGenModelDetailControl(parent);
  }
  
  protected void createButtonsForButtonBar(Composite parent)
  {
    if (isShowBackButton())
    {
      Button backButton = createButton(parent, 14, IDialogConstants.BACK_LABEL, false);
      Listener backButtonListener = new Listener()
      {
        public void handleEvent(Event event)
        {
          setReturnCode(14);
          close();
        }
      };
      backButton.addListener(13, backButtonListener);
      
      Button button = createButton(parent, 15, IDialogConstants.NEXT_LABEL, false);
      button.setEnabled(false);
    }
    super.createButtonsForButtonBar(parent);
    if (isShowBackButton()) {
      getButton(0).setText(IDialogConstants.FINISH_LABEL);
    }
    updateButtons(Boolean.valueOf(false));
  }
  
  protected void createTable(Composite parent)
  {
    CLabel label = new CLabel(parent, 0);
    label.setText(GenModelEditPlugin.INSTANCE.getString("_UI_GenModelGenerationDialog_message"));
    
    genModelTable = new Table(parent, 2048);
    genModelTable.setLinesVisible(true);
    genModelTable.setHeaderVisible(true);
    GridData gridData = new GridData(4, 4, true, true);
    genModelTable.setLayoutData(gridData);
    
    Listener tableListener = new Listener()
    {
      public void handleEvent(Event event)
      {
        if (genModelTable.getSelectionCount() == 1)
        {
          if (type == 8)
          {
            Boolean select = null;
            TableColumn[] tableColumns = genModelTable.getColumns();
            for (int i = 1; i < tableColumns.length; i++) {
              select = checkBoxColumnHeaderSelected(tableColumns[i], genModelTable.getSelectionIndex(), select);
            }
            updateButtons(select);
          }
          TableItem tableItem = genModelTable.getSelection()[0];
          selectionChanged((GenModel)tableItem.getData());
        }
      }
    };
    genModelTable.addListener(13, tableListener);
    genModelTable.addListener(8, tableListener);
    
    TableColumn genModelColumn = new TableColumn(genModelTable, 0);
    genModelColumn.setText(GenModelEditPlugin.INSTANCE.getString("_UI_GenModelFile_title"));
    
    Listener genModelColumnListener = new Listener()
    {
      public void handleEvent(Event event)
      {
        Boolean select = null;
        TableColumn[] tableColumns = genModelTable.getColumns();
        for (int i = 1; i < tableColumns.length; i++) {
          select = checkBoxColumnHeaderSelected(tableColumns[i], -1, select);
        }
        updateButtons(select);
      }
    };
    genModelColumn.addListener(13, genModelColumnListener);
    
    Listener checkBoxColumnListener = new Listener()
    {
      public void handleEvent(Event event)
      {
        TableColumn tableColumn = (TableColumn)widget;
        Boolean select = checkBoxColumnHeaderSelected(tableColumn, -1, null);
        updateButtons(select);
      }
    };
    int maxWidth = 0;
    ProjectType[] arrayOfProjectType;
    int j = (arrayOfProjectType = ProjectType.values()).length;
    for (int i = 0; i < j; i++)
    {
      ProjectType projectType = arrayOfProjectType[i];
      
      maxWidth = Math.max(maxWidth, createCheckBoxColumn(projectType, checkBoxColumnListener));
    }
    TableColumn[] tableColumns = genModelTable.getColumns();
    for (int i = 1; i < tableColumns.length; i++) {
      tableColumns[i].setWidth(maxWidth);
    }
  }
  
  protected int createCheckBoxColumn(ProjectType projectType, Listener listener)
  {
    TableColumn tableColumn = new TableColumn(genModelTable, 0);
    tableColumn.setText("  " + projectType.getLabel() + "  ");
    tableColumn.setData("type", projectType);
    tableColumn.setResizable(false);
    tableColumn.pack();
    tableColumn.addListener(13, listener);
    return tableColumn.getWidth();
  }
  
  protected Boolean checkBoxColumnHeaderSelected(TableColumn tableColumn, int itemIndex, Boolean select)
  {
    List<Button> buttons = (List)tableColumn.getData("buttons");
    if ((buttons != null) && (!buttons.isEmpty()))
    {
      if (itemIndex > -1) {
        buttons = buttons.subList(itemIndex, itemIndex + 1);
      }
      for (Button button : buttons) {
        if (button.isEnabled())
        {
          if (select == null) {
            select = Boolean.valueOf(!button.getSelection());
          }
          button.setSelection(select.booleanValue());
        }
      }
    }
    return select;
  }
  
  protected void selectionChanged(GenModel genModel)
  {
    StringBuilder text = new StringBuilder();
    for (GenPackage genPackage : genModel.getGenPackages()) {
      text.append(", ").append(genPackage.getEcorePackage().getNsURI());
    }
    Image image = ExtendedImageRegistry.INSTANCE.getImage(URI.createPlatformPluginURI("/org.eclipse.emf.ecore.edit/icons/full/obj16/EPackage.gif", false));
    genModelLabel.setImage(image);
    genModelLabel.setText(text.substring(", ".length()));
  }
  
  protected void refresh()
  {
    genModelLabel.setText("");
    genModelTable.clearAll();
    
    TableColumn[] tableColumns = genModelTable.getColumns();
    for (int i = 1; i < tableColumns.length; i++)
    {
      buttons = (List)tableColumns[i].getData("buttons");
      if (buttons != null)
      {
        for (Button button : buttons) {
          button.dispose();
        }
        buttons.clear();
      }
      else
      {
        tableColumns[i].setData("buttons", new ArrayList());
      }
    }
    int i;
    for (List<Button> buttons = genModels.iterator(); buttons.hasNext(); i < tableColumns.length)
    {
      GenModel genModel = (GenModel)buttons.next();
      
      TableItem tableItem = new TableItem(genModelTable, 0);
      tableItem.setText(0, genModel.eResource().getURI().toPlatformString(true) + "   ");
      tableItem.setImage(ExtendedImageRegistry.INSTANCE.getImage(URI.createPlatformPluginURI("/org.eclipse.emf.codegen.ecore.ui/icons/full/obj16/GenModel.gif", false)));
      tableItem.setData(genModel);
      
      i = 1; continue;
      
      TableColumn tableColumn = tableColumns[i];
      ProjectType projectType = (ProjectType)tableColumn.getData("type");
      
      Button button = new Button(genModelTable, 32);
      if (projectType.canGenerate(genModel)) {
        button.setSelection(startWithProjectSelected);
      } else {
        button.setEnabled(false);
      }
      button.pack();
      
      Listener buttonListener = new Listener()
      {
        public void handleEvent(Event event)
        {
          updateButtons(Boolean.valueOf(((Button)widget).getSelection()));
        }
      };
      button.addListener(13, buttonListener);
      
      List<Button> buttons = (List)tableColumn.getData("buttons");
      buttons.add(button);
      
      TableEditor editor = new TableEditor(genModelTable);
      minimumWidth = getSizex;
      horizontalAlignment = 16777216;
      editor.setEditor(button, tableItem, i);i++;
    }
    tableColumns[0].pack();
    updateButtons(Boolean.valueOf(false));
  }
  
  protected void createGenModelDetailControl(Composite parent)
  {
    ViewForm viewForm = new ViewForm(parent, 8390656);
    viewForm.setLayoutData(new GridData(4, 4, true, false));
    
    genModelLabel = new CLabel(viewForm, 8388608);
    genModelLabel.setFont(parent.getFont());
    genModelLabel.setLayoutData(new GridData(4, 4, true, false));
    genModelLabel.setToolTipText(GenModelEditPlugin.INSTANCE.getString("_UI_GenModelGenerationDetail_message"));
    genModelLabel.pack();
    
    viewForm.setContent(genModelLabel);
  }
  
  protected void okPressed()
  {
    getGeneratorAndArgumentsList().addAll(prepareGenerators());
    super.okPressed();
  }
  
  protected void updateButtons(Boolean hasSelection)
  {
    Button okButton = getButton(0);
    if (okButton != null)
    {
      if (hasSelection == null)
      {
        hasSelection = Boolean.valueOf(false);
      }
      else if (!hasSelection.booleanValue())
      {
        TableColumn[] tableColumns = genModelTable.getColumns();
        for (int column = 1; column < tableColumns.length; column++)
        {
          List<Button> buttons = (List)tableColumns[column].getData("buttons");
          for (Button button : buttons)
          {
            hasSelection = Boolean.valueOf(hasSelection.booleanValue() | ((button.isEnabled()) && (button.getSelection())));
            if (hasSelection.booleanValue()) {
              break;
            }
          }
        }
      }
      okButton.setEnabled(hasSelection.booleanValue());
    }
  }
  
  public boolean close()
  {
    location = getShell().getLocation();
    size = getShell().getSize();
    
    return super.close();
  }
  
  protected List<Object[]> prepareGenerators()
  {
    TableColumn[] tableColumns = genModelTable.getColumns();
    TableItem[] tableItems = genModelTable.getItems();
    List<Object[]> generatorAndArgumentsList = new ArrayList(tableItems.length * (tableColumns.length - 1));
    for (int line = 0; line < tableItems.length; line++)
    {
      GenModel genModel = (GenModel)tableItems[line].getData();
      for (int column = 1; column < tableColumns.length; column++)
      {
        Button button = (Button)((List)tableColumns[column].getData("buttons")).get(line);
        if ((button.isEnabled()) && (button.getSelection()))
        {
          ProjectType projectType = (ProjectType)tableColumns[column].getData("type");
          
          Generator generator = GenModelUtil.createGenerator(genModel);
          
          Object[] generatorAndArguments = new Object[4];
          generatorAndArguments[0] = generator;
          generatorAndArguments[1] = genModel;
          generatorAndArguments[2] = projectType.getID();
          generatorAndArguments[3] = projectType.getLabel();
          generatorAndArgumentsList.add(generatorAndArguments);
        }
      }
    }
    return generatorAndArgumentsList;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.ecore.genmodel.handler.GenerateHandler.GenModelGenerationDialog
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.ecore.genmodel.handler;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog.ResourceFilter;

public class GenerateHandler$GenModelSelectionDialog$GenModelResourceFilter
  extends FilteredResourcesSelectionDialog.ResourceFilter
{
  public GenerateHandler$GenModelSelectionDialog$GenModelResourceFilter(GenerateHandler.GenModelSelectionDialog paramGenModelSelectionDialog, IContainer container)
  {
    super(paramGenModelSelectionDialog, container, false, 1);
  }
  
  public boolean matchItem(Object item)
  {
    return ((item instanceof IFile)) && ("genmodel".equals(((IFile)item).getFileExtension())) && (super.matchItem(item));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.ecore.genmodel.handler.GenerateHandler.GenModelSelectionDialog.GenModelResourceFilter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.ecore.genmodel.handler;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.presentation.GeneratorUIUtil;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jface.action.StatusLineManager;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter;
import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog;
import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog.ResourceFilter;

public class GenerateHandler$GenModelSelectionDialog
  extends FilteredResourcesSelectionDialog
{
  protected IContainer container;
  protected IStatus status;
  protected StatusLineManager statusLineManager;
  protected List<GenModel> genModels;
  protected Point size;
  protected Point location;
  
  protected class GenModelResourceFilter
    extends FilteredResourcesSelectionDialog.ResourceFilter
  {
    public GenModelResourceFilter(IContainer container)
    {
      super(container, false, 1);
    }
    
    public boolean matchItem(Object item)
    {
      return ((item instanceof IFile)) && ("genmodel".equals(((IFile)item).getFileExtension())) && (super.matchItem(item));
    }
  }
  
  public GenerateHandler$GenModelSelectionDialog(Shell shell, boolean multi, IContainer container, int typesMask)
  {
    super(shell, multi, container, typesMask);
    this.container = container;
  }
  
  public void initialize(Point size, Point location)
  {
    this.size = size;
    this.location = location;
  }
  
  public List<GenModel> getGenModels()
  {
    if (genModels == null) {
      genModels = new ArrayList();
    }
    return genModels;
  }
  
  public Point getSize()
  {
    return size;
  }
  
  public Point getLocation()
  {
    return location;
  }
  
  protected void configureShell(Shell newShell)
  {
    super.configureShell(newShell);
    if (size != null) {
      newShell.setSize(size);
    }
    if (location != null) {
      newShell.setLocation(location);
    }
  }
  
  public void create()
  {
    super.create();
    if (size != null)
    {
      Point shellSize = getShell().computeSize(-1, -1);
      getShell().setSize(Math.max(x, size.x), size.y);
    }
    if (location != null) {
      getShell().setLocation(location);
    }
  }
  
  protected Control createDialogArea(Composite parent)
  {
    Composite composite = (Composite)super.createDialogArea(parent);
    
    statusLineManager = new StatusLineManager();
    statusLineManager.createControl(composite);
    statusLineManager.setCancelEnabled(true);
    GridData gridData = new GridData();
    horizontalAlignment = 4;
    grabExcessHorizontalSpace = true;
    heightHint = convertVerticalDLUsToPixels(9);
    statusLineManager.getControl().setLayoutData(gridData);
    
    return composite;
  }
  
  protected void createButtonsForButtonBar(Composite parent)
  {
    super.createButtonsForButtonBar(parent);
    
    Button okButton = getOkButton();
    okButton.setText(IDialogConstants.NEXT_LABEL);
    
    Button button = createButton(parent, 14, IDialogConstants.BACK_LABEL, false);
    button.moveAbove(okButton);
    button.setEnabled(false);
    button = createButton(parent, 16, IDialogConstants.FINISH_LABEL, false);
    button.moveBelow(okButton);
    button.setEnabled(false);
  }
  
  protected FilteredItemsSelectionDialog.ItemsFilter createFilter()
  {
    return new GenModelResourceFilter(container);
  }
  
  protected void updateStatus(IStatus status)
  {
    this.status = status;
    super.updateStatus(status);
  }
  
  protected void cancelPressed()
  {
    super.cancelPressed();
  }
  
  public boolean close()
  {
    location = getShell().getLocation();
    size = getShell().getSize();
    
    return super.close();
  }
  
  protected void okPressed()
  {
    if ((status != null) && ((status.isOK()) || (status.getCode() == 1)))
    {
      computeResult();
      
      IProgressMonitor progressMonitor = statusLineManager.getProgressMonitor();
      progressMonitor.beginTask("", 10);
      List<URI> uris = GenerateHandler.getGenModelURIs(new SubProgressMonitor(progressMonitor, 3, 4), getResult());
      List<GenModel> genModels = GeneratorUIUtil.loadGenModels(new SubProgressMonitor(progressMonitor, 7), uris, getShell());
      progressMonitor.done();
      if (!genModels.isEmpty())
      {
        getGenModels().addAll(genModels);
        close();
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.codegen.ecore.genmodel.handler.GenerateHandler.GenModelSelectionDialog
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.codegen.ecore.genmodel.handler;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.emf.codegen.ecore.generator.Generator;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
import org.eclipse.emf.codegen.ecore.genmodel.presentation.GeneratorUIUtil;
import org.eclipse.emf.codegen.ecore.genmodel.presentation.GeneratorUIUtil.GeneratorOperation;
import org.eclipse.emf.codegen.ecore.genmodel.provider.GenModelEditPlugin;
import org.eclipse.emf.codegen.ecore.genmodel.util.GenModelUtil;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.jface.action.StatusLineManager;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.custom.ViewForm;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter;
import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog;
import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog.ResourceFilter;
import org.eclipse.ui.handlers.HandlerUtil;

public class GenerateHandler
  extends AbstractHandler
{
  protected static List<URI> getGenModelURIs(IProgressMonitor progressMonitor, Object[] objects)
  {
    if (objects.length > 0)
    {
      progressMonitor.beginTask(GenModelEditPlugin.INSTANCE.getString("_UI_AnalyzingObjects_message"), objects.length);
      List<URI> uris = new ArrayList(objects.length);
      Object[] arrayOfObject;
      int j = (arrayOfObject = objects).length;
      for (int i = 0; i < j; i++)
      {
        Object object = arrayOfObject[i];
        
        IFile file = null;
        if ((object instanceof IFile)) {
          file = (IFile)object;
        } else if ((object instanceof IAdaptable)) {
          file = (IFile)((IAdaptable)object).getAdapter(IFile.class);
        }
        if ((file != null) && ("genmodel".equals(file.getFileExtension())))
        {
          progressMonitor.subTask(file.getName());
          URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
          uris.add(uri);
        }
        progressMonitor.worked(1);
      }
      return uris;
    }
    return new ArrayList();
  }
  
  protected static class GenModelSelectionDialog
    extends FilteredResourcesSelectionDialog
  {
    protected IContainer container;
    protected IStatus status;
    protected StatusLineManager statusLineManager;
    protected List<GenModel> genModels;
    protected Point size;
    protected Point location;
    
    protected class GenModelResourceFilter
      extends FilteredResourcesSelectionDialog.ResourceFilter
    {
      public GenModelResourceFilter(IContainer container)
      {
        super(container, false, 1);
      }
      
      public boolean matchItem(Object item)
      {
        return ((item instanceof IFile)) && ("genmodel".equals(((IFile)item).getFileExtension())) && (super.matchItem(item));
      }
    }
    
    public GenModelSelectionDialog(Shell shell, boolean multi, IContainer container, int typesMask)
    {
      super(multi, container, typesMask);
      this.container = container;
    }
    
    public void initialize(Point size, Point location)
    {
      this.size = size;
      this.location = location;
    }
    
    public List<GenModel> getGenModels()
    {
      if (genModels == null) {
        genModels = new ArrayList();
      }
      return genModels;
    }
    
    public Point getSize()
    {
      return size;
    }
    
    public Point getLocation()
    {
      return location;
    }
    
    protected void configureShell(Shell newShell)
    {
      super.configureShell(newShell);
      if (size != null) {
        newShell.setSize(size);
      }
      if (location != null) {
        newShell.setLocation(location);
      }
    }
    
    public void create()
    {
      super.create();
      if (size != null)
      {
        Point shellSize = getShell().computeSize(-1, -1);
        getShell().setSize(Math.max(x, size.x), size.y);
      }
      if (location != null) {
        getShell().setLocation(location);
      }
    }
    
    protected Control createDialogArea(Composite parent)
    {
      Composite composite = (Composite)super.createDialogArea(parent);
      
      statusLineManager = new StatusLineManager();
      statusLineManager.createControl(composite);
      statusLineManager.setCancelEnabled(true);
      GridData gridData = new GridData();
      horizontalAlignment = 4;
      grabExcessHorizontalSpace = true;
      heightHint = convertVerticalDLUsToPixels(9);
      statusLineManager.getControl().setLayoutData(gridData);
      
      return composite;
    }
    
    protected void createButtonsForButtonBar(Composite parent)
    {
      super.createButtonsForButtonBar(parent);
      
      Button okButton = getOkButton();
      okButton.setText(IDialogConstants.NEXT_LABEL);
      
      Button button = createButton(parent, 14, IDialogConstants.BACK_LABEL, false);
      button.moveAbove(okButton);
      button.setEnabled(false);
      button = createButton(parent, 16, IDialogConstants.FINISH_LABEL, false);
      button.moveBelow(okButton);
      button.setEnabled(false);
    }
    
    protected FilteredItemsSelectionDialog.ItemsFilter createFilter()
    {
      return new GenModelResourceFilter(container);
    }
    
    protected void updateStatus(IStatus status)
    {
      this.status = status;
      super.updateStatus(status);
    }
    
    protected void cancelPressed()
    {
      super.cancelPressed();
    }
    
    public boolean close()
    {
      location = getShell().getLocation();
      size = getShell().getSize();
      
      return super.close();
    }
    
    protected void okPressed()
    {
      if ((status != null) && ((status.isOK()) || (status.getCode() == 1)))
      {
        computeResult();
        
        IProgressMonitor progressMonitor = statusLineManager.getProgressMonitor();
        progressMonitor.beginTask("", 10);
        List<URI> uris = GenerateHandler.getGenModelURIs(new SubProgressMonitor(progressMonitor, 3, 4), getResult());
        List<GenModel> genModels = GeneratorUIUtil.loadGenModels(new SubProgressMonitor(progressMonitor, 7), uris, getShell());
        progressMonitor.done();
        if (!genModels.isEmpty())
        {
          getGenModels().addAll(genModels);
          close();
        }
      }
    }
  }
  
  protected static class GenModelGenerationDialog
    extends TrayDialog
  {
    protected List<GenModel> genModels;
    protected List<Object[]> generatorAndArgumentsList;
    
    protected static abstract enum ProjectType
    {
      MODEL,  EDIT,  EDITOR,  TESTS;
      
      public abstract boolean canGenerate(GenModel paramGenModel);
      
      public abstract String getID();
      
      public abstract String getLabel();
    }
    
    protected boolean startWithProjectSelected = true;
    protected Point size;
    protected Point location;
    protected Table genModelTable;
    protected CLabel genModelLabel;
    protected boolean showBackButton = false;
    
    public GenModelGenerationDialog(Shell shell, List<GenModel> genModels)
    {
      super();
      this.genModels = genModels;
      setShellStyle(getShellStyle() | 0x10 | 0x400);
    }
    
    public boolean isShowBackButton()
    {
      return showBackButton;
    }
    
    public void setShowBackButton(boolean showBackButton)
    {
      this.showBackButton = showBackButton;
    }
    
    public List<Object[]> getGeneratorAndArgumentsList()
    {
      if (generatorAndArgumentsList == null) {
        generatorAndArgumentsList = new ArrayList();
      }
      return generatorAndArgumentsList;
    }
    
    public void initialize(Point size, Point location)
    {
      this.size = size;
      this.location = location;
    }
    
    public Point getSize()
    {
      return size;
    }
    
    public Point getLocation()
    {
      return location;
    }
    
    protected void configureShell(Shell newShell)
    {
      super.configureShell(newShell);
      newShell.setText(GenModelEditPlugin.INSTANCE.getString("_UI_GenModelGenerationDialog_title"));
    }
    
    public void c
1 2 3 4 5 6 7 8

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