01: /*
02: * Copyright 2006 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: */
13: package org.pentaho.designstudio.controls;
14:
15: import org.eclipse.swt.SWT;
16: import org.eclipse.swt.events.SelectionEvent;
17: import org.eclipse.swt.events.SelectionListener;
18: import org.eclipse.swt.graphics.Image;
19: import org.eclipse.swt.widgets.Composite;
20: import org.eclipse.swt.widgets.Control;
21: import org.eclipse.swt.widgets.ToolBar;
22: import org.eclipse.swt.widgets.ToolItem;
23: import org.pentaho.designstudio.editors.actionsequence.ActionSequenceEditorPlugin;
24: import org.pentaho.designstudio.messages.Messages;
25:
26: public class PrintMapKeysListToolbar {
27:
28: ToolBar toolBar;
29: PrintMapKeysList actionInputsList;
30: ToolItem addToolItem;
31: ToolItem deleteToolItem;
32:
33: static final Image ADD_ACTION_ICON = ActionSequenceEditorPlugin
34: .getImageDescriptor(
35: Messages
36: .getString("ActionsMasterDetailBlock.ICON_ADD_ACTION")).createImage(); //$NON-NLS-1$
37: static final Image REMOVE_ACTION_ICON = ActionSequenceEditorPlugin
38: .getImageDescriptor(
39: Messages
40: .getString("ActionsMasterDetailBlock.ICON_REMOVE_ACTION")).createImage(); //$NON-NLS-1$
41:
42: public PrintMapKeysListToolbar(Composite parent,
43: PrintMapKeysList inputsList) {
44: actionInputsList = inputsList;
45:
46: toolBar = new ToolBar(parent, SWT.FLAT);
47:
48: addToolItem = new ToolItem(toolBar, SWT.NULL);
49: addToolItem.setImage(ADD_ACTION_ICON);
50: addToolItem.setToolTipText(Messages
51: .getString("ActionsMasterDetailBlock.ADD_NEW_INPUT")); //$NON-NLS-1$
52: addToolItem.addSelectionListener(new SelectionListener() {
53: public void widgetDefaultSelected(SelectionEvent e) {
54: }
55:
56: public void widgetSelected(SelectionEvent e) {
57: actionInputsList.addKey();
58: }
59:
60: });
61:
62: deleteToolItem = new ToolItem(toolBar, SWT.NULL);
63: deleteToolItem.setImage(REMOVE_ACTION_ICON);
64: deleteToolItem
65: .setToolTipText(Messages
66: .getString("ActionsMasterDetailBlock.REMOVE_SELECTED_INPUT")); //$NON-NLS-1$
67: deleteToolItem.addSelectionListener(new SelectionListener() {
68: public void widgetDefaultSelected(SelectionEvent e) {
69: }
70:
71: public void widgetSelected(SelectionEvent e) {
72: actionInputsList.removeSelectedKey();
73: }
74: });
75:
76: }
77:
78: public void refresh() {
79: }
80:
81: public Control getControl() {
82: return toolBar;
83: }
84: }
|