org.eclipse.wst.validation.ui_1.2.300.v201201050300

16:49:29.070 INFO  jd.cli.Main - Decompiling org.eclipse.wst.validation.ui_1.2.300.v201201050300.jar
package org.eclipse.wst.validation.internal.ui;

public abstract interface ContextIds
{
  public static final String PREFIX = "org.eclipse.wst.common.frameworks.ui";
  public static final String VALIDATION_PROPERTIES_PAGE = "org.eclipse.wst.common.frameworks.ui.jvpp0000";
  public static final String VALIDATION_PROPERTIES_PAGE_DISABLED_OVERRIDE = "org.eclipse.wst.common.frameworks.ui.jvpp0001";
  public static final String VALIDATION_PROPERTIES_PAGE_DISABLED_BUILD_NOVALSELECTED = "org.eclipse.wst.common.frameworks.ui.jvpp0003";
  public static final String VALIDATION_PROPERTIES_PAGE_DISABLED_AUTO_AUTOBUILD = "org.eclipse.wst.common.frameworks.ui.jvpp0004";
  public static final String VALIDATION_PROPERTIES_PAGE_DISABLED_AUTO_NOINCVALSELECTED = "org.eclipse.wst.common.frameworks.ui.jvpp0005";
  public static final String VALIDATION_PROPERTIES_PAGE_DISABLED_AUTO_NOINCVALCONFIG = "org.eclipse.wst.common.frameworks.ui.jvpp0006";
  public static final String VALIDATION_PROPERTIES_PAGE_AUTO_ENABLED = "org.eclipse.wst.common.frameworks.ui.jvpp0020";
  public static final String VALIDATION_PROPERTIES_PAGE_OVERRIDE_ENABLED = "org.eclipse.wst.common.frameworks.ui.jvpp0030";
  public static final String VALIDATION_PROPERTIES_PAGE_OVERRIDE_ENABLED_CANNOT_HONOUR_BOTH = "org.eclipse.wst.common.frameworks.ui.jvpp0031";
  public static final String VALIDATION_PROPERTIES_PAGE_OVERRIDE_ENABLED_CANNOT_HONOUR_AUTO = "org.eclipse.wst.common.frameworks.ui.jvpp0032";
  public static final String VALIDATION_PROPERTIES_PAGE_OVERRIDE_ENABLED_CANNOT_HONOUR_MANUAL = "org.eclipse.wst.common.frameworks.ui.jvpp0033";
  public static final String VALIDATION_PROPERTIES_PAGE_REBUILD_ENABLED = "org.eclipse.wst.common.frameworks.ui.jvpp0040";
  public static final String VALIDATION_PROPERTIES_PAGE_MAX_MESSAGES = "org.eclipse.wst.common.frameworks.ui.jvpp0050";
  public static final String VALIDATION_PREFERENCE_PAGE = "org.eclipse.wst.common.frameworks.ui.jvgp0000";
  public static final String VALIDATION_PREFERENCE_PAGE_OVERRIDE = "org.eclipse.wst.common.frameworks.ui.jvgp0005";
  public static final String VALIDATION_PREFERENCE_PAGE_DISABLE_ALL_ENABLED = "org.eclipse.wst.common.frameworks.ui.jvgp0010";
  public static final String VALIDATION_PREFERENCE_PAGE_AUTO_ENABLED = "org.eclipse.wst.common.frameworks.ui.jvgp0020";
  public static final String VALIDATION_PREFERENCE_PAGE_MAX_MESSAGES = "org.eclipse.wst.common.frameworks.ui.jvgp0030";
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.ContextIds
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.wst.validation.internal.delegates.ValidatorDelegateDescriptor;

class DelegatingValidatorPreferencesDialog$1
  implements ISelectionChangedListener
{
  DelegatingValidatorPreferencesDialog$1(DelegatingValidatorPreferencesDialog paramDelegatingValidatorPreferencesDialog, ComboViewer paramComboViewer) {}
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    IStructuredSelection selection = (IStructuredSelection)val$comboViewer.getSelection();
    DelegatingValidatorPreferencesDialog.access$0(this$0, ((ValidatorDelegateDescriptor)selection.getFirstElement()).getId());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.DelegatingValidatorPreferencesDialog.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

import java.util.Collection;
import java.util.Map;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.wst.validation.internal.delegates.ValidatorDelegatesRegistry;

final class DelegatingValidatorPreferencesDialog$DelegatesContentProvider
  implements IStructuredContentProvider
{
  private DelegatingValidatorPreferencesDialog$DelegatesContentProvider(DelegatingValidatorPreferencesDialog paramDelegatingValidatorPreferencesDialog) {}
  
  public void dispose() {}
  
  public Object[] getElements(Object inputElement)
  {
    String targetID = (String)inputElement;
    Map delegatesByID = ValidatorDelegatesRegistry.getInstance().getDelegateDescriptors(targetID);
    if (delegatesByID == null) {
      return new Object[0];
    }
    return delegatesByID.values().toArray();
  }
  
  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.DelegatingValidatorPreferencesDialog.DelegatesContentProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.validation.internal.delegates.ValidatorDelegateDescriptor;

final class DelegatingValidatorPreferencesDialog$DelegatesLabelProvider
  implements ILabelProvider
{
  private DelegatingValidatorPreferencesDialog$DelegatesLabelProvider(DelegatingValidatorPreferencesDialog paramDelegatingValidatorPreferencesDialog) {}
  
  public void addListener(ILabelProviderListener listener) {}
  
  public void dispose() {}
  
  public Image getImage(Object element)
  {
    return null;
  }
  
  public String getText(Object element)
  {
    return ((ValidatorDelegateDescriptor)element).getName();
  }
  
  public boolean isLabelProperty(Object element, String property)
  {
    return false;
  }
  
  public void removeListener(ILabelProviderListener listener) {}
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.DelegatingValidatorPreferencesDialog.DelegatesLabelProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

import java.util.Collection;
import java.util.Map;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.wst.validation.internal.ValidatorMetaData;
import org.eclipse.wst.validation.internal.delegates.ValidatorDelegateDescriptor;
import org.eclipse.wst.validation.internal.delegates.ValidatorDelegatesRegistry;
import org.eclipse.wst.validation.ui.internal.ValUIMessages;

public class DelegatingValidatorPreferencesDialog
  extends Dialog
{
  private ValidatorMetaData delegatingValidatorDescriptor;
  private String delegateID;
  
  public DelegatingValidatorPreferencesDialog(Shell parentShell, ValidatorMetaData vmd, String delegateID)
  {
    super(parentShell);
    
    delegatingValidatorDescriptor = vmd;
    this.delegateID = delegateID;
  }
  
  protected Control createDialogArea(Composite parent)
  {
    super.createDialogArea(parent);
    
    getShell().setText(ValUIMessages.DelegatesDialogTitle);
    
    GridLayout layout = new GridLayout();
    parent.setLayout(layout);
    
    Label label = new Label(parent, 0);
    GridData labelData = new GridData(4, 16777216, true, false);
    widthHint = 250;
    label.setLayoutData(labelData);
    label.setFont(JFaceResources.getFontRegistry().getBold("org.eclipse.jface.dialogfont"));
    String delegatingValidatorName = delegatingValidatorDescriptor.getValidatorDisplayName();
    label.setText(delegatingValidatorName);
    
    Label separator = new Label(parent, 258);
    GridData separatorData = new GridData(4, 16777216, true, false);
    separator.setLayoutData(separatorData);
    
    Composite group = new Composite(parent, 0);
    GridData groupGridData = new GridData(4, 16777216, true, false);
    group.setLayoutData(groupGridData);
    GridLayout groupLayout = new GridLayout(2, false);
    group.setLayout(groupLayout);
    
    Label comboLabel = new Label(group, 0);
    comboLabel.setLayoutData(new GridData());
    comboLabel.setText(ValUIMessages.DelegatesComboLabel);
    
    Combo combo = new Combo(group, 8);
    GridData comboGridData = new GridData(4, 16777216, true, false);
    combo.setLayoutData(comboGridData);
    
    final ComboViewer comboViewer = new ComboViewer(combo);
    comboViewer.setContentProvider(new DelegatesContentProvider(null));
    comboViewer.setLabelProvider(new DelegatesLabelProvider(null));
    String targetID = delegatingValidatorDescriptor.getValidatorUniqueName();
    
    comboViewer.addSelectionChangedListener(new ISelectionChangedListener()
    {
      public void selectionChanged(SelectionChangedEvent event)
      {
        IStructuredSelection selection = (IStructuredSelection)comboViewer.getSelection();
        DelegatingValidatorPreferencesDialog.this.setDelegateID(((ValidatorDelegateDescriptor)selection.getFirstElement()).getId());
      }
    });
    comboViewer.setInput(targetID);
    
    ValidatorDelegateDescriptor selected = ValidatorDelegatesRegistry.getInstance().getDescriptor(targetID, delegateID);
    if (selected != null) {
      comboViewer.setSelection(new StructuredSelection(new Object[] { selected }));
    }
    Label endSeparator = new Label(parent, 258);
    GridData endSeparatorData = new GridData(4, 16777216, true, false);
    endSeparator.setLayoutData(endSeparatorData);
    Dialog.applyDialogFont(parent);
    
    return parent;
  }
  
  private final class DelegatesContentProvider
    implements IStructuredContentProvider
  {
    private DelegatesContentProvider() {}
    
    public void dispose() {}
    
    public Object[] getElements(Object inputElement)
    {
      String targetID = (String)inputElement;
      Map delegatesByID = ValidatorDelegatesRegistry.getInstance().getDelegateDescriptors(targetID);
      if (delegatesByID == null) {
        return new Object[0];
      }
      return delegatesByID.values().toArray();
    }
    
    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
  }
  
  private final class DelegatesLabelProvider
    implements ILabelProvider
  {
    private DelegatesLabelProvider() {}
    
    public void addListener(ILabelProviderListener listener) {}
    
    public void dispose() {}
    
    public Image getImage(Object element)
    {
      return null;
    }
    
    public String getText(Object element)
    {
      return ((ValidatorDelegateDescriptor)element).getName();
    }
    
    public boolean isLabelProperty(Object element, String property)
    {
      return false;
    }
    
    public void removeListener(ILabelProviderListener listener) {}
  }
  
  public String getDelegateID()
  {
    return delegateID;
  }
  
  private void setDelegateID(String delegateID)
  {
    this.delegateID = delegateID;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.DelegatingValidatorPreferencesDialog
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

import java.util.List;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;

public class ListContentProvider
  implements IStructuredContentProvider
{
  List fContents;
  
  public Object[] getElements(Object input)
  {
    if ((fContents != null) && (fContents == input)) {
      return fContents.toArray();
    }
    return new Object[0];
  }
  
  public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
  {
    if ((newInput instanceof List)) {
      fContents = ((List)newInput);
    } else {
      fContents = null;
    }
  }
  
  public void dispose() {}
  
  public boolean isDeleted(Object o)
  {
    return (fContents != null) && (!fContents.contains(o));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.ListContentProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.wst.validation.internal.ConfigurationManager;
import org.eclipse.wst.validation.internal.GlobalConfiguration;
import org.eclipse.wst.validation.internal.ui.plugin.ValidationUIPlugin;

class SaveFilesDialog$1
  extends SelectionAdapter
{
  SaveFilesDialog$1(SaveFilesDialog paramSaveFilesDialog, Button paramButton) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    try
    {
      GlobalConfiguration config = ConfigurationManager.getManager().getGlobalConfiguration();
      config.setSaveAutomatically(val$check.getSelection());
      config.store();
    }
    catch (InvocationTargetException exc)
    {
      Logger.getLogger(ValidationUIPlugin.getBundleName()).log(Level.WARNING, 
        ValidationUIMessages.UnableToSave + exc);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.SaveFilesDialog.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorPart;

class SaveFilesDialog$2
  extends LabelProvider
{
  SaveFilesDialog$2(SaveFilesDialog paramSaveFilesDialog) {}
  
  public Image getImage(Object element)
  {
    return ((IEditorPart)element).getTitleImage();
  }
  
  public String getText(Object element)
  {
    return ((IEditorPart)element).getTitle();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.SaveFilesDialog.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.dialogs.ListDialog;
import org.eclipse.wst.validation.internal.ConfigurationManager;
import org.eclipse.wst.validation.internal.GlobalConfiguration;
import org.eclipse.wst.validation.internal.ui.plugin.ValidationUIPlugin;

public class SaveFilesDialog
  extends ListDialog
{
  public SaveFilesDialog(Shell parent)
  {
    super(parent);
    setTitle(ValidationUIMessages.SaveFilesDialog_save_all_resources);
    setAddCancelButton(true);
    setLabelProvider(createDialogLabelProvider());
    setMessage(ValidationUIMessages.SaveFilesDialog_must_save);
    setContentProvider(new ListContentProvider());
  }
  
  protected Control createDialogArea(Composite container)
  {
    Composite result = (Composite)super.createDialogArea(container);
    boolean fAllowSaveAlways = true;
    if (fAllowSaveAlways)
    {
      final Button check = new Button(result, 32);
      check.setText(ValidationUIMessages.SaveFilesDialog_always_save);
      
      check.addSelectionListener(new SelectionAdapter()
      {
        public void widgetSelected(SelectionEvent e)
        {
          try
          {
            GlobalConfiguration config = ConfigurationManager.getManager().getGlobalConfiguration();
            config.setSaveAutomatically(check.getSelection());
            config.store();
          }
          catch (InvocationTargetException exc)
          {
            Logger.getLogger(ValidationUIPlugin.getBundleName()).log(Level.WARNING, 
              ValidationUIMessages.UnableToSave + exc);
          }
        }
      });
      applyDialogFont(result);
    }
    return result;
  }
  
  private ILabelProvider createDialogLabelProvider()
  {
    new LabelProvider()
    {
      public Image getImage(Object element)
      {
        return ((IEditorPart)element).getTitleImage();
      }
      
      public String getText(Object element)
      {
        return ((IEditorPart)element).getTitle();
      }
    };
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.SaveFilesDialog
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;

public class SaveFilesHelper
{
  public static IEditorPart[] getDirtyEditors(List files)
  {
    Set<IEditorInput> inputs = new HashSet();
    List<IEditorPart> result = new LinkedList();
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
    for (int i = 0; i < windows.length; i++)
    {
      IWorkbenchPage[] pages = windows[i].getPages();
      for (int x = 0; x < pages.length; x++)
      {
        IEditorPart[] editors = pages[x].getDirtyEditors();
        for (int z = 0; z < editors.length; z++)
        {
          IEditorPart ep = editors[z];
          IEditorInput input = ep.getEditorInput();
          if ((input instanceof IFileEditorInput))
          {
            IFileEditorInput fileInput = (IFileEditorInput)input;
            if ((files.contains(fileInput.getFile())) && 
              (!inputs.contains(input)))
            {
              inputs.add(input);
              result.add(ep);
            }
          }
        }
      }
    }
    return (IEditorPart[])result.toArray(new IEditorPart[result.size()]);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.SaveFilesHelper
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.actions.SelectionListenerAction;

public class ValidateAction
  extends SelectionListenerAction
{
  protected ValidationMenuAction delegate;
  
  public ValidateAction()
  {
    super(ValidationUIMessages.Validate);
    delegate = new ValidationMenuAction();
  }
  
  public void run()
  {
    delegate.run(this);
  }
  
  protected boolean updateSelection(IStructuredSelection selection)
  {
    if (!super.updateSelection(selection)) {
      return false;
    }
    delegate.selectionChanged(this, selection);
    
    return isEnabled();
  }
  
  protected IResource[] getResource(Object selected)
  {
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.ValidateAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.Job;

public class ValidationJob
  extends Job
{
  private Map projects;
  
  public ValidationJob(String name)
  {
    super(name);
  }
  
  public void setProjectsMap(Map projects)
  {
    this.projects = projects;
  }
  
  protected IStatus run(IProgressMonitor monitor)
  {
    return null;
  }
  
  protected Map getProjects()
  {
    return projects;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.ValidationJob
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceVisitor;

class ValidationMenuAction$1
  implements IResourceVisitor
{
  ValidationMenuAction$1(ValidationMenuAction paramValidationMenuAction) {}
  
  public boolean visit(IResource res)
  {
    if ((res instanceof IFile)) {
      this$0.addSelected(res);
    } else if ((res instanceof IFolder)) {
      this$0.addSelected(res);
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.ValidationMenuAction.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

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.IResourceVisitor;
import org.eclipse.wst.validation.internal.DisabledResourceManager;

class ValidationMenuAction$2
  implements IResourceVisitor
{
  ValidationMenuAction$2(ValidationMenuAction paramValidationMenuAction) {}
  
  public boolean visit(IResource res)
  {
    if (DisabledResourceManager.getDefault().isDisabled(res)) {
      return false;
    }
    if ((res instanceof IFile)) {
      this$0.addSelected(res);
    } else if ((res instanceof IFolder)) {
      this$0.addSelected(res);
    } else if ((res instanceof IProject)) {
      this$0.addSelected(res);
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.ValidationMenuAction.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.ui.IEditorPart;

class ValidationMenuAction$3
  implements IRunnableWithProgress
{
  ValidationMenuAction$3(ValidationMenuAction paramValidationMenuAction, IEditorPart[] paramArrayOfIEditorPart) {}
  
  /* Error */
  public void run(org.eclipse.core.runtime.IProgressMonitor monitor)
    throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException
  {
    // Byte code:
    //   0: aload_1
    //   1: getstatic 57	org/eclipse/wst/validation/internal/ui/ValidationUIMessages:SaveFilesDialog_saving	Ljava/lang/String;
    //   4: aload_0
    //   5: getfield 55	org/eclipse/wst/validation/internal/ui/ValidationMenuAction$3:val$dirtyEditors	[Lorg/eclipse/ui/IEditorPart;
    //   8: arraylength
    //   9: invokeinterface 61 3 0
    //   14: aload_0
    //   15: getfield 55	org/eclipse/wst/validation/internal/ui/ValidationMenuAction$3:val$dirtyEditors	[Lorg/eclipse/ui/IEditorPart;
    //   18: arraylength
    //   19: istore_2
    //   20: iconst_0
    //   21: istore_3
    //   22: goto +26 -> 48
    //   25: aload_0
    //   26: getfield 55	org/eclipse/wst/validation/internal/ui/ValidationMenuAction$3:val$dirtyEditors	[Lorg/eclipse/ui/IEditorPart;
    //   29: iload_3
    //   30: aaload
    //   31: new 31	org/eclipse/core/runtime/SubProgressMonitor
    //   34: dup
    //   35: aload_1
    //   36: iconst_1
    //   37: invokespecial 59	org/eclipse/core/runtime/SubProgressMonitor:<init>	(Lorg/eclipse/core/runtime/IProgressMonitor;I)V
    //   40: invokeinterface 62 2 0
    //   45: iinc 3 1
    //   48: iload_3
    //   49: iload_2
    //   50: if_icmplt -25 -> 25
    //   53: goto +14 -> 67
    //   56: astore 4
    //   58: aload_1
    //   59: invokeinterface 60 1 0
    //   64: aload 4
    //   66: athrow
    //   67: aload_1
    //   68: invokeinterface 60 1 0
    //   73: return
    // Line number table:
    //   Java source line #360	-> byte code offset #0
    //   Java source line #361	-> byte code offset #14
    //   Java source line #362	-> byte code offset #20
    //   Java source line #363	-> byte code offset #25
    //   Java source line #362	-> byte code offset #45
    //   Java source line #365	-> byte code offset #56
    //   Java source line #366	-> byte code offset #58
    //   Java source line #367	-> byte code offset #64
    //   Java source line #366	-> byte code offset #67
    //   Java source line #368	-> byte code offset #73
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	74	0	this	3
    //   0	74	1	monitor	org.eclipse.core.runtime.IProgressMonitor
    //   19	31	2	numDirtyEditors	int
    //   21	28	3	i	int
    //   56	9	4	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	56	56	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.ValidationMenuAction.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
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.IResourceVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.wst.validation.ValidationFramework;
import org.eclipse.wst.validation.internal.ConfigurationManager;
import org.eclipse.wst.validation.internal.DisabledResourceManager;
import org.eclipse.wst.validation.internal.GlobalConfiguration;
import org.eclipse.wst.validation.internal.ValManager;
import org.eclipse.wst.validation.internal.ValType;
import org.eclipse.wst.validation.internal.ValidationRegistryReader;
import org.eclipse.wst.validation.internal.ValidationSelectionHandlerRegistryReader;
import org.eclipse.wst.validation.internal.model.GlobalPreferences;
import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
import org.eclipse.wst.validation.internal.ui.plugin.ValidationUIPlugin;
import org.eclipse.wst.validation.ui.internal.ManualValidationRunner;

public class ValidationMenuAction
  implements IViewActionDelegate
{
  private ISelection _currentSelection;
  protected static final String SEP = "/";
  private Display _currentDisplay;
  private IResourceVisitor _folderVisitor;
  private IResourceVisitor _projectVisitor;
  private Map<IProject, Set<IResource>> _selectedResources;
  
  public ValidationMenuAction()
  {
    _currentDisplay = Display.getCurrent();
    _selectedResources = new HashMap();
  }
  
  private Display getDisplay()
  {
    return _currentDisplay == null ? Display.getCurrent() : _currentDisplay;
  }
  
  Shell getShell()
  {
    Display display = getDisplay();
    Shell shell = display == null ? null : display.getActiveShell();
    if ((shell == null) && (display != null))
    {
      Shell[] shells = display.getShells();
      if (shells.length > 0) {
        shell = shells[0];
      }
    }
    return shell;
  }
  
  private Map<IProject, Set<IResource>> loadSelected(ValidateAction action)
  {
    _selectedResources.clear();
    if ((_currentSelection == null) || (_currentSelection.isEmpty()) || 
      (!(_currentSelection instanceof IStructuredSelection))) {
      return null;
    }
    Object[] elements = ((IStructuredSelection)_currentSelection).toArray();
    Object[] arrayOfObject1;
    int j = (arrayOfObject1 = elements).length;
    for (int i = 0; i < j; i++)
    {
      Object element = arrayOfObject1[i];
      if (element != null) {
        addSelected(action, element);
      }
    }
    return _selectedResources;
  }
  
  private void addSelected(ValidateAction action, Object selected)
  {
    if ((selected instanceof IProject))
    {
      addVisitor((IProject)selected);
    }
    else if ((selected instanceof IFile))
    {
      addSelected((IFile)selected);
    }
    else if ((selected instanceof IFolder))
    {
      addVisitor((IFolder)selected);
    }
    else if (isValidType(getExtendedType(selected)))
    {
      addSelected(action, getExtendedType(selected));
    }
    else
    {
      boolean valid = false;
      if (action != null)
      {
        IResource[] resources = action.getResource(selected);
        if (resources != null)
        {
          valid = true;
          for (int i = 0; i < resources.length; i++) {
            addSelected(action, resources[i]);
          }
        }
      }
      if (!valid) {
        _selectedResources.clear();
      }
    }
  }
  
  private Object getExtendedType(Object selected)
  {
    Object result = ValidationSelectionHandlerRegistryReader.getInstance().getExtendedType(selected);
    return result == null ? selected : result;
  }
  
  private boolean isValidType(Object object)
  {
    return ((object instanceof IProject)) || ((object instanceof IFile)) || ((object instanceof IFolder));
  }
  
  void addSelected(IResource selected)
  {
    IProject project = selected.getProject();
    boolean added = _selectedResources.containsKey(project);
    Set<IResource> changedRes = null;
    if (added)
    {
      changedRes = (Set)_selectedResources.get(project);
      if (changedRes != null) {}
    }
    else
    {
      changedRes = new HashSet();
    }
    if (changedRes.add(selected)) {
      _selectedResources.put(project, changedRes);
    }
  }
  
  private void addVisitor(IFolder selected)
  {
    try
    {
      selected.accept(getFolderVisitor());
    }
    catch (CoreException exc)
    {
      ValidationUIPlugin.getPlugin().handleException(exc);
      return;
    }
  }
  
  private IResourceVisitor getFolderVisitor()
  {
    if (_folderVisitor == null) {
      _folderVisitor = new IResourceVisitor()
      {
        public boolean visit(IResource res)
        {
          if ((res instanceof IFile)) {
            addSelected(res);
          } else if ((res instanceof IFolder)) {
            addSelected(res);
          }
          return true;
        }
      };
    }
    return _folderVisitor;
  }
  
  private void addVisitor(IProject selected)
  {
    if (!selected.isAccessible()) {
      return;
    }
    try
    {
      selected.accept(getProjectVisitor());
    }
    catch (CoreException exc)
    {
      ValidationUIPlugin.getPlugin().handleException(exc);
      return;
    }
  }
  
  private IResourceVisitor getProjectVisitor()
  {
    if (_projectVisitor == null) {
      _projectVisitor = new IResourceVisitor()
      {
        public boolean visit(IResource res)
        {
          if (DisabledResourceManager.getDefault().isDisabled(res)) {
            return false;
          }
          if ((res instanceof IFile)) {
            addSelected(res);
          } else if ((res instanceof IFolder)) {
            addSelected(res);
          } else if ((res instanceof IProject)) {
            addSelected(res);
          }
          return true;
        }
      };
    }
    return _projectVisitor;
  }
  
  public void run(IAction action)
  {
    ValidateAction vaction = null;
    if ((action instanceof ValidateAction)) {
      vaction = (ValidateAction)action;
    }
    Map<IProject, Set<IResource>> projects = loadSelected(vaction);
    if ((projects == null) || (projects.size() == 0)) {
      return;
    }
    if (!handleFilesToSave(projects)) {
      return;
    }
    boolean confirm = ValManager.getDefault().getGlobalPreferences()
      .getConfirmDialog();
    ManualValidationRunner.validate(projects, ValType.Manual, confirm);
  }
  
  public void selectionChanged(IAction action, ISelection selection)
  {
    _currentSelection = selection;
    boolean enabled = quickCheck(selection);
    if ((enabled) && (ValidationPlugin.isActivated()) && (ValidationRegistryReader.isActivated())) {
      enabled = hasManualValidators(selection);
    }
    action.setEnabled(enabled);
  }
  
  private boolean quickCheck(ISelection selection)
  {
    if ((selection == null) || (selection.isEmpty())) {
      return false;
    }
    if ((selection instanceof IStructuredSelection))
    {
      IStructuredSelection ss = (IStructuredSelection)selection;
      Object sel = ss.getFirstElement();
      if ((sel != null) && 
        ((sel instanceof IProject)))
      {
        IProject project = (IProject)sel;
        if (!project.isOpen()) {
          return false;
        }
      }
    }
    return true;
  }
  
  private boolean hasManualValidators(ISelection selection)
  {
    if ((selection instanceof IStructuredSelection))
    {
      IStructuredSelection ss = (IStructuredSelection)selection;
      for (Iterator it = ss.iterator(); it.hasNext();)
      {
        Object sel = it.next();
        if ((sel instanceof IResource))
        {
          IResource resource = (IResource)sel;
          if (ValidationFramework.getDefault().hasValidators(resource, true, false)) {
            return true;
          }
        }
      }
    }
    return false;
  }
  
  public void init(IViewPart view) {}
  
  protected boolean handleFilesToSave(Map<IProject, Set<IResource>> projects)
  {
    List fileList = getIFiles(projects);
    final IEditorPart[] dirtyEditors = SaveFilesHelper.getDirtyEditors(fileList);
    if ((dirtyEditors == null) || (dirtyEditors.length == 0)) {
      return true;
    }
    boolean saveAutomatically = false;
    try
    {
      saveAutomatically = ConfigurationManager.getManager().getGlobalConfiguration().getSaveAutomatically();
    }
    catch (InvocationTargetException localInvocationTargetException1) {}
    SaveFilesDialog sfDialog = null;
    if (!saveAutomatically)
    {
      sfDialog = new SaveFilesDialog(ValidationUIPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindow().getShell());
      sfDialog.setInput(Arrays.asList(dirtyEditors));
    }
    if ((saveAutomatically) || (sfDialog.open() == 0))
    {
      ProgressMonitorDialog ctx = new ProgressMonitorDialog(getShell());
      
      IRunnableWithProgress runnable = new IRunnableWithProgress()
      {
        /* Error */
        public void run(org.eclipse.core.runtime.IProgressMonitor monitor)
          throws InvocationTargetException, InterruptedException
        {
          // Byte code:
          //   0: aload_1
          //   1: getstatic 57	org/eclipse/wst/validation/internal/ui/ValidationUIMessages:SaveFilesDialog_saving	Ljava/lang/String;
          //   4: aload_0
          //   5: getfield 55	org/eclipse/wst/validation/internal/ui/ValidationMenuAction$3:val$dirtyEditors	[Lorg/eclipse/ui/IEditorPart;
          //   8: arraylength
          //   9: invokeinterface 61 3 0
          //   14: aload_0
          //   15: getfield 55	org/eclipse/wst/validation/internal/ui/ValidationMenuAction$3:val$dirtyEditors	[Lorg/eclipse/ui/IEditorPart;
          //   18: arraylength
          //   19: istore_2
          //   20: iconst_0
          //   21: istore_3
          //   22: goto +26 -> 48
          //   25: aload_0
          //   26: getfield 55	org/eclipse/wst/validation/internal/ui/ValidationMenuAction$3:val$dirtyEditors	[Lorg/eclipse/ui/IEditorPart;
          //   29: iload_3
          //   30: aaload
          //   31: new 31	org/eclipse/core/runtime/SubProgressMonitor
          //   34: dup
          //   35: aload_1
          //   36: iconst_1
          //   37: invokespecial 59	org/eclipse/core/runtime/SubProgressMonitor:<init>	(Lorg/eclipse/core/runtime/IProgressMonitor;I)V
          //   40: invokeinterface 62 2 0
          //   45: iinc 3 1
          //   48: iload_3
          //   49: iload_2
          //   50: if_icmplt -25 -> 25
          //   53: goto +14 -> 67
          //   56: astore 4
          //   58: aload_1
          //   59: invokeinterface 60 1 0
          //   64: aload 4
          //   66: athrow
          //   67: aload_1
          //   68: invokeinterface 60 1 0
          //   73: return
          // Line number table:
          //   Java source line #360	-> byte code offset #0
          //   Java source line #361	-> byte code offset #14
          //   Java source line #362	-> byte code offset #20
          //   Java source line #363	-> byte code offset #25
          //   Java source line #362	-> byte code offset #45
          //   Java source line #365	-> byte code offset #56
          //   Java source line #366	-> byte code offset #58
          //   Java source line #367	-> byte code offset #64
          //   Java source line #366	-> byte code offset #67
          //   Java source line #368	-> byte code offset #73
          // Local variable table:
          //   start	length	slot	name	signature
          //   0	74	0	this	3
          //   0	74	1	monitor	org.eclipse.core.runtime.IProgressMonitor
          //   19	31	2	numDirtyEditors	int
          //   21	28	3	i	int
          //   56	9	4	localObject	Object
          // Exception table:
          //   from	to	target	type
          //   0	56	56	finally
        }
      };
      try
      {
        ctx.run(false, true, runnable);
        return true;
      }
      catch (InvocationTargetException e)
      {
        ValidationUIPlugin.getPlugin().handleException(e);
      }
      catch (InterruptedException e)
      {
        ValidationUIPlugin.getPlugin().handleException(e);
      }
    }
    return false;
  }
  
  protected List<IFile> getIFiles(Map<IProject, Set<IResource>> projects)
  {
    List<IFile> fileList = new LinkedList();
    Iterator localIterator2;
    for (Iterator localIterator1 = projects.keySet().iterator(); localIterator1.hasNext(); localIterator2.hasNext())
    {
      IProject project = (IProject)localIterator1.next();
      localIterator2 = ((Set)projects.get(project)).iterator(); continue;IResource resource = (IResource)localIterator2.next();
      if ((resource instanceof IFile)) {
        fileList.add((IFile)resource);
      }
    }
    return fileList;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.validation.internal.ui.ValidationMenuAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.validation.internal.ui;

import org.eclipse.osgi.util.NLS;

public class ValidationUIMessages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.wst.validation.internal.ui.validationui";
  public static String SaveFilesDialog_saving;
  public static String SaveFilesDialog_always_save;
  public static String SaveFilesDialog_save_all_resources;
  public static String SaveFilesDialog_must_save;
  public static String PrefPage_always_save;
  public static String RunValidationDialogTitle;
  public static String UnableToSave;
  public static String Validate;
  public static String ValResults;
  public static String ValE
1 2 3 4 5 6 7 8

Further reading...

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

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd