COMMON: Add LinkDialog 04/15004/2
authorhyunsik.noh <hyunsik.noh@samsung.com>
Wed, 15 Jan 2014 02:41:00 +0000 (11:41 +0900)
committerhyunsik.noh <hyunsik.noh@samsung.com>
Mon, 20 Jan 2014 04:24:34 +0000 (13:24 +0900)
Change-Id: I6813784141a1373ac0e1d96f5b353b645b814dc9
Signed-off-by: hyunsik.noh <hyunsik.noh@samsung.com>
org.tizen.common.ui/src/org/tizen/common/ui/dialog/LinkDialog.java [new file with mode: 0644]

diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/dialog/LinkDialog.java b/org.tizen.common.ui/src/org/tizen/common/ui/dialog/LinkDialog.java
new file mode 100644 (file)
index 0000000..30433f2
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@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.ui.dialog;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IconAndMessageDialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Link Dialog.
+ * This dialog provides text link which do something when user select it.
+ *
+ * @author hyunsik.noh {@literal <hyunsik.noh@samsung.com>} (S-Core)
+ */
+public class LinkDialog extends IconAndMessageDialog{
+    
+    private String message = null;
+    private SelectionListener listener = null;
+    private String title = null;
+
+    /**
+     * 
+     * @param parentShell Parent shell
+     * @param listener The listener to handle event when user select the link. (if null, do nothing) 
+     * @param title The dialog title.
+     * @param msg The dialog messages. The message to link needs {@code <A></A>} tag.
+     */
+    public LinkDialog(Shell parentShell, SelectionListener listener, String title, String msg) {
+        super(parentShell);
+        this.title = title;
+        this.listener =  listener;
+        this.message = msg;
+    }
+    
+    @Override
+    protected void configureShell(Shell shell) {
+        super.configureShell(shell);
+        shell.setText(title);
+    }
+    
+    @Override
+    protected Control createDialogArea(Composite composite) {
+
+        Link launchDialog = new Link(composite, getMessageLabelStyle());
+        launchDialog.setText(message);
+        GridDataFactory
+                .fillDefaults()
+                .align(SWT.FILL, SWT.BEGINNING)
+                .grab(true, false)
+                .hint(
+                        convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH),
+                        SWT.DEFAULT).applyTo(launchDialog);
+
+        if(listener != null) {
+            launchDialog.addSelectionListener(listener);
+        }
+        return composite;
+    }
+
+    @Override
+    protected Image getImage() {
+        return null;
+    }
+    
+    /**
+     * Creates the buttons
+     * 
+     * @param parent the parent composite
+     */
+    @Override
+    protected void createButtonsForButtonBar(Composite parent) {
+      createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+    }
+}
\ No newline at end of file