Code Search for Developers
 
 
  

DirtyEditorDialog.java from PovClipse at Krugle


Show DirtyEditorDialog.java syntax highlighted

/* PovClipse - Eclipse plugin for editing and rendering Povray sceene files.
 * Copyright (C) 2006-2007  Wolfgang Moestl  wmoestl@web.de
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */

package com.wm.povclipse.dialogs;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
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.wm.povclipse.PovClipseEditorPlugin;
import com.wm.povclipse.i18n.I18nRenderAS;
import com.wm.povclipse.tools.WidgetTool;

/**
 * Modal dialog asking the user to save all dirty dialogs.
 * @author Wolfgang Möstl
 */
public class DirtyEditorDialog extends Dialog {
	private Button btnNoAskAnymore;
	private Button btnMakePermanent;
	private boolean noAskAnymore;
	private boolean makePermanent;
	
	/**
	 * Constructor
	 * @param parentShell The parent shell for this modal dialog.
	 */
	public DirtyEditorDialog(Shell parentShell) {
		super(parentShell);
		this.setBlockOnOpen(true);	
	}
	
	/**
	 * Sets the dialog title and image.
	 * @see org.eclipse.jface.dialogs.Dialog#create()
	 */
	public void create() {
		super.create();
		getShell().setText(I18nRenderAS.dlg_autosave_title);
		getShell().setImage(PovClipseEditorPlugin.getDefault().getImageRegistry().get(PovClipseEditorPlugin.IMAGE_LOGO_POVRAY));
		setDefaultImage(PovClipseEditorPlugin.getDefault().getImageRegistry().get(PovClipseEditorPlugin.IMAGE_LOGO_POVRAY));
	}
	
	/**
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
	protected Control createDialogArea(Composite parent) {
		Control retControl = super.createDialogArea(parent);
		
		Composite composite = new Composite((Composite)retControl, SWT.NONE); 
		composite.setLayoutData(new GridData(GridData.FILL_BOTH));
		GridLayout layout = new GridLayout(3, false);
		composite.setLayout(layout);
		
		Image image = parent.getDisplay().getSystemImage(SWT.ICON_QUESTION);
		Label imageLabel = new Label(composite, SWT.NULL);
        image.setBackground(imageLabel.getBackground());
        imageLabel.setImage(image);
        GridData gData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_BEGINNING);
        gData.verticalSpan = 5;
        imageLabel.setLayoutData(gData);
        
        Label spacer = WidgetTool.createDefaultSpacer(composite, 1);
		gData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_BEGINNING);
        gData.verticalSpan = 5;
        spacer.setLayoutData(gData);
        
		Label labMsg = new Label(composite, SWT.NONE);
		labMsg.setText(I18nRenderAS.dlg_autosave_msg);
		
		WidgetTool.createDefaultSpacer(composite, 1);
		       
		btnNoAskAnymore = new Button(composite, SWT.CHECK);
		btnNoAskAnymore.setText(I18nRenderAS.dlg_autosave_no_asking_anymore);
		btnNoAskAnymore.setToolTipText(I18nRenderAS.dlg_autosave_no_asking_anymore_tt);
		
		btnMakePermanent = new Button(composite, SWT.CHECK);
		btnMakePermanent.setText(I18nRenderAS.dlg_autosave_make_permanent);
		btnMakePermanent.setToolTipText(I18nRenderAS.dlg_autosave_make_permanent_tt);
		
		Label labHint = new Label(composite, SWT.NONE);
		labHint.setText(I18nRenderAS.dlg_autosave_preference_hint);
		return retControl;
	}
	
	


	/**
	 * The lables of the "OK" and "Cancel" buttons are switched
	 * to "Yes" and "No".
	 * @see org.eclipse.jface.dialogs.Dialog#createButtonBar(org.eclipse.swt.widgets.Composite)
	 */
	protected Control createButtonBar(Composite parent) {
		Control ret = super.createButtonBar(parent);
		
		getButton(IDialogConstants.OK_ID).setText(IDialogConstants.YES_LABEL);
		getButton(IDialogConstants.CANCEL_ID).setText(IDialogConstants.NO_LABEL);
		
		return ret;
	}

	/**
	 * @see org.eclipse.jface.dialogs.Dialog#close()
	 */
	public boolean close() {
		noAskAnymore  = btnNoAskAnymore.getSelection();
		makePermanent = btnMakePermanent.getSelection();
		return super.close();
	}

	/**
	 * @return The value of the <code>btnNoAskAnymore button</code>
	 * after closing the dialog.
	 */
	public boolean isNoAskingAnymore() {
		return noAskAnymore;
	}
	
	/**
	 * @return The value of the <code>btnMakePermanent button</code>
	 * after closing the dialog.
	 */
	public boolean isMakePermanent() {
		return makePermanent;
	}
}



See more files for this project here

PovClipse

PovClipse is an eclipse editor plugin for Povray (Persistence of Vision Raytracer) sceene- and include files.\r\nIt features syntax highlighting, code folding, code assist, outline view as well as running Povray using render configurations.

Project homepage: http://sourceforge.net/projects/povclipse
Programming language(s): Java
License: other

  color/
    ColorEditorDialog.java
    ColorPositionEditorDialog.java
  flow/
    color/
      ColorFlowDialog.java
      ColorFlowEntry.java
      ColorFlowWidget.java
    AbstractFlowEntry.java
    AbstractFlowWidget.java
    FlowEntryComparator.java
    FlowEntryValueDialog.java
    IFlowEntry.java
  DirtyEditorDialog.java
  ISizeUpdater.java