--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Dongkye Lee <dongkyu6.lee@samsung.com>
+ * Jaeyong Lee <jae-yong.lee@@samsung.com>
+ * Gihun Chang <gihun.chang@@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.
+ *
+ */
+
+package org.tizen.dynamicanalyzer.ui.toolbar.setting;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.events.ShellListener;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.dynamicanalyzer.nl.PreferencesDialogLabels;
+import org.tizen.dynamicanalyzer.nl.WidgetLabels;
+import org.tizen.dynamicanalyzer.resources.ColorResources;
+import org.tizen.dynamicanalyzer.resources.FontResources;
+import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.dynamicanalyzer.widgets.da.base.DAButton;
+import org.tizen.dynamicanalyzer.widgets.da.base.DAMessageBox;
+
+public class PreferencesDialog extends DAMessageBox {
+ private static boolean opened = false;
+
+ public PreferencesDialog(Shell parentShell) {
+ super(parentShell);
+ }
+
+ protected boolean run() {
+ if (opened) {
+ return false;
+ }
+
+ shell.setSize(610, 620);
+ shell.setLayout(new FormLayout());
+ shell.setText(PreferencesDialogLabels.TITLE);
+ shell.setBackground(ColorResources.WHITE);
+
+ // base composite
+ Composite baseComp = new Composite(shell, SWT.NONE);
+ FormLayout compLayout = new FormLayout();
+ baseComp.setLayout(compLayout);
+
+ FormData compData = new FormData();
+ compData.top = new FormAttachment(0, 0);
+ compData.left = new FormAttachment(0, 0);
+ compData.right = new FormAttachment(100, 0);
+ compData.bottom = new FormAttachment(100, -60);
+ baseComp.setLayoutData(compData);
+
+ ScrolledComposite scrolledComp = new ScrolledComposite(baseComp, SWT.BORDER | SWT.V_SCROLL);
+ scrolledComp.setLayout(new FormLayout());
+ FormData scrollCompData = new FormData();
+ scrollCompData.top = new FormAttachment(0, 0);
+ scrollCompData.left = new FormAttachment(0, 0);
+ scrollCompData.right = new FormAttachment(100, 0);
+ scrollCompData.bottom = new FormAttachment(100, 0);
+ scrolledComp.setLayoutData(scrollCompData);
+ scrolledComp.setExpandVertical(true);
+ scrolledComp.setBackground(ColorResources.WHITE);
+
+
+
+ // button composite
+ Composite buttonContentsComp = new Composite(shell, SWT.NONE);
+ compLayout = new FormLayout();
+ buttonContentsComp.setLayout(compLayout);
+ buttonContentsComp.setBackground(ColorResources.WHITE);
+ compData = new FormData();
+ compData.top = new FormAttachment(100, -60);
+ compData.left = new FormAttachment(0, 0);
+ compData.right = new FormAttachment(100, 0);
+ compData.bottom = new FormAttachment(100, 0);
+ buttonContentsComp.setLayoutData(compData);
+
+ DACustomButton okButton = new DAButton(buttonContentsComp, SWT.NONE);
+ okButton.addClickListener(okButtonListener);
+ okButton.setText(WidgetLabels.OK);
+ okButton.setButtonFont(FontResources.DIALOG_BUTTON_FONT);
+ FormData buttonData = new FormData();
+ buttonData.top = new FormAttachment(0, 15);
+ buttonData.right = new FormAttachment(100, -15);
+ buttonData.width = 100;
+ buttonData.height = 30;
+ okButton.setLayoutData(buttonData);
+
+ DACustomButton cancelButton = new DAButton(buttonContentsComp, SWT.NONE);
+ cancelButton.addClickListener(cancelButtonListener);
+ cancelButton.setText(WidgetLabels.CANCEL);
+ cancelButton.setButtonFont(FontResources.DIALOG_BUTTON_FONT);
+ buttonData = new FormData();
+ buttonData.top = new FormAttachment(0, 15);
+ buttonData.right = new FormAttachment(okButton, -8);
+ buttonData.width = 100;
+ buttonData.height = 30;
+ cancelButton.setLayoutData(buttonData);
+
+ DACustomButton setAsDefaultButton = new DAButton(buttonContentsComp, SWT.NONE);
+ setAsDefaultButton.addClickListener(setAsDefaultButtonListener);
+ setAsDefaultButton.setText(PreferencesDialogLabels.SET_AS_DEFAULT);
+ setAsDefaultButton.setButtonFont(FontResources.DIALOG_BUTTON_FONT);
+ buttonData = new FormData();
+ buttonData.top = new FormAttachment(0, 15);
+ buttonData.right = new FormAttachment(cancelButton, -8);
+ buttonData.width = 100;
+ buttonData.height = 30;
+ setAsDefaultButton.setLayoutData(buttonData);
+
+ opened = true;
+ ShortCutManager.getInstance().setEnabled(!opened);
+
+ shell.addShellListener(shellListener);
+ shell.open();
+
+ return true;
+ }
+
+ private DACustomButtonClickEventListener okButtonListener = new DACustomButtonClickEventListener() {
+
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ shell.close();
+ }
+ };
+
+ private DACustomButtonClickEventListener cancelButtonListener = new DACustomButtonClickEventListener() {
+
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ shell.close();
+ }
+ };
+
+ private DACustomButtonClickEventListener setAsDefaultButtonListener = new DACustomButtonClickEventListener() {
+
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+
+ }
+ };
+
+ private ShellListener shellListener = new ShellListener() {
+
+ @Override
+ public void shellActivated(ShellEvent e) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void shellClosed(ShellEvent e) {
+ opened = false;
+ ShortCutManager.getInstance().setEnabled(!opened);
+ }
+
+ @Override
+ public void shellDeactivated(ShellEvent e) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void shellDeiconified(ShellEvent e) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void shellIconified(ShellEvent e) {
+ // TODO Auto-generated method stub
+ }
+
+ };
+}