4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
7 * Hoon Kang <h245.kang@samsung.com>
8 * Hyunsik Noh <hyunsik.noh@samsung.com>
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
26 package org.tizen.common.connection.properties;
28 import org.eclipse.swt.SWT;
29 import org.eclipse.swt.layout.GridData;
30 import org.eclipse.swt.layout.GridLayout;
31 import org.eclipse.swt.widgets.Composite;
32 import org.eclipse.swt.widgets.Control;
33 import org.eclipse.swt.widgets.Group;
34 import org.eclipse.swt.widgets.Label;
35 import org.eclipse.swt.widgets.Table;
36 import org.eclipse.swt.widgets.TableColumn;
37 import org.eclipse.swt.widgets.TableItem;
38 import org.eclipse.ui.dialogs.PropertyPage;
40 import org.tizen.sdblib.FileListingService;
41 import org.tizen.sdblib.FileListingService.FileEntry;
43 public class ConnectionExplorerPermissionPropertyPages extends PropertyPage {
46 private static final String PERMISSION_TITLE = "Permission:";
48 private TableItem itemUser;
49 private TableItem itemGroup;
50 private TableItem itemOther;
54 * Constructor for SamplePropertyPage.
56 public ConnectionExplorerPermissionPropertyPages() {
61 private void addFirstSection(Composite parent) {
63 FileEntry f = (FileEntry) getElement().getAdapter(FileEntry.class);
64 String permission = f.getPermissions();
66 itemUser.setText(1, permission.charAt(1) != '-' ? "O" : "X");
67 itemUser.setText(2, permission.charAt(2) != '-' ? "O" : "X");
68 itemUser.setText(3, permission.charAt(3) != '-' ? "O" : "X");
70 itemGroup.setText(1, permission.charAt(4) != '-' ? "O" : "X");
71 itemGroup.setText(2, permission.charAt(5) != '-' ? "O" : "X");
72 itemGroup.setText(3, permission.charAt(6) != '-' ? "O" : "X");
74 itemOther.setText(1, permission.charAt(7) != '-' ? "O" : "X");
75 itemOther.setText(2, permission.charAt(8) != '-' ? "O" : "X");
76 itemOther.setText(3, permission.charAt(9) != '-' ? "O" : "X");
81 private void addSeparator(Composite parent) {
82 Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
83 GridData gridData = new GridData();
84 gridData.horizontalAlignment = GridData.FILL;
85 gridData.grabExcessHorizontalSpace = true;
86 separator.setLayoutData(gridData);
91 * @see PreferencePage#createContents(Composite)
93 protected Control createContents(Composite parent) {
94 noDefaultAndApplyButton();
95 Composite composite = new Composite(parent, SWT.NONE);
96 GridLayout layout = new GridLayout();
97 composite.setLayout(layout);
98 GridData data = new GridData();
99 composite.setLayoutData(data);
101 FileEntry f = (FileEntry) getElement().getAdapter(FileEntry.class);
102 if (f.getType() == FileListingService.TYPE_ROOT_DEVICE ||
103 f.getType() == FileListingService.TYPE_ROOT_EMULATOR) {
106 createTable(composite);
107 addFirstSection(composite);
108 addSeparator(composite);
112 private void createTable(Composite parent) {
113 Group group = new Group(parent, SWT.NONE);
114 group.setText(PERMISSION_TITLE);
115 GridLayout layout = new GridLayout();
116 layout.numColumns = 1;
117 group.setLayout(layout);
118 GridData data = new GridData();
119 data.horizontalSpan = 1;
120 group.setLayoutData(data);
122 Table table = new Table(group, SWT.BORDER);
123 GridData gridData = new GridData();
124 gridData.horizontalSpan = 3;
125 gridData.verticalSpan = 3;
126 table.setLayoutData(gridData);
128 table.setHeaderVisible(true);
129 table.setLinesVisible(true);
131 TableColumn colMsg = createTableColumn(table, "", SWT.NONE,
133 colMsg = createTableColumn(table, "Read", SWT.NONE,
135 colMsg = createTableColumn(table, "Write", SWT.NONE,
137 colMsg = createTableColumn(table, "Execute", SWT.NONE,
141 itemUser = new TableItem(table, SWT.NONE);
142 itemUser.setText(0, "User");
144 itemGroup = new TableItem(table, SWT.NONE);
145 itemGroup.setText(0, "Group");
147 itemOther = new TableItem(table, SWT.NONE);
148 itemOther.setText(0, "Other");
151 private TableColumn createTableColumn(Table parent, String header,
152 int style, String sampleText) {
154 TableColumn col = new TableColumn(parent, style);
156 col.setText(sampleText);
157 col.setResizable(false);
166 public boolean performOk() {