org.eclipse.jst.jsf.common.ui_1.2.100.v201104061711

  {
    return fSeverity == 0;
  }
  
  public boolean isWarning()
  {
    return fSeverity == 2;
  }
  
  public boolean isInfo()
  {
    return fSeverity == 1;
  }
  
  public boolean isError()
  {
    return fSeverity == 4;
  }
  
  public String getMessage()
  {
    return fStatusMessage;
  }
  
  public void setError(String errorMessage)
  {
    Assert.isNotNull(errorMessage);
    fStatusMessage = errorMessage;
    fSeverity = 4;
  }
  
  public void setWarning(String warningMessage)
  {
    Assert.isNotNull(warningMessage);
    fStatusMessage = warningMessage;
    fSeverity = 2;
  }
  
  public void setInfo(String infoMessage)
  {
    Assert.isNotNull(infoMessage);
    fStatusMessage = infoMessage;
    fSeverity = 1;
  }
  
  public void setOK()
  {
    fStatusMessage = null;
    fSeverity = 0;
  }
  
  public boolean matches(int severityMask)
  {
    return (fSeverity & severityMask) != 0;
  }
  
  public boolean isMultiStatus()
  {
    return false;
  }
  
  public int getSeverity()
  {
    return fSeverity;
  }
  
  public String getPlugin()
  {
    return JSFUICommonPlugin.getPluginId();
  }
  
  public Throwable getException()
  {
    return null;
  }
  
  public int getCode()
  {
    return fSeverity;
  }
  
  public IStatus[] getChildren()
  {
    return new IStatus[0];
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.StatusInfo
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.DialogPage;

public class StatusUtil
{
  public static IStatus getMoreSevere(IStatus s1, IStatus s2)
  {
    if ((s1 == null) && (s2 == null)) {
      return null;
    }
    if (s1 == null) {
      return s2;
    }
    if (s2 == null) {
      return s1;
    }
    if (s1.getSeverity() > s2.getSeverity()) {
      return s1;
    }
    return s2;
  }
  
  public static IStatus getMostSevere(IStatus[] status)
  {
    if (status == null) {
      return null;
    }
    IStatus max = null;
    for (int i = 0; i < status.length; i++)
    {
      IStatus curr = status[i];
      if (curr != null)
      {
        if (curr.matches(4)) {
          return curr;
        }
        if ((max == null) || (curr.getSeverity() > max.getSeverity())) {
          max = curr;
        }
      }
    }
    if (max != null) {
      return max;
    }
    return null;
  }
  
  public static void applyToStatusLine(DialogPage page, IStatus status)
  {
    if (status == null)
    {
      page.setMessage(null);
      page.setErrorMessage(null);
    }
    else
    {
      String message = status.getMessage();
      switch (status.getSeverity())
      {
      case 0: 
        page.setMessage(message, 0);
        page.setErrorMessage(null);
        break;
      case 2: 
        page.setMessage(message, 2);
        page.setErrorMessage(null);
        break;
      case 1: 
        page.setMessage(message, 1);
        page.setErrorMessage(null);
        break;
      default: 
        if (message.length() == 0) {
          message = null;
        }
        page.setMessage(null);
        page.setErrorMessage(message);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.StatusUtil
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

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

class StringButtonDialogField$1
  implements SelectionListener
{
  StringButtonDialogField$1(StringButtonDialogField paramStringButtonDialogField) {}
  
  public void widgetDefaultSelected(SelectionEvent e)
  {
    this$0.changeControlPressed();
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.changeControlPressed();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringButtonDialogField.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import org.eclipse.jst.jsf.common.ui.JSFUICommonPlugin;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;

public class StringButtonDialogField
  extends StringDialogField
{
  private Button _browseButton;
  private String _browseButtonLabel;
  private IStringButtonAdapter _stringButtonAdapter;
  private boolean _buttonEnabled;
  
  public StringButtonDialogField(IStringButtonAdapter adapter)
  {
    _stringButtonAdapter = adapter;
    _browseButtonLabel = 
      JSFUICommonPlugin.getResourceString("DialogField.Browse");
    _buttonEnabled = true;
  }
  
  public void setButtonLabel(String label)
  {
    _browseButtonLabel = label;
  }
  
  public void changeControlPressed()
  {
    _stringButtonAdapter.changeControlPressed(this);
  }
  
  public Control[] doFillIntoGrid(FormToolkit toolkit, Composite parent, int nColumns)
  {
    assertEnoughColumns(nColumns);
    
    Control requiredLabel = getRequiredLabelControl(toolkit, parent);
    requiredLabel.setLayoutData(gridDataForLabel(1));
    
    Control label = getLabelControl(toolkit, parent);
    label.setLayoutData(gridDataForLabel(1));
    
    Text text = getTextControl(toolkit, parent);
    text.setLayoutData(gridDataForText(nColumns - 3));
    Button button = getChangeControl(toolkit, parent);
    button.setLayoutData(gridDataForButton(toolkit, button, text, 1));
    
    return new Control[] { requiredLabel, label, text, button };
  }
  
  public int getNumberOfControls()
  {
    return 4;
  }
  
  protected static GridData gridDataForButton(FormToolkit toolkit, Button button, Text text, int span)
  {
    GridData gd = new GridData();
    horizontalAlignment = 4;
    grabExcessHorizontalSpace = false;
    horizontalSpan = span;
    
    widthHint = LayoutUtil.getButtonWidthHint(button);
    heightHint = LayoutUtil.getButtonHeightHint(toolkit, text);
    return gd;
  }
  
  public Button getChangeControl(FormToolkit toolkit, Composite parent)
  {
    if ((_browseButton == null) || (_browseButton.isDisposed()))
    {
      assertCompositeNotNull(parent);
      if (toolkit != null)
      {
        _browseButton = toolkit.createButton(parent, 
          _browseButtonLabel, 8);
      }
      else
      {
        _browseButton = new Button(parent, 8);
        _browseButton.setText(_browseButtonLabel);
      }
      _browseButton.setEnabled((isEnabled()) && (_buttonEnabled));
      _browseButton.addSelectionListener(new SelectionListener()
      {
        public void widgetDefaultSelected(SelectionEvent e)
        {
          changeControlPressed();
        }
        
        public void widgetSelected(SelectionEvent e)
        {
          changeControlPressed();
        }
      });
    }
    return _browseButton;
  }
  
  public void enableButton(boolean enable)
  {
    if (isOkToUse(_browseButton)) {
      _browseButton.setEnabled((isEnabled()) && (enable));
    }
    _buttonEnabled = enable;
  }
  
  protected void updateEnableState()
  {
    super.updateEnableState();
    if (isOkToUse(_browseButton)) {
      _browseButton.setEnabled((isEnabled()) && (_buttonEnabled));
    }
  }
  
  public IStringButtonAdapter getStringButtonAdapter()
  {
    return _stringButtonAdapter;
  }
  
  public void setStringButtonAdapter(IStringButtonAdapter buttonAdapter)
  {
    _stringButtonAdapter = buttonAdapter;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringButtonDialogField
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

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

class StringDialogField$1
  implements ModifyListener
{
  StringDialogField$1(StringDialogField paramStringDialogField) {}
  
  public void modifyText(ModifyEvent e)
  {
    StringDialogField.access$0(this$0, e);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

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

class StringDialogField$2
  extends FocusAdapter
{
  StringDialogField$2(StringDialogField paramStringDialogField) {}
  
  public void focusLost(FocusEvent e)
  {
    this$0.doFocusLost(e);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

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

class StringDialogField$3
  extends KeyAdapter
{
  StringDialogField$3(StringDialogField paramStringDialogField) {}
  
  public void keyReleased(KeyEvent e)
  {
    this$0.doKeyReleased(e);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
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.graphics.FontMetrics;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;

public class StringDialogField
  extends DialogFieldBase
  implements ISupportTextValue
{
  private static final int TEXT_WIDTH_HINT = 10;
  private String _text;
  private Text _textControl;
  private ModifyListener _modifyListener;
  private int _numRows;
  private boolean _pending = false;
  
  public StringDialogField()
  {
    this(1);
    _text = "";
  }
  
  public StringDialogField(int numRows)
  {
    _text = "";
    _numRows = numRows;
  }
  
  public Control[] doFillIntoGrid(FormToolkit kit, Composite parent, int nColumns)
  {
    assertEnoughColumns(nColumns);
    
    Control requiredLabel = getRequiredLabelControl(kit, parent);
    requiredLabel.setLayoutData(gridDataForLabel(1));
    
    Control label = getLabelControl(kit, parent);
    label.setLayoutData(gridDataForLabel(1));
    
    Text text = getTextControl(kit, parent);
    int heightHint = -1;
    if (_numRows > 1) {
      heightHint = getDialogUnits(parent).getHeight() * _numRows;
    }
    text.setLayoutData(gridDataForText(nColumns - 2, heightHint));
    
    return new Control[] { requiredLabel, label, text };
  }
  
  public int getNumberOfControls()
  {
    return 3;
  }
  
  protected static GridData gridDataForLabel(int span)
  {
    GridData gd = new GridData(256);
    horizontalSpan = span;
    return gd;
  }
  
  protected static GridData gridDataForText(int span, int heightHint)
  {
    GridData gd = new GridData();
    horizontalAlignment = 4;
    grabExcessHorizontalSpace = false;
    heightHint = heightHint;
    horizontalSpan = span;
    widthHint = 10;
    return gd;
  }
  
  protected static GridData gridDataForText(int span)
  {
    GridData gd = gridDataForText(span, -1);
    return gd;
  }
  
  public boolean setFocus()
  {
    if (isOkToUse(_textControl))
    {
      _textControl.setFocus();
      _textControl.setSelection(0, _textControl.getText().length());
    }
    return true;
  }
  
  public Text getTextControl(FormToolkit toolkit, Composite parent)
  {
    if ((_textControl == null) || (_textControl.isDisposed()))
    {
      assertCompositeNotNull(parent);
      _modifyListener = new ModifyListener()
      {
        public void modifyText(ModifyEvent e)
        {
          StringDialogField.this.doModifyText(e);
        }
      };
      if (toolkit != null)
      {
        if (_numRows <= 1) {
          _textControl = toolkit.createText(parent, "");
        } else {
          _textControl = toolkit.createText(parent, "", 512);
        }
      }
      else if (_numRows <= 1) {
        _textControl = new Text(parent, 2052);
      } else {
        _textControl = new Text(parent, 2624);
      }
      _textControl.setText(_text);
      _textControl.setFont(parent.getFont());
      _textControl.addModifyListener(_modifyListener);
      _textControl.addFocusListener(new FocusAdapter()
      {
        public void focusLost(FocusEvent e)
        {
          doFocusLost(e);
        }
      });
      _textControl.addKeyListener(new KeyAdapter()
      {
        public void keyReleased(KeyEvent e)
        {
          doKeyReleased(e);
        }
      });
      _textControl.setEnabled(isEnabled());
      
      _textControl.setToolTipText(getToolTip());
    }
    return _textControl;
  }
  
  protected void doKeyReleased(KeyEvent e)
  {
    if (character == '\r') {
      if (_pending)
      {
        _pending = false;
        dialogFieldApplied();
      }
    }
  }
  
  protected void doFocusLost(FocusEvent e)
  {
    if (_pending)
    {
      _pending = false;
      dialogFieldApplied();
    }
  }
  
  private void doModifyText(ModifyEvent e)
  {
    if (isOkToUse(_textControl)) {
      _text = _textControl.getText();
    }
    _pending = true;
    dialogFieldChanged();
  }
  
  protected void updateEnableState()
  {
    super.updateEnableState();
    if (isOkToUse(_textControl)) {
      _textControl.setEnabled(isEnabled());
    }
  }
  
  public String getText()
  {
    return _text;
  }
  
  public void setText(String text)
  {
    setTextWithoutUpdate(text);
    dialogFieldChangedAndApplied();
  }
  
  public void setTextWithoutUpdate(String text)
  {
    _pending = false;
    if (text == null) {
      text = "";
    }
    _text = text;
    if (isOkToUse(_textControl))
    {
      _textControl.removeModifyListener(_modifyListener);
      _textControl.setText(text);
      _textControl.addModifyListener(_modifyListener);
    }
  }
  
  public void handleGrabHorizontal()
  {
    LayoutUtil.setGrabHorizontal(_textControl, true);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

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

class StyleComboDialogField$1
  implements ModifyListener
{
  StyleComboDialogField$1(StyleComboDialogField paramStyleComboDialogField) {}
  
  public void modifyText(ModifyEvent e)
  {
    StyleComboDialogField.access$0(this$0, e);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.StyleComboDialogField.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

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

class StyleComboDialogField$2
  implements SelectionListener
{
  StyleComboDialogField$2(StyleComboDialogField paramStyleComboDialogField) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    StyleComboDialogField.access$1(this$0, e);
  }
  
  public void widgetDefaultSelected(SelectionEvent e)
  {
    this$0.handleDefaultSelection(e);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.StyleComboDialogField.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import org.eclipse.jst.jsf.common.ui.internal.utils.StyleCombo;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.forms.FormColors;

class StyleComboDialogField$3
  implements PaintListener
{
  StyleComboDialogField$3(StyleComboDialogField paramStyleComboDialogField, FormColors paramFormColors) {}
  
  public void paintControl(PaintEvent event)
  {
    Composite composite = (Composite)widget;
    Control[] children = composite.getChildren();
    for (int i = 0; i < children.length; i++)
    {
      Control c = children[i];
      if (((c instanceof StyleCombo)) && (c.isVisible()))
      {
        Rectangle b = c.getBounds();
        GC gc = gc;
        gc.setForeground(val$colors.getBorderColor());
        gc.drawRectangle(x - 1, y - 1, width + 1, 
          height + 1);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.StyleComboDialogField.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.ui.forms.FormColors;

class StyleComboDialogField$4
  implements DisposeListener
{
  StyleComboDialogField$4(StyleComboDialogField paramStyleComboDialogField, FormColors paramFormColors) {}
  
  public void widgetDisposed(DisposeEvent e)
  {
    val$colors.dispose();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.StyleComboDialogField.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

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

class StyleComboDialogField$5
  extends FocusAdapter
{
  StyleComboDialogField$5(StyleComboDialogField paramStyleComboDialogField) {}
  
  public void focusLost(FocusEvent e)
  {
    this$0.doFocusLost(e);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.StyleComboDialogField.5
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import org.eclipse.jst.jsf.common.ui.internal.utils.StyleCombo;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.forms.FormColors;
import org.eclipse.ui.forms.widgets.FormToolkit;

public class StyleComboDialogField
  extends DialogFieldBase
  implements ISupportTextValue
{
  private static final int WIDTH_HINT = 10;
  private String _text;
  private int _selectionIndex;
  private String[] _items;
  private StyleCombo _comboControl;
  private ModifyListener _modifyListener;
  private int _flags;
  private boolean _pending = false;
  private Map _entryMap;
  private String _defaultValue;
  
  public void setDefaultValue(String defaultValue)
  {
    _defaultValue = defaultValue;
    if ((_comboControl != null) && (!_comboControl.isDisposed())) {
      _comboControl.setDefaultValue(_defaultValue);
    }
  }
  
  public StyleComboDialogField(int flags)
  {
    _text = "";
    _items = new String[0];
    _flags = flags;
    _selectionIndex = -1;
  }
  
  public Control[] doFillIntoGrid(FormToolkit toolkit, Composite parent, int nColumns)
  {
    assertEnoughColumns(nColumns);
    
    Control requiredLabel = getRequiredLabelControl(toolkit, parent);
    requiredLabel.setLayoutData(gridDataForLabel(1));
    
    Control label = getLabelControl(toolkit, parent);
    label.setLayoutData(gridDataForLabel(1));
    
    StyleCombo combo = getComboControl(toolkit, parent);
    combo.setLayoutData(gridDataForCombo(nColumns - 2));
    
    return new Control[] { requiredLabel, label, combo };
  }
  
  public int getNumberOfControls()
  {
    return 3;
  }
  
  protected static GridData gridDataForCombo(int span)
  {
    GridData gd = new GridData();
    horizontalAlignment = 4;
    grabExcessHorizontalSpace = false;
    horizontalSpan = span;
    widthHint = 10;
    return gd;
  }
  
  public boolean setFocus()
  {
    if (isOkToUse(_comboControl)) {
      _comboControl.setFocus();
    }
    return true;
  }
  
  public StyleCombo getComboControl(FormToolkit toolkit, Composite parent)
  {
    if ((_comboControl == null) || (_comboControl.isDisposed()))
    {
      assertCompositeNotNull(parent);
      _modifyListener = new ModifyListener()
      {
        public void modifyText(ModifyEvent e)
        {
          StyleComboDialogField.this.doModifyText(e);
        }
      };
      SelectionListener selectionListener = new SelectionListener()
      {
        public void widgetSelected(SelectionEvent e)
        {
          StyleComboDialogField.this.doSelectionChanged(e);
        }
        
        public void widgetDefaultSelected(SelectionEvent e)
        {
          handleDefaultSelection(e);
        }
      };
      if (toolkit != null)
      {
        _comboControl = new StyleCombo(parent, _flags);
        final FormColors colors = new FormColors(parent.getDisplay());
        parent.addPaintListener(new PaintListener()
        {
          public void paintControl(PaintEvent event)
          {
            Composite composite = (Composite)widget;
            Control[] children = composite.getChildren();
            for (int i = 0; i < children.length; i++)
            {
              Control c = children[i];
              if (((c instanceof StyleCombo)) && (c.isVisible()))
              {
                Rectangle b = c.getBounds();
                GC gc = gc;
                gc.setForeground(colors.getBorderColor());
                gc.drawRectangle(x - 1, y - 1, width + 1, 
                  height + 1);
              }
            }
          }
        });
        parent.addDisposeListener(new DisposeListener()
        {
          public void widgetDisposed(DisposeEvent e)
          {
            colors.dispose();
          }
        });
        toolkit.adapt(_comboControl);
      }
      else
      {
        _comboControl = new StyleCombo(parent, _flags | 0x800);
        _comboControl.setBackground(Display.getCurrent()
          .getSystemColor(25));
      }
      _comboControl.setItems(_items);
      _comboControl.setDefaultValue(_defaultValue);
      if (_selectionIndex != -1) {
        _comboControl.select(_selectionIndex);
      } else {
        _comboControl.setText(_text);
      }
      _comboControl.setFont(parent.getFont());
      _comboControl.addModifyListener(_modifyListener);
      _comboControl.addSelectionListener(selectionListener);
      _comboControl.addFocusListener(new FocusAdapter()
      {
        public void focusLost(FocusEvent e)
        {
          doFocusLost(e);
        }
      });
      _comboControl.setEnabled(isEnabled());
      _comboControl.setToolTipText(getToolTip());
    }
    return _comboControl;
  }
  
  protected void handleDefaultSelection(SelectionEvent e)
  {
    if (_pending)
    {
      _pending = false;
      dialogFieldApplied();
    }
  }
  
  protected void doFocusLost(FocusEvent e)
  {
    if (_pending)
    {
      _pending = false;
      dialogFieldApplied();
    }
  }
  
  private void doModifyText(ModifyEvent e)
  {
    if (isOkToUse(_comboControl))
    {
      _text = getEntryKey(_comboControl.getText());
      _selectionIndex = _comboControl.getSelectionIndex();
    }
    _pending = true;
    dialogFieldChanged();
  }
  
  private void doSelectionChanged(SelectionEvent e)
  {
    if (isOkToUse(_comboControl))
    {
      _items = _comboControl.getItems();
      _text = getEntryKey(_comboControl.getText());
      _selectionIndex = _comboControl.getSelectionIndex();
    }
    _pending = false;
    dialogFieldChangedAndApplied();
  }
  
  protected void updateEnableState()
  {
    super.updateEnableState();
    if (isOkToUse(_comboControl)) {
      _comboControl.setEnabled(isEnabled());
    }
  }
  
  public void setItems(String[] items)
  {
    _items = items;
    if (isOkToUse(_comboControl)) {
      _comboControl.setItems(items);
    }
    _pending = false;
  }
  
  public void setEntryMap(Map map)
  {
    _entryMap = map;
    if (_entryMap == null) {
      _entryMap = new TreeMap();
    }
    Map.Entry[] entries = (Map.Entry[])_entryMap.entrySet().toArray(new Map.Entry[0]);
    String[] items = new String[entries.length];
    for (int i = 0; i < entries.length; i++) {
      items[i] = entries[i].getValue().toString();
    }
    setItems(items);
  }
  
  public String getText()
  {
    return _text;
  }
  
  public void setText(String text)
  {
    setTextWithoutUpdate(text);
    _pending = false;
    dialogFieldChangedAndApplied();
  }
  
  public void selectItem(int index)
  {
    if (isOkToUse(_comboControl))
    {
      _comboControl.select(index);
    }
    else if ((index >= 0) && (index < _items.length))
    {
      _text = getEntryKey(_items[index]);
      _selectionIndex = index;
    }
    dialogFieldChangedAndApplied();
  }
  
  public int getSelectionIndex()
  {
    return _selectionIndex;
  }
  
  public void setTextWithoutUpdate(String text)
  {
    _pending = false;
    if (text == null) {
      text = "";
    }
    _text = text;
    if (isOkToUse(_comboControl))
    {
      _comboControl.removeModifyListener(_modifyListener);
      _comboControl.setText(getEntryValue(text));
      _comboControl.addModifyListener(_modifyListener);
    }
  }
  
  private String getEntryValue(String key)
  {
    if ((_entryMap == null) || (!_entryMap.containsKey(key))) {
      return key;
    }
    return _entryMap.get(key).toString();
  }
  
  private String getEntryKey(String value)
  {
    if ((_entryMap == null) || (!_entryMap.containsValue(value))) {
      return value;
    }
    Map.Entry[] entries = (Map.Entry[])_entryMap.entrySet().toArray(new Map.Entry[0]);
    for (int i = 0; i < entries.length; i++) {
      if ((entries[i].getValue() == value) || (
        (value != null) && (value.equals(entries[i].getValue())))) {
        return entries[i].getKey().toString();
      }
    }
    return value;
  }
  
  public void handleGrabHorizontal()
  {
    LayoutUtil.setGrabHorizontal(_comboControl, true);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.StyleComboDialogField
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import java.util.Collection;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.ui.dialogs.ISelectionStatusValidator;

class TypedElementSelectionValidator
  implements ISelectionStatusValidator
{
  private IStatus _fgErrorStatus = new StatusInfo(4, "");
  private IStatus _fgOKStatus = new StatusInfo();
  private Class[] _fAcceptedTypes;
  private boolean _fAllowMultipleSelection;
  private Collection _fRejectedElements;
  
  public TypedElementSelectionValidator(Class[] acceptedTypes, boolean allowMultipleSelection)
  {
    this(acceptedTypes, allowMultipleSelection, null);
  }
  
  public TypedElementSelectionValidator(Class[] acceptedTypes, boolean allowMultipleSelection, Collection rejectedElements)
  {
    Assert.isNotNull(acceptedTypes);
    _fAcceptedTypes = acceptedTypes;
    _fAllowMultipleSelection = allowMultipleSelection;
    _fRejectedElements = rejectedElements;
  }
  
  public IStatus validate(Object[] elements)
  {
    if (isValid(elements)) {
      return _fgOKStatus;
    }
    return _fgErrorStatus;
  }
  
  private boolean isOfAcceptedType(Object o)
  {
    for (int i = 0; i < _fAcceptedTypes.length; i++) {
      if (_fAcceptedTypes[i].isInstance(o)) {
        return true;
      }
    }
    return false;
  }
  
  private boolean isRejectedElement(Object elem)
  {
    return (_fRejectedElements != null) && (_fRejectedElements.contains(elem));
  }
  
  private boolean isValid(Object[] selection)
  {
    if (selection.length == 0) {
      return false;
    }
    if ((!_fAllowMultipleSelection) && (selection.length != 1)) {
      return false;
    }
    for (int i = 0; i < selection.length; i++)
    {
      Object o = selection[i];
      if ((!isOfAcceptedType(o)) || (isRejectedElement(o))) {
        return false;
      }
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.TypedElementSelectionValidator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

class TypedViewerFilter
  extends ViewerFilter
{
  private Class[] _fAcceptedTypes;
  private Object[] _fRejectedElements;
  
  public TypedViewerFilter(Class[] acceptedTypes)
  {
    this(acceptedTypes, null);
  }
  
  public TypedViewerFilter(Class[] acceptedTypes, Object[] rejectedElements)
  {
    Assert.isNotNull(acceptedTypes);
    _fAcceptedTypes = acceptedTypes;
    _fRejectedElements = rejectedElements;
  }
  
  public boolean select(Viewer viewer, Object parentElement, Object element)
  {
    if (_fRejectedElements != null) {
      for (int i = 0; i < _fRejectedElements.length; i++) {
        if (element.equals(_fRejectedElements[i])) {
          return false;
        }
      }
    }
    for (int i = 0; i < _fAcceptedTypes.length; i++) {
      if (_fAcceptedTypes[i].isInstance(element)) {
        return true;
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogfield.TypedViewerFilter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogs;

import java.util.Arrays;
import java.util.List;
import org.eclipse.core.resources.IContainer;
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.runtime.CoreException;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
import org.eclipse.jst.jsf.common.ui.internal.utils.WebrootUtil;

class CommonResourceDialog$CommonResourceFilter
  extends ViewerFilter
{
  private String[] _filterSuffixs = null;
  
  CommonResourceDialog$CommonResourceFilter(CommonResourceDialog paramCommonResourceDialog) {}
  
  public String[] getSuffixs()
  {
    return _filterSuffixs;
  }
  
  public void setSuffixs(String[] _suffixs)
  {
    _filterSuffixs = _suffixs;
  }
  
  public boolean select(Viewer viewer, Object parentElement, Object element)
  {
    if ((element instanceof IFile))
    {
      IFile file = (IFile)element;
      if (!WebrootUtil.isUnderWebContentFolder(file)) {
        return false;
      }
      if (CommonResourceDialog.access$1(this$0)) {
        return true;
      }
      if ((file.getFileExtension() != null) && 
        (Arrays.asList(_filterSuffixs).contains(
        file.getFileExtension().toLowerCase()))) {
        return true;
      }
    }
    else if ((element instanceof IContainer))
    {
      if (!((IContainer)element).isAccessible()) {
        return false;
      }
      if ((element instanceof IProject)) {
        return true;
      }
      if ((element instanceof IFolder))
      {
        IContainer container = (IContainer)element;
        try
        {
          IResource[] members = container.members();
          for (int i = 0; i < members.length; i++) {
            if (select(viewer, members[i].getParent(), 
              members[i])) {
              return true;
            }
          }
        }
        catch (CoreException e)
        {
          CommonResourceDialog.access$0().error(
            "Error.ProjectFileDialogContentProvider.0", e);
          return false;
        }
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogs.CommonResourceDialog.CommonResourceFilter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogs;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;

class CommonResourceDialog$ProjectFileDialogContentProvider
  implements ITreeContentProvider
{
  CommonResourceDialog$ProjectFileDialogContentProvider(CommonResourceDialog paramCommonResourceDialog) {}
  
  public void dispose() {}
  
  public Object[] getChildren(Object element)
  {
    if ((element instanceof Object[])) {
      return (Object[])element;
    }
    if ((element instanceof IContainer))
    {
      IContainer container = (IContainer)element;
      if (container.isAccessible()) {
        try
        {
          return container.members();
        }
        catch (CoreException e)
        {
          CommonResourceDialog.access$0().error(
            "Error.ProjectFileDialogContentProvider.0", e);
        }
      }
    }
    return new Object[0];
  }
  
  public Object[] getElements(Object element)
  {
    return getChildren(element);
  }
  
  public Object getParent(Object element)
  {
    if ((element instanceof IResource)) {
      return ((IResource)element).getParent();
    }
    return null;
  }
  
  public boolean hasChildren(Object element)
  {
    return getChildren(element).length > 0;
  }
  
  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.common.ui.internal.dialogs.CommonResourceDialog.ProjectFileDialogContentProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.common.ui.internal.dialogs;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.core.resources.IContainer;
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.runtime.CoreException;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jst.jsf.common.ui.JSFUICommonPlugin;
import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
import org.eclipse.jst.jsf.common.ui.internal.utils.WebrootUtil;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.views.navigator.ResourceComparator;

public class CommonResourceDialog
  extends TreeViewerSelectionDialog
{
  private static Logger _log = JSFUICommonPlugin.getLogger(CommonResourceDialog.class);
  private IProject _project = null;
  private String[] _suffixs = null;
  private CommonResourceFilter _filter = null;
  private String _resourceDescription = null;
  private IFolder _folder;
  
  class ProjectFileDialogContentProvider
    implements ITreeContentProvider
  {
    ProjectFileDialogContentProvider() {}
    
    public void dispose() {}
    
    public Object[] getChildren(Object element)
    {
      if ((element instanceof Object[])) {
        return (Object[])element;
      }
      if ((element instanceof IContainer))
      {
        IContainer container = (IContainer)element;
        if (container.isAccessible()) {
          try
          {
            return container.members();
          }
          catch (CoreException e)
          {
            CommonResourceDialog._log.error(
              "Error.ProjectFileDialogContentProvider.0", e);
          }
        }
      }
      return new Object[0];
    }
    
    public Object[] getElements(Object element)
    {
      return getChildren(element);
    }
    
    public Object getParent(Object element)
    {
      if ((element instanceof IResource)) {
        return ((IResource)element).getParent();
      }
      return null;
    }
    
    public boolean hasChildren(Object element)
    {
      return getChildren(element).length > 0;
    }
    
    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
  }
  
  class CommonResourceFilter
    extends ViewerFilter
  {
    private String[] _filterSuffixs = null;
    
    CommonResourceFilter() {}
    
    public String[] getSuffixs()
    {
      return _filterSuffixs;
    }
    
    public void setSuffixs(String[] _suffixs)
    {
      _filterSuffixs = _suffixs;
    }
    
    public boolean select(Viewer viewer, Object parentElement, Object element)
    {
      if ((element instanceof IFile))
      {
        IFile file = (IFile)element;
        if (!WebrootUtil.isUnderWebContentFolder(file)) {
          return false;
        }
        if (CommonResourceDialog.this.isSuffixBlank()) {
          return true;
        }
        if ((file.getFileExtension() != null) && 
          (Arrays.asList(_filterSuffixs).contains(
          file.getFileExtension().toLowerCase()))) {
          return true;
        }
      }
      else if ((element instanceof IContainer))
      {
        if (!((IContainer)element).isAccessible()) {
          return false;
        }
        if ((element instanceof IProject)) {
          return true;
        }
        if ((element instanceof IFolder))
        {
          IContainer container = (IContainer)element;
          try
          {
            IResource[] members = container.members();
            for (int i = 0; i < members.length; i++) {
              if (select(viewer, members[i].getParent(), 
                members[i])) {
                return true;
              }
            }
          }
          catch (CoreException e)
          {
            CommonResourceDialog._log.error(
              "Error.ProjectFileDialogContentProvider.0", e);
            return false;
          }
        }
      }
      return false;
    }
  }
  
  public CommonResourceDialog(Shell parentShell, IProject project, int style)
  {
    super(parentShell, "", style);
    if (project == null) {
      throw new IllegalArgumentException(
        "Argument(project) cannot be null");
    }
    _project = project;
    setContentProvider(new ProjectFileDialogContentProvider());
    setLabelProvider(
      WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
    _filter = new CommonResourceFilter();
    setFilter(_filter);
    setViewerComparator(new ResourceComparator(2));
    _project = project;
    setStatusMessage(getStatusMessage());
  }
  
  public CommonResourceDialog(Shell parentShell, IProject project)
  {
    this(parentShell, project, 0);
  }
  
  private String getStatusMessage()
  {
    if (_resourceDescription == null) {
      return "";
    }
    return _resourceDescription;
  }
  
  protected Object findInputElement()
  {
    if (_folder != null) {
      
1 2 3 4 5 6 7 8 9 10 11

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