org.eclipse.mylyn.tasks.ui_3.7.1.v20120425-0100

g/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentWizard$ImageSource:page	Lorg/eclipse/mylyn/commons/ui/wizard/ScreenshotCreationPage;
    //   29: iconst_0
    //   30: invokevirtual 126	org/eclipse/mylyn/commons/ui/wizard/ScreenshotCreationPage:setImageDirty	(Z)V
    //   33: aload_0
    //   34: ldc 4
    //   36: ldc 1
    //   38: invokestatic 118	java/io/File:createTempFile	(Ljava/lang/String;Ljava/lang/String;)Ljava/io/File;
    //   41: putfield 113	org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentWizard$ImageSource:file	Ljava/io/File;
    //   44: aload_0
    //   45: getfield 113	org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentWizard$ImageSource:file	Ljava/io/File;
    //   48: invokevirtual 117	java/io/File:deleteOnExit	()V
    //   51: new 72	org/eclipse/swt/graphics/ImageLoader
    //   54: dup
    //   55: invokespecial 131	org/eclipse/swt/graphics/ImageLoader:<init>	()V
    //   58: astore_3
    //   59: aload_3
    //   60: iconst_1
    //   61: anewarray 71	org/eclipse/swt/graphics/ImageData
    //   64: dup
    //   65: iconst_0
    //   66: aload_2
    //   67: invokevirtual 130	org/eclipse/swt/graphics/Image:getImageData	()Lorg/eclipse/swt/graphics/ImageData;
    //   70: aastore
    //   71: putfield 115	org/eclipse/swt/graphics/ImageLoader:data	[Lorg/eclipse/swt/graphics/ImageData;
    //   74: new 61	java/io/FileOutputStream
    //   77: dup
    //   78: aload_0
    //   79: getfield 113	org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentWizard$ImageSource:file	Ljava/io/File;
    //   82: invokespecial 121	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   85: astore 4
    //   87: aload_3
    //   88: aload 4
    //   90: iconst_5
    //   91: invokevirtual 132	org/eclipse/swt/graphics/ImageLoader:save	(Ljava/io/OutputStream;I)V
    //   94: goto +13 -> 107
    //   97: astore 5
    //   99: aload 4
    //   101: invokevirtual 120	java/io/FileOutputStream:close	()V
    //   104: aload 5
    //   106: athrow
    //   107: aload 4
    //   109: invokevirtual 120	java/io/FileOutputStream:close	()V
    //   112: goto +12 -> 124
    //   115: astore 6
    //   117: aload_2
    //   118: invokevirtual 129	org/eclipse/swt/graphics/Image:dispose	()V
    //   121: aload 6
    //   123: athrow
    //   124: aload_2
    //   125: invokevirtual 129	org/eclipse/swt/graphics/Image:dispose	()V
    //   128: new 60	java/io/FileInputStream
    //   131: dup
    //   132: aload_0
    //   133: getfield 113	org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentWizard$ImageSource:file	Ljava/io/File;
    //   136: invokespecial 119	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   139: areturn
    //   140: astore_2
    //   141: new 63	org/eclipse/core/runtime/CoreException
    //   144: dup
    //   145: new 64	org/eclipse/core/runtime/Status
    //   148: dup
    //   149: iconst_4
    //   150: ldc 3
    //   152: aload_2
    //   153: invokevirtual 122	java/io/IOException:getMessage	()Ljava/lang/String;
    //   156: aload_2
    //   157: invokespecial 124	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   160: invokespecial 123	org/eclipse/core/runtime/CoreException:<init>	(Lorg/eclipse/core/runtime/IStatus;)V
    //   163: athrow
    // Line number table:
    //   Java source line #209	-> byte code offset #0
    //   Java source line #210	-> byte code offset #17
    //   Java source line #211	-> byte code offset #25
    //   Java source line #213	-> byte code offset #33
    //   Java source line #214	-> byte code offset #44
    //   Java source line #215	-> byte code offset #51
    //   Java source line #216	-> byte code offset #59
    //   Java source line #218	-> byte code offset #74
    //   Java source line #220	-> byte code offset #87
    //   Java source line #221	-> byte code offset #97
    //   Java source line #222	-> byte code offset #99
    //   Java source line #223	-> byte code offset #104
    //   Java source line #222	-> byte code offset #107
    //   Java source line #224	-> byte code offset #115
    //   Java source line #225	-> byte code offset #117
    //   Java source line #226	-> byte code offset #121
    //   Java source line #225	-> byte code offset #124
    //   Java source line #228	-> byte code offset #128
    //   Java source line #229	-> byte code offset #140
    //   Java source line #230	-> byte code offset #141
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	164	0	this	ImageSource
    //   0	164	1	monitor	org.eclipse.core.runtime.IProgressMonitor
    //   24	101	2	image	org.eclipse.swt.graphics.Image
    //   140	17	2	e	java.io.IOException
    //   58	30	3	loader	org.eclipse.swt.graphics.ImageLoader
    //   85	23	4	out	java.io.FileOutputStream
    //   97	8	5	localObject1	Object
    //   115	7	6	localObject2	Object
    // Exception table:
    //   from	to	target	type
    //   87	97	97	finally
    //   33	115	115	finally
    //   0	139	140	java/io/IOException
  }
  
  public String getContentType()
  {
    return "image/png";
  }
  
  public String getDescription()
  {
    return Messages.TaskAttachmentWizard_Screenshot;
  }
  
  public long getLength()
  {
    return file != null ? file.length() : -1L;
  }
  
  public String getName()
  {
    return "screenshot.png";
  }
  
  public boolean isLocal()
  {
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.ImageSource
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.wizards;

import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.mylyn.commons.workbench.GradientDrawer;
import org.eclipse.mylyn.internal.tasks.core.Category;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.themes.IThemeManager;

class SelectRepositoryPage$4
  extends GradientDrawer
{
  SelectRepositoryPage$4(SelectRepositoryPage paramSelectRepositoryPage, IThemeManager $anonymous0, TreeViewer $anonymous1)
  {
    super($anonymous0, $anonymous1);
  }
  
  protected boolean shouldApplyGradient(Event event)
  {
    return item.getData() instanceof Category;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.wizards.SelectRepositoryPage.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.wizards;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class TaskDataImportWizardPage$4
  extends SelectionAdapter
{
  TaskDataImportWizardPage$4(TaskDataImportWizardPage paramTaskDataImportWizardPage) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.controlChanged();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.wizards.TaskDataImportWizardPage.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.wizards;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.mylyn.internal.tasks.ui.TaskListBackupManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.util.TaskDataExportOperation;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.ui.IExportWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;

public class TaskDataExportWizard
  extends Wizard
  implements IExportWizard
{
  private static final String SETTINGS_SECTION = "org.eclipse.mylyn.tasklist.ui.exportWizard";
  private TaskDataExportWizardPage exportPage = null;
  
  public TaskDataExportWizard()
  {
    IDialogSettings masterSettings = TasksUiPlugin.getDefault().getDialogSettings();
    setDialogSettings(getSettingsSection(masterSettings));
    setNeedsProgressMonitor(true);
    setWindowTitle(Messages.TaskDataExportWizard_Export);
  }
  
  private IDialogSettings getSettingsSection(IDialogSettings master)
  {
    IDialogSettings settings = master.getSection("org.eclipse.mylyn.tasklist.ui.exportWizard");
    if (settings == null) {
      settings = master.addNewSection("org.eclipse.mylyn.tasklist.ui.exportWizard");
    }
    return settings;
  }
  
  public void addPages()
  {
    exportPage = new TaskDataExportWizardPage();
    addPage(exportPage);
  }
  
  public void init(IWorkbench workbench, IStructuredSelection selection) {}
  
  public boolean performFinish()
  {
    String destDir = exportPage.getDestinationDirectory();
    
    File destZipFile = new File(destDir + File.separator + TaskListBackupManager.getBackupFileName());
    
    TaskDataExportOperation job = new TaskDataExportOperation(exportPage.getDestinationDirectory(), 
      destZipFile.getName());
    try
    {
      if (getContainer() != null)
      {
        getContainer().run(true, true, job);
      }
      else
      {
        IProgressService service = PlatformUI.getWorkbench().getProgressService();
        service.run(true, true, job);
      }
    }
    catch (InvocationTargetException e)
    {
      Status status = new Status(4, "org.eclipse.mylyn.tasks.ui", e.getMessage(), e);
      TasksUiInternal.logAndDisplayStatus(Messages.TaskDataExportWizard_export_failed, status);
    }
    catch (InterruptedException localInterruptedException) {}
    exportPage.saveSettings();
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.wizards.TaskDataExportWizard
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.wizards;

import org.eclipse.jface.wizard.IWizard;
import org.eclipse.mylyn.internal.tasks.core.ITaskRepositoryFilter;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;

final class NewQueryWizard$SelectRepositoryPageForNewQuery
  extends SelectRepositoryPage
{
  public NewQueryWizard$SelectRepositoryPageForNewQuery()
  {
    super(ITaskRepositoryFilter.CAN_QUERY);
  }
  
  protected IWizard createWizard(TaskRepository taskRepository)
  {
    AbstractRepositoryConnectorUi repositoryUi = TasksUiPlugin.getConnectorUi(taskRepository.getConnectorKind());
    return repositoryUi.getQueryWizard(taskRepository, null);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.wizards.NewQueryWizard.SelectRepositoryPageForNewQuery
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.wizards;

import java.io.InputStream;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;

class AttachmentPreviewPage$4$1
  implements Runnable
{
  AttachmentPreviewPage$4$1(AttachmentPreviewPage.4 param4, InputStream paramInputStream, Composite paramComposite, Object[] paramArrayOfObject) {}
  
  public void run()
  {
    Image originalImage = new Image(AttachmentPreviewPage.4.access$0(this$1).getShell().getDisplay(), val$in);
    Image bufferedImage = new Image(AttachmentPreviewPage.4.access$0(this$1).getShell().getDisplay(), 
      originalImage.getBounds());
    GC gc = new GC(bufferedImage);
    gc.setBackground(val$composite.getBackground());
    gc.fillRectangle(originalImage.getBounds());
    gc.drawImage(originalImage, 0, 0);
    gc.dispose();
    originalImage.dispose();
    val$result[0] = bufferedImage;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.wizards.AttachmentPreviewPage.4.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.wizards;

import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.mylyn.commons.workbench.WorkbenchUtil;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.actions.AddRepositoryAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.Messages;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryManager;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.ui.wizards.ITaskRepositoryPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;

public class NewRepositoryWizard
  extends Wizard
  implements INewWizard
{
  private static final String PREF_ADD_QUERY = "org.eclipse.mylyn.internal.tasks.add.query";
  private AbstractRepositoryConnector connector;
  private final String connectorKind;
  private TaskRepository taskRepository;
  private SelectRepositoryConnectorPage selectConnectorPage;
  private ITaskRepositoryPage settingsPage;
  private String lastConnectorKind;
  private boolean showNewQueryPromptOnFinish;
  
  public NewRepositoryWizard()
  {
    this(null);
  }
  
  public NewRepositoryWizard(String connectorKind)
  {
    this.connectorKind = connectorKind;
    setDefaultPageImageDescriptor(TasksUiImages.BANNER_REPOSITORY);
    setForcePreviousAndNextButtons(connectorKind == null);
    setNeedsProgressMonitor(true);
    setWindowTitle(AddRepositoryAction.TITLE);
    setShowNewQueryPromptOnFinish(true);
  }
  
  public void addPages()
  {
    if ((connectorKind != null) && 
      (TasksUi.getRepositoryManager().getRepositoryConnector(connectorKind).canCreateRepository()))
    {
      connector = TasksUi.getRepositoryManager().getRepositoryConnector(connectorKind);
      updateSettingsPage();
      if (settingsPage != null) {
        addPage(settingsPage);
      }
    }
    else
    {
      selectConnectorPage = new SelectRepositoryConnectorPage();
      addPage(selectConnectorPage);
    }
  }
  
  public boolean canFinish()
  {
    return ((selectConnectorPage == null) || (selectConnectorPage.isPageComplete())) && (getContainer().getCurrentPage() != selectConnectorPage) && (settingsPage != null) && (settingsPage.isPageComplete());
  }
  
  public IWizardPage getNextPage(IWizardPage page)
  {
    if (page == selectConnectorPage)
    {
      connector = selectConnectorPage.getConnector();
      updateSettingsPage();
      return settingsPage;
    }
    return super.getNextPage(page);
  }
  
  public void init(IWorkbench workbench, IStructuredSelection selection) {}
  
  public boolean performFinish()
  {
    if (canFinish())
    {
      taskRepository = new TaskRepository(connector.getConnectorKind(), settingsPage.getRepositoryUrl());
      boolean finishAccepted = settingsPage.preFinish(taskRepository);
      if (finishAccepted)
      {
        settingsPage.performFinish(taskRepository);
        TasksUi.getRepositoryManager().addRepository(taskRepository);
        if ((showNewQueryPromptOnFinish()) && 
          (connector.canQuery(taskRepository))) {
          promptToAddQuery(taskRepository);
        }
        return true;
      }
    }
    return false;
  }
  
  public TaskRepository getTaskRepository()
  {
    return taskRepository;
  }
  
  private void updateSettingsPage()
  {
    assert (connector != null);
    if (!connector.getConnectorKind().equals(lastConnectorKind))
    {
      AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(connector.getConnectorKind());
      settingsPage = connectorUi.getSettingsPage(null);
      if (settingsPage == null) {
        TasksUiInternal.displayFrameworkError(NLS.bind(
          "The connector implementation is incomplete: AbstractRepositoryConnectorUi.getSettingsPage() for connector ''{0}'' returned null. Please contact the vendor of the connector to resolve the problem.", connector.getConnectorKind()));
      }
      settingsPage.setWizard(this);
      lastConnectorKind = connector.getConnectorKind();
    }
  }
  
  public void promptToAddQuery(TaskRepository taskRepository)
  {
    IPreferenceStore preferenceStore = TasksUiPlugin.getDefault().getPreferenceStore();
    if (!preferenceStore.getBoolean("org.eclipse.mylyn.internal.tasks.add.query"))
    {
      MessageDialogWithToggle messageDialog = MessageDialogWithToggle.openYesNoQuestion(getShell(), 
        Messages.AddRepositoryAction_Add_new_query, 
        Messages.AddRepositoryAction_Add_a_query_to_the_Task_List, 
        Messages.AddRepositoryAction_Do_not_show_again, false, preferenceStore, "org.eclipse.mylyn.internal.tasks.add.query");
      preferenceStore.setValue("org.eclipse.mylyn.internal.tasks.add.query", messageDialog.getToggleState());
      if (messageDialog.getReturnCode() == 2)
      {
        AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(taskRepository.getConnectorKind());
        final IWizard queryWizard = connectorUi.getQueryWizard(taskRepository, null);
        ((Wizard)queryWizard).setForcePreviousAndNextButtons(true);
        
        getShell().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            WizardDialog queryDialog = new WizardDialog(WorkbenchUtil.getShell(), queryWizard);
            queryDialog.create();
            queryDialog.setBlockOnOpen(true);
            queryDialog.open();
          }
        });
      }
    }
  }
  
  public boolean showNewQueryPromptOnFinish()
  {
    return showNewQueryPromptOnFinish;
  }
  
  public void setShowNewQueryPromptOnFinish(boolean showNewQueryPromptOnFinish)
  {
    this.showNewQueryPromptOnFinish = showNewQueryPromptOnFinish;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.wizards.NewRepositoryWizard
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.wizards;

import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;

class AttachmentPreviewPage$1
  implements PaintListener
{
  AttachmentPreviewPage$1(AttachmentPreviewPage paramAttachmentPreviewPage, Image paramImage) {}
  
  public void paintControl(PaintEvent event)
  {
    gc.drawImage(val$bufferedImage, 0, 0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.wizards.AttachmentPreviewPage.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.wizards;

import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.wizard.IWizardContainer;

class SelectRepositoryConnectorPage$2
  implements IOpenListener
{
  SelectRepositoryConnectorPage$2(SelectRepositoryConnectorPage paramSelectRepositoryConnectorPage) {}
  
  public void open(OpenEvent event)
  {
    SelectRepositoryConnectorPage.access$1(this$0).showPage(this$0.getNextPage());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.wizards.SelectRepositoryConnectorPage.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.wizards;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;

class AttachmentSourcePage$6
  extends SelectionAdapter
{
  AttachmentSourcePage$6(AttachmentSourcePage paramAttachmentSourcePage) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    if (!AttachmentSourcePage.access$9(this$0).getSelection()) {
      return;
    }
    AttachmentSourcePage.access$1(this$0);
    
    AttachmentSourcePage.access$2(this$0, !AttachmentSourcePage.access$10(this$0).getSelection().isEmpty());
    AttachmentSourcePage.access$4(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.wizards.AttachmentSourcePage.6
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.wizards;

import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.WizardDialog;

class SelectRepositoryPage$5
  implements IOpenListener
{
  SelectRepositoryPage$5(SelectRepositoryPage paramSelectRepositoryPage) {}
  
  public void open(OpenEvent event)
  {
    if (this$0.canFlipToNextPage()) {
      SelectRepositoryPage.access$1(this$0).showPage(this$0.getNextPage());
    } else if ((this$0.canFinish()) && 
      (this$0.getWizard().performFinish())) {
      ((WizardDialog)SelectRepositoryPage.access$1(this$0)).close();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.wizards.SelectRepositoryPage.5
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.wizards;

import com.ibm.icu.text.DateFormat;
import java.io.File;
import java.util.SortedMap;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.tasks.ui.TaskListBackupManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;

public class TaskDataImportWizardPage
  extends WizardPage
{
  private Button browseButtonZip = null;
  private Text sourceZipText = null;
  private Button importViaBackupButton;
  private Button importViaZipButton;
  private Table backupFilesTable;
  private static final String SETTINGS_SAVED = Messages.TaskDataImportWizardPage_Import_Settings_saved;
  private static final String SOURCE_ZIP_SETTING = Messages.TaskDataImportWizardPage_Import_Source_zip_file_setting;
  private static final String IMPORT_ZIPMETHOD_SETTING = Messages.TaskDataImportWizardPage_Import_method_zip;
  private static final String IMPORT_BACKUPMETHOD_SETTING = Messages.TaskDataImportWizardPage_Import_method_backup;
  
  public TaskDataImportWizardPage()
  {
    super("org.eclipse.mylyn.tasklist.importPage");
    setPageComplete(false);
    setMessage(Messages.TaskDataImportWizardPage_Importing_overwrites_current_tasks_and_repositories, 
      2);
    setImageDescriptor(CommonImages.BANNER_IMPORT);
    setTitle(Messages.TaskDataImportWizardPage_Restore_tasks_from_history);
  }
  
  public void createControl(Composite parent)
  {
    Composite container = new Composite(parent, 0);
    GridLayout layout = new GridLayout(3, false);
    verticalSpacing = 15;
    container.setLayout(layout);
    createImportFromZipControl(container);
    createImportFromBackupControl(container);
    addRadioListeners();
    initSettings();
    Dialog.applyDialogFont(container);
    setControl(container);
    setPageComplete(validate());
  }
  
  private void addRadioListeners()
  {
    SelectionListener radioListener = new SelectionListener()
    {
      public void widgetSelected(SelectionEvent e)
      {
        browseButtonZip.setEnabled(importViaZipButton.getSelection());
        backupFilesTable.setEnabled(importViaBackupButton.getSelection());
        sourceZipText.setEnabled(importViaZipButton.getSelection());
        controlChanged();
      }
      
      public void widgetDefaultSelected(SelectionEvent e) {}
    };
    importViaZipButton.addSelectionListener(radioListener);
    importViaBackupButton.addSelectionListener(radioListener);
  }
  
  private void createImportFromZipControl(Composite parent)
  {
    importViaZipButton = new Button(parent, 16);
    importViaZipButton.setText(Messages.TaskDataImportWizardPage_From_zip_file);
    
    sourceZipText = new Text(parent, 2048);
    sourceZipText.setEditable(true);
    GridDataFactory.fillDefaults().grab(true, false).hint(250, -1).applyTo(sourceZipText);
    sourceZipText.addModifyListener(new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        controlChanged();
      }
    });
    browseButtonZip = new Button(parent, 8);
    browseButtonZip.setText(Messages.TaskDataImportWizardPage_Browse_);
    browseButtonZip.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        FileDialog dialog = new FileDialog(getShell());
        dialog.setText(Messages.TaskDataImportWizardPage_Zip_File_Selection);
        String dir = sourceZipText.getText();
        dialog.setFilterPath(dir);
        dir = dialog.open();
        if ((dir == null) || (dir.equals(""))) {
          return;
        }
        sourceZipText.setText(dir);
      }
    });
  }
  
  private void createImportFromBackupControl(Composite container)
  {
    importViaBackupButton = new Button(container, 16);
    importViaBackupButton.setText(Messages.TaskDataImportWizardPage_From_snapshot);
    addBackupFileView(container);
  }
  
  private void addBackupFileView(Composite composite)
  {
    backupFilesTable = new Table(composite, 2048);
    GridDataFactory.fillDefaults().span(2, -1).grab(true, true).applyTo(backupFilesTable);
    
    TableColumn filenameColumn = new TableColumn(backupFilesTable, 16384);
    filenameColumn.setWidth(200);
    
    SortedMap<Long, File> backupFilesMap = TasksUiPlugin.getBackupManager().getBackupFiles();
    for (Long time : backupFilesMap.keySet())
    {
      File file = (File)backupFilesMap.get(time);
      TableItem item = new TableItem(backupFilesTable, 0);
      item.setData(file.getAbsolutePath());
      item.setText(DateFormat.getDateTimeInstance().format(time));
    }
    backupFilesTable.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        controlChanged();
      }
    });
  }
  
  protected void initSettings()
  {
    IDialogSettings settings = getDialogSettings();
    if (settings.get(SETTINGS_SAVED) == null)
    {
      importViaZipButton.setSelection(true);
      sourceZipText.setEnabled(true);
      backupFilesTable.setEnabled(false);
    }
    else
    {
      importViaZipButton.setSelection(settings.getBoolean(IMPORT_ZIPMETHOD_SETTING));
      importViaBackupButton.setSelection(settings.getBoolean(IMPORT_BACKUPMETHOD_SETTING));
      browseButtonZip.setEnabled(importViaZipButton.getSelection());
      sourceZipText.setEnabled(importViaZipButton.getSelection());
      
      backupFilesTable.setEnabled(importViaBackupButton.getSelection());
      String zipFile = settings.get(SOURCE_ZIP_SETTING);
      if (zipFile != null) {
        sourceZipText.setText(settings.get(SOURCE_ZIP_SETTING));
      }
    }
  }
  
  public void setVisible(boolean visible)
  {
    if (visible) {
      if (importViaZipButton.getSelection()) {
        sourceZipText.setFocus();
      } else {
        importViaBackupButton.setFocus();
      }
    }
    super.setVisible(visible);
  }
  
  public void saveSettings()
  {
    IDialogSettings settings = getDialogSettings();
    
    settings.put(IMPORT_ZIPMETHOD_SETTING, importViaZipButton.getSelection());
    settings.put(IMPORT_BACKUPMETHOD_SETTING, importViaBackupButton.getSelection());
    settings.put(SETTINGS_SAVED, SETTINGS_SAVED);
  }
  
  public void controlChanged()
  {
    setPageComplete(validate());
  }
  
  protected boolean validate()
  {
    if ((importViaZipButton.getSelection()) && (sourceZipText.getText().equals(""))) {
      return false;
    }
    if ((importViaBackupButton.getSelection()) && (backupFilesTable.getSelection().length == 0)) {
      return false;
    }
    return true;
  }
  
  public String getSourceZipFile()
  {
    if (importViaZipButton.getSelection()) {
      return sourceZipText.getText();
    }
    if (backupFilesTable.getSelectionIndex() != -1) {
      return (String)backupFilesTable.getSelection()[0].getData();
    }
    return Messages.TaskDataImportWizardPage__unspecified_;
  }
  
  public void setSource(boolean zip, String sourceZip)
  {
    sourceZipText.setText(sourceZip);
    importViaZipButton.setSelection(zip);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.wizards.TaskDataImportWizardPage
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.wizards;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceMappingContext;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.mylyn.internal.tasks.core.data.FileTaskAttachmentSource;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentSource;
import org.eclipse.mylyn.tasks.core.data.TaskAttachmentModel;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.views.navigator.ResourceComparator;

public class AttachmentSourcePage
  extends WizardPage
{
  protected static final int SIZING_TEXT_FIELD_WIDTH = 250;
  protected static final int COMBO_HISTORY_LENGTH = 5;
  protected static final int CLIPBOARD = 1;
  protected static final int FILE = 2;
  protected static final int WORKSPACE = 3;
  protected static final int SCREENSHOT = 4;
  static final char SEPARATOR = System.getProperty("file.separator").charAt(0);
  private boolean showError = false;
  private Button useClipboardButton;
  private Combo fileNameField;
  private Button fileBrowseButton;
  private Button useFileButton;
  private Button useWorkspaceButton;
  private Label workspaceSelectLabel;
  private TreeViewer treeViewer;
  private String clipboardContents;
  private boolean initUseClipboard = false;
  private final String DIALOG_SETTINGS = "InputAttachmentSourcePage";
  private final String S_LAST_SELECTION = "lastSelection";
  private final String S_FILE_HISTORY = "fileHistory";
  private final String S_LAST_FILE = "lastFile";
  private final TaskAttachmentModel model;
  private String lastFilename;
  
  public AttachmentSourcePage(TaskAttachmentModel model)
  {
    super("InputAttachmentPage");
    this.model = model;
    setTitle(Messages.AttachmentSourcePage_Select_attachment_source);
    setDescription(Messages.AttachmentSourcePage_Clipboard_supports_text_and_image_attachments_only);
  }
  
  private void restoreDialogSettings()
  {
    IDialogSettings settings = getDialogSettings();
    if (settings == null)
    {
      updateWidgetEnablements();
      return;
    }
    String selection = settings.get("lastSelection");
    if (selection != null) {
      setInputMethod(Integer.valueOf(selection).intValue());
    } else {
      updateWidgetEnablements();
    }
    String[] fileNames = settings.getArray("fileHistory");
    if (fileNames != null)
    {
      String[] arrayOfString1;
      int j = (arrayOfString1 = fileNames).length;
      for (int i = 0; i < j; i++)
      {
        String fileName = arrayOfString1[i];
        fileNameField.add(fileName);
      }
    }
    lastFilename = settings.get("lastFile");
  }
  
  protected IPath getPathFromText(Text textField)
  {
    return new Path(textField.getText()).makeAbsolute();
  }
  
  public String getAttachmentName()
  {
    if (getInputMethod() == 1) {
      return Messages.AttachmentSourcePage__Clipboard_;
    }
    if (getInputMethod() == 3) {
      return getResources(treeViewer.getSelection())[0].getFullPath().toOSString();
    }
    return getAttachmentFilePath();
  }
  
  public void createControl(Composite parent)
  {
    Composite composite = new Composite(parent, 0);
    composite.setLayout(new GridLayout());
    GridData gd = new GridData(272);
    heightHint = 800;
    composite.setLayoutData(gd);
    setControl(composite);
    
    initializeDialogUnits(parent);
    
    createAttachmentFileGroup(composite);
    
    showError = false;
    clearErrorMessage();
    restoreDialogSettings();
    
    Dialog.applyDialogFont(composite);
  }
  
  public IWizardPage getNextPage()
  {
    AbstractTaskAttachmentSource source = getSource();
    model.setSource(source);
    if (source != null) {
      model.setContentType(source.getContentType());
    }
    saveDialogSettings();
    return super.getNextPage();
  }
  
  private void saveDialogSettings()
  {
    IDialogSettings settings = getDialogSettings();
    settings.put("lastSelection", getInputMethod());
    
    String[] fileNames = settings.getArray("fileHistory");
    String newFileName = fileNameField.getText().trim();
    if ((getInputMethod() == 2) && (newFileName.length() > 0))
    {
      List<String> history = new ArrayList(10);
      history.add(newFileName);
      if (fileNames != null) {
        for (int i = 0; (i < fileNames.length) && (history.size() < 5); i++) {
          if (!newFileName.equals(fileNames[i])) {
            history.add(fileNames[i]);
          }
        }
      }
      settings.put("fileHistory", (String[])history.toArray(new String[0]));
    }
    settings.put("lastFile", lastFilename);
  }
  
  public boolean canFlipToNextPage()
  {
    return isPageComplete();
  }
  
  private void setEnableAttachmentFile(boolean enable)
  {
    fileNameField.setEnabled(enable);
    fileBrowseButton.setEnabled(enable);
  }
  
  private void setEnableWorkspaceAttachment(boolean enable)
  {
    workspaceSelectLabel.setEnabled(enable);
    treeViewer.getTree().setEnabled(enable);
  }
  
  private void createAttachmentFileGroup(Composite parent)
  {
    final Composite composite = new Composite(parent, 0);
    GridLayout gridLayout = new GridLayout();
    numColumns = 3;
    composite.setLayout(gridLayout);
    composite.setLayoutData(new GridData(768));
    
    GridData gd = new GridData(32);
    useFileButton = new Button(composite, 16);
    useFileButton.setText(Messages.AttachmentSourcePage_File);
    
    fileNameField = new Combo(composite, 2048);
    gd = new GridData(768);
    widthHint = 250;
    fileNameField.setLayoutData(gd);
    fileNameField.setText("");
    
    fileBrowseButton = new Button(composite, 8);
    fileBrowseButton.setText(Messages.AttachmentSourcePage_Browse_);
    GridData data = new GridData(256);
    int widthHint = convertHorizontalDLUsToPixels(61);
    Point minSize = fileBrowseButton.computeSize(-1, -1, true);
    widthHint = Math.max(widthHint, x);
    fileBrowseButton.setLayoutData(data);
    
    gd = new GridData(32);
    horizontalSpan = 3;
    useClipboardButton = new Button(composite, 16);
    useClipboardButton.setText(Messages.AttachmentSourcePage_Clipboard);
    useClipboardButton.setLayoutData(gd);
    useClipboardButton.setSelection(initUseClipboard);
    
    useWorkspaceButton = new Button(composite, 16);
    useWorkspaceButton.setText(Messages.AttachmentSourcePage_Workspace);
    gd = new GridData(32);
    useWorkspaceButton.setLayoutData(gd);
    
    addWorkspaceControls(parent);
    
    useClipboardButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        if (!useClipboardButton.getSelection()) {
          return;
        }
        AttachmentSourcePage.this.clearErrorMessage();
        showError = true;
        AttachmentSourcePage.this.storeClipboardContents();
        AttachmentSourcePage.this.updateWidgetEnablements();
      }
    });
    useFileButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        if (!useFileButton.getSelection()) {
          return;
        }
        AttachmentSourcePage.this.clearErrorMessage();
        showError = (fileNameField.getText() != "");
        AttachmentSourcePage.this.updateWidgetEnablements();
      }
    });
    fileNameField.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        setSourceName(fileNameField.getText());
        AttachmentSourcePage.this.updateWidgetEnablements();
      }
    });
    fileNameField.addModifyListener(new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        AttachmentSourcePage.this.clearErrorMessage();
        showError = true;
        AttachmentSourcePage.this.updateWidgetEnablements();
      }
    });
    fileBrowseButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        AttachmentSourcePage.this.clearErrorMessage();
        showError = true;
        
        FileDialog fileChooser = new FileDialog(composite.getShell(), 4096);
        fileChooser.setText(Messages.AttachmentSourcePage_Select_File_Dialog_Title);
        if (fileNameField.getText().trim().length() > 0) {
          lastFilename = fileNameField.getText().trim();
        }
   
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79

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-2019. Infinite Loop Ltd