/******************************************************************************* * Copyright (c) 2015 hangum. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * Contributors: * hangum - initial API and implementation ******************************************************************************/ package com.hangum.tadpole.rdb.core.dialog.msg; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import com.hangum.tadpole.ace.editor.core.widgets.TadpoleEditorWidget; import com.hangum.tadpole.commons.libs.core.message.CommonMessages; import com.hangum.tadpole.commons.util.GlobalImageUtils; import com.hangum.tadpole.engine.utils.EditorDefine; import com.hangum.tadpole.rdb.core.Messages; /** * dircet change dialg * * @author hangum * */ public class DirectChangeDialog extends Dialog { TadpoleEditorWidget textSQL; String strMessage = ""; String strQuery = ""; /** * Create the dialog. * @param parentShell * @param strQuery */ public DirectChangeDialog(Shell parentShell, String strMessage, String strQuery) { super(parentShell); setShellStyle(SWT.MAX | SWT.RESIZE | SWT.TITLE | SWT.APPLICATION_MODAL); this.strMessage = strMessage; this.strQuery = strQuery; } @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText(Messages.get().ExecuteQuery); newShell.setImage(GlobalImageUtils.getTadpoleIcon()); } /** * Create contents of the dialog. * @param parent */ @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridLayout gridLayout = (GridLayout) container.getLayout(); gridLayout.verticalSpacing = 4; gridLayout.horizontalSpacing = 4; gridLayout.marginHeight = 4; gridLayout.marginWidth = 4; Composite composite = new Composite(container, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); composite.setLayout(new GridLayout(1, false)); Label lblNewLabel = new Label(composite, SWT.NONE); lblNewLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); lblNewLabel.setText(strMessage); textSQL = new TadpoleEditorWidget(composite, SWT.BORDER, EditorDefine.EXT_DEFAULT, strQuery, ""); textSQL.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); return container; } @Override protected void buttonPressed(int buttonId) { strQuery = textSQL.getText(); super.buttonPressed(buttonId); } /** * Create contents of the button bar. * @param parent */ @Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, CommonMessages.get().Confirm, false); createButton(parent, IDialogConstants.CANCEL_ID, CommonMessages.get().Cancel, true); } public String getSQL() { return strQuery; } /** * Return the initial size of the dialog. */ @Override protected Point getInitialSize() { return new Point(650, 500); } }