Package com.google.gdt.eclipse.designer.gef.policy.grid.header.selection

Source Code of com.google.gdt.eclipse.designer.gef.policy.grid.header.selection.ColumnSelectionEditPolicy

/*******************************************************************************
* Copyright 2011 Google Inc. All Rights Reserved.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.google.gdt.eclipse.designer.gef.policy.grid.header.selection;

import com.google.gdt.eclipse.designer.gef.policy.grid.header.edit.ColumnHeaderEditPart;
import com.google.gdt.eclipse.designer.model.widgets.panels.grid.ColumnInfo;
import com.google.gdt.eclipse.designer.model.widgets.panels.grid.HTMLTableInfo;

import org.eclipse.wb.gef.core.requests.KeyRequest;
import org.eclipse.wb.gef.core.requests.Request;
import org.eclipse.wb.gef.graphical.policies.LayoutEditPolicy;
import org.eclipse.wb.gef.graphical.policies.SelectionEditPolicy;
import org.eclipse.wb.internal.core.utils.execution.ExecutionUtils;
import org.eclipse.wb.internal.core.utils.execution.RunnableEx;

/**
* Implementation of {@link SelectionEditPolicy} for {@link ColumnHeaderEditPart}.
*
* @author scheglov_ke
* @coverage gwt.gef.policy
*/
public final class ColumnSelectionEditPolicy extends DimensionSelectionEditPolicy<ColumnInfo> {
  ////////////////////////////////////////////////////////////////////////////
  //
  // Constructor
  //
  ////////////////////////////////////////////////////////////////////////////
  public ColumnSelectionEditPolicy(LayoutEditPolicy mainPolicy) {
    super(mainPolicy);
  }

  ////////////////////////////////////////////////////////////////////////////
  //
  // Keyboard
  //
  ////////////////////////////////////////////////////////////////////////////
  @Override
  public void performRequest(Request request) {
    super.performRequest(request);
    if (request instanceof KeyRequest) {
      KeyRequest keyRequest = (KeyRequest) request;
      if (keyRequest.isPressed()) {
        char c = keyRequest.getCharacter();
        if (c == 'd' || c == 'u') {
          setAlignment(ColumnInfo.Alignment.UNKNOWN);
        } else if (c == 'l') {
          setAlignment(ColumnInfo.Alignment.LEFT);
        } else if (c == 'c') {
          setAlignment(ColumnInfo.Alignment.CENTER);
        } else if (c == 'r') {
          setAlignment(ColumnInfo.Alignment.RIGHT);
        } else if (c == 'f') {
        }
      }
    }
  }

  /**
   * Sets the alignment for {@link ColumnInfo}.
   */
  private void setAlignment(final ColumnInfo.Alignment alignment) {
    final HTMLTableInfo panel = getPanel();
    ExecutionUtils.run(panel, new RunnableEx() {
      public void run() throws Exception {
        getDimension().setAlignment(alignment);
      }
    });
  }
}
TOP

Related Classes of com.google.gdt.eclipse.designer.gef.policy.grid.header.selection.ColumnSelectionEditPolicy

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.