001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource.so6.plugin.wizards;
034:
035: /**
036: * @author Guillaume Bort
037: * @author Sebastien Jourdain
038: */
039: import org.eclipse.core.resources.IProject;
040: import org.eclipse.core.runtime.IStatus;
041: import org.eclipse.core.runtime.Status;
042:
043: import org.eclipse.jface.dialogs.ErrorDialog;
044: import org.eclipse.jface.resource.ImageDescriptor;
045: import org.eclipse.jface.wizard.IWizardPage;
046: import org.eclipse.jface.wizard.Wizard;
047: import org.eclipse.jface.wizard.WizardPage;
048:
049: import org.eclipse.swt.SWT;
050: import org.eclipse.swt.events.ModifyEvent;
051: import org.eclipse.swt.events.ModifyListener;
052: import org.eclipse.swt.layout.GridData;
053: import org.eclipse.swt.layout.GridLayout;
054: import org.eclipse.swt.widgets.Composite;
055: import org.eclipse.swt.widgets.Text;
056:
057: import org.libresource.so6.plugin.Plugin;
058: import org.libresource.so6.plugin.core.So6Util;
059: import org.libresource.so6.plugin.ui.So6Images;
060: import org.libresource.so6.plugin.ui.So6ResourceUILabelDecorator;
061:
062: /**
063: * DOCUMENT ME!
064: *
065: * @author $author$
066: * @version $Revision: 1.3 $
067: */
068: public class EditIgnoreFileWizard extends Wizard {
069: /** DOCUMENT ME! */
070: protected String ignoreFileValue;
071: private IProject project;
072:
073: /**
074: * Creates a new EditIgnoreFileWizard object.
075: *
076: * @param project DOCUMENT ME!
077: */
078: public EditIgnoreFileWizard(IProject project) {
079: this .project = project;
080: }
081:
082: /**
083: * DOCUMENT ME!
084: */
085: public void addPages() {
086: WizardPage editFile = new EditIgnoreFilePage("edit",
087: "Edit So6 Ignore file", So6Images.getSo6WizardImage());
088: editFile
089: .setDescription("This file contain a sequence of regular expressions");
090: addPage(editFile);
091: }
092:
093: /**
094: * DOCUMENT ME!
095: *
096: * @param pageContainer DOCUMENT ME!
097: */
098: public void createPageControls(Composite pageContainer) {
099: super .createPageControls(pageContainer);
100: setWindowTitle("Ignore file of project " + project.getName());
101: }
102:
103: /**
104: * DOCUMENT ME!
105: *
106: * @return DOCUMENT ME!
107: */
108: public IWizardPage getStartingPage() {
109: return getPage("edit");
110: }
111:
112: /**
113: * DOCUMENT ME!
114: *
115: * @return DOCUMENT ME!
116: */
117: public boolean performFinish() {
118: try {
119: So6Util.setIgnoreFileContent(project, ignoreFileValue);
120: So6ResourceUILabelDecorator.update();
121:
122: return true;
123: } catch (Exception e) {
124: ErrorDialog.openError(getShell(),
125: "Error while saving ignore file", e.getMessage(),
126: new Status(IStatus.ERROR, Plugin.ID, IStatus.OK, e
127: .getMessage(), e));
128:
129: return false;
130: }
131: }
132:
133: class EditIgnoreFilePage extends WizardPage implements
134: ModifyListener {
135: private Text file;
136:
137: public EditIgnoreFilePage(String pageName) {
138: super (pageName);
139: }
140:
141: public EditIgnoreFilePage(String pageName, String title,
142: ImageDescriptor titleImage) {
143: super (pageName, title, titleImage);
144: }
145:
146: public void createControl(Composite composite) {
147: Composite pageContainer = new Composite(composite, SWT.NULL);
148: setControl(pageContainer);
149: setNeedsProgressMonitor(true);
150:
151: GridLayout layout = new GridLayout(1, false);
152: pageContainer.setLayout(layout);
153: file = new Text(pageContainer, SWT.MULTI | SWT.BORDER);
154: file.addModifyListener(this );
155:
156: try {
157: file.setText(So6Util.getIgnoreFileContent(project));
158: } catch (Exception e) {
159: ErrorDialog.openError(getShell(),
160: "Error while loading ignore file", e
161: .getMessage(), new Status(
162: IStatus.ERROR, Plugin.ID, IStatus.OK, e
163: .getMessage(), e));
164: }
165:
166: GridData gd = new GridData();
167: gd.widthHint = 420;
168: gd.heightHint = 250;
169: file.setLayoutData(gd);
170: }
171:
172: public void modifyText(ModifyEvent e) {
173: try {
174: ignoreFileValue = file.getText();
175: } catch (Exception e1) {
176: //
177: }
178: }
179: }
180: }
|