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

16:46:33.908 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.commons.ui_3.7.1.v20120425-0100.jar
package org.eclipse.mylyn.commons.ui;

import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

class ControlListViewer$5
  implements ControlListItem.IndexListener
{
  ControlListViewer$5(ControlListViewer paramControlListViewer, ControlListItem paramControlListItem) {}
  
  public void selectNext()
  {
    Control[] children = this$0.control.getChildren();
    for (int i = 0; i < children.length; i++) {
      if (val$item == children[i])
      {
        if (i >= children.length - 1) {
          break;
        }
        this$0.setSelection(new StructuredSelection(children[(i + 1)].getData()));
        
        break;
      }
    }
  }
  
  public void selectPrevious()
  {
    Control[] children = this$0.control.getChildren();
    for (int i = 0; i < children.length; i++) {
      if (val$item == children[i])
      {
        if (i <= 0) {
          break;
        }
        this$0.setSelection(new StructuredSelection(children[(i - 1)].getData()));
        
        break;
      }
    }
  }
  
  public void select()
  {
    this$0.setSelection(new StructuredSelection(val$item.getData()));
    this$0.setFocus();
  }
  
  public void open()
  {
    this$0.handleOpen();
  }
}

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

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

class GradientCanvas$2
  implements Listener
{
  GradientCanvas$2(GradientCanvas paramGradientCanvas) {}
  
  public void handleEvent(Event e)
  {
    if (GradientCanvas.access$1(this$0) != null)
    {
      GradientCanvas.access$1(this$0).dispose();
      GradientCanvas.access$2(this$0, null);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.GradientCanvas.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Text;

class CredentialsDialog$3
  implements ModifyListener
{
  CredentialsDialog$3(CredentialsDialog paramCredentialsDialog, Text paramText) {}
  
  public void modifyText(ModifyEvent e)
  {
    CredentialsDialog.access$3(this$0, val$passwordField.getText());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.CredentialsDialog.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

import org.eclipse.swt.widgets.Shell;

class AbstractNotificationPopup$1$1
  implements Runnable
{
  AbstractNotificationPopup$1$1(AbstractNotificationPopup.1 param1) {}
  
  public void run()
  {
    Shell shell = AbstractNotificationPopup.1.access$0(this$1).getShell();
    if ((shell == null) || (shell.isDisposed())) {
      return;
    }
    if (AbstractNotificationPopup.access$1(AbstractNotificationPopup.1.access$0(this$1), shell))
    {
      AbstractNotificationPopup.1.access$0(this$1).scheduleAutoClose();
      return;
    }
    AbstractNotificationPopup.1.access$0(this$1).closeFade();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.AbstractNotificationPopup.1.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;

class AbstractInPlaceDialog$1
  implements DisposeListener
{
  AbstractInPlaceDialog$1(AbstractInPlaceDialog paramAbstractInPlaceDialog) {}
  
  public void widgetDisposed(DisposeEvent e)
  {
    this$0.dispose();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.AbstractInPlaceDialog.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.mylyn.commons.ui.CommonImages;
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.Image;
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.Control;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class CredentialsDialog
  extends TitleAreaDialog
{
  private String domain;
  private Image keyLockImage;
  private String keyStoreFileName;
  private final Mode mode;
  private boolean needsDomain;
  private String password;
  private boolean savePassword;
  private String username;
  
  public static enum Mode
  {
    KEY_STORE,  USER;
  }
  
  public CredentialsDialog(Shell parentShell, Mode mode)
  {
    super(parentShell);
    this.mode = mode;
    domain = "";
    username = "";
    password = "";
    keyStoreFileName = "";
  }
  
  public boolean close()
  {
    if (keyLockImage != null) {
      keyLockImage.dispose();
    }
    return super.close();
  }
  
  public String getDomain()
  {
    return domain;
  }
  
  public String getKeyStoreFileName()
  {
    return keyStoreFileName;
  }
  
  public Mode getMode()
  {
    return mode;
  }
  
  public String getPassword()
  {
    return password;
  }
  
  public boolean getSavePassword()
  {
    return savePassword;
  }
  
  public String getUserName()
  {
    return username;
  }
  
  public boolean needsDomain()
  {
    return needsDomain;
  }
  
  public void setDomain(String domain)
  {
    Assert.isNotNull(domain);
    this.domain = domain;
  }
  
  public void setKeyStoreFileName(String keyStoreFileName)
  {
    Assert.isNotNull(this.keyStoreFileName);
    this.keyStoreFileName = keyStoreFileName;
  }
  
  public void setNeedsDomain(boolean needsDomain)
  {
    this.needsDomain = needsDomain;
  }
  
  public void setPassword(String password)
  {
    Assert.isNotNull(password);
    this.password = password;
  }
  
  public void setSavePassword(boolean savePassword)
  {
    this.savePassword = savePassword;
  }
  
  public void setUsername(String username)
  {
    Assert.isNotNull(username);
    this.username = username;
  }
  
  private void createCenterArea(Composite parent)
  {
    Composite composite = new Composite(parent, 0);
    composite.setLayout(new GridLayout(3, false));
    composite.setLayoutData(new GridData(768));
    if (mode == Mode.USER) {
      createUserControls(composite);
    } else if (mode == Mode.KEY_STORE) {
      createKeyStoreControls(composite);
    }
    createPasswordControls(composite);
  }
  
  private void createKeyStoreControls(Composite composite)
  {
    new Label(composite, 0).setText("Key Store:");
    
    final Text keyStoreField = new Text(composite, 2048);
    keyStoreField.addModifyListener(new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        keyStoreFileName = keyStoreField.getText();
      }
    });
    keyStoreField.setText(keyStoreFileName);
    if (keyStoreFileName.length() == 0) {
      keyStoreField.setFocus();
    }
    GridDataFactory.fillDefaults().align(4, 16777216).hint(convertHorizontalDLUsToPixels(200), -1).grab(true, false).applyTo(keyStoreField);
    
    Button browseButton = new Button(composite, 8);
    browseButton.setText("Browse...");
    browseButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        FileDialog fileDialog = new FileDialog(getShell(), 4096);
        if (keyStoreFileName != null) {
          fileDialog.setFilterPath(System.getProperty("user.home", "."));
        }
        String returnFile = fileDialog.open();
        if (returnFile != null)
        {
          username = returnFile;
          keyStoreField.setText(returnFile);
        }
      }
    });
  }
  
  private void createPasswordControls(Composite composite)
  {
    new Label(composite, 0).setText("Password:");
    
    final Text passwordField = new Text(composite, 4196352);
    passwordField.addModifyListener(new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        password = passwordField.getText();
      }
    });
    passwordField.setText(password);
    if (username.length() > 0) {
      passwordField.setFocus();
    }
    GridDataFactory.fillDefaults().align(4, 16777216).span(2, 1).hint(convertHorizontalDLUsToPixels(200), -1).grab(true, false).applyTo(passwordField);
    
    final Button savePasswordButton = new Button(composite, 32);
    savePasswordButton.setText("Save Password");
    savePasswordButton.setSelection(savePassword);
    savePasswordButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        savePassword = savePasswordButton.getSelection();
      }
    });
    GridDataFactory.fillDefaults().span(3, 1).applyTo(savePasswordButton);
  }
  
  private void createUserControls(Composite composite)
  {
    new Label(composite, 0).setText("Username:");
    
    final Text usernameText = new Text(composite, 2048);
    usernameText.setText(username);
    usernameText.addModifyListener(new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        username = usernameText.getText();
      }
    });
    if (username.length() == 0) {
      usernameText.setFocus();
    }
    GridDataFactory.fillDefaults().align(4, 16777216).hint(convertHorizontalDLUsToPixels(200), -1).span(2, 1).grab(true, false).applyTo(usernameText);
    if (needsDomain())
    {
      new Label(composite, 0).setText("Domain:");
      
      final Text domainText = new Text(composite, 2048);
      domainText.setText(domain);
      domainText.addModifyListener(new ModifyListener()
      {
        public void modifyText(ModifyEvent e)
        {
          domain = domainText.getText();
        }
      });GridDataFactory.fillDefaults().align(4, 16777216).hint(convertHorizontalDLUsToPixels(200), -1).span(2, 1).grab(true, false)
        .applyTo(domainText);
    }
  }
  
  protected Control createContents(Composite parent)
  {
    getShell().setText("Enter credentials");
    setTitle("Authentication");
    
    Control control = super.createContents(parent);
    
    keyLockImage = CommonImages.BANNER_SECURE_ROLE.createImage();
    setTitleImage(keyLockImage);
    
    applyDialogFont(control);
    return control;
  }
  
  protected Control createDialogArea(Composite parent)
  {
    Composite parent2 = (Composite)super.createDialogArea(parent);
    
    Composite composite = new Composite(parent2, 0);
    composite.setLayout(new GridLayout(1, false));
    GridDataFactory.fillDefaults().align(4, 1).applyTo(composite);
    
    createCenterArea(composite);
    
    composite.pack();
    return parent;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.CredentialsDialog
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

import org.eclipse.mylyn.commons.ui.GradientColors;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;

class AbstractNotificationPopup$5
  extends ControlAdapter
{
  AbstractNotificationPopup$5(AbstractNotificationPopup paramAbstractNotificationPopup, Composite paramComposite) {}
  
  public void controlResized(ControlEvent e)
  {
    Rectangle clArea = val$outerCircle.getClientArea();
    AbstractNotificationPopup.access$3(this$0, new Image(val$outerCircle.getDisplay(), width, height));
    GC gc = new GC(AbstractNotificationPopup.access$4(this$0));
    
    drawGradient(gc, clArea);
    
    fixRegion(gc, clArea);
    
    gc.dispose();
    
    Image oldBGImage = val$outerCircle.getBackgroundImage();
    val$outerCircle.setBackgroundImage(AbstractNotificationPopup.access$4(this$0));
    if (oldBGImage != null) {
      oldBGImage.dispose();
    }
  }
  
  private void drawGradient(GC gc, Rectangle clArea)
  {
    gc.setForeground(AbstractNotificationPopup.access$5(this$0).getGradientBegin());
    gc.setBackground(AbstractNotificationPopup.access$5(this$0).getGradientEnd());
    gc.fillGradientRectangle(x, y, width, height, true);
  }
  
  private void fixRegion(GC gc, Rectangle clArea)
  {
    gc.setForeground(AbstractNotificationPopup.access$5(this$0).getBorder());
    
    gc.drawPoint(2, 0);
    gc.drawPoint(3, 0);
    gc.drawPoint(1, 1);
    gc.drawPoint(0, 2);
    gc.drawPoint(0, 3);
    
    gc.drawPoint(width - 4, 0);
    gc.drawPoint(width - 3, 0);
    gc.drawPoint(width - 2, 1);
    gc.drawPoint(width - 1, 2);
    gc.drawPoint(width - 1, 3);
    
    gc.drawPoint(2, height - 0);
    gc.drawPoint(3, height - 0);
    gc.drawPoint(1, height - 1);
    gc.drawPoint(0, height - 2);
    gc.drawPoint(0, height - 3);
    
    gc.drawPoint(width - 4, height - 0);
    gc.drawPoint(width - 3, height - 0);
    gc.drawPoint(width - 2, height - 1);
    gc.drawPoint(width - 1, height - 2);
    gc.drawPoint(width - 1, height - 3);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.AbstractNotificationPopup.5
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

import java.util.HashMap;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.commons.ui.Messages;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;

public class ValidatableWizardDialog
  extends EnhancedWizardDialog
{
  private static final String VALIDATE_BUTTON_KEY = "validate";
  private Button validateServerButton;
  private static final int VALIDATE_BUTTON_ID = 2000;
  
  public ValidatableWizardDialog(Shell parentShell, IWizard newWizard)
  {
    super(parentShell, newWizard);
    setHelpAvailable(false);
  }
  
  protected void createExtraButtons(Composite composite)
  {
    validateServerButton = createButton(composite, 2000, 
      Messages.ValidatableWizardDialog_Validate_Button_Label, false);
    validateServerButton.setImage(CommonImages.getImage(CommonImages.VALIDATE));
    validateServerButton.setVisible(false);
    setButtonLayoutData(validateServerButton);
  }
  
  public void updateExtraButtons()
  {
    IValidatable validatable = getValidatablePage();
    if ((validatable != null) && (validatable.needsValidation()))
    {
      if (!validateServerButton.isVisible()) {
        validateServerButton.setVisible(true);
      }
      validateServerButton.setEnabled(validatable.canValidate());
    }
    else if ((validateServerButton != null) && (validateServerButton.isVisible()))
    {
      validateServerButton.setVisible(false);
    }
  }
  
  private IValidatable getValidatablePage()
  {
    IValidatable validatable = null;
    IWizardPage currentPage = getCurrentPage();
    if ((currentPage instanceof IValidatable)) {
      validatable = (IValidatable)currentPage;
    } else if ((currentPage instanceof IAdaptable)) {
      validatable = (IValidatable)((IAdaptable)currentPage).getAdapter(IValidatable.class);
    }
    return validatable;
  }
  
  protected boolean handleExtraButtonPressed(int buttonId)
  {
    if (buttonId == 2000)
    {
      IValidatable validatable = getValidatablePage();
      if (validatable != null)
      {
        validatable.validate();
        return true;
      }
    }
    return false;
  }
  
  protected HashMap<String, Boolean> saveAndSetEnabledStateMylyn()
  {
    HashMap<String, Boolean> savedEnabledState = null;
    if (getShell() != null)
    {
      savedEnabledState = new HashMap();
      if ((validateServerButton != null) && (validateServerButton.getShell() == getShell()))
      {
        savedEnabledState.put("validate", Boolean.valueOf(validateServerButton.getEnabled()));
        validateServerButton.setEnabled(false);
      }
    }
    return savedEnabledState;
  }
  
  protected void restoreEnabledStateMylyn(HashMap<String, Boolean> savedEnabledState)
  {
    if (savedEnabledState != null)
    {
      Boolean savedValidateEnabledState = (Boolean)savedEnabledState.get("validate");
      if ((validateServerButton != null) && (savedValidateEnabledState != null)) {
        validateServerButton.setEnabled(savedValidateEnabledState.booleanValue());
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.ValidatableWizardDialog
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

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

class CredentialsDialog$4
  extends SelectionAdapter
{
  CredentialsDialog$4(CredentialsDialog paramCredentialsDialog, Button paramButton) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    CredentialsDialog.access$4(this$0, val$savePasswordButton.getSelection());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.CredentialsDialog.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

public enum CredentialsDialog$Mode
{
  KEY_STORE,  USER;
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.CredentialsDialog.Mode
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

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

class AbstractInPlaceDialog$2
  implements SelectionListener
{
  AbstractInPlaceDialog$2(AbstractInPlaceDialog paramAbstractInPlaceDialog, int paramInt, boolean paramBoolean) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    AbstractInPlaceDialog.access$0(this$0, val$returnCode);
    if (val$shouldClose) {
      this$0.close();
    } else {
      AbstractInPlaceDialog.access$1(this$0, false);
    }
  }
  
  public void widgetDefaultSelected(SelectionEvent e)
  {
    widgetSelected(e);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.AbstractInPlaceDialog.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

import org.eclipse.mylyn.internal.commons.ui.AnimationUtil;
import org.eclipse.mylyn.internal.commons.ui.AnimationUtil.FadeJob;
import org.eclipse.mylyn.internal.commons.ui.AnimationUtil.IFadeListener;
import org.eclipse.swt.widgets.Shell;

class AbstractNotificationPopup$6
  implements AnimationUtil.IFadeListener
{
  AbstractNotificationPopup$6(AbstractNotificationPopup paramAbstractNotificationPopup) {}
  
  public void faded(Shell shell, int alpha)
  {
    if (!shell.isDisposed()) {
      if (alpha == 0)
      {
        shell.close();
      }
      else if (AbstractNotificationPopup.access$1(this$0, shell))
      {
        if (AbstractNotificationPopup.access$6(this$0) != null) {
          AbstractNotificationPopup.access$6(this$0).cancelAndWait(false);
        }
        AbstractNotificationPopup.access$7(this$0, AnimationUtil.fastFadeIn(shell, new AnimationUtil.IFadeListener()
        {
          public void faded(Shell shell, int alpha)
          {
            if (shell.isDisposed()) {
              return;
            }
            if (alpha == 255) {
              this$0.scheduleAutoClose();
            }
          }
        }));
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.AbstractNotificationPopup.6
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Text;

class CredentialsDialog$5
  implements ModifyListener
{
  CredentialsDialog$5(CredentialsDialog paramCredentialsDialog, Text paramText) {}
  
  public void modifyText(ModifyEvent e)
  {
    CredentialsDialog.access$2(this$0, val$usernameText.getText());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.CredentialsDialog.5
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

import org.eclipse.core.runtime.ISafeRunnable;

class AbstractInPlaceDialog$3
  implements ISafeRunnable
{
  AbstractInPlaceDialog$3(AbstractInPlaceDialog paramAbstractInPlaceDialog, IInPlaceDialogListener paramIInPlaceDialogListener, InPlaceDialogEvent paramInPlaceDialogEvent) {}
  
  public void run()
    throws Exception
  {
    val$listener.buttonPressed(val$event);
  }
  
  public void handleException(Throwable exception) {}
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.AbstractInPlaceDialog.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Text;

class CredentialsDialog$6
  implements ModifyListener
{
  CredentialsDialog$6(CredentialsDialog paramCredentialsDialog, Text paramText) {}
  
  public void modifyText(ModifyEvent e)
  {
    CredentialsDialog.access$5(this$0, val$domainText.getText());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.CredentialsDialog.6
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

public abstract interface IInPlaceDialogListener
{
  public abstract void buttonPressed(InPlaceDialogEvent paramInPlaceDialogEvent);
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.IInPlaceDialogListener
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.jface.window.Window;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.commons.ui.CommonUiUtil;
import org.eclipse.mylyn.commons.ui.GradientColors;
import org.eclipse.mylyn.commons.ui.compatibility.CommonFonts;
import org.eclipse.mylyn.internal.commons.ui.AnimationUtil;
import org.eclipse.mylyn.internal.commons.ui.AnimationUtil.FadeJob;
import org.eclipse.mylyn.internal.commons.ui.AnimationUtil.IFadeListener;
import org.eclipse.mylyn.internal.commons.ui.Messages;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;

public abstract class AbstractNotificationPopup
  extends Window
{
  private static final int TITLE_HEIGHT = 24;
  private static final String LABEL_NOTIFICATION = Messages.AbstractNotificationPopup_Notification;
  private static final String LABEL_JOB_CLOSE = Messages.AbstractNotificationPopup_Close_Notification_Job;
  private static final int MAX_WIDTH = 400;
  private static final int MIN_HEIGHT = 100;
  private static final long DEFAULT_DELAY_CLOSE = 8000L;
  private static final int PADDING_EDGE = 5;
  private long delayClose = 8000L;
  protected LocalResourceManager resources;
  private GradientColors color;
  private final Display display;
  private Shell shell;
  private Region lastUsedRegion;
  private Image lastUsedBgImage;
  private final Job closeJob = new Job(LABEL_JOB_CLOSE)
  {
    protected IStatus run(IProgressMonitor monitor)
    {
      if (!display.isDisposed()) {
        display.asyncExec(new Runnable()
        {
          public void run()
          {
            Shell shell = getShell();
            if ((shell == null) || (shell.isDisposed())) {
              return;
            }
            if (AbstractNotificationPopup.this.isMouseOver(shell))
            {
              scheduleAutoClose();
              return;
            }
            closeFade();
          }
        });
      }
      if (monitor.isCanceled()) {
        return Status.CANCEL_STATUS;
      }
      return Status.OK_STATUS;
    }
  };
  private final boolean respectDisplayBounds = true;
  private final boolean respectMonitorBounds = true;
  private AnimationUtil.FadeJob fadeJob;
  private boolean fadingEnabled;
  
  public AbstractNotificationPopup(Display display)
  {
    this(display, 540684);
  }
  
  public AbstractNotificationPopup(Display display, int style)
  {
    super(new Shell(display));
    setShellStyle(style);
    
    this.display = display;
    resources = new LocalResourceManager(JFaceResources.getResources());
    initResources();
    
    closeJob.setSystem(true);
  }
  
  public boolean isFadingEnabled()
  {
    return fadingEnabled;
  }
  
  public void setFadingEnabled(boolean fadingEnabled)
  {
    this.fadingEnabled = fadingEnabled;
  }
  
  protected String getPopupShellTitle()
  {
    String productName = CommonUiUtil.getProductName();
    if (productName != null) {
      return productName + " " + LABEL_NOTIFICATION;
    }
    return LABEL_NOTIFICATION;
  }
  
  protected Image getPopupShellImage(int maximumHeight)
  {
    return null;
  }
  
  protected void createContentArea(Composite parent) {}
  
  protected void createTitleArea(Composite parent)
  {
    getLayoutDataheightHint = 24;
    
    Label titleImageLabel = new Label(parent, 0);
    titleImageLabel.setImage(getPopupShellImage(24));
    
    Label titleTextLabel = new Label(parent, 0);
    titleTextLabel.setText(getPopupShellTitle());
    titleTextLabel.setFont(CommonFonts.BOLD);
    titleTextLabel.setForeground(getTitleForeground());
    
    titleTextLabel.setLayoutData(new GridData(4, 16777216, true, true));
    titleTextLabel.setCursor(parent.getDisplay().getSystemCursor(21));
    
    final Label button = new Label(parent, 0);
    button.setImage(CommonImages.getImage(CommonImages.NOTIFICATION_CLOSE));
    button.addMouseTrackListener(new MouseTrackAdapter()
    {
      public void mouseEnter(MouseEvent e)
      {
        button.setImage(CommonImages.getImage(CommonImages.NOTIFICATION_CLOSE_HOVER));
      }
      
      public void mouseExit(MouseEvent e)
      {
        button.setImage(CommonImages.getImage(CommonImages.NOTIFICATION_CLOSE));
      }
    });
    button.addMouseListener(new MouseAdapter()
    {
      public void mouseUp(MouseEvent e)
      {
        close();
        setReturnCode(1);
      }
    });
  }
  
  protected Color getTitleForeground()
  {
    return color.getTitleText();
  }
  
  private void initResources()
  {
    color = new GradientColors(display, resources);
  }
  
  protected void configureShell(Shell newShell)
  {
    super.configureShell(newShell);
    
    shell = newShell;
    newShell.setBackground(color.getBorder());
  }
  
  public void create()
  {
    super.create();
    addRegion(shell);
  }
  
  private void addRegion(Shell shell)
  {
    Region region = new Region();
    Point s = shell.getSize();
    
    region.add(0, 0, x, y);
    
    region.subtract(0, 0, 5, 1);
    region.subtract(0, 1, 3, 1);
    region.subtract(0, 2, 2, 1);
    region.subtract(0, 3, 1, 1);
    region.subtract(0, 4, 1, 1);
    
    region.subtract(x - 5, 0, 5, 1);
    region.subtract(x - 3, 1, 3, 1);
    region.subtract(x - 2, 2, 2, 1);
    region.subtract(x - 1, 3, 1, 1);
    region.subtract(x - 1, 4, 1, 1);
    
    region.subtract(0, y, 5, 1);
    region.subtract(0, y - 1, 3, 1);
    region.subtract(0, y - 2, 2, 1);
    region.subtract(0, y - 3, 1, 1);
    region.subtract(0, y - 4, 1, 1);
    
    region.subtract(x - 5, y - 0, 5, 1);
    region.subtract(x - 3, y - 1, 3, 1);
    region.subtract(x - 2, y - 2, 2, 1);
    region.subtract(x - 1, y - 3, 1, 1);
    region.subtract(x - 1, y - 4, 1, 1);
    if (shell.getRegion() != null) {
      shell.getRegion().dispose();
    }
    shell.setRegion(region);
    
    lastUsedRegion = region;
  }
  
  private boolean isMouseOver(Shell shell)
  {
    if (display.isDisposed()) {
      return false;
    }
    return shell.getBounds().contains(display.getCursorLocation());
  }
  
  public int open()
  {
    if ((shell == null) || (shell.isDisposed()))
    {
      shell = null;
      create();
    }
    constrainShellSize();
    shell.setLocation(fixupDisplayBounds(shell.getSize(), shell.getLocation()));
    if (isFadingEnabled()) {
      shell.setAlpha(0);
    }
    shell.setVisible(true);
    fadeJob = AnimationUtil.fadeIn(shell, new AnimationUtil.IFadeListener()
    {
      public void faded(Shell shell, int alpha)
      {
        if (shell.isDisposed()) {
          return;
        }
        if (alpha == 255) {
          scheduleAutoClose();
        }
      }
    });
    return 0;
  }
  
  protected void scheduleAutoClose()
  {
    if (delayClose > 0L) {
      closeJob.schedule(delayClose);
    }
  }
  
  protected Control createContents(Composite parent)
  {
    getLayoutmarginWidth = 1;
    getLayoutmarginHeight = 1;
    
    final Composite outerCircle = new Composite(parent, 524288);
    outerCircle.setLayoutData(new GridData(4, 4, true, true));
    outerCircle.setBackgroundMode(2);
    
    outerCircle.addControlListener(new ControlAdapter()
    {
      public void controlResized(ControlEvent e)
      {
        Rectangle clArea = outerCircle.getClientArea();
        lastUsedBgImage = new Image(outerCircle.getDisplay(), width, height);
        GC gc = new GC(lastUsedBgImage);
        
        drawGradient(gc, clArea);
        
        fixRegion(gc, clArea);
        
        gc.dispose();
        
        Image oldBGImage = outerCircle.getBackgroundImage();
        outerCircle.setBackgroundImage(lastUsedBgImage);
        if (oldBGImage != null) {
          oldBGImage.dispose();
        }
      }
      
      private void drawGradient(GC gc, Rectangle clArea)
      {
        gc.setForeground(color.getGradientBegin());
        gc.setBackground(color.getGradientEnd());
        gc.fillGradientRectangle(x, y, width, height, true);
      }
      
      private void fixRegion(GC gc, Rectangle clArea)
      {
        gc.setForeground(color.getBorder());
        
        gc.drawPoint(2, 0);
        gc.drawPoint(3, 0);
        gc.drawPoint(1, 1);
        gc.drawPoint(0, 2);
        gc.drawPoint(0, 3);
        
        gc.drawPoint(width - 4, 0);
        gc.drawPoint(width - 3, 0);
        gc.drawPoint(width - 2, 1);
        gc.drawPoint(width - 1, 2);
        gc.drawPoint(width - 1, 3);
        
        gc.drawPoint(2, height - 0);
        gc.drawPoint(3, height - 0);
        gc.drawPoint(1, height - 1);
        gc.drawPoint(0, height - 2);
        gc.drawPoint(0, height - 3);
        
        gc.drawPoint(width - 4, height - 0);
        gc.drawPoint(width - 3, height - 0);
        gc.drawPoint(width - 2, height - 1);
        gc.drawPoint(width - 1, height - 2);
        gc.drawPoint(width - 1, height - 3);
      }
    });
    GridLayout layout = new GridLayout(1, false);
    marginWidth = 0;
    marginHeight = 0;
    verticalSpacing = 0;
    
    outerCircle.setLayout(layout);
    
    Composite titleCircle = new Composite(outerCircle, 524288);
    titleCircle.setLayoutData(new GridData(4, 16777216, true, false));
    titleCircle.setBackgroundMode(2);
    
    layout = new GridLayout(4, false);
    marginWidth = 3;
    marginHeight = 0;
    verticalSpacing = 5;
    horizontalSpacing = 3;
    
    titleCircle.setLayout(layout);
    
    createTitleArea(titleCircle);
    
    Composite outerContentCircle = new Composite(outerCircle, 0);
    outerContentCircle.setBackgroundMode(2);
    
    layout = new GridLayout(1, false);
    marginWidth = 0;
    marginHeight = 0;
    
    outerContentCircle.setLayout(layout);
    outerContentCircle.setLayoutData(new GridData(4, 4, true, true));
    outerContentCircle.setBackground(outerCircle.getBackground());
    
    Composite middleContentCircle = new Composite(outerContentCircle, 524288);
    middleContentCircle.setBackgroundMode(2);
    
    layout = new GridLayout(1, false);
    marginWidth = 0;
    marginHeight = 0;
    marginTop = 1;
    
    middleContentCircle.setLayout(layout);
    middleContentCircle.setLayoutData(new GridData(4, 4, true, true));
    middleContentCircle.setBackground(color.getBorder());
    
    Composite innerContent = new Composite(middleContentCircle, 524288);
    innerContent.setLayoutData(new GridData(4, 4, true, true));
    innerContent.setBackgroundMode(2);
    
    layout = new GridLayout(1, false);
    marginWidth = 0;
    marginHeight = 5;
    marginLeft = 5;
    marginRight = 5;
    innerContent.setLayout(layout);
    
    innerContent.setBackground(shell.getDisplay().getSystemColor(1));
    
    createContentArea(innerContent);
    
    setNullBackground(outerCircle);
    
    return outerCircle;
  }
  
  private void setNullBackground(Composite outerCircle)
  {
    Control[] arrayOfControl;
    int j = (arrayOfControl = outerCircle.getChildren()).length;
    for (int i = 0; i < j; i++)
    {
      Control c = arrayOfControl[i];
      c.setBackground(null);
      if ((c instanceof Composite)) {
        setNullBackground((Composite)c);
      }
    }
  }
  
  protected void initializeBounds()
  {
    Rectangle clArea = getPrimaryClientArea();
    Point initialSize = shell.computeSize(-1, -1);
    int height = Math.max(y, 100);
    int width = Math.min(x, 400);
    
    Point size = new Point(width, height);
    shell.setLocation(width + x - x - 5, height + y - y - 
      5);
    shell.setSize(size);
  }
  
  private Rectangle getPrimaryClientArea()
  {
    Monitor primaryMonitor = shell.getDisplay().getPrimaryMonitor();
    return primaryMonitor != null ? primaryMonitor.getClientArea() : shell.getDisplay().getClientArea();
  }
  
  public void closeFade()
  {
    if (fadeJob != null) {
      fadeJob.cancelAndWait(false);
    }
    fadeJob = AnimationUtil.fadeOut(getShell(), new AnimationUtil.IFadeListener()
    {
      public void faded(Shell shell, int alpha)
      {
        if (!shell.isDisposed()) {
          if (alpha == 0)
          {
            shell.close();
          }
          else if (AbstractNotificationPopup.this.isMouseOver(shell))
          {
            if (fadeJob != null) {
              fadeJob.cancelAndWait(false);
            }
            fadeJob = AnimationUtil.fastFadeIn(shell, new AnimationUtil.IFadeListener()
            {
              public void faded(Shell shell, int alpha)
              {
                if (shell.isDisposed()) {
                  return;
                }
                if (alpha == 255) {
                  scheduleAutoClose();
                }
              }
            });
          }
        }
      }
    });
  }
  
  public boolean close()
  {
    resources.dispose();
    if (lastUsedRegion != null) {
      lastUsedRegion.dispose();
    }
    if ((lastUsedBgImage != null) && (!lastUsedBgImage.isDisposed())) {
      lastUsedBgImage.dispose();
    }
    return super.close();
  }
  
  public long getDelayClose()
  {
    return delayClose;
  }
  
  public void setDelayClose(long delayClose)
  {
    this.delayClose = delayClose;
  }
  
  private Point fixupDisplayBounds(Point tipSize, Point location)
  {
    Point rightBounds = new Point(x + x, y + y);
    
    Rectangle bounds = shell.getDisplay().getPrimaryMonitor().getBounds();
    if ((!bounds.contains(location)) || (!bounds.contains(rightBounds)))
    {
      if (x > x + width) {
        x -= x - (x + width);
      }
      if (y > y + height) {
        y -= y - (y + height);
      }
      if (x < x) {
        x = x;
      }
      if (y < y) {
        y = y;
      }
    }
    return location;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.AbstractNotificationPopup
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

public class InPlaceDialogEvent
{
  private final int returnCode;
  private final boolean isClosing;
  
  public InPlaceDialogEvent(int returnCode, boolean isClosing)
  {
    this.returnCode = returnCode;
    this.isClosing = isClosing;
  }
  
  public boolean isClosing()
  {
    return isClosing;
  }
  
  public int getReturnCode()
  {
    return returnCode;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.InPlaceDialogEvent
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

class AbstractNotificationPopup$1
  extends Job
{
  AbstractNotificationPopup$1(AbstractNotificationPopup paramAbstractNotificationPopup, String $anonymous0)
  {
    super($anonymous0);
  }
  
  protected IStatus run(IProgressMonitor monitor)
  {
    if (!AbstractNotificationPopup.access$0(this$0).isDisposed()) {
      AbstractNotificationPopup.access$0(this$0).asyncExec(new Runnable()
      {
        public void run()
        {
          Shell shell = this$0.getShell();
          if ((shell == null) || (shell.isDisposed())) {
            return;
          }
          if (AbstractNotificationPopup.access$1(this$0, shell))
          {
            this$0.scheduleAutoClose();
            return;
          }
          this$0.closeFade();
        }
      });
    }
    if (monitor.isCanceled()) {
      return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.AbstractNotificationPopup.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.dialogs;

import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.widgets.Label;

class AbstractNotificationPopup$2
  extends MouseTrackAdapter
{
  AbstractNotificationPopup$2(AbstractNotificationPopup paramAbstractNotificationPopup, Label paramLabel) {}
  
  public void mouseEnter(MouseEvent e)
  {
    val$button.setImage(CommonImages.getImage(CommonImages.NOTIFICATION_CLOSE_HOVER));
  }
  
  public void mouseExit(MouseEvent e)
  {
    val$button.setImage(CommonImages.getImage(CommonImages.NOTIFICATION_CLOSE));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.dialogs.Abs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

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