org.tizen.web.localization_2.0.0.201311011708

16:50:43.162 INFO  jd.cli.Main - Decompiling org.tizen.web.localization_2.0.0.201311011708.jar
package org.tizen.web.localization;

import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;

public class AvailableLocalesContentProvider
  implements IContentProvider, IStructuredContentProvider
{
  public Object[] getElements(Object inputElement)
  {
    return ((InternationalizeModelTable)inputElement).getModels();
  }
  
  public void dispose() {}
  
  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.AvailableLocalesContentProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization;

import java.util.ArrayList;
import java.util.List;

public class InternationalizeModelTable
{
  private List<Object> fModels;
  private List<Object> fPreSelected;
  
  public InternationalizeModelTable()
  {
    fModels = new ArrayList();
    fPreSelected = new ArrayList();
  }
  
  public void addToModelTable(Object model, boolean selected)
  {
    if (selected) {
      fPreSelected.add(model);
    } else {
      fModels.add(model);
    }
  }
  
  public void addModel(Object model)
  {
    fModels.add(model);
  }
  
  public void removeModel(Object model)
  {
    fModels.remove(model);
  }
  
  public int getModelCount()
  {
    return fPreSelected.size() + fModels.size();
  }
  
  public Object[] getModels()
  {
    return fModels.toArray();
  }
  
  public Object[] getPreSelected()
  {
    return fPreSelected.toArray();
  }
  
  public boolean hasPreSelected()
  {
    return fPreSelected.size() > 0;
  }
  
  public boolean isEmpty()
  {
    return fModels.size() == 0;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.InternationalizeModelTable
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tizen.web.localization.support.PatternConstructor;

public class LocaleFolderFilesContentProvider
{
  protected final Logger logger = LoggerFactory.getLogger(getClass());
  public static final String WILDCARD = "*";
  public static final String DELIMITER = ":";
  
  public Object[] getElements(Object inputElement)
  {
    IFolder folder = (IFolder)inputElement;
    
    List<IFile> folderFiles = getFolderFileList(folder);
    
    String patterns = "*.css:*.html:*.js:*.png";
    String ignoreFilter = "";
    
    List<IFile> filteredFiles = findFilesMatchingPattern(folderFiles, patterns, ignoreFilter);
    
    folderFiles = findFilesMatchingPattern(filteredFiles, "locales/*", ".*");
    folderFiles = findFilesMatchingPattern(folderFiles, "*.css:*.html:*.js:*.png", ".*");
    
    return folderFiles.toArray();
  }
  
  private List<IFile> getFolderFileList(IFolder folder)
  {
    if (folder == null) {
      return null;
    }
    List<IFile> files = new ArrayList();
    try
    {
      IResource[] resources = folder.members();
      for (int i = 0; i < resources.length; i++) {
        if ((resources[i] instanceof IFile)) {
          files.add((IFile)resources[i]);
        } else if ((resources[i] instanceof IFolder)) {
          files.addAll(getFiles((IFolder)resources[i]));
        }
      }
    }
    catch (CoreException e)
    {
      logger.error("Error occured", e);
    }
    return files;
  }
  
  private List<IFile> getFiles(IFolder folder)
  {
    if (folder == null) {
      return null;
    }
    List<IFile> files = new ArrayList();
    try
    {
      IResource[] resources = folder.members();
      for (int i = 0; i < resources.length; i++) {
        if ((resources[i] instanceof IFile)) {
          files.add((IFile)resources[i]);
        } else if ((resources[i] instanceof IFolder)) {
          files.addAll(getFiles((IFolder)resources[i]));
        }
      }
    }
    catch (CoreException e)
    {
      logger.error("Error occured", e);
    }
    return files;
  }
  
  private List<IFile> findFilesMatchingPattern(List<IFile> files, String patterns, String ignore)
  {
    List<IFile> outputFiles = new ArrayList();
    Iterator<IFile> iterator = files.iterator();
    while (iterator.hasNext())
    {
      IFile file = (IFile)iterator.next();
      String name = file.getProjectRelativePath().toString();
      boolean ignorePatternMatched = false;
      String[] arrayOfString1;
      int j;
      int i;
      if ((ignore != null) && (!ignore.isEmpty()))
      {
        String[] patternIgnore = ignore.split(":");
        j = (arrayOfString1 = patternIgnore).length;
        for (i = 0; i < j; i++)
        {
          String pattern = arrayOfString1[i];
          if (PatternConstructor.createPattern(pattern, true).matcher(name.toLowerCase()).matches())
          {
            ignorePatternMatched = true;
            break;
          }
        }
        if (ignorePatternMatched) {}
      }
      else
      {
        if ((patterns == null) || (patterns.isEmpty())) {
          patterns = "*";
        }
        String[] patternArray = patterns.split(":");
        j = (arrayOfString1 = patternArray).length;
        for (i = 0; i < j; i++)
        {
          String pattern = arrayOfString1[i];
          if (PatternConstructor.createPattern(pattern, true).matcher(name.toLowerCase()).matches())
          {
            outputFiles.add(file);
            break;
          }
        }
      }
    }
    return outputFiles;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.LocaleFolderFilesContentProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LocaleFoldersContentProvider
  extends ArrayContentProvider
{
  protected final Logger logger = LoggerFactory.getLogger(getClass());
  public static final String WILDCARD = "*";
  public static final String DELIMITER = ":";
  
  public Object[] getElements(Object inputElement)
  {
    IProject project = (IProject)inputElement;
    List<IFolder> localeFoldersList = getLocaleFoldersList(project);
    return localeFoldersList.toArray();
  }
  
  private List<IFolder> getLocaleFoldersList(IProject project)
  {
    if (project == null) {
      return null;
    }
    List<IFolder> folders = new ArrayList();
    try
    {
      IResource[] resources = project.members();
      for (int i = 0; i < resources.length; i++) {
        if ((resources[i] instanceof IFolder))
        {
          IFolder folder = (IFolder)resources[i];
          if (folder.getName().equals("locales"))
          {
            System.out.println("ROOT OF LOCALE FOLDERS FOUND !!!");
            folders = getFolders(folder);
          }
        }
      }
    }
    catch (CoreException e)
    {
      logger.error("Error occured", e);
    }
    return folders;
  }
  
  private List<IFolder> getFolders(IFolder folder)
  {
    List<IFolder> folders = new ArrayList();
    try
    {
      IResource[] resources = folder.members();
      for (int i = 0; i < resources.length; i++) {
        if ((resources[i] instanceof IFolder)) {
          folders.add((IFolder)resources[i]);
        }
      }
    }
    catch (CoreException e)
    {
      logger.error("Error occured", e);
    }
    return folders;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.LocaleFoldersContentProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization;

import java.util.Locale;

public class LocaleItem
{
  private Locale locale;
  private boolean preSelected;
  
  public LocaleItem() {}
  
  public LocaleItem(Locale locale, boolean preSelected)
  {
    this.locale = locale;
    this.preSelected = preSelected;
  }
  
  public Locale getLocale()
  {
    return locale;
  }
  
  public void setLocale(Locale locale)
  {
    this.locale = locale;
  }
  
  public boolean isPreSelected()
  {
    return preSelected;
  }
  
  public void setPreSelected(boolean preSelected)
  {
    this.preSelected = preSelected;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.LocaleItem
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization;

import java.util.Locale;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

public class LocaleLabelProvider
  extends LabelProvider
  implements ITableLabelProvider, IColorProvider
{
  public Image getColumnImage(Object element, int columnIndex)
  {
    return getImage(element);
  }
  
  public String getColumnText(Object element, int columnIndex)
  {
    return getText(element);
  }
  
  public String getText(Object obj)
  {
    if ((obj instanceof LocaleItem)) {
      return getObjectText((LocaleItem)obj);
    }
    return super.getText(obj);
  }
  
  public Image getImage(Object obj)
  {
    if ((obj instanceof LocaleItem))
    {
      Image image = null;
      LocaleItem localeItem = (LocaleItem)obj;
      if (localeItem.isPreSelected())
      {
        ImageDescriptor imageDecriptor = LocalizationPlugin.getImageDescriptor("icons/language-selector-ltgrayed.png");
        if (imageDecriptor != null) {
          image = get(imageDecriptor);
        }
      }
      else
      {
        ImageDescriptor imageDecriptor = LocalizationPlugin.getImageDescriptor("icons/language-selector.png");
        if (imageDecriptor != null) {
          image = get(imageDecriptor);
        }
      }
      return image;
    }
    return super.getImage(obj);
  }
  
  private String getObjectText(LocaleItem obj)
  {
    Locale locale = obj.getLocale();
    
    String name = locale.toString();
    if (name.isEmpty()) {
      name = locale.getVariant();
    }
    name = name.replace('_', '-');
    
    String displayLanguage = locale.getDisplayLanguage();
    String addidtionalInfo = "";
    if (locale.equals(Locale.TRADITIONAL_CHINESE)) {
      addidtionalInfo = Messages.LocaleLabel_Traditional;
    } else if (locale.equals(Locale.SIMPLIFIED_CHINESE)) {
      addidtionalInfo = Messages.LocaleLabel_Simplified;
    }
    String displayCountry = addidtionalInfo.isEmpty() ? " (" + locale.getDisplayCountry() + ") " : locale.getDisplayCountry().isEmpty() ? "" : "";
    
    return displayLanguage + displayCountry + addidtionalInfo + " [ " + name + " ] ";
  }
  
  public Image get(ImageDescriptor desc)
  {
    return desc.createImage();
  }
  
  public Color getBackground(Object element)
  {
    return null;
  }
  
  public Color getForeground(Object element)
  {
    LocaleItem localeItem = (LocaleItem)element;
    if (localeItem.isPreSelected())
    {
      Display display = PlatformUI.getWorkbench().getDisplay();
      return display.getSystemColor(15);
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.LocaleLabelProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class LocalizationPlugin
  extends AbstractUIPlugin
{
  public static final String PLUGIN_ID = "org.tizen.web.localization";
  private static LocalizationPlugin plugin;
  BundleContext context;
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    this.context = context;
    plugin = this;
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    this.context = null;
    plugin = null;
    super.stop(context);
  }
  
  public static LocalizationPlugin getDefault()
  {
    return plugin;
  }
  
  public static ImageDescriptor getImageDescriptor(String path)
  {
    return imageDescriptorFromPlugin("org.tizen.web.localization", path);
  }
  
  public BundleContext getContext()
  {
    return context;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.LocalizationPlugin
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization;

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.tizen.web.localization.messages";
  public static String LocaleLabel_Traditional;
  public static String LocaleLabel_Simplified;
  
  static
  {
    NLS.initializeMessages("org.tizen.web.localization.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.Messages
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization;

import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;

public class PreSelectedLocalesContentProvider
  implements IContentProvider, IStructuredContentProvider
{
  public Object[] getElements(Object inputElement)
  {
    return ((InternationalizeModelTable)inputElement).getPreSelected();
  }
  
  public void dispose() {}
  
  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.PreSelectedLocalesContentProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization.handlers;

import org.eclipse.jface.dialogs.IPageChangedListener;
import org.eclipse.jface.dialogs.PageChangedEvent;
import org.tizen.web.localization.ui.LocalizationWizard;

class LocalizeWidgetHandler$1
  implements IPageChangedListener
{
  LocalizeWidgetHandler$1(LocalizeWidgetHandler paramLocalizeWidgetHandler, LocalizationWizard paramLocalizationWizard) {}
  
  public void pageChanged(PageChangedEvent event)
  {
    val$wizard.pageChanged(event);
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.handlers.LocalizeWidgetHandler.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.IPageChangedListener;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.PageChangedEvent;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.tizen.web.common.CommonMessages;
import org.tizen.web.localization.ui.LocalizationWizard;

public class LocalizeWidgetHandler
  extends AbstractHandler
  implements IHandler
{
  public Object execute(ExecutionEvent event)
    throws ExecutionException
  {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    
    IProject project = getActiveProject(window);
    if (project == null)
    {
      MessageDialog.openWarning(window.getShell(), "Localize files", CommonMessages.Project_does_not_exist);
    }
    else
    {
      try
      {
        project.refreshLocal(2, null);
      }
      catch (CoreException e1)
      {
        e1.printStackTrace();
      }
      Shell parentShell = HandlerUtil.getActiveShellChecked(event);
      
      final LocalizationWizard wizard = new LocalizationWizard(project);
      
      WizardDialog dialog = new WizardDialog(parentShell, wizard);
      
      dialog.addPageChangedListener(new IPageChangedListener()
      {
        public void pageChanged(PageChangedEvent event)
        {
          wizard.pageChanged(event);
        }
      });
      dialog.open();
    }
    return null;
  }
  
  private IProject getActiveProject(IWorkbenchWindow window)
  {
    ISelectionService selectionService = window.getSelectionService();
    
    IProject project = null;
    ISelection selection = selectionService.getSelection();
    if ((selection instanceof IStructuredSelection))
    {
      Object element = ((IStructuredSelection)selection).getFirstElement();
      if ((element instanceof IResource)) {
        project = ((IResource)element).getProject();
      }
    }
    else
    {
      IEditorPart editorPart = window.getActivePage().getActiveEditor();
      if (editorPart != null)
      {
        IEditorInput input = editorPart.getEditorInput();
        if ((input instanceof IFileEditorInput))
        {
          IFileEditorInput feinput = (IFileEditorInput)input;
          IFile file = feinput.getFile();
          project = file.getProject();
        }
      }
    }
    return project;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.handlers.LocalizeWidgetHandler
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization.handlers;

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.tizen.web.localization.handlers.messages";
  
  static
  {
    NLS.initializeMessages("org.tizen.web.localization.handlers.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.handlers.Messages
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization.support;

public class AssociationsTableConnector
{
  private int fColumnIndex;
  private Object fElement;
  
  public void setColumn(int column)
  {
    fColumnIndex = column;
  }
  
  public int getColumn()
  {
    return fColumnIndex;
  }
  
  public void setElement(Object element)
  {
    fElement = element;
  }
  
  public Object getElement()
  {
    return fElement;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.support.AssociationsTableConnector
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization.support;

import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;

public class AssociationsTableContentProvider
  implements IStructuredContentProvider
{
  public Object[] getElements(Object inputElement)
  {
    Map<IFile, List<Locale>> elements = (Map)inputElement;
    
    return elements.entrySet().toArray();
  }
  
  public void dispose() {}
  
  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.support.AssociationsTableContentProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization.support;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map.Entry;
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.CheckboxCellEditor;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.tizen.web.localization.LocaleItem;

public class AssociationsTableEditingSupport
  extends EditingSupport
{
  private int fColumnIndex;
  private AssociationsTableConnector fConnector;
  private CellEditor editor;
  private TableViewer fTableViewer;
  
  public AssociationsTableEditingSupport(ColumnViewer viewer, int columnIndex, AssociationsTableConnector connector)
  {
    super(viewer);
    
    fTableViewer = ((TableViewer)viewer);
    
    fConnector = connector;
    fColumnIndex = columnIndex;
    if (columnIndex == 0) {
      editor = new TextCellEditor(fTableViewer.getTable());
    } else {
      editor = new CheckboxCellEditor(fTableViewer.getTable(), 16777256);
    }
    editor.getLayoutData().horizontalAlignment = 16777216;
  }
  
  protected boolean canEdit(Object element)
  {
    fConnector.setColumn(fColumnIndex);
    fConnector.setElement(element);
    if (fColumnIndex != 0) {
      return true;
    }
    return false;
  }
  
  protected CellEditor getCellEditor(Object element)
  {
    return editor;
  }
  
  protected Object getValue(Object element)
  {
    if (fColumnIndex != 0)
    {
      boolean result = false;
      
      Locale locale = (Locale)fTableViewer.getTable().getColumn(fColumnIndex).getData();
      
      Map.Entry<IFile, ArrayList<LocaleItem>> entry = (Map.Entry)element;
      
      List<LocaleItem> selectedLocaleItems = (List)entry.getValue();
      for (LocaleItem selectedLocaleItem : selectedLocaleItems)
      {
        if (selectedLocaleItem.getLocale().equals(locale))
        {
          result = false;
          break;
        }
        result = true;
      }
      return Boolean.valueOf(result);
    }
    return null;
  }
  
  protected void setValue(Object element, Object value)
  {
    if (fColumnIndex != 0)
    {
      Locale locale = (Locale)fTableViewer.getTable().getColumn(fColumnIndex).getData();
      
      Map.Entry<IFile, ArrayList<LocaleItem>> entry = (Map.Entry)element;
      
      LocaleItem foundLocaleItem = null;
      List<LocaleItem> selectedLocaleItems = (List)entry.getValue();
      for (LocaleItem selectedLocaleItem : selectedLocaleItems) {
        if (selectedLocaleItem.getLocale().equals(locale))
        {
          foundLocaleItem = selectedLocaleItem;
          break;
        }
      }
      if (foundLocaleItem != null)
      {
        if (!foundLocaleItem.isPreSelected()) {
          selectedLocaleItems.remove(foundLocaleItem);
        }
      }
      else {
        selectedLocaleItems.add(new LocaleItem(locale, false));
      }
      fTableViewer.refresh();
    }
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.support.AssociationsTableEditingSupport
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization.support;

import java.util.List;
import java.util.Locale;
import java.util.Map.Entry;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;
import org.tizen.web.localization.LocaleItem;
import org.tizen.web.localization.LocalizationPlugin;

public class AssociationsTableLabelProvider
  implements ITableLabelProvider
{
  public static final String CHECKED_IMAGE = "checked";
  public static final String UNCHECKED_IMAGE = "unchecked";
  public static final String CHECKED_GRAYED_IMAGE = "checked-grayed";
  private static ImageRegistry imageRegistry = new ImageRegistry();
  
  static
  {
    String iconPath = "icons/";
    imageRegistry.put("checked", LocalizationPlugin.getImageDescriptor(
      iconPath + "checked" + ".gif"));
    
    imageRegistry.put("unchecked", LocalizationPlugin.getImageDescriptor(
      iconPath + "unchecked" + ".gif"));
    
    imageRegistry.put("checked-grayed", LocalizationPlugin.getImageDescriptor(
      iconPath + "checked-grayed" + ".gif"));
  }
  
  List<Locale> fSelectedLocales = null;
  
  public AssociationsTableLabelProvider(List<Locale> selectedLocales)
  {
    fSelectedLocales = selectedLocales;
  }
  
  public Image getColumnImage(Object element, int columnIndex)
  {
    Map.Entry<IFile, List<LocaleItem>> entry = (Map.Entry)element;
    
    Image image = null;
    if (columnIndex != 0)
    {
      int index = columnIndex - 1;
      Locale locale = (Locale)fSelectedLocales.get(index);
      List<LocaleItem> localeItems = (List)entry.getValue();
      
      boolean isSelected = false;
      boolean isPreSelected = false;
      if (!((List)entry.getValue()).isEmpty()) {
        for (LocaleItem nextitem : localeItems) {
          if (nextitem.getLocale().equals(locale))
          {
            if (nextitem.isPreSelected()) {
              isPreSelected = true;
            }
            isSelected = true;
          }
        }
      }
      String key = "unchecked";
      if (isPreSelected) {
        key = "checked-grayed";
      } else if (isSelected) {
        key = "checked";
      } else {
        key = "unchecked";
      }
      image = imageRegistry.get(key);
    }
    return image;
  }
  
  public String getColumnText(Object element, int columnIndex)
  {
    String result = null;
    Map.Entry<IFile, List<Locale>> entry = (Map.Entry)element;
    if (columnIndex == 0) {
      result = ((IFile)entry.getKey()).getProjectRelativePath().toString();
    }
    return result;
  }
  
  public void addListener(ILabelProviderListener listener) {}
  
  public void dispose() {}
  
  public boolean isLabelProperty(Object element, String property)
  {
    return false;
  }
  
  public void removeListener(ILabelProviderListener listener) {}
  
  public Image get(ImageDescriptor desc)
  {
    return desc.createImage();
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.support.AssociationsTableLabelProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization.support;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.tizen.web.localization.LocaleItem;

public class AssociationsTableModelProvider
{
  private static AssociationsTableModelProvider content;
  private HashMap<IFile, List<LocaleItem>> elements;
  
  public AssociationsTableModelProvider()
  {
    elements = new HashMap();
  }
  
  public static synchronized AssociationsTableModelProvider getInstance()
  {
    if (content != null) {
      return content;
    }
    content = new AssociationsTableModelProvider();
    return content;
  }
  
  public void addElement(IFile key, List<LocaleItem> value)
  {
    elements.put(key, value);
  }
  
  public void addElements(Set<Map.Entry<IFile, List<LocaleItem>>> elements)
  {
    Iterator<Map.Entry<IFile, List<LocaleItem>>> iterator = elements.iterator();
    while (iterator.hasNext())
    {
      Map.Entry<IFile, List<LocaleItem>> entry = (Map.Entry)iterator.next();
      
      getInstance().addElement((IFile)entry.getKey(), (List)entry.getValue());
    }
  }
  
  public void removeElement(IFile key)
  {
    elements.remove(key);
  }
  
  public void removeElements(Set<IFile> keys)
  {
    Iterator<IFile> iterator = keys.iterator();
    while (iterator.hasNext())
    {
      IFile key = (IFile)iterator.next();
      removeElement(key);
    }
  }
  
  public void clear()
  {
    elements.clear();
  }
  
  public List<LocaleItem> getElements(String key)
  {
    return (List)elements.get(key);
  }
  
  public HashMap<IFile, List<LocaleItem>> getElements()
  {
    return elements;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.support.AssociationsTableModelProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization.support;

import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

public class AvailableFilter
  extends ViewerFilter
{
  public static final String WILDCARD = "*";
  private Pattern fPattern;
  private final Map<?, ?> selected;
  private final ILabelProvider labelProvider;
  
  public AvailableFilter(Map<?, ?> selected, ILabelProvider labelProvider)
  {
    setPattern("*");
    this.selected = selected;
    this.labelProvider = labelProvider;
  }
  
  public boolean select(Viewer viewer, Object parentElement, Object element)
  {
    if (selected.containsKey(element)) {
      return false;
    }
    String displayName = labelProvider.getText(element);
    return (matches(element.toString())) || (matches(displayName));
  }
  
  private boolean matches(String s)
  {
    return fPattern.matcher(s.toLowerCase()).matches();
  }
  
  public boolean setPattern(String pattern)
  {
    String newPattern = pattern.toLowerCase();
    if (!newPattern.endsWith("*")) {
      newPattern = newPattern + "*";
    }
    if (!newPattern.startsWith("*")) {
      newPattern = "*" + newPattern;
    }
    if (fPattern != null)
    {
      String oldPattern = fPattern.pattern();
      if (newPattern.equals(oldPattern)) {
        return false;
      }
    }
    fPattern = PatternConstructor.createPattern(newPattern, true);
    return true;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.support.AvailableFilter
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization.support;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.viewers.ArrayContentProvider;

public class FilteredFilesContentProvider
  extends ArrayContentProvider
{
  public static final String WILDCARD = "*";
  public static final String DELIMITER = ":";
  
  public Object[] getElements(Object inputElement)
  {
    List<IFile> projectFiles = (List)inputElement;
    
    String patterns = "*.css:*.html:*.js:*.png";
    String ignoreFilter = ".*";
    
    List<IFile> filteredFiles = findFilesMatchingPattern(projectFiles, patterns, ignoreFilter);
    
    return filteredFiles.toArray();
  }
  
  private List<IFile> findFilesMatchingPattern(List<IFile> files, String patterns, String ignore)
  {
    List<IFile> outputFiles = new ArrayList();
    Iterator<IFile> iterator = files.iterator();
    while (iterator.hasNext())
    {
      IFile file = (IFile)iterator.next();
      String name = file.getName();
      boolean ignorePatternMatched = false;
      String[] arrayOfString1;
      int j;
      int i;
      if ((ignore != null) && (!ignore.isEmpty()))
      {
        String[] patternIgnore = ignore.split(":");
        j = (arrayOfString1 = patternIgnore).length;
        for (i = 0; i < j; i++)
        {
          String pattern = arrayOfString1[i];
          if (PatternConstructor.createPattern(pattern, true).matcher(name.toLowerCase()).matches())
          {
            ignorePatternMatched = true;
            break;
          }
        }
        if (ignorePatternMatched) {}
      }
      else
      {
        if ((patterns == null) || (patterns.isEmpty())) {
          patterns = "*";
        }
        String[] patternArray = patterns.split(":");
        j = (arrayOfString1 = patternArray).length;
        for (i = 0; i < j; i++)
        {
          String pattern = arrayOfString1[i];
          if (PatternConstructor.createPattern(pattern, true).matcher(name.toLowerCase()).matches())
          {
            outputFiles.add(file);
            break;
          }
        }
      }
    }
    return outputFiles;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.support.FilteredFilesContentProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization.support;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;

public class LocalizedFilesContentProvider
  extends FilteredFilesContentProvider
{
  public Object[] getElements(Object inputElement)
  {
    Object[] objects = super.getElements(inputElement);
    
    return findLocalizedFiles(objects);
  }
  
  private Object[] findLocalizedFiles(Object[] objects)
  {
    List<IFile> fileNotFromLocalizeFolders = new ArrayList();
    List<IFile> fileFromLocalizeFolders = new ArrayList();
    
    List<IFile> localizedFiles = new ArrayList();
    Object localObject1;
    int j = (localObject1 = objects).length;
    for (int i = 0; i < j; i++)
    {
      Object obj = localObject1[i];
      if ((obj instanceof IFile))
      {
        IFile file = (IFile)obj;
        if (isChildOfLocaleFolder(file)) {
          fileFromLocalizeFolders.add(file);
        } else {
          fileNotFromLocalizeFolders.add(file);
        }
      }
    }
    Iterator<IFile> iterator = fileNotFromLocalizeFolders.iterator();
    for (; iterator.hasNext(); ((Iterator)localObject1).hasNext())
    {
      IFile file = (IFile)iterator.next();
      localObject1 = fileFromLocalizeFolders.iterator(); continue;IFile lFile = (IFile)((Iterator)localObject1).next();
      if (lFile.getName().equals(file.getName())) {
        if (!localizedFiles.contains(file)) {
          localizedFiles.add(file);
        }
      }
    }
    return localizedFiles.toArray();
  }
  
  private boolean isChildOfLocaleFolder(IFile file)
  {
    IPath path = file.getFullPath();
    if (PatternConstructor.createPattern("*/locales/*", true).matcher(path.toString().toLowerCase()).matches()) {
      return true;
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.support.LocalizedFilesContentProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization.support;

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.tizen.web.localization.support.messages";
  public static String StyledCellLocalesLabelProvider_2;
  public static String StyledCellLocalesLabelProvider_3;
  
  static
  {
    NLS.initializeMessages("org.tizen.web.localization.support.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.support.Messages
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization.support;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

public class NonLocalizedFileLabelProvider
  extends LabelProvider
{
  public Image getImage(Object element)
  {
    ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
    return images.getImage("IMG_OBJ_FILE");
  }
  
  public String getText(Object element)
  {
    IFile file = (IFile)element;
    return file.getProjectRelativePath().toString();
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.support.NonLocalizedFileLabelProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization.support;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;

public class NonLocalizedFilesContentProvider
  extends FilteredFilesContentProvider
{
  public static final String WILDCARD = "*";
  
  public Object[] getElements(Object inputElement)
  {
    Object[] objects = super.getElements(inputElement);
    
    return findNonLocalizedFiles(objects);
  }
  
  private Object[] findNonLocalizedFiles(Object[] objects)
  {
    List<IFile> nonLocalizedFiles = new ArrayList();
    Object[] arrayOfObject1;
    int j = (arrayOfObject1 = objects).length;
    for (int i = 0; i < j; i++)
    {
      Object obj = arrayOfObject1[i];
      if ((obj instanceof IFile)) {
        nonLocalizedFiles.add((IFile)obj);
      }
    }
    Object[] localizedFileNames = findFileNamesFromLocaleFolder(objects);
    Object[] arrayOfObject2;
    int k = (arrayOfObject2 = objects).length;
    for (j = 0; j < k; j++)
    {
      Object obj = arrayOfObject2[j];
      if ((obj instanceof IFile))
      {
        IFile file = (IFile)obj;
        Object[] arrayOfObject3;
        int n = (arrayOfObject3 = localizedFileNames).length;
        for (int m = 0; m < n; m++)
        {
          Object name = arrayOfObject3[m];
          if (file.getName().equals(name)) {
            nonLocalizedFiles.remove(file);
          }
        }
      }
    }
    return nonLocalizedFiles.toArray();
  }
  
  private Object[] findFileNamesFromLocaleFolder(Object[] objects)
  {
    Set<String> set = new HashSet();
    Object[] arrayOfObject;
    int j = (arrayOfObject = objects).length;
    for (int i = 0; i < j; i++)
    {
      Object obj = arrayOfObject[i];
      if ((obj instanceof IFile))
      {
        IFile file = (IFile)obj;
        if (isChildOfLocaleFolder(file)) {
          set.add(file.getName());
        }
      }
    }
    return set.toArray();
  }
  
  private boolean isChildOfLocaleFolder(IFile file)
  {
    IPath path = file.getFullPath();
    if (PatternConstructor.createPattern("*/locales/*", true).matcher(path.toString().toLowerCase()).matches()) {
      return true;
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.localization.support.NonLocalizedFilesContentProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.localization.support;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PatternConstructor
{
  private static final Pattern PATTERN_BACK_SLASH = Pattern.compile("\\\\");
  private static final Pattern PATTERN_QUESTION = Pattern.compile("\\?");
  private static final Pattern PATTERN_STAR = Pattern.compile("\\*");
  private static final Pattern PATTERN_LBRACKET = Pattern.compile("\\(");
  private static final Pattern PATTERN_RBRACKET = Pattern.compile("\\)");
  
  private static String asRegEx(String pattern, boolean group)
  {
    String result1 = PATTERN_BACK_SLASH.matcher(pattern).replaceAll("\\\\E\\\\\\\\\\\\Q");
    String result2 = PATTERN_STAR.matcher(result1).replaceAll("\\\\E.*\\\\Q");
    String result3 = PATTERN_QUESTION.matcher(result2).replaceAll("\\\\E.\\\\Q");
    if (group)
    {
      result3 = PATTERN_LBRACKET.matcher(result3).replaceAll("\\\\E(\\\\Q");
      result3 = PATTERN_RBRACKET.matcher(result3).replaceAll("\\\\E)\\\\Q");
    }
    return "\\Q" + result3 + "\\E";
  }
  
  public static Pattern createPattern(String pattern, boolean isCaseSensitive)
  {
    if (isCaseSensitive) {
      return Pattern.comp
1 2 3 4

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