summaryrefslogtreecommitdiff
path: root/org.tizen.common/src/org/tizen/common/control
diff options
context:
space:
mode:
authorJenkins <taeyoung2.son@samsung.com>2012-09-18 13:27:40 +0900
committerJenkins <taeyoung2.son@samsung.com>2012-09-18 13:27:40 +0900
commitfec9e294bc016e821e16a07e6be923e17d12f8fe (patch)
tree261f0f3a6e105010a44904cfd848eaf27725ed59 /org.tizen.common/src/org/tizen/common/control
parent497d5ab077dbf5ca4146e516535da17e3f7314db (diff)
downloadcommon-eplugin-master.tar.gz
common-eplugin-master.tar.bz2
common-eplugin-master.zip
Merge sources from S-Core's RSA git (release)HEAD2.0_alphamaster2.0alpha
Change-Id: Id40e89a773ceb063b1b0a84fcc651d63cf869b98
Diffstat (limited to 'org.tizen.common/src/org/tizen/common/control')
-rw-r--r--org.tizen.common/src/org/tizen/common/control/NotSupportedTypeException.java35
-rw-r--r--org.tizen.common/src/org/tizen/common/control/TableViewCellModifier.java136
-rw-r--r--org.tizen.common/src/org/tizen/common/control/TableViewColumnSorter.java160
-rw-r--r--org.tizen.common/src/org/tizen/common/control/TableViewContentProvider.java50
-rw-r--r--org.tizen.common/src/org/tizen/common/control/TableViewLabelProvider.java121
-rw-r--r--org.tizen.common/src/org/tizen/common/control/TreeViewContentProvider.java69
-rw-r--r--org.tizen.common/src/org/tizen/common/control/TreeViewLabelProvider.java32
7 files changed, 0 insertions, 603 deletions
diff --git a/org.tizen.common/src/org/tizen/common/control/NotSupportedTypeException.java b/org.tizen.common/src/org/tizen/common/control/NotSupportedTypeException.java
deleted file mode 100644
index 64cfa87c8..000000000
--- a/org.tizen.common/src/org/tizen/common/control/NotSupportedTypeException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Kangho Kim <kh5325.kim@samsung.com>
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* 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.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
-package org.tizen.common.control;
-
-public class NotSupportedTypeException extends Exception {
-
- public NotSupportedTypeException(){
- super();
- }
- public NotSupportedTypeException(String message){
- super(message);
- }
-}
diff --git a/org.tizen.common/src/org/tizen/common/control/TableViewCellModifier.java b/org.tizen.common/src/org/tizen/common/control/TableViewCellModifier.java
deleted file mode 100644
index 6bbc54ede..000000000
--- a/org.tizen.common/src/org/tizen/common/control/TableViewCellModifier.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Kangho Kim <kh5325.kim@samsung.com>
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* 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.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
-
-package org.tizen.common.control;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ComboBoxCellEditor;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.tizen.common.model.ITableVO;
-
-
-/**
- * This class implements an ICellModifier
- * An ICellModifier is called when the user modifes a cell in the
- * tableViewer
- */
-
-public class TableViewCellModifier implements ICellModifier {
- private TableViewer viewer;
- private String[] columnNames;
- CellEditor[] cellEditors;
- /**
- * Constructor
- * @param TableViewerExample an instance of a TableViewerExample
- */
- public TableViewCellModifier(TableViewer viewer) {
- super();
- this.viewer = viewer;
- this.columnNames = getColumnNames();
- this.viewer.setColumnProperties(columnNames);
- }
-
- private String[] getColumnNames() {
- TableColumn[] columns = viewer.getTable().getColumns();
- String[] columnNames = new String[columns.length];
- for(int i=0;i<columnNames.length;i++){
- columnNames[i] = columns[i].getText();
- }
-
- return columnNames;
- }
-
- /**
- * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
- */
- public boolean canModify(Object element, String property) {
- return true;
- }
-
- /**
- * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String)
- */
- public Object getValue(Object element, String property) {
-
- Object result = null;
- int idx = getColumnIndex(property);
- ITableVO vo = (ITableVO)element;
-
- CellEditor ce = getCellEditor(idx);
-
- if(ce instanceof ComboBoxCellEditor){
- result = vo.getColumnValue(idx);
- }else if(ce instanceof TextCellEditor){
- result = vo.getColumnValue(idx);
- }else{
- result = ""; //$NON-NLS-1$
- }
- return result;
- }
-
- private CellEditor getCellEditor(int idx) {
- if(this.cellEditors==null)
- this.cellEditors = viewer.getCellEditors();
- return this.cellEditors[idx];
- }
-
- private int getColumnIndex(String property) {
- for(int i=0;i<columnNames.length;i++){
- if(columnNames[i].equals(property))
- return i;
- }
- return 0;
- }
-
- private int getComboIndex(String[] items, Object str) {
- for(int i=0;i<items.length;i++){
- if(items[i].equals(str))
- return i;
- }
- return 0;
- }
-
- /**
- * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
- */
- public void modify(Object element, String property, Object value) {
- int idx = getColumnIndex(property);
- ITableVO vo = (ITableVO)((TableItem) element).getData();
-
- if(cellEditors[idx] instanceof ComboBoxCellEditor){
- if((Integer)value < 0)
- return;
- else
- vo.setColumnValue(idx, value);
- }else if(cellEditors[idx] instanceof TextCellEditor){
- vo.setColumnValue(idx, value);
- }
-
- viewer.update(vo, null);
- }
-}
diff --git a/org.tizen.common/src/org/tizen/common/control/TableViewColumnSorter.java b/org.tizen.common/src/org/tizen/common/control/TableViewColumnSorter.java
deleted file mode 100644
index 1456f8928..000000000
--- a/org.tizen.common/src/org/tizen/common/control/TableViewColumnSorter.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Kangho Kim <kh5325.kim@samsung.com>
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* 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.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
-
-package org.tizen.common.control;
-
-import java.util.Comparator;
-
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.tizen.common.model.ITableVO;
-
-
-
-
-/**
- * A viewer sorter is used by a structured viewer to reorder the elements
- * provided by its content provider. In addition, the TableViewColumnSorter
- * listens for mouse clicks in the column headers and resorts the table content
- * based on the column that was selected. Clicking on a column a second time
- * toggles the sort order.
- */
-public class TableViewColumnSorter extends ViewerSorter {
- private static final String COLUMN_INDEX_KEY = "COLUMN_INDEX"; //$NON-NLS-1$
- private static final String HEADER_TEXT_KEY = "HEADER_TEXT"; //$NON-NLS-1$
- private static final String TAG_DESCENDING = "\u25b2"; // up-pointing triangle
- private static final String TAG_ASCENDING = "\u25bc"; // down-pointing triangle
-
- private TableViewer viewer;
- private Table table;
- private TableColumn[] columns;
- Cursor waitCursor;
-
- private Comparator<String> stringComparator = new Comparator<String>(){
- @Override
- public int compare(String str1, String str2) {
- str1=str1==null?"":str1; //$NON-NLS-1$
- str2=str2==null?"":str2; //$NON-NLS-1$
- return str1.compareTo(str2);
- }
- };
-
- private Comparator<Integer> numberComparator = new Comparator<Integer>(){
- @Override
- public int compare(Integer num1, Integer num2) {
- return num1>num2?1:(num1==num2?0:-1);
- }
- };
-
- public TableViewColumnSorter(TableViewer viewer) {
- this.viewer = viewer;
- this.table = viewer.getTable();
- this.columns = viewer.getTable().getColumns();
-
- createCursor();
- createSelectionListener(columns);
- }
-
- private void createCursor(){
- waitCursor = Display.getCurrent().getSystemCursor(SWT.CURSOR_WAIT);
- }
-
- public int compare(Viewer viewer, Object object1, Object object2) {
- TableColumn column = table.getSortColumn();
-
- int index = -1;
- if(column==null){
- return 0;
- }else{
- index = (Integer)column.getData(COLUMN_INDEX_KEY);
- }
-
- Object target1 = ((ITableVO)object1).getColumnValue(index);
- Object target2 = ((ITableVO)object2).getColumnValue(index);
-
- int result = compare(target1, target2);
-
- if(table.getSortDirection()==SWT.UP)
- return result;
- else
- return -result;
- }
-
- public int compare(Object object1, Object object2){
- if(object1 instanceof Integer){
- return numberComparator.compare((Integer)object1, (Integer)object2);
- }else{
- return stringComparator.compare(object1.toString(), object2.toString());
- }
- }
-
- private void createSelectionListener(TableColumn[] columns) {
- for (int i = 0; i < columns.length; i++) {
- columns[i].setData(COLUMN_INDEX_KEY,i);
- columns[i].setData(HEADER_TEXT_KEY,columns[i].getText());
- columns[i].addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- TableColumn column = (TableColumn)e.getSource();
- clearColumnHeader(column);
- renderColumnHeader(column);
-
- table.setCursor(waitCursor);
- viewer.refresh();
- table.setCursor(null);
- }
- });
- }
- }
-
- private void renderColumnHeader(TableColumn column){
- int direction = table.getSortDirection()==SWT.UP?SWT.DOWN:SWT.UP;
- table.setSortDirection(direction);
- table.setSortColumn(column);
-
- String title = (String)column.getData(HEADER_TEXT_KEY);
- String directionShape = direction==SWT.UP?TAG_DESCENDING:TAG_ASCENDING;
- column.setText(title+" "+directionShape); //$NON-NLS-1$
- }
-
- private void clearColumnHeader(TableColumn column){
- TableColumn prevColumn = table.getSortColumn();
-
- if(prevColumn==null){
- return;
- }else{
- prevColumn.setText((String)prevColumn.getData(HEADER_TEXT_KEY));
- }
- }
-
-} \ No newline at end of file
diff --git a/org.tizen.common/src/org/tizen/common/control/TableViewContentProvider.java b/org.tizen.common/src/org/tizen/common/control/TableViewContentProvider.java
deleted file mode 100644
index 2d9038cac..000000000
--- a/org.tizen.common/src/org/tizen/common/control/TableViewContentProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Kangho Kim <kh5325.kim@samsung.com>
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* 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.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
-
-package org.tizen.common.control;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.tizen.common.model.ITableModel;
-
-
-public class TableViewContentProvider implements IStructuredContentProvider {
-
- public TableViewContentProvider() {
- }
-
- public Object[] getElements(Object model) {
- return ((ITableModel)model).getDatas();
- }
-
- public void dispose() {
-
- }
-
- public void inputChanged(Viewer viewer, Object obj, Object obj1) {
-
- }
-
-}
diff --git a/org.tizen.common/src/org/tizen/common/control/TableViewLabelProvider.java b/org.tizen.common/src/org/tizen/common/control/TableViewLabelProvider.java
deleted file mode 100644
index 12bfa05cb..000000000
--- a/org.tizen.common/src/org/tizen/common/control/TableViewLabelProvider.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Kangho Kim <kh5325.kim@samsung.com>
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* 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.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
-
-package org.tizen.common.control;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ComboBoxCellEditor;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.graphics.Image;
-import org.tizen.common.model.ITableVO;
-
-
-
-
-
-public class TableViewLabelProvider extends ColumnLabelProvider implements ITableLabelProvider {
-
- public TableViewLabelProvider() {
- }
-
- private TableViewer viewer;
- CellEditor[] cellEditors;
-
- public TableViewLabelProvider(TableViewer viewer) {
- this.viewer = viewer;
- this.cellEditors = viewer.getCellEditors();
- }
-
- private Field[] fields;
-
- private int getColumnIndex(int columnIndex){
- return fields.length>columnIndex?columnIndex:fields.length;
- }
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
-// private void hasCellEditor(){
-// if(this.cellEditors==null)
-// this.cellEditors = viewer.getCellEditors();
-// }
-
- private CellEditor getCellEditor(int idx) {
- if(this.cellEditors==null)
- return null;
- else
- return this.cellEditors[idx];
- }
-
- public String getColumnText(Object element, int columnIndex) {
- Object obj = null;
-
- if(element instanceof ITableVO){
- ITableVO data = (ITableVO)element;
- if(this.cellEditors != null){
- CellEditor ce = getCellEditor(columnIndex);
- if(ce instanceof ComboBoxCellEditor){
- ComboBoxCellEditor editor = (ComboBoxCellEditor)ce;
- String items[] = editor.getItems();
- int idx = (Integer) data.getColumnValue(columnIndex);
- if(idx<0)
- obj = null;
- else if(idx>items.length)
- obj = items[0];
- else
- obj = items[idx];
- }else{
- obj = data.getColumnValue(columnIndex);
- }
- }else{
- obj = data.getColumnValue(columnIndex);
- }
- }else{
- if(fields==null)
- fields = element.getClass().getDeclaredFields();
-
- int idx = getColumnIndex(columnIndex);
- String fieldName = fields[idx].getName().substring(0, 1).toUpperCase()
- + fields[idx].getName().substring(1,fields[idx].getName().length());
-
- try{
- Method method = element.getClass().getMethod("get" + fieldName, new Class[] {}); //$NON-NLS-1$
- obj = method.invoke(element, new Object[] {});
- }catch(Exception e){
- return ""; //$NON-NLS-1$
- }
- }
-
- return obj==null?"":String.valueOf(obj); //$NON-NLS-1$
- }
-
-
-}
diff --git a/org.tizen.common/src/org/tizen/common/control/TreeViewContentProvider.java b/org.tizen.common/src/org/tizen/common/control/TreeViewContentProvider.java
deleted file mode 100644
index 726fb9390..000000000
--- a/org.tizen.common/src/org/tizen/common/control/TreeViewContentProvider.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Kangho Kim <kh5325.kim@samsung.com>
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* 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.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
-
-package org.tizen.common.control;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.tizen.common.model.ITreeModel;
-import org.tizen.common.model.ITreeVO;
-
-
-public class TreeViewContentProvider implements ITreeContentProvider {
-
- public Object[] getChildren(Object element) {
- if(element instanceof ITreeModel)
- return ((ITreeModel)element).getDatas();
- else
- return ((ITreeVO)element).getChildren();
- }
-
- public Object getParent(Object element) {
- if(element instanceof ITreeModel)
- return null;
- else
- return ((ITreeVO)element).getParent();
-
- }
-
- public boolean hasChildren(Object element) {
- if(element instanceof ITreeModel)
- return ((ITreeModel)element).size()>0;
- else
- return ((ITreeVO)element).hasChildren();
- }
-
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
-
-}
diff --git a/org.tizen.common/src/org/tizen/common/control/TreeViewLabelProvider.java b/org.tizen.common/src/org/tizen/common/control/TreeViewLabelProvider.java
deleted file mode 100644
index 77bb41387..000000000
--- a/org.tizen.common/src/org/tizen/common/control/TreeViewLabelProvider.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Kangho Kim <kh5325.kim@samsung.com>
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* 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.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
-
-package org.tizen.common.control;
-
-import org.eclipse.jface.viewers.LabelProvider;
-
-public class TreeViewLabelProvider extends LabelProvider {
-
-}