org.eclipse.birt.core.ui_3.7.2.v20120213

16:41:30.465 INFO  jd.cli.Main - Decompiling org.eclipse.birt.core.ui_3.7.2.v20120213.jar
package org.eclipse.birt.core.ui.frameworks.errordisplay;

import org.eclipse.birt.core.ui.frameworks.taskwizard.composites.MessageComposite;
import org.eclipse.birt.core.ui.i18n.Messages;
import org.eclipse.birt.core.ui.utils.UIHelper;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
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.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class ErrorDialog
  implements SelectionListener
{
  public static final String OPTION_ACCEPT = "ACCEPT";
  public static final String OPTION_CANCEL = "CANCEL";
  public static final int MAX_TRACE_DEPTH = 2;
  public static final int DEFAULT_WIDTH = 450;
  public static final int DEFAULT_HEIGHT = 0;
  public static final int MAX_HEIGHT = 200;
  private transient Display display = Display.getDefault();
  private transient Shell shell = null;
  private transient Label lblImage = null;
  private transient Composite cmpContainer = null;
  private transient Composite cmpDetails = null;
  private transient StackLayout slDetails = null;
  private transient Group grpDetails = null;
  private transient Text txtDetails = null;
  private transient Composite cmpDummy = null;
  private transient MessageComposite mcSheetHeading = null;
  private transient Button btnOK = null;
  private transient Button btnDetails = null;
  private transient Text txtProblems = null;
  private transient Button btnCancel = null;
  private transient Group grpProblems = null;
  private transient String sMessage = null;
  private transient String sSelection = "CANCEL";
  private transient boolean bError = true;
  private transient String sErrors = null;
  private transient String sFixes = null;
  private transient String sExceptionMessage = null;
  private transient String sTrace = null;
  private transient Shell shellParent = null;
  
  private void init(String sTitle)
  {
    display = Display.getDefault();
    if (shellParent == null) {
      shell = new Shell(display, 67696);
    } else {
      shell = new Shell(shellParent, 67696);
    }
    shell.setText(sTitle);
    shell.setLayout(new GridLayout());
    placeComponents();
    
    UIHelper.centerOnScreen(shell);
    
    shell.setDefaultButton(btnOK);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
  }
  
  public ErrorDialog(Shell shellParent, String sTitle, String sMessage, String[] sErrors, String[] sFixes)
  {
    this.shellParent = shellParent;
    this.sMessage = sMessage;
    this.sErrors = getOrganizedErrors(sErrors);
    this.sFixes = getOrganizedFixes(sFixes);
    bError = true;
    init(sTitle);
  }
  
  public ErrorDialog(Shell shellParent, String sTitle, String sMessage, Throwable t)
  {
    this.shellParent = shellParent;
    this.sMessage = sMessage;
    sExceptionMessage = t.getLocalizedMessage();
    if (sExceptionMessage == null) {
      sExceptionMessage = t.toString();
    }
    sTrace = getOrganizedTrace(t);
    bError = false;
    init(sTitle);
  }
  
  private void placeComponents()
  {
    cmpContainer = new Composite(shell, 0);
    
    GridLayout glDialog = new GridLayout(3, false);
    
    marginWidth = 6;
    marginHeight = 6;
    horizontalSpacing = 5;
    verticalSpacing = 2;
    cmpContainer.setLayoutData(new GridData(1808));
    cmpContainer.setLayout(glDialog);
    
    mcSheetHeading = new MessageComposite(cmpContainer, 
      "", sMessage, "", true);
    GridData gdMSGHeading = new GridData(768);
    heightHint = 25;
    horizontalSpan = 3;
    mcSheetHeading.setLayoutData(gdMSGHeading);
    mcSheetHeading.setBackground(display.getSystemColor(1));
    
    lblImage = new Label(cmpContainer, 0);
    lblImage.setImage(display.getSystemImage(1));
    
    grpProblems = new Group(cmpContainer, 0);
    
    GridData gdGrpProblems = new GridData(768);
    horizontalSpan = 2;
    heightHint = 60;
    grpProblems.setLayoutData(gdGrpProblems);
    GridLayout layout = new GridLayout();
    marginWidth = 2;
    marginHeight = 2;
    grpProblems.setLayout(layout);
    
    txtProblems = new Text(grpProblems, 576);
    
    txtProblems.setEditable(false);
    txtProblems.setLayoutData(new GridData(1808));
    
    new Label(cmpContainer, 0);
    
    btnDetails = new Button(cmpContainer, 2);
    GridData gdBtnDetails = new GridData();
    horizontalSpan = 2;
    btnDetails.setLayoutData(gdBtnDetails);
    btnDetails.addSelectionListener(this);
    
    new Label(cmpContainer, 0);
    
    slDetails = new StackLayout();
    
    cmpDetails = new Composite(cmpContainer, 0);
    GridData gdCmpDetails = new GridData(1808);
    horizontalSpan = 2;
    heightHint = 0;
    cmpDetails.setLayoutData(gdCmpDetails);
    cmpDetails.setLayout(slDetails);
    
    cmpDummy = new Composite(cmpDetails, 0);
    
    grpDetails = new Group(cmpDetails, 0);
    FillLayout flSolutions = new FillLayout();
    marginWidth = 5;
    marginHeight = 5;
    grpDetails.setLayout(flSolutions);
    
    txtDetails = new Text(grpDetails, 2624);
    txtDetails.setEditable(false);
    
    GridLayout glButtons = new GridLayout();
    numColumns = 2;
    horizontalSpacing = 5;
    marginHeight = 5;
    marginWidth = 5;
    
    Composite cmpButtons = new Composite(cmpContainer, 0);
    GridData gdCmpButtons = new GridData(768);
    horizontalSpan = 3;
    cmpButtons.setLayoutData(gdCmpButtons);
    cmpButtons.setLayout(glButtons);
    
    btnOK = new Button(cmpButtons, 0);
    GridData gdBtnOK = null;
    if (bError) {
      gdBtnOK = new GridData(640);
    } else {
      gdBtnOK = new GridData(576);
    }
    btnOK.setLayoutData(gdBtnOK);
    btnOK.addSelectionListener(this);
    if (bError)
    {
      btnCancel = new Button(cmpButtons, 0);
      GridData gdBtnCancel = new GridData(544);
      
      btnCancel.setLayoutData(gdBtnCancel);
      btnCancel.addSelectionListener(this);
    }
    if (bError)
    {
      grpProblems.setText(Messages.getString("ErrorDialog.text.ErrorList"));
      txtProblems.setText(sErrors);
      btnDetails.setText(Messages.getString("ErrorDialog.text.ShowDetails"));
      grpDetails.setText(Messages.getString("ErrorDialog.text.SuggestedFixes"));
      btnOK.setText(Messages.getString("ErrorDialog.text.FixIt"));
      btnCancel.setText(Messages.getString("ErrorDialog.text.ProceedWithoutFixing"));
      if ((sFixes == null) || (sFixes.length() == 0))
      {
        btnDetails.setEnabled(false);
      }
      else
      {
        btnDetails.setEnabled(true);
        txtDetails.setText(sFixes);
      }
    }
    else
    {
      txtProblems.setText(sExceptionMessage);
      btnDetails.setText(Messages.getString("ErrorDialog.text.ShowTrace"));
      grpDetails.setText(Messages.getString("ErrorDialog.text.StackTrace"));
      btnOK.setText(Messages.getString("ErrorDialog.text.Ok"));
      if ((sTrace == null) || (sTrace.length() == 0))
      {
        btnDetails.setEnabled(false);
      }
      else
      {
        btnDetails.setEnabled(true);
        txtDetails.setText(sTrace);
      }
    }
    slDetails.topControl = cmpDummy;
    shell.pack();
    shell.layout();
  }
  
  public String getOption()
  {
    return sSelection;
  }
  
  private String getOrganizedErrors(String[] errors)
  {
    if (errors.length == 1) {
      return errors[0];
    }
    StringBuffer sbErrors = new StringBuffer("");
    for (int i = 0; i < errors.length; i++)
    {
      if (i > 0) {
        sbErrors.append("\n");
      }
      sbErrors.append(i + 1 + "] ");
      sbErrors.append(errors[i]);
    }
    return sbErrors.toString();
  }
  
  private String getOrganizedFixes(String[] fixes)
  {
    StringBuffer sbFixes = new StringBuffer("");
    for (int i = 0; i < fixes.length; i++)
    {
      if (i > 0) {
        sbFixes.append("\n");
      }
      sbFixes.append(fixes[i]);
    }
    return sbFixes.toString();
  }
  
  private String getOrganizedTrace(Throwable t)
  {
    StringBuffer sbTrace = new StringBuffer(t.getClass().getName());
    sbTrace.append(" at:\n");
    for (int d = 0; d < 2; d++)
    {
      if (d > 0)
      {
        while (t.getCause() != null) {
          t = t.getCause();
        }
        sbTrace.append(Messages.getString("ErrorDialog.text.CausedBy") + 
          t.getLocalizedMessage() + "\n");
      }
      StackTraceElement[] se = t.getStackTrace();
      for (int i = 0; i < se.length; i++)
      {
        if (i > 0) {
          sbTrace.append("\n");
        }
        sbTrace.append(se[i].toString());
      }
    }
    return sbTrace.toString();
  }
  
  public void widgetDefaultSelected(SelectionEvent e) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    if (e.getSource().equals(btnOK))
    {
      sSelection = "ACCEPT";
      shell.dispose();
    }
    else if (e.getSource().equals(btnCancel))
    {
      sSelection = "CANCEL";
      shell.dispose();
    }
    else if (e.getSource().equals(btnDetails))
    {
      toggleDetails(btnDetails.getSelection());
    }
  }
  
  private void toggleDetails(boolean bVisible)
  {
    if (bVisible)
    {
      slDetails.topControl = grpDetails;
      cmpDetails.getLayoutData()).heightHint = 200;
    }
    else
    {
      slDetails.topControl = cmpDummy;
      cmpDetails.getLayoutData()).heightHint = 0;
    }
    shell.pack();
    shell.layout();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.core.ui.frameworks.errordisplay.ErrorDialog
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.core.ui.frameworks.taskwizard;

import java.util.LinkedHashMap;
import org.eclipse.birt.core.ui.frameworks.taskwizard.interfaces.ISubtaskSheet;

public class CompoundTask
  extends SimpleTask
{
  private transient LinkedHashMap<String, ISubtaskSheet> subtasks = new LinkedHashMap();
  protected transient ISubtaskSheet sCurrentTaskSheet = null;
  private transient String sCurrentSubtask = "";
  
  public CompoundTask(String title)
  {
    super(title);
  }
  
  public void addSubtask(String sSubtaskPath, ISubtaskSheet subtask)
  {
    subtasks.put(sSubtaskPath, subtask);
  }
  
  public void removeSubtask(String sSubtaskPath)
  {
    if ((subtasks.containsKey(sSubtaskPath)) && 
      (sCurrentSubtask.equals(sSubtaskPath))) {
      switchTo(subtasks.keySet().toArray()[0].toString());
    }
    subtasks.remove(sSubtaskPath);
  }
  
  public void switchTo(String sSubtaskPath)
  {
    if (getCurrentSubtask() != null) {
      getCurrentSubtask().onHide();
    }
    if (containSubtask(sSubtaskPath))
    {
      sCurrentTaskSheet = getSubtask(sSubtaskPath);
      sCurrentSubtask = sSubtaskPath;
    }
    getCurrentSubtask().onShow(context, container);
  }
  
  protected boolean containSubtask(String sSubtaskPath)
  {
    return subtasks.containsKey(sSubtaskPath);
  }
  
  protected ISubtaskSheet getSubtask(String sSubtaskPath)
  {
    if (!subtasks.containsKey(sSubtaskPath)) {
      return null;
    }
    return (ISubtaskSheet)subtasks.get(sSubtaskPath);
  }
  
  protected ISubtaskSheet getCurrentSubtask()
  {
    return sCurrentTaskSheet;
  }
  
  public void dispose()
  {
    super.dispose();
    if (sCurrentTaskSheet != null) {
      sCurrentTaskSheet.onHide();
    }
    sCurrentTaskSheet = null;
    for (ISubtaskSheet subtask : subtasks.values()) {
      subtask.dispose();
    }
    subtasks.clear();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.core.ui.frameworks.taskwizard.CompoundTask
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.core.ui.frameworks.taskwizard;

import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.widgets.Shell;

public class ErrorsManager
{
  private static ErrorsManager thisInstance = null;
  public static final String YSERIESDATA = "YSeriesData";
  private String errorMessage = null;
  private WizardBase wizard = null;
  
  public static ErrorsManager instance()
  {
    if (thisInstance == null) {
      thisInstance = new ErrorsManager();
    }
    return thisInstance;
  }
  
  public void registerWizard(WizardBase wizard)
  {
    this.wizard = wizard;
  }
  
  public void showErrors(String errorMessage)
  {
    this.errorMessage = errorMessage;
    if ((wizard.getDialog().getShell() == null) || (wizard.getDialog().getShell().isDisposed())) {
      return;
    }
    wizard.getDialog().setErrorMessage(errorMessage);
  }
  
  public void removeErrors()
  {
    errorMessage = null;
    if (!wizard.isDisposed()) {
      wizard.getDialog().setErrorMessage(null);
    }
  }
  
  public String getErrors()
  {
    return errorMessage;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.core.ui.frameworks.taskwizard.ErrorsManager
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.core.ui.frameworks.taskwizard;

import com.ibm.icu.util.ULocale;
import java.util.Vector;
import org.eclipse.birt.core.ui.frameworks.taskwizard.interfaces.ITask;
import org.eclipse.birt.core.ui.frameworks.taskwizard.interfaces.IWizardContext;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

/**
 * @deprecated
 */
class SequencedTask
  implements ITask
{
  private transient Vector subtasks = new Vector();
  protected transient IWizardContext context = null;
  protected transient WizardBase container = null;
  private transient int iCurrentSubtaskIndex = 0;
  private transient String sLabel = "";
  
  public SequencedTask(String sLabel)
  {
    this.sLabel = sLabel;
  }
  
  public Composite getUI(Composite parent)
  {
    return null;
  }
  
  public String getDisplayLabel(ULocale locale)
  {
    return sLabel;
  }
  
  public void addSubtask(int iSubtaskIndex, ITask task)
  {
    if (subtasks.size() <= iSubtaskIndex) {
      subtasks.add(task);
    } else {
      subtasks.setElementAt(task, iSubtaskIndex);
    }
  }
  
  public void next()
  {
    iCurrentSubtaskIndex += 1;
  }
  
  public void previous()
  {
    iCurrentSubtaskIndex -= 1;
  }
  
  public void setContext(IWizardContext context)
  {
    this.context = context;
  }
  
  public IWizardContext getContext()
  {
    return context;
  }
  
  public void setUIProvider(WizardBase wizard)
  {
    container = wizard;
  }
  
  public String[] getErrors()
  {
    return null;
  }
  
  public void setErrorHints(Object[] errorHints) {}
  
  public String getDescription(ULocale locale)
  {
    return sLabel;
  }
  
  public void createControl(Composite parent) {}
  
  public void dispose() {}
  
  public Control getControl()
  {
    return null;
  }
  
  public String getDescription()
  {
    return null;
  }
  
  public String getErrorMessage()
  {
    return null;
  }
  
  public Image getImage()
  {
    return null;
  }
  
  public String getMessage()
  {
    return null;
  }
  
  public String getTitle()
  {
    return null;
  }
  
  public void performHelp() {}
  
  public void setDescription(String description) {}
  
  public void setImageDescriptor(ImageDescriptor image) {}
  
  public void setTitle(String title) {}
  
  public void setVisible(boolean visible) {}
}

/* Location:
 * Qualified Name:     org.eclipse.birt.core.ui.frameworks.taskwizard.SequencedTask
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.core.ui.frameworks.taskwizard;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.birt.core.ui.frameworks.taskwizard.interfaces.ITask;
import org.eclipse.birt.core.ui.frameworks.taskwizard.interfaces.IWizardContext;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;

public class SimpleTask
  implements ITask
{
  protected transient Composite topControl = null;
  protected transient IWizardContext context = null;
  protected transient WizardBase container = null;
  private transient String sDesc = "";
  private transient String sTitle = "";
  private transient List errorList = new ArrayList();
  
  private void placeComponents(Composite parent)
  {
    Label lbl = new Label(parent, 16777220);
    lbl.setText("This is a placeholder for the task : " + 
      getTitle());
  }
  
  public SimpleTask()
  {
    setTitle("Task");
  }
  
  public SimpleTask(String title)
  {
    setTitle(title);
  }
  
  public void setContext(IWizardContext context)
  {
    this.context = context;
  }
  
  public IWizardContext getContext()
  {
    return context;
  }
  
  public void setUIProvider(WizardBase wizard)
  {
    container = wizard;
  }
  
  public String[] getErrors()
  {
    return (String[])errorList.toArray(new String[errorList.size()]);
  }
  
  protected void addError(String errorInfo)
  {
    if (!errorList.contains(errorInfo)) {
      errorList.add(errorInfo);
    }
  }
  
  protected void removeError(String errorInfo)
  {
    errorList.remove(errorInfo);
  }
  
  public void setErrorHints(Object[] errorHints)
  {
    errorList.clear();
    for (int i = 0; i < errorHints.length; i++) {
      errorList.add(errorHints[i].toString());
    }
  }
  
  public void dispose()
  {
    topControl = null;
    context = null;
    container = null;
    errorList.clear();
  }
  
  public void createControl(Composite parent)
  {
    if ((topControl == null) || (topControl.isDisposed()))
    {
      topControl = new Composite(parent, 0);
      topControl.setLayout(new FillLayout());
      placeComponents(topControl);
    }
  }
  
  public Control getControl()
  {
    return topControl;
  }
  
  public String getDescription()
  {
    return sDesc;
  }
  
  public String getErrorMessage()
  {
    return sDesc;
  }
  
  public Image getImage()
  {
    return null;
  }
  
  public String getMessage()
  {
    return sDesc;
  }
  
  public String getTitle()
  {
    return sTitle;
  }
  
  /**
   * @deprecated
   */
  public void performHelp() {}
  
  public void setDescription(String description)
  {
    sDesc = description;
  }
  
  /**
   * @deprecated
   */
  public void setImageDescriptor(ImageDescriptor image) {}
  
  public void setTitle(String title)
  {
    sTitle = title;
  }
  
  public void setVisible(boolean visible)
  {
    getControl().setVisible(visible);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.core.ui.frameworks.taskwizard.SimpleTask
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.core.ui.frameworks.taskwizard;

import org.eclipse.birt.core.ui.frameworks.taskwizard.interfaces.ITask;

public class TaskRegistrationEntry
{
  private final String taskID;
  private final ITask classDefinition;
  private final int priority;
  
  public TaskRegistrationEntry(String taskID, ITask classDefinition, int priority)
  {
    this.taskID = taskID;
    this.classDefinition = classDefinition;
    this.priority = priority;
  }
  
  public String getTaskID()
  {
    return taskID;
  }
  
  public ITask getClassDefinition()
  {
    return classDefinition;
  }
  
  public int getPriority()
  {
    return priority;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.core.ui.frameworks.taskwizard.TaskRegistrationEntry
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.core.ui.frameworks.taskwizard;

import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.Vector;
import org.eclipse.birt.core.framework.FrameworkException;
import org.eclipse.birt.core.framework.IConfigurationElement;
import org.eclipse.birt.core.framework.IExtension;
import org.eclipse.birt.core.framework.IExtensionPoint;
import org.eclipse.birt.core.framework.IExtensionRegistry;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.core.ui.frameworks.taskwizard.interfaces.IRegistrationListener;
import org.eclipse.birt.core.ui.frameworks.taskwizard.interfaces.ITask;
import org.eclipse.birt.core.ui.i18n.Messages;
import org.eclipse.birt.core.ui.utils.UIHelper;

public class TasksManager
{
  private transient LinkedHashMap<String, TaskRegistrationEntry> registeredTasks = null;
  private transient Hashtable<String, Vector<String>> registeredWizards = null;
  private transient Vector<IRegistrationListener> registeredListeners = null;
  private static TasksManager thisInstance = null;
  
  public static TasksManager instance()
  {
    if (thisInstance == null) {
      thisInstance = new TasksManager();
    }
    return thisInstance;
  }
  
  private TasksManager()
  {
    registeredTasks = new LinkedHashMap();
    registeredWizards = new Hashtable();
    registeredListeners = new Vector();
    processExtensions();
  }
  
  private void processExtensions()
  {
    if (UIHelper.isEclipseMode())
    {
      IExtension[] extensions = Platform.getExtensionRegistry()
        .getExtensionPoint("org.eclipse.birt.core.ui", 
        "tasks").getExtensions();
      for (int iC = 0; iC < extensions.length; iC++)
      {
        IConfigurationElement[] elements = extensions[iC].getConfigurationElements();
        for (int i = 0; i < elements.length; i++) {
          try
          {
            String sID = elements[i].getAttribute("taskID");
            String strPriority = elements[i].getAttribute("priority");
            int priority = 0;
            try
            {
              priority = Integer.valueOf(strPriority).intValue();
            }
            catch (NumberFormatException localNumberFormatException1)
            {
              priority = 0;
            }
            if (registeredTasks.containsKey(sID))
            {
              TaskRegistrationEntry entry = (TaskRegistrationEntry)registeredTasks.get(sID);
              if (entry.getPriority() >= priority) {}
            }
            else
            {
              ITask task = (ITask)elements[i].createExecutableExtension("classDefinition");
              TaskRegistrationEntry entry = new TaskRegistrationEntry(sID, 
                task, 
                priority);
              registeredTasks.put(sID, entry);
            }
          }
          catch (FrameworkException e)
          {
            WizardBase.displayException(e);
          }
        }
      }
      extensions = 
      
        Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.birt.core.ui", "taskWizards").getExtensions();
      for (int iC = 0; iC < extensions.length; iC++)
      {
        IConfigurationElement[] elements = extensions[iC].getConfigurationElements();
        for (int i = 0; i < elements.length; i++)
        {
          String sID = elements[i].getAttribute("wizardID");
          String sTaskList = elements[i].getAttribute("tasklist");
          String[] sTasks = new String[0];
          if (sTaskList != null) {
            sTasks = sTaskList.split(",");
          }
          if (registeredWizards.containsKey(sID))
          {
            String sInsertionKey = elements[i].getAttribute("positionBefore");
            int insertIndex;
            try
            {
              insertIndex = Integer.parseInt(sInsertionKey);
            }
            catch (NumberFormatException localNumberFormatException2)
            {
              int insertIndex;
              insertIndex = -1;
            }
            Vector<String> vTemp = (Vector)registeredWizards.get(sID);
            if ((sInsertionKey != null) && 
              (sInsertionKey.trim().length() > 0) && 
              (insertIndex < 0))
            {
              int iInsertionPosition = ((Vector)registeredWizards.get(sID))
                .indexOf(sInsertionKey);
              if (iInsertionPosition != -1)
              {
                for (int iTaskIndex = 0; iTaskIndex < sTasks.length; iTaskIndex++) {
                  vTemp.add(iInsertionPosition + iTaskIndex, 
                    sTasks[iTaskIndex].trim());
                }
                continue;
              }
            }
            registeredWizards.put(sID, 
              addAllTasks(vTemp, sTasks, insertIndex));
          }
          else if ((sTaskList != null) && 
            (sTaskList.trim().length() > 0))
          {
            registeredWizards.put(sID, 
              addAllTasks(new Vector(), 
              sTasks, 
              -1));
          }
          else
          {
            registeredWizards.put(sID, new Vector());
          }
        }
      }
    }
  }
  
  private Vector<String> addAllTasks(Vector<String> vTemp, String[] sTasks, int insertIndex)
  {
    for (int iTaskIndex = 0; iTaskIndex < sTasks.length; iTaskIndex++) {
      if (insertIndex >= 0) {
        vTemp.add(iTaskIndex + insertIndex, sTasks[iTaskIndex].trim());
      } else {
        vTemp.add(sTasks[iTaskIndex].trim());
      }
    }
    return vTemp;
  }
  
  private void updateWizard(String sWizardID, String sTasks, String sPosition)
  {
    Vector<String> vTaskList = new Vector();
    if (registeredWizards.containsKey(sWizardID)) {
      vTaskList = (Vector)registeredWizards.get(sWizardID);
    }
    if ((sTasks != null) && (sTasks.trim().length() > 0))
    {
      String[] sTaskArr = sTasks.split(",");
      for (int i = 0; i < sTaskArr.length; i++) {
        vTaskList.add(sTaskArr[i]);
      }
    }
    registeredWizards.put(sWizardID, vTaskList);
  }
  
  public void registerTask(String sTaskID, ITask task)
    throws IllegalArgumentException
  {
    if ((!registeredTasks.containsKey(sTaskID)) && (task != null))
    {
      registeredTasks.put(sTaskID, new TaskRegistrationEntry(sTaskID, 
        task, 
        0));
      fireTaskRegisteredEvent(sTaskID);
    }
    else
    {
      throw new IllegalArgumentException(Messages.getFormattedString("TasksManager.Exception.RegisterTask", 
        sTaskID));
    }
  }
  
  public void deregisterTask(String sTaskID)
    throws IllegalArgumentException
  {
    if (registeredTasks.containsKey(sTaskID))
    {
      registeredTasks.remove(sTaskID);
      fireTaskDeregisteredEvent(sTaskID);
    }
    else
    {
      throw new IllegalArgumentException(Messages.getFormattedString("TasksManager.Exception.DeregisterTask", 
        sTaskID));
    }
  }
  
  public void registerWizard(String sWizardID, String sTasks, String sPosition)
    throws IllegalArgumentException
  {
    if (sWizardID != null) {
      updateWizard(sWizardID, sTasks, sPosition);
    } else {
      throw new IllegalArgumentException(Messages.getString("TasksManager.Excepion.RegisterWizard"));
    }
  }
  
  public ITask getTask(String sTaskID)
  {
    if (!isRegistered(sTaskID)) {
      return null;
    }
    return ((TaskRegistrationEntry)registeredTasks.get(sTaskID)).getClassDefinition();
  }
  
  public String[] getTasksForWizard(String sWizardID)
  {
    if (registeredWizards.containsKey(sWizardID))
    {
      Vector<String> vTemp = (Vector)registeredWizards.get(sWizardID);
      String[] sTasks = new String[vTemp.size()];
      for (int iTaskCount = 0; iTaskCount < vTemp.size(); iTaskCount++) {
        sTasks[iTaskCount] = ((String)vTemp.get(iTaskCount));
      }
      return sTasks;
    }
    return new String[0];
  }
  
  public boolean isRegistered(String sTaskID)
  {
    boolean b = registeredTasks.containsKey(sTaskID);
    return b;
  }
  
  public void addRegistrationListener(IRegistrationListener listener)
  {
    registeredListeners.add(listener);
  }
  
  public void removeRegistrationListener(IRegistrationListener listener)
  {
    registeredListeners.remove(listener);
  }
  
  private void fireTaskRegisteredEvent(String sTaskID)
  {
    for (int i = 0; i < registeredListeners.size(); i++) {
      ((IRegistrationListener)registeredListeners.get(i)).taskRegistered(sTaskID);
    }
  }
  
  private void fireTaskDeregisteredEvent(String sTaskID)
  {
    for (int i = 0; i < registeredListeners.size(); i++) {
      ((IRegistrationListener)registeredListeners.get(i)).taskDeregistered(sTaskID);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.core.ui.frameworks.taskwizard.TasksManager
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.core.ui.frameworks.taskwizard;

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

class TreeCompoundTask$1
  implements Listener
{
  TreeCompoundTask$1(TreeCompoundTask paramTreeCompoundTask) {}
  
  public void handleEvent(Event event)
  {
    this$0.switchToTreeItem((TreeItem)item);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.core.ui.frameworks.taskwizard.TreeCompoundTask.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.core.ui.frameworks.taskwizard;

import java.util.HashMap;
import java.util.Map;
import org.eclipse.birt.core.ui.frameworks.taskwizard.composites.NavTree;
import org.eclipse.birt.core.ui.frameworks.taskwizard.interfaces.ISubtaskSheet;
import org.eclipse.birt.core.ui.frameworks.taskwizard.interfaces.IWizardContext;
import org.eclipse.birt.core.ui.frameworks.taskwizard.internal.SubtaskHistory;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.TreeItem;

public class TreeCompoundTask
  extends CompoundTask
{
  protected Composite cmpSubtaskContainer;
  protected NavTree navTree;
  private SubtaskHistory history;
  private boolean needHistory = true;
  protected static final String INDEX_SEPARATOR = " - ";
  private Map<String, String> lastSubtaskRegistry = new HashMap();
  private Map<String, String> lastPopupRegistry = new HashMap();
  
  public TreeCompoundTask(String sLabel, boolean needHistory)
  {
    super(sLabel);
    this.needHistory = needHistory;
    if (needHistory) {
      history = new SubtaskHistory(this);
    }
  }
  
  public void createControl(Composite parent)
  {
    if ((topControl == null) || (topControl.isDisposed()))
    {
      topControl = new Composite(parent, 0);
      
      GridLayout layout = new GridLayout(2, false);
      marginHeight = 0;
      marginWidth = 0;
      horizontalSpacing = 0;
      topControl.setLayout(layout);
      GridData gridData = new GridData();
      horizontalAlignment = 4;
      verticalAlignment = 4;
      topControl.setLayoutData(gridData);
      
      navTree = new NavTree(topControl, 2048);
      
      GridData gridData = new GridData(1296);
      
      widthHint = 127;
      navTree.setLayoutData(gridData);
      navTree.addListener(13, new Listener()
      {
        public void handleEvent(Event event)
        {
          switchToTreeItem((TreeItem)item);
        }
      });
      cmpSubtaskContainer = createContainer(topControl);
    }
    updateTree();
    switchToDefaultItem();
  }
  
  protected void switchToDefaultItem()
  {
    TreeItem defaultSelection = getDefaultSelection();
    if (defaultSelection != null) {
      switchToTreeItem(defaultSelection);
    }
  }
  
  protected TreeItem getDefaultSelection()
  {
    TreeItem lastselection = navTree.findTreeItem(getSubtaskSelection());
    if (navTree.getSelection().length == 0)
    {
      if (lastselection != null) {
        return lastselection;
      }
      if (navTree.getItems().length > 0) {
        return navTree.getItems()[0];
      }
      return null;
    }
    return navTree.getSelection()[0];
  }
  
  protected Composite createContainer(Composite parent)
  {
    Composite cmpTask = new Composite(parent, 0);
    
    GridLayout layout = new GridLayout();
    marginWidth = 10;
    cmpTask.setLayout(layout);
    GridData gridData = new GridData(1808);
    cmpTask.setLayoutData(gridData);
    
    createTitleArea(cmpTask);
    return cmpTask;
  }
  
  protected Composite createTitleArea(Composite parent)
  {
    Composite cmpTitle = new Composite(parent, 0);
    GridLayout layout = new GridLayout(2, false);
    marginWidth = 0;
    marginHeight = 0;
    cmpTitle.setLayout(layout);
    
    GridData gridData = new GridData(1808);
    cmpTitle.setLayoutData(gridData);
    
    Label label = new Label(cmpTitle, 0);
    
    label.setFont(JFaceResources.getBannerFont());
    label.setText(getTitleAreaString());
    if (needHistory)
    {
      ToolBar historyBar = new ToolBar(cmpTitle, 8388864);
      
      GridData gd = new GridData();
      horizontalAlignment = 16777224;
      historyBar.setLayoutData(gd);
      ToolBarManager historyManager = new ToolBarManager(historyBar);
      history.createHistoryControls(historyBar, historyManager);
      historyManager.update(false);
    }
    else
    {
      new Label(cmpTitle, 0);
    }
    return cmpTitle;
  }
  
  protected String getTitleAreaString()
  {
    return "";
  }
  
  protected void populateSubtasks() {}
  
  protected void updateTreeItem() {}
  
  public void updateTree()
  {
    populateSubtasks();
    updateTreeItem();
    
    TreeItem defaultSelection = getDefaultSelection();
    if (defaultSelection != null) {
      navTree.setSelection(new TreeItem[] {
        defaultSelection });
    }
  }
  
  protected ISubtaskSheet getSubtask(String sSubtaskPath)
  {
    int separatorIndex = sSubtaskPath.indexOf(" - ");
    int subtaskIndex = 0;
    if (separatorIndex > -1)
    {
      subtaskIndex = Integer.parseInt(sSubtaskPath.substring(separatorIndex + 
        " - ".length())
        .trim()) - 1;
      sSubtaskPath = sSubtaskPath.substring(0, separatorIndex).trim();
    }
    ISubtaskSheet itask = super.getSubtask(sSubtaskPath);
    itask.setIndex(subtaskIndex);
    return itask;
  }
  
  protected boolean containSubtask(String sSubtaskPath)
  {
    int separatorIndex = sSubtaskPath.indexOf(" - ");
    if (separatorIndex > -1) {
      sSubtaskPath = sSubtaskPath.substring(0, separatorIndex).trim();
    }
    return super.containSubtask(sSubtaskPath);
  }
  
  protected void switchTo(String sSubtaskPath, boolean needSelection)
  {
    super.switchTo(sSubtaskPath);
    if (needSelection)
    {
      TreeItem treeItem = navTree.findTreeItem(sSubtaskPath);
      if (treeItem != null) {
        navTree.setSelection(new TreeItem[] {
          treeItem });
      }
    }
    createSubtaskArea(cmpSubtaskContainer, getSubtask(sSubtaskPath));
    cmpSubtaskContainer.layout();
    if (container != null) {
      container.packWizard();
    }
    setSubtaskSelection(sSubtaskPath);
    if (container != null) {
      container.firePageChanged(getCurrentSubtask());
    }
    if (needHistory) {
      history.addHistoryEntry(sSubtaskPath);
    }
  }
  
  public void switchTo(String sSubtaskPath)
  {
    switchTo(sSubtaskPath, true);
  }
  
  public void switchToTreeItem(TreeItem treeItem)
  {
    if (treeItem == null) {
      return;
    }
    navTree.setSelection(new TreeItem[] {
      treeItem });
    
    switchTo(navTree.getNodePath(treeItem), false);
  }
  
  protected void createSubtaskArea(Composite parent, ISubtaskSheet subtask)
  {
    if (subtask != null)
    {
      subtask.createControl(parent);
      subtask.attachPopup(getPopupSelection());
    }
  }
  
  public NavTree getNavigatorTree()
  {
    return navTree;
  }
  
  public void setPopupSelection(String popupName)
  {
    lastPopupRegistry.put(getContext().getWizardID(), popupName);
  }
  
  protected String getPopupSelection()
  {
    return (String)lastPopupRegistry.get(getContext().getWizardID());
  }
  
  protected void setSubtaskSelection(String subtaskPath)
  {
    lastSubtaskRegistry.put(getContext().getWizardID(), subtaskPath);
  }
  
  protected String getSubtaskSelection()
  {
    return (String)lastSubtaskRegistry.get(getContext().getWizardID());
  }
  
  public void dispose()
  {
    super.dispose();
    if (needHistory) {
      history.clearHistory();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.core.ui.frameworks.taskwizard.TreeCompoundTask
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.core.ui.frameworks.taskwizard;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Vector;
import org.eclipse.birt.core.ui.frameworks.errordisplay.ErrorDialog;
import org.eclipse.birt.core.ui.frameworks.taskwizard.interfaces.IButtonHandler;
import org.eclipse.birt.core.ui.frameworks.taskwizard.interfaces.IRegistrationListener;
import org.eclipse.birt.core.ui.frameworks.taskwizard.interfaces.ITask;
import org.eclipse.birt.core.ui.frameworks.taskwizard.interfaces.IWizardContext;
import org.eclipse.birt.core.ui.i18n.Messages;
import org.eclipse.jface.dialogs.IDialogPage;
import org.eclipse.jface.dialogs.PageChangedEvent;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class WizardBase
  implements IRegistrationListener
{
  private transient LinkedHashMap<String, ITask> availableTasks = null;
  transient Vector<String> vTaskIDs = null;
  transient List<IButtonHandler> buttonList = null;
  List<IButtonHandler> tabToolButtonList = null;
  transient String sCurrentActiveTask = null;
  protected transient IWizardContext context = null;
  transient String sWizardID = "";
  transient Shell shellParent = null;
  private transient Object[] errorHints = null;
  private WizardBaseDialog dialog;
  boolean packNeeded = true;
  boolean bEnterClosed = true;
  boolean isDisposed = false;
  
  public IWizardContext open(String[] sTasks, String topTaskId, IWizardContext initialContext)
  {
    context = initialContext;
    dialog.tmpTaskArray = sTasks;
    dialog.tmpTopTaskId = topTaskId;
    
    return dialog.open() == 0 ? context : null;
  }
  
  public IWizardContext open(IWizardContext initialContext)
  {
    return open(null, null, initialContext);
  }
  
  public void setMinimumSize(int iWidth, int iHeight)
  {
    dialog.setMinimumSize(iWidth, iHeight);
  }
  
  public void firePageChanged(IDialogPage taskPage)
  {
    dialog.firePageChanged(new PageChangedEvent(dialog, taskPage));
  }
  
  public void setWizardClosedWhenEnterPressed(boolean bClosed)
  {
    bEnterClosed = bClosed;
  }
  
  public void addCustomButton(IButtonHandler buttonHandler)
  {
    buttonList.add(buttonHandler);
  }
  
  protected List<IButtonHandler> getCustomButtons()
  {
    return buttonList;
  }
  
  public void addTabToolButton(IButtonHandler buttonHandler)
  {
    tabToolButtonList.add(buttonHandler);
  }
  
  public List<IButtonHandler> getTabToolButtons()
  {
    return tabToolButtonList;
  }
  
  public void addTask(String sTaskID)
  {
    ITask task = TasksManager.instance().getTask(sTaskID);
    if (task == null) {
      try
      {
        throw new RuntimeException("Task " + sTaskID + " is not registered!");
      }
      catch (RuntimeException e)
      {
        e.printStackTrace();
        return;
      }
    }
    task.setUIProvider(this);
    if (!vTaskIDs.contains(sTaskID))
    {
      availableTasks.put(sTaskID, task);
      vTaskIDs.add(sTaskID);
    }
  }
  
  public void removeTask(String sTaskID)
  {
    if (vTaskIDs.size() == 1) {
      throw new RuntimeException("There is only one task left in the wizard...you are not allowed to remove all tasks from a wizard!");
    }
 
1 2 3

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