com.sthaa.ui.jface.viewers

16:34:32.190 INFO  jd.cli.Main - Decompiling com.sthaa.ui.jface.viewers.jar
package com.sthaa.ui.jface.viewers;

import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;

class EditableDialogCellEditor$1
  extends KeyAdapter
{
  EditableDialogCellEditor$1(EditableDialogCellEditor paramEditableDialogCellEditor) {}
  
  public void keyReleased(KeyEvent e)
  {
    if (character == '\033') {
      EditableDialogCellEditor.access$4(this$0);
    }
  }
}

/* Location:
 * Qualified Name:     com.sthaa.ui.jface.viewers.EditableDialogCellEditor.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sthaa.ui.jface.viewers;

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

class EditableDialogCellEditor$10
  implements ModifyListener
{
  EditableDialogCellEditor$10(EditableDialogCellEditor paramEditableDialogCellEditor) {}
  
  public void modifyText(ModifyEvent e)
  {
    this$0.editOccured(e);
  }
}

/* Location:
 * Qualified Name:     com.sthaa.ui.jface.viewers.EditableDialogCellEditor.10
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sthaa.ui.jface.viewers;

import java.text.MessageFormat;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;

class EditableDialogCellEditor$2
  extends SelectionAdapter
{
  EditableDialogCellEditor$2(EditableDialogCellEditor paramEditableDialogCellEditor) {}
  
  public void widgetSelected(SelectionEvent event)
  {
    EditableDialogCellEditor.access$1(this$0).removeFocusListener(EditableDialogCellEditor.access$5(this$0));
    
    Object newValue = this$0.openDialogBox(EditableDialogCellEditor.access$6(this$0));
    
    EditableDialogCellEditor.access$1(this$0).addFocusListener(EditableDialogCellEditor.access$5(this$0));
    if (newValue != null)
    {
      boolean newValidState = EditableDialogCellEditor.access$7(this$0, newValue);
      if (newValidState)
      {
        EditableDialogCellEditor.access$8(this$0);
        this$0.doSetValue(newValue);
      }
      else
      {
        EditableDialogCellEditor.access$9(this$0, MessageFormat.format(this$0.getErrorMessage(), new Object[] { newValue.toString() }));
      }
      EditableDialogCellEditor.access$10(this$0);
    }
  }
}

/* Location:
 * Qualified Name:     com.sthaa.ui.jface.viewers.EditableDialogCellEditor.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sthaa.ui.jface.viewers;

import java.text.MessageFormat;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;

class EditableDialogCellEditor$3
  implements SelectionListener
{
  EditableDialogCellEditor$3(EditableDialogCellEditor paramEditableDialogCellEditor) {}
  
  public void widgetDefaultSelected(SelectionEvent e) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    Object newValue = "";
    if (newValue != null)
    {
      boolean newValidState = EditableDialogCellEditor.access$7(this$0, newValue);
      if (newValidState)
      {
        EditableDialogCellEditor.access$8(this$0);
        this$0.doSetValue(newValue);
      }
      else
      {
        EditableDialogCellEditor.access$9(this$0, MessageFormat.format(this$0.getErrorMessage(), new Object[] { newValue.toString() }));
      }
      EditableDialogCellEditor.access$10(this$0);
    }
  }
}

/* Location:
 * Qualified Name:     com.sthaa.ui.jface.viewers.EditableDialogCellEditor.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sthaa.ui.jface.viewers;

import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;

class EditableDialogCellEditor$4
  implements FocusListener
{
  EditableDialogCellEditor$4(EditableDialogCellEditor paramEditableDialogCellEditor) {}
  
  public void focusGained(FocusEvent e) {}
  
  public void focusLost(FocusEvent e)
  {
    EditableDialogCellEditor.access$10(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sthaa.ui.jface.viewers.EditableDialogCellEditor.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sthaa.ui.jface.viewers;

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

class EditableDialogCellEditor$5
  extends SelectionAdapter
{
  EditableDialogCellEditor$5(EditableDialogCellEditor paramEditableDialogCellEditor) {}
  
  public void widgetDefaultSelected(SelectionEvent e)
  {
    this$0.handleDefaultSelection(e);
  }
}

/* Location:
 * Qualified Name:     com.sthaa.ui.jface.viewers.EditableDialogCellEditor.5
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sthaa.ui.jface.viewers;

import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.widgets.Composite;

class EditableDialogCellEditor$6
  extends KeyAdapter
{
  EditableDialogCellEditor$6(EditableDialogCellEditor paramEditableDialogCellEditor) {}
  
  public void keyPressed(KeyEvent e)
  {
    this$0.keyReleaseOccured(e);
    if ((this$0.getControl() == null) || (this$0.getControl().isDisposed())) {
      return;
    }
    EditableDialogCellEditor.access$11(this$0);
    EditableDialogCellEditor.access$12(this$0);
    EditableDialogCellEditor.access$13(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sthaa.ui.jface.viewers.EditableDialogCellEditor.6
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sthaa.ui.jface.viewers;

import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;

class EditableDialogCellEditor$7
  implements TraverseListener
{
  EditableDialogCellEditor$7(EditableDialogCellEditor paramEditableDialogCellEditor) {}
  
  public void keyTraversed(TraverseEvent e)
  {
    if ((detail == 2) || 
      (detail == 4)) {
      doit = false;
    }
  }
}

/* Location:
 * Qualified Name:     com.sthaa.ui.jface.viewers.EditableDialogCellEditor.7
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sthaa.ui.jface.viewers;

import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;

class EditableDialogCellEditor$8
  extends MouseAdapter
{
  EditableDialogCellEditor$8(EditableDialogCellEditor paramEditableDialogCellEditor) {}
  
  public void mouseUp(MouseEvent e)
  {
    EditableDialogCellEditor.access$11(this$0);
    EditableDialogCellEditor.access$12(this$0);
    EditableDialogCellEditor.access$13(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sthaa.ui.jface.viewers.EditableDialogCellEditor.8
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sthaa.ui.jface.viewers;

import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;

class EditableDialogCellEditor$9
  extends FocusAdapter
{
  EditableDialogCellEditor$9(EditableDialogCellEditor paramEditableDialogCellEditor) {}
  
  public void focusLost(FocusEvent e) {}
}

/* Location:
 * Qualified Name:     com.sthaa.ui.jface.viewers.EditableDialogCellEditor.9
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sthaa.ui.jface.viewers;

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Text;

class EditableDialogCellEditor$EditableDialogCellLayout
  extends Layout
{
  private EditableDialogCellEditor$EditableDialogCellLayout(EditableDialogCellEditor paramEditableDialogCellEditor) {}
  
  public void layout(Composite editor, boolean force)
  {
    Rectangle bounds = editor.getClientArea();
    Point fileButtonSize = EditableDialogCellEditor.access$1(this$0).computeSize(-1, 
      -1, force);
    Point clearButtonSize = EditableDialogCellEditor.access$2(this$0).computeSize(-1, 
      -1, force);
    if (EditableDialogCellEditor.access$3(this$0) != null) {
      EditableDialogCellEditor.access$3(this$0).setBounds(0, 0, width - (x + 
        x + 2), height);
    }
    EditableDialogCellEditor.access$1(this$0).setBounds(access$3this$0).getBounds().width + 1, 0, 
      x, height);
    EditableDialogCellEditor.access$2(this$0).setBounds(access$3this$0).getBounds().width + 1 + 
      access$1this$0).getBounds().width + 1, 0, x, 
      height);
  }
  
  public Point computeSize(Composite editor, int wHint, int hHint, boolean force)
  {
    if ((wHint != -1) && (hHint != -1)) {
      return new Point(wHint, hHint);
    }
    Point textSize = EditableDialogCellEditor.access$3(this$0).computeSize(-1, -1, force);
    Point fileButtonSize = EditableDialogCellEditor.access$1(this$0).computeSize(-1, 
      -1, force);
    Point clearButtonSize = EditableDialogCellEditor.access$2(this$0).computeSize(-1, 
      -1, force);
    
    Point result = new Point(x + x, 
      Math.max(y, y + y));
    return result;
  }
}

/* Location:
 * Qualified Name:     com.sthaa.ui.jface.viewers.EditableDialogCellEditor.EditableDialogCellLayout
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sthaa.ui.jface.viewers;

import java.io.File;
import java.text.MessageFormat;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
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.Layout;
import org.eclipse.swt.widgets.Text;

public class EditableDialogCellEditor
  extends CellEditor
{
  private Text text;
  private Button fileButton;
  private Button clearButton;
  private Composite editor;
  private Object value = null;
  private FocusListener fileButtonFocusListener;
  private ModifyListener textModifyListener;
  private boolean isSelection = false;
  private boolean isDeleteable = false;
  private boolean isSelectable = false;
  
  public EditableDialogCellEditor(Composite parent, int style)
  {
    super(parent, style);
  }
  
  protected Control createControl(Composite parent)
  {
    Font font = parent.getFont();
    Color bg = parent.getBackground();
    
    editor = new Composite(parent, getStyle());
    editor.setFont(font);
    editor.setBackground(bg);
    editor.setLayout(new EditableDialogCellLayout(null));
    
    text = createTextControl(editor);
    updateContents(value);
    
    fileButton = createButton(editor, "...", null);
    fileButton.setToolTipText("Opens a file Selector Dialog");
    fileButton.addKeyListener(new KeyAdapter()
    {
      public void keyReleased(KeyEvent e)
      {
        if (character == '\033') {
          fireCancelEditor();
        }
      }
    });
    fileButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent event)
      {
        fileButton.removeFocusListener(EditableDialogCellEditor.this.getFileButtonFocusListener());
        
        Object newValue = openDialogBox(editor);
        
        fileButton.addFocusListener(EditableDialogCellEditor.this.getFileButtonFocusListener());
        if (newValue != null)
        {
          boolean newValidState = isCorrect(newValue);
          if (newValidState)
          {
            markDirty();
            doSetValue(newValue);
          }
          else
          {
            setErrorMessage(MessageFormat.format(getErrorMessage(), new Object[] { newValue.toString() }));
          }
          fireApplyEditorValue();
        }
      }
    });
    clearButton = 
      createButton(editor, "", ImageDescriptor.createFromFile(EditableDialogCellEditor.class, "clear.GIF").createImage());
    clearButton.setToolTipText("Clears the cell");
    clearButton.addSelectionListener(new SelectionListener()
    {
      public void widgetDefaultSelected(SelectionEvent e) {}
      
      public void widgetSelected(SelectionEvent e)
      {
        Object newValue = "";
        if (newValue != null)
        {
          boolean newValidState = isCorrect(newValue);
          if (newValidState)
          {
            markDirty();
            doSetValue(newValue);
          }
          else
          {
            setErrorMessage(MessageFormat.format(getErrorMessage(), new Object[] { newValue.toString() }));
          }
          fireApplyEditorValue();
        }
      }
    });
    return editor;
  }
  
  protected Text createTextControl(Composite editor)
  {
    text = new Text(editor, 0);
    text.setEditable(false);
    return text;
  }
  
  protected Button createButton(Composite parent, String text, Image image)
  {
    Button result = new Button(parent, 1024);
    result.setText(text);
    if (image != null) {
      result.setImage(image);
    }
    return result;
  }
  
  public void setClearButtonImage(Image image)
  {
    if (image != null) {
      clearButton.setImage(image);
    }
  }
  
  protected Object doGetValue()
  {
    return value;
  }
  
  protected void doSetFocus()
  {
    fileButton.addFocusListener(getFileButtonFocusListener());
  }
  
  protected void doSetValue(Object value)
  {
    this.value = value;
    text.removeModifyListener(getTextModifyListener());
    updateContents(value);
    text.addModifyListener(getTextModifyListener());
  }
  
  public Composite getControl()
  {
    return editor;
  }
  
  public Object openDialogBox(Control cellEditorWindow)
  {
    FileDialog fileDialog = new FileDialog(cellEditorWindow.getShell());
    fileDialog.setFilterExtensions(new String[] { "*" });
    fileDialog.setFilterPath(value.toString());
    fileDialog.setFileName(getFileName(value));
    return fileDialog.open();
  }
  
  private String getFileName(Object value)
  {
    int fileNameIndex = value.toString().lastIndexOf(File.pathSeparator);
    String fileName = value.toString().substring(fileNameIndex + 1);
    return fileName;
  }
  
  private FocusListener getFileButtonFocusListener()
  {
    if (fileButtonFocusListener == null) {
      fileButtonFocusListener = new FocusListener()
      {
        public void focusGained(FocusEvent e) {}
        
        public void focusLost(FocusEvent e)
        {
          fireApplyEditorValue();
        }
      };
    }
    return fileButtonFocusListener;
  }
  
  protected void updateContents(Object value)
  {
    if (text == null) {
      return;
    }
    String valueOfText = "";
    if (value != null) {
      valueOfText = value.toString().trim();
    }
    text.setText(valueOfText);
  }
  
  public void deactivate()
  {
    if ((fileButton != null) && (!fileButton.isDisposed())) {
      fileButton.removeFocusListener(getFileButtonFocusListener());
    }
    super.deactivate();
  }
  
  public void setTextEditable(boolean editable)
  {
    text.setEditable(editable);
    if (editable)
    {
      text.addSelectionListener(new SelectionAdapter()
      {
        public void widgetDefaultSelected(SelectionEvent e)
        {
          handleDefaultSelection(e);
        }
      });
      text.addKeyListener(new KeyAdapter()
      {
        public void keyPressed(KeyEvent e)
        {
          keyReleaseOccured(e);
          if ((getControl() == null) || (getControl().isDisposed())) {
            return;
          }
          EditableDialogCellEditor.this.checkSelection();
          EditableDialogCellEditor.this.checkDeleteable();
          EditableDialogCellEditor.this.checkSelectable();
        }
      });
      text.addTraverseListener(new TraverseListener()
      {
        public void keyTraversed(TraverseEvent e)
        {
          if ((detail == 2) || 
            (detail == 4)) {
            doit = false;
          }
        }
      });
      text.addMouseListener(new MouseAdapter()
      {
        public void mouseUp(MouseEvent e)
        {
          EditableDialogCellEditor.this.checkSelection();
          EditableDialogCellEditor.this.checkDeleteable();
          EditableDialogCellEditor.this.checkSelectable();
        }
      });
      text.addFocusListener(new FocusAdapter()
      {
        public void focusLost(FocusEvent e) {}
      });
      text.addModifyListener(getTextModifyListener());
    }
  }
  
  private void checkDeleteable()
  {
    boolean oldIsDeleteable = isDeleteable;
    isDeleteable = isDeleteEnabled();
    if (oldIsDeleteable != isDeleteable) {
      fireEnablementChanged("delete");
    }
  }
  
  private void checkSelectable()
  {
    boolean oldIsSelectable = isSelectable;
    isSelectable = isSelectAllEnabled();
    if (oldIsSelectable != isSelectable) {
      fireEnablementChanged("selectall");
    }
  }
  
  private void checkSelection()
  {
    boolean oldIsSelection = isSelection;
    isSelection = (text.getSelectionCount() > 0);
    if (oldIsSelection != isSelection)
    {
      fireEnablementChanged("copy");
      fireEnablementChanged("cut");
    }
  }
  
  protected void handleDefaultSelection(SelectionEvent event)
  {
    fireApplyEditorValue();
    deactivate();
  }
  
  private ModifyListener getTextModifyListener()
  {
    if (textModifyListener == null) {
      textModifyListener = new ModifyListener()
      {
        public void modifyText(ModifyEvent e)
        {
          editOccured(e);
        }
      };
    }
    return textModifyListener;
  }
  
  protected void editOccured(ModifyEvent e)
  {
    value = text.getText();
    if (value == null) {
      value = "";
    }
    Object typedValue = value;
    boolean oldValidState = isValueValid();
    boolean newValidState = isCorrect(typedValue);
    if ((typedValue == null) && (newValidState)) {
      Assert.isTrue(false, 
        "Validator isn't limiting the cell editor's type range");
    }
    if (!newValidState) {
      setErrorMessage(
        MessageFormat.format(getErrorMessage(), new Object[] { value }));
    }
    updateContents(value);
    valueChanged(oldValidState, newValidState);
  }
  
  public boolean isCopyEnabled()
  {
    if ((text == null) || (text.isDisposed())) {
      return false;
    }
    return text.getSelectionCount() > 0;
  }
  
  public boolean isCutEnabled()
  {
    if ((text == null) || (text.isDisposed())) {
      return false;
    }
    return text.getSelectionCount() > 0;
  }
  
  public boolean isDeleteEnabled()
  {
    if ((text == null) || (text.isDisposed())) {
      return false;
    }
    return (text.getSelectionCount() > 0) || (text.getCaretPosition() < text.getCharCount());
  }
  
  public boolean isPasteEnabled()
  {
    if ((text == null) || (text.isDisposed())) {
      return false;
    }
    return true;
  }
  
  public boolean isSaveAllEnabled()
  {
    if ((text == null) || (text.isDisposed())) {
      return false;
    }
    return true;
  }
  
  public boolean isSelectAllEnabled()
  {
    if ((text == null) || (text.isDisposed())) {
      return false;
    }
    return text.getCharCount() > 0;
  }
  
  protected void keyReleaseOccured(KeyEvent keyEvent)
  {
    if (character == '\r')
    {
      if ((text != null) && (!text.isDisposed()) && 
        ((text.getStyle() & 0x2) != 0) && 
        ((stateMask & 0x40000) != 0)) {
        super.keyReleaseOccured(keyEvent);
      }
      return;
    }
    super.keyReleaseOccured(keyEvent);
  }
  
  public void performCopy()
  {
    text.copy();
  }
  
  public void performCut()
  {
    text.cut();
    checkSelection();
    checkDeleteable();
    checkSelectable();
  }
  
  public void performDelete()
  {
    if (text.getSelectionCount() > 0)
    {
      text.insert("");
    }
    else
    {
      int pos = text.getCaretPosition();
      if (pos < text.getCharCount())
      {
        text.setSelection(pos, pos + 1);
        text.insert("");
      }
    }
    checkSelection();
    checkDeleteable();
    checkSelectable();
  }
  
  public void performPaste()
  {
    text.paste();
    checkSelection();
    checkDeleteable();
    checkSelectable();
  }
  
  public void performSelectAll()
  {
    text.selectAll();
    checkSelection();
    checkDeleteable();
  }
  
  private class EditableDialogCellLayout
    extends Layout
  {
    private EditableDialogCellLayout() {}
    
    public void layout(Composite editor, boolean force)
    {
      Rectangle bounds = editor.getClientArea();
      Point fileButtonSize = fileButton.computeSize(-1, 
        -1, force);
      Point clearButtonSize = clearButton.computeSize(-1, 
        -1, force);
      if (text != null) {
        text.setBounds(0, 0, width - (x + 
          x + 2), height);
      }
      fileButton.setBounds(text.getBounds().width + 1, 0, 
        x, height);
      clearButton.setBounds(text.getBounds().width + 1 + 
        fileButton.getBounds().width + 1, 0, x, 
        height);
    }
    
    public Point computeSize(Composite editor, int wHint, int hHint, boolean force)
    {
      if ((wHint != -1) && (hHint != -1)) {
        return new Point(wHint, hHint);
      }
      Point textSize = text.computeSize(-1, -1, force);
      Point fileButtonSize = fileButton.computeSize(-1, 
        -1, force);
      Point clearButtonSize = clearButton.computeSize(-1, 
        -1, force);
      
      Point result = new Point(x + x, 
        Math.max(y, y + y));
      return result;
    }
  }
}

/* Location:
 * Qualified Name:     com.sthaa.ui.jface.viewers.EditableDialogCellEditor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
1

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