eclox/ 0000755 0000764 0000764 00000000000 12166321517 011266 5 ustar willy willy eclox/eclox.ui/ 0000755 0000764 0000764 00000000000 12166321432 013010 5 ustar willy willy eclox/eclox.ui/META-INF/ 0000755 0000764 0000764 00000000000 12166321431 014147 5 ustar willy willy eclox/eclox.ui/META-INF/MANIFEST.MF 0000644 0000764 0000764 00000000733 12166012446 015607 0 ustar willy willy Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Eclox User Interface Bundle-SymbolicName: org.gna.eclox.ui; singleton:=true Bundle-Version: 0.10.0 Bundle-Activator: eclox.ui.Plugin Bundle-Vendor: Guillaume Brocker Bundle-Localization: Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.ui.console, org.gna.eclox.core, org.eclipse.core.resources, org.eclipse.ui.ide, org.eclipse.ui.forms, org.eclipse.ui.editors Eclipse-LazyStart: true eclox/eclox.ui/src/ 0000755 0000764 0000764 00000000000 12166321431 013576 5 ustar willy willy eclox/eclox.ui/src/eclox/ 0000755 0000764 0000764 00000000000 12166321431 014710 5 ustar willy willy eclox/eclox.ui/src/eclox/ui/ 0000755 0000764 0000764 00000000000 12166321432 015326 5 ustar willy willy eclox/eclox.ui/src/eclox/ui/IPreferences.java 0000644 0000764 0000764 00000003664 12166012446 020556 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2006, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui; /** * Provides all preference names of the plugin. * * @author gbrocker */ public interface IPreferences { /** * Constant name for the build history content. */ // public static final String BUILD_HISTORY_CONTENT = "build-history-content"; /** * Constant name for the build history size. */ // public static final String BUILD_HISTORY_SIZE = "build-history-size"; /** * Constant name for the build job history size. */ public static final String BUILD_HISTORY_SIZE = "buildHistory.size"; /** * Constant name for workspace autosave flag. * * @see AUTO_SAVE_NEVER * @see AUTO_SAVE_ALWAYS * @see AUTO_SAVE_ASK */ public static final String AUTO_SAVE = "editor.autosave"; /** * Constant for AUTO_SAVE never state. * * @see AUTO_SAVE * @see AUTO_SAVE_ALWAYS * @see AUTO_SAVE_ASK */ public static final String AUTO_SAVE_NEVER = "never"; /** * Constant for AUTO_SAVE always state. * * @see AUTO_SAVE * @see AUTO_SAVE_NEVER * @see AUTO_SAVE_ASK */ public static final String AUTO_SAVE_ALWAYS = "always"; /** * Constant for AUTO_SAVE ask state. * * @see AUTO_SAVE * @see AUTO_SAVE_ALWAYS * @see AUTO_SAVE_NEVER */ public static final String AUTO_SAVE_ASK = "ask"; /** * Constant name for the automatic value string escapes. */ public static final String HANDLE_ESCAPED_VALUES = "editor.handleEscapedValues"; } eclox/eclox.ui/src/eclox/ui/console/ 0000755 0000764 0000764 00000000000 12166321431 016767 5 ustar willy willy eclox/eclox.ui/src/eclox/ui/console/ConsolePage.java 0000644 0000764 0000764 00000016162 12166012446 022042 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013 Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.console; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.IJobChangeListener; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.IActionBars; import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.IConsoleConstants; import org.eclipse.ui.part.Page; import eclox.core.doxygen.BuildJob; import eclox.core.doxygen.IBuildJobListener; import eclox.ui.console.action.CancelJob; import eclox.ui.console.action.ClearLog; import eclox.ui.console.action.LockScroll; import eclox.ui.console.action.RemoveConsole; /** * Implements the page for the doxygen console. * * @author gbrocker */ public class ConsolePage extends Page { /** * Implements a build job listener that will maintain the console up-to-date * with the job log. * * @author gbrocker */ private class MyBuildJobListener implements IBuildJobListener { /** * @see eclox.core.doxygen.IBuildJobListener#buildJobLogCleared(eclox.core.doxygen.BuildJob) */ public void buildJobLogCleared(BuildJob job) { ConsolePlugin.getStandardDisplay().asyncExec( new Runnable() { public void run() { clear(); } } ); } /** * @see eclox.core.doxygen.IBuildJobListener#buildJobLogUpdated(eclox.core.doxygen.BuildJob, java.lang.String) */ public void buildJobLogUpdated(BuildJob job, String output) { final String text = new String( output ); ConsolePlugin.getStandardDisplay().asyncExec( new Runnable() { public void run() { append( text ); } } ); } /** * @see eclox.core.doxygen.IBuildJobListener#buildJobRemoved(eclox.core.doxygen.BuildJob) */ public void buildJobRemoved(BuildJob job) {} } /** * @brief Implements a job change listener used to update the interface state according to the * build job events. * * @author gbrocker */ private class MyJobChangedListener implements IJobChangeListener { public void aboutToRun(IJobChangeEvent event) { ConsolePlugin.getStandardDisplay().syncExec( new Runnable() { public void run() { updateActionStates(); } } ); } public void awake(IJobChangeEvent event) {} public void done(final IJobChangeEvent event) { ConsolePlugin.getStandardDisplay().syncExec( new Runnable() { public void run() { updateActionStates(); IStatus status = event.getResult(); if( status.isOK() ) { append( "*** Build finished!" ); } else { append( "*** Build aborted! " ); append( status.getMessage() ); } } } ); } public void running(IJobChangeEvent event) {} public void scheduled(IJobChangeEvent event) {} public void sleeping(IJobChangeEvent event) {} } private boolean scrollLocked = false; ///< a boolean telling if the console scrolling is locked or not private StyledText styledText; ///< the control used to display text private Console console; ///< the console the page is attached to private CancelJob cancelJobAction; ///< the action that cancels the build job private MyBuildJobListener jobListener; ///< the build job listener private MyJobChangedListener jobChangedListener; ///< the build job change listener /** * Constructor * * @param console the console the page is attached to */ public ConsolePage( Console console ) { this.console = console; } /** * Appends text to the console. * * @param text a string containing the text to append */ private void append( String text ) { assert styledText != null; styledText.append( text ); scroll(); } /** * Clears the console content. */ private void clear() { assert styledText != null; styledText.setText( new String() ); } /** * @see org.eclipse.ui.part.Page#dispose() */ public void dispose() { // Removes job listeners. console.getJob().removeBuidJobListener(jobListener); console.getJob().removeJobChangeListener(jobChangedListener); // Release some references. console = null; styledText = null; cancelJobAction = null; // Base treatment. super.dispose(); } /** * @see org.eclipse.ui.part.Page#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { assert console != null; assert styledText == null; assert cancelJobAction == null; // Creates the text control. styledText = new StyledText( parent, SWT.READ_ONLY|SWT.MULTI|SWT.H_SCROLL|SWT.V_SCROLL ); styledText.setFont( JFaceResources.getTextFont() ); // Creates the cancel job action. cancelJobAction = new CancelJob( console ); // Creates job listeners; jobListener = new MyBuildJobListener(); jobChangedListener = new MyJobChangedListener(); console.getJob().addBuidJobListener(jobListener); console.getJob().addJobChangeListener(jobChangedListener); // Creates the actions IActionBars actionBars = getSite().getActionBars(); actionBars.getToolBarManager().appendToGroup( IConsoleConstants.LAUNCH_GROUP, cancelJobAction ); actionBars.getToolBarManager().appendToGroup( IConsoleConstants.LAUNCH_GROUP, new RemoveConsole(console) ); actionBars.getToolBarManager().appendToGroup( IConsoleConstants.OUTPUT_GROUP, new ClearLog(console) ); actionBars.getToolBarManager().appendToGroup( IConsoleConstants.OUTPUT_GROUP, new LockScroll(this) ); actionBars.updateActionBars(); } /** * @see org.eclipse.ui.part.Page#getControl() */ public Control getControl() { return styledText; } /** * Scrolls the console to the end of the log */ private void scroll() { assert styledText != null; if( scrollLocked == false ) { styledText.setSelection( styledText.getCharCount() ); styledText.showSelection(); } } /** * @see org.eclipse.ui.part.Page#setFocus() */ public void setFocus() { assert styledText != null; styledText.setFocus(); } /** * Updates the lock of the console scroll. * * @param locked a boolean giving the new lock state */ public void setScrollLocked( boolean locked ) { scrollLocked = locked; } /** * Updates the state of some action according to the current job's state */ private void updateActionStates() { assert cancelJobAction != null; assert console != null; BuildJob job = console.getJob(); cancelJobAction.setEnabled( job != null && job.getState() == Job.RUNNING ); } } eclox/eclox.ui/src/eclox/ui/console/action/ 0000755 0000764 0000764 00000000000 12166321431 020244 5 ustar willy willy eclox/eclox.ui/src/eclox/ui/console/action/RemoveConsole.java 0000644 0000764 0000764 00000002542 12166012446 023675 0 ustar willy willy /******************************************************************************* * Copyright (C) 2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.console.action; import org.eclipse.jface.action.Action; import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.IConsole; import eclox.ui.Images; import eclox.ui.Plugin; import eclox.ui.console.Console; /** * Implements an action that removes a given console. * * @author gbrocker */ public class RemoveConsole extends Action { /** * the console the action is attached to */ Console console; /** * Constructor * * @param console the build console */ public RemoveConsole( Console console ) { super( "Remove", Plugin.getImageDescriptor(Images.REMOVE) ); this.console = console; setToolTipText( "Remove Doxygen Build Console" ); } public void run() { ConsolePlugin.getDefault().getConsoleManager().removeConsoles( new IConsole[] {console} ); super.run(); } } eclox/eclox.ui/src/eclox/ui/console/action/CancelJob.java 0000644 0000764 0000764 00000002363 12166012446 022736 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2006, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.console.action; import org.eclipse.jface.action.Action; import eclox.ui.Images; import eclox.ui.Plugin; import eclox.ui.console.Console; /** * Implements an action that will cancel the current build job of the console. * * @author gbrocker */ public class CancelJob extends Action { /** * the console the action is attached to */ Console console; /** * Constructor * * @param console the build console */ public CancelJob( Console console ) { super( "Terminate", Plugin.getImageDescriptor(Images.TERMINATE) ); this.console = console; setToolTipText( "Terminate Build" ); setEnabled( false ); } public void run() { console.getJob().cancel(); super.run(); } } eclox/eclox.ui/src/eclox/ui/console/action/ClearLog.java 0000644 0000764 0000764 00000002313 12166012446 022601 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2006, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.console.action; import org.eclipse.jface.action.Action; import eclox.core.doxygen.BuildJob; import eclox.ui.Images; import eclox.ui.Plugin; import eclox.ui.console.Console; public class ClearLog extends Action { /** * the console to act on */ private Console console; /** * Constructor * * @param console the console to act on */ public ClearLog( Console console ) { super( "Clear Console", Plugin.getImageDescriptor(Images.CLEAR_CONSOLE) ); this.console = console; setToolTipText( "Clear Build Log" ); } public void run() { BuildJob job = console.getJob(); if( job != null ) { job.clearLog(); } super.run(); } } eclox/eclox.ui/src/eclox/ui/console/action/LockScroll.java 0000644 0000764 0000764 00000002521 12166012446 023161 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.console.action; import org.eclipse.jface.action.Action; import eclox.ui.Images; import eclox.ui.Plugin; import eclox.ui.console.ConsolePage; /** * Implements the action that will lock the console from scrolling while output * is appended to the log. * * @author gbrocker */ public class LockScroll extends Action { /** * the console page to act on */ private ConsolePage consolePage; /** * Constructor * * @param consolePage the console to act on */ public LockScroll( ConsolePage consolePage ) { super("Scroll Lock", AS_CHECK_BOX); this.consolePage = consolePage; setImageDescriptor( Plugin.getImageDescriptor(Images.LOCK_CONSOLE) ); setToolTipText( "Scroll Lock" ); } public void run() { consolePage.setScrollLocked( isChecked() ); super.run(); } } eclox/eclox.ui/src/eclox/ui/console/Console.java 0000644 0000764 0000764 00000007360 12166012446 021245 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013 Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.console; import java.util.HashMap; import java.util.Map; import org.eclipse.ui.console.AbstractConsole; import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.IConsole; import org.eclipse.ui.console.IConsoleManager; import org.eclipse.ui.console.IConsoleView; import org.eclipse.ui.part.IPageBookViewPage; import eclox.core.doxygen.BuildJob; import eclox.core.doxygen.IBuildJobListener; /** * Implements the doxygen output console * * @author Guillaume Brocker */ public class Console extends AbstractConsole { /** * @brief Implements a build job listener. */ private class MyBuildJobListener implements IBuildJobListener { /** * @see eclox.core.doxygen.IBuildJobListener#buildJobLogCleared(eclox.core.doxygen.BuildJob) */ public void buildJobLogCleared(BuildJob job) {} /** * @see eclox.core.doxygen.IBuildJobListener#buildJobLogUpdated(eclox.core.doxygen.BuildJob, java.lang.String) */ public void buildJobLogUpdated(BuildJob job, String output) {} /** * @see eclox.core.doxygen.IBuildJobListener#buildJobRemoved(eclox.core.doxygen.BuildJob) */ public void buildJobRemoved(BuildJob job) { final BuildJob localJob = job; ConsolePlugin.getStandardDisplay().asyncExec( new Runnable() { public void run() { remove(localJob); } } ); } } private static Map consoles = new HashMap(); ///< Holds all known console instances. private BuildJob job; ///< the build job /** * Constructor * * @param job the build job whose output must be shown */ private Console(BuildJob job) { super( job.getName(), null ); this.job = job; this.job.addBuidJobListener(new MyBuildJobListener()); } /** * @see org.eclipse.ui.console.IConsole#createPage(org.eclipse.ui.console.IConsoleView) */ public IPageBookViewPage createPage(IConsoleView view) { return new ConsolePage(this); } /** * @see org.eclipse.ui.console.AbstractConsole#dispose() */ protected void dispose() { consoles.remove(job); super.dispose(); } /** * @see org.eclipse.ui.console.AbstractConsole#init() */ protected void init() { consoles.put(job, this); super.init(); } /** * Retrieves the job currently monitored by the console * * @return a build job or null if none */ public BuildJob getJob() { return job; } /** * Shows a console for the given job. * * @param job a build that needs a console to be shown */ static public void show( BuildJob job ) { // Retrieves the active workbench window and console manager. IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager(); Console console = null; if( consoles.containsKey(job) ) { console = (Console) consoles.get(job); } else { console = new Console(job); consoleManager.addConsoles( new IConsole[] {console} ); } // Shows the console view. console.activate(); } /** * Removes the console for the given build job. * * @param job a build job */ public static void remove(BuildJob job) { if( consoles.containsKey(job) ) { Console console = (Console) consoles.get(job); ConsolePlugin.getDefault().getConsoleManager().removeConsoles( new IConsole[] {console} ); } } } eclox/eclox.ui/src/eclox/ui/editor/ 0000755 0000764 0000764 00000000000 12166321432 016614 5 ustar willy willy eclox/eclox.ui/src/eclox/ui/editor/Location.java 0000644 0000764 0000764 00000003143 12166012446 021232 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor; import org.eclipse.ui.IMemento; import org.eclipse.ui.INavigationLocation; import org.eclipse.ui.NavigationLocation; /** * Implements the navigation location used for the doxyfile editor. * * @author Guillaume Brocker */ public class Location extends NavigationLocation { private final String PAGE_KEY = "page"; private final String SETTING_KEY = "setting"; private String page; private String setting; public Location( Editor editor ) { super( editor ); this.page = editor.getActivePageInstance().getId(); } public boolean mergeInto(INavigationLocation currentLocation) { // TODO Auto-generated method stub return false; } public void restoreLocation() { // TODO Auto-generated method stub } public void restoreState(IMemento memento) { page = memento.getString(PAGE_KEY); setting = memento.getString(SETTING_KEY); } public void saveState(IMemento memento) { memento.putString(PAGE_KEY, page); memento.putString(SETTING_KEY, setting); } public void update() { // TODO Auto-generated method stub } } eclox/eclox.ui/src/eclox/ui/editor/internal/ 0000755 0000764 0000764 00000000000 12166321432 020430 5 ustar willy willy eclox/eclox.ui/src/eclox/ui/editor/internal/ResourceChangeListener.java 0000644 0000764 0000764 00000004035 12166012446 025702 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2006, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.internal; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.IResourceDelta; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IFileEditorInput; import eclox.ui.editor.Editor; /** * Implements a resource change listener that will trigger relevant actions * on the given editor when its input gets updated. * * @author Guillaume Brocker */ public class ResourceChangeListener implements IResourceChangeListener { /** * a reference on the editor to manage */ private Editor editor; /** * Constructor * * @param editor the editor to manage */ public ResourceChangeListener( Editor editor ) { this.editor = editor; } public void resourceChanged(IResourceChangeEvent event) { IEditorInput editorInput = editor.getEditorInput(); IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput; IFile editorFile = fileEditorInput.getFile(); IResourceDelta doxyfileDelta = event.getDelta().findMember( editorFile.getFullPath() ); if( doxyfileDelta != null && doxyfileDelta.getKind() == IResourceDelta.REMOVED ) { closeEditor(); } } /** * Closes the editor. */ private void closeEditor() { editor.getSite().getShell().getDisplay().asyncExec( new Runnable() { public void run() { editor.getSite().getPage().closeEditor( editor, false ); } } ); } } eclox/eclox.ui/src/eclox/ui/editor/Page.java 0000644 0000764 0000764 00000001600 12166012446 020332 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor; import org.eclipse.ui.forms.editor.FormPage; import eclox.core.doxyfiles.Setting; public abstract class Page extends FormPage { public Page( Editor editor, String id, String title ) { super(editor, id, title); } public abstract Setting getCurrentSetting(); public abstract void setCurrentSetting( Setting setting ); } eclox/eclox.ui/src/eclox/ui/editor/Editor.java 0000644 0000764 0000764 00000015433 12166012446 020715 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2006, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor; import java.util.Iterator; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IMemento; import org.eclipse.ui.IPersistableEditor; import org.eclipse.ui.forms.editor.FormEditor; import eclox.core.doxyfiles.Doxyfile; import eclox.core.doxyfiles.ISettingValueListener; import eclox.core.doxyfiles.Setting; import eclox.core.doxyfiles.io.Serializer; import eclox.ui.editor.internal.ResourceChangeListener; /** * Implements the doxyfile editor. * * @author gbrocker */ /** * @author willy * */ public class Editor extends FormEditor implements ISettingValueListener, IPersistableEditor { public final static String PROP_SETTING_DIRTY = "dirty"; ///< the name of the property attached to a dirty setting. public final static String SAVED_ACTIVE_PAGE_ID = "SavedActivePageId"; ///< Identifies the memo entry containing the identifier if the saved active page identifier. private Doxyfile doxyfile; ///< The doxyfile content. private ResourceChangeListener resourceChangeListener; ///< the resource listener that will manage the editor life-cycle private boolean dirty = false; ///< The dirty state of the editor private IMemento savedState; ///< References a saved state to restore, null otherwise. /** * @see org.eclipse.ui.forms.editor.FormEditor#addPages() */ protected void addPages() { try { addPage(new eclox.ui.editor.basic.Page(this)); addPage(new eclox.ui.editor.advanced.Page(this)); // TODO reactivate //this.addPage(new SourcePage(this)); // Restores the saved active page. String savedPageId = (savedState != null) ? savedState.getString(SAVED_ACTIVE_PAGE_ID) : null; setActivePage(savedPageId); } catch( Throwable throwable ) {} } /** * @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor) */ public void doSave( IProgressMonitor monitor ) { // Retrieves the file input. IEditorInput editorInput = this.getEditorInput(); IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput; IFile file = fileEditorInput.getFile(); try { // Commits all pending changes. commitPages(true); // Stores the doxyfile content. Serializer serializer = new Serializer( doxyfile ); file.setContents( serializer, false, true, monitor ); // Clears the dirty property set on some settings. Iterator i = doxyfile.settingIterator(); while( i.hasNext() ) { Setting setting = (Setting) i.next(); setting.removeProperty( PROP_SETTING_DIRTY ); } // Resets the dirty flag. this.dirty = false; this.firePropertyChange( IEditorPart.PROP_DIRTY ); } catch( Throwable throwable ) { MessageDialog.openError(getSite().getShell(), "Unexpected Error", throwable.toString()); } } /** * @see org.eclipse.ui.ISaveablePart#doSaveAs() */ public void doSaveAs() { // TODO implement "save as" } /** * Retrieves the doxyfile attached to the editor. * * @return a doxyfile instance */ public Doxyfile getDoxyfile() { return this.doxyfile; } /** * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed() */ public boolean isSaveAsAllowed() { // TODO implement "save as" return false; } /** * @see eclox.doxyfiles.ISettingListener#settingValueChanged(eclox.doxyfiles.Setting) */ public void settingValueChanged( Setting setting ) { // Updates the internal editor state. this.dirty = true; this.firePropertyChange( IEditorPart.PROP_DIRTY ); // Assigns a dynamic property to the setting. setting.setProperty( PROP_SETTING_DIRTY, "yes" ); } /** * @see org.eclipse.ui.IWorkbenchPart#dispose() */ public void dispose() { // Unregisters the editor from the settings Iterator i = this.doxyfile.settingIterator(); while( i.hasNext() == true ) { Setting setting = (Setting) i.next(); setting.removeSettingListener( this ); } // Un-references the doxyfile. this.doxyfile = null; // Detaches the resource change listener ResourcesPlugin.getWorkspace().removeResourceChangeListener( resourceChangeListener ); resourceChangeListener = null; // Continue... super.dispose(); } /** * @see org.eclipse.ui.ISaveablePart#isDirty() */ public boolean isDirty() { return super.isDirty() || this.dirty; } /** * @see org.eclipse.ui.IPersistableEditor#restoreState(org.eclipse.ui.IMemento) */ public void restoreState(IMemento memento) { savedState = memento; } /** * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento) */ public void saveState(IMemento memento) { memento.putString(SAVED_ACTIVE_PAGE_ID, getActivePageInstance().getId()); } /** * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput) */ protected void setInput(IEditorInput input) { super.setInput(input); try { IFileEditorInput fileInput = (IFileEditorInput) input; // Attaches the resource change listener resourceChangeListener = new ResourceChangeListener(this); ResourcesPlugin.getWorkspace().addResourceChangeListener( resourceChangeListener ); // Parses the doxyfile and attaches to all settings. this.doxyfile = new Doxyfile( fileInput.getFile() ); Iterator i = this.doxyfile.settingIterator(); while( i.hasNext() == true ) { Setting setting = (Setting) i.next(); setting.addSettingListener( this ); } // Continue initialization. setPartName( input.getName() ); } catch( Throwable throwable ) { MessageDialog.openError(getSite().getShell(), "Unexpected Error", throwable.toString()); } } } eclox/eclox.ui/src/eclox/ui/editor/editors/ 0000755 0000764 0000764 00000000000 12166321432 020265 5 ustar willy willy eclox/eclox.ui/src/eclox/ui/editor/editors/CheckBoxEditor.java 0000644 0000764 0000764 00000010464 12166012446 023774 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2008, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.editors; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; /** * @author gbrocker * */ public class CheckBoxEditor extends SettingEditor { /** * Implements a selection listener for the button */ private class MySelectionListener implements SelectionListener { public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } public void widgetSelected(SelectionEvent e) { dirty = true; fireEditorChanged(); commit(); } } private static String YES = "YES"; ///< Defines the yes setting value private static String NO = "NO"; ///< Defines the no setting value private String text; ///< the text of the check box button private Button button; ///< the check box button private boolean dirty = false; ///< the current dirty state /** * Constructor * * @param text the text to set along to the check box button */ public CheckBoxEditor( String text ) { this.text = new String(text); } /** * @see eclox.ui.editor.editors.IEditor#commit() */ public void commit() { if( hasInput() ) { getInput().setValue( getSelection() ); dirty = false; fireEditorChanged(); } } /** * @see eclox.ui.editor.editors.IEditor#createContent(org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit) */ public void createContent(Composite parent, FormToolkit formToolkit) { // Pre-condition assert button == null; button = formToolkit.createButton(parent, text, SWT.CHECK); button.addSelectionListener(new MySelectionListener()); parent.setLayout(new FillLayout() ); // Post-condition assert button != null; } /** * @see eclox.ui.editor.editors.IEditor#dispose() */ public void dispose() { // Pre-condition assert button != null; button.dispose(); button = null; super.dispose(); } /** * @see eclox.ui.editor.editors.IEditor#grabVerticalSpace() */ public boolean grabVerticalSpace() { return false; } /** * Retrieves the current value of the editor. * * @return the current value of the editor */ public boolean getValue() { // Pre-condition assert button != null; return button.getSelection(); } /** * @see eclox.ui.editor.editors.IEditor#isDirty() */ public boolean isDirty() { return dirty; } /** * @see eclox.ui.editor.editors.IEditor#isStale() */ public boolean isStale() { boolean result = false; if( hasInput() ) { result = getSelection().equalsIgnoreCase(getInput().getValue()) == false; } return result; } /** * @see eclox.ui.editor.editors.IEditor#refresh() */ public void refresh() { // Pre-condition assert getInput() != null; assert button != null; assert button.isDisposed() == false; if( hasInput() ) { // Updates the button state. button.setSelection( getInput().getValue().equalsIgnoreCase(YES) ); fireEditorChanged(); } } /** * @see eclox.ui.editor.editors.IEditor#setEnabled(boolean) */ public void setEnabled(boolean enabled) { // Pre-condition assert button != null; button.setEnabled(enabled); } /** * @see eclox.ui.editor.editors.IEditor#setFocus() */ public void setFocus() { // Pre-condition assert button != null; assert button.isDisposed() == false; button.setFocus(); } /** * Retrieves the current value selected in the user interface button. * * @return a string containing the selected value */ private String getSelection() { // Pre-condition assert button != null; assert button.isDisposed() == false; return button.getSelection() == true ? YES : NO; } } eclox/eclox.ui/src/eclox/ui/editor/editors/TextListEditor.java 0000644 0000764 0000764 00000003256 12166012446 024067 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2006, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.editors; import org.eclipse.jface.dialogs.IInputValidator; import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.swt.widgets.Shell; import eclox.core.doxyfiles.Setting; /** * Implements a list editor that handle value compounds as simple text * * @author gbrocker */ public class TextListEditor extends ListEditor { /** * Implements an input validator for the input dialog used to edit value compunds. */ private class MyInputValidator implements IInputValidator { public String isValid(String newText) { if( newText.length() == 0 ) { return "Empty value is not allowed."; } else { return null; } } } protected String editValueCompound(Shell parent, Setting setting, String compound) { // Creates the edition dialog. InputDialog dialog = new InputDialog( parent, "Value Edition", "Enter the new text for the value.", Convenience.unescapeValue( compound ), new MyInputValidator() ); // Lauches the value edition if( dialog.open() == InputDialog.OK ) { return Convenience.escapeValue( dialog.getValue() ); } else { return null; } } } eclox/eclox.ui/src/eclox/ui/editor/editors/TextEditor.java 0000644 0000764 0000764 00000010545 12166012446 023232 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2008, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.editors; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.widgets.FormToolkit; /** * Implements a simple setting editor. * * @author gbrocker */ public class TextEditor extends SettingEditor { /** * Defines a modify listener class. */ private class TextModifyListener implements ModifyListener { /** * Tells if the listener should sleep (ignore notifications). */ public boolean sleeping = true; public void modifyText(ModifyEvent e) { if(sleeping == false) { hasChanged = true; fireEditorChanged(); commit(); } } }; /** * The text widget. */ protected Text text; /** * The current modification listener of the text control */ private TextModifyListener textModifyListener = new TextModifyListener(); /** * Remerbers if the text has changed. */ private boolean hasChanged = false; /** * @see eclox.ui.editor.editors.IEditor#commit() */ public void commit() { if( hasInput() ) { getInput().setValue( text.getText() ); hasChanged = false; fireEditorChanged(); } } /** * @see eclox.ui.editor.editors.IEditor#createContent(org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit) */ public void createContent( Composite parent, FormToolkit formToolkit ) { // Activates border painting. formToolkit.paintBordersFor( parent ); // Prepere the parent's layout. GridLayout layout = new GridLayout(); layout.marginTop = 0; layout.marginLeft = 0; layout.marginBottom = 0; layout.marginRight = 0; layout.marginHeight = 2; layout.marginWidth = 1; layout.horizontalSpacing = 5; parent.setLayout( layout ); // Creates the text widget. text = formToolkit.createText(parent, new String()); text.setLayoutData( new GridData(GridData.FILL_HORIZONTAL|GridData.VERTICAL_ALIGN_CENTER) ); text.addModifyListener( textModifyListener ); } /** * @see eclox.ui.editor.editors.IEditor#grabVerticalSpace() */ public boolean grabVerticalSpace() { return false; } /** * @see eclox.ui.editor.editors.IEditor#dispose() */ public void dispose() { text.dispose(); } /** * @see eclox.ui.editor.editors.IEditor#isDirty() */ public boolean isDirty() { return hasChanged; } /** * @see eclox.ui.editor.editors.IEditor#isStale() */ public boolean isStale() { boolean result = false; if( hasInput() ) { result = text.getText().equals( getInput().getValue() ) == false; } return result; } /** * @see eclox.ui.editor.editors.IEditor#refresh() */ public void refresh() { if( hasInput() ) { textModifyListener.sleeping = true; text.setText( getInput().getValue() ); hasChanged = false; textModifyListener.sleeping = false; fireEditorChanged(); } } /** * @see eclox.ui.editor.editors.IEditor#setEnabled(boolean) */ public void setEnabled(boolean enabled) { // pre-condition assert text != null; text.setEnabled(enabled); } /** * @see eclox.ui.editor.editors.IEditor#setFocus() */ public void setFocus() { text.selectAll(); text.setFocus(); } /** * @see eclox.ui.editor.editors.SettingEditor#setInput(eclox.core.doxyfiles.Setting) */ // public void setInput(Setting input) { // super.setInput(input); // // if( hasInput() ) { // textModifyListener.sleeping = true; // text.setText(input.getValue()); // textModifyListener.sleeping = false; // hasChanged = false; // } // } } eclox/eclox.ui/src/eclox/ui/editor/editors/Convenience.java 0000644 0000764 0000764 00000022662 12166012446 023376 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003, 2006, 2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.editors; import java.io.File; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IInputValidator; import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Shell; import eclox.core.doxyfiles.Doxyfile; import eclox.ui.IPreferences; import eclox.ui.Plugin; /** * Implements convenience methods for setting editors. * * @author gbrocker */ public final class Convenience { /** * Implements a specialized input dialog that adds buttons for browsing * workspace or file system for paths. */ private static class PathInputDialog extends InputDialog { /** * Implements an input validator for the input dialog used to edit value compunds. */ private static class MyInputValidator implements IInputValidator { public String isValid(String newText) { if( newText.length() == 0 ) { return "Empty value is not allowed."; } else { return null; } } } private final static int BROWSE_FILESYSTEM_FILE_ID = IDialogConstants.CLIENT_ID + 3; private final static int BROWSE_FILESYSTEM_DIRECTORY_ID = IDialogConstants.CLIENT_ID + 4; private Doxyfile doxyfile; private int styles; /** * Constructor * * @param shell the parent shell * @param doxyfile the reference doxyfile * @param initValue the initial value * @param styles a combination of browse facility flags */ public PathInputDialog( Shell shell, Doxyfile doxyfile, String initValue, int styles ) { super( shell, "Value Edition", "Edit the path. You may use buttons bellow to browse for a path.", initValue, new MyInputValidator() ); this.doxyfile = doxyfile; this.styles = styles; } protected void createButtonsForButtonBar(Composite parent) { // Create additionnal buttons. if( (styles & BROWSE_FILESYSTEM_FILE) != 0 ) { createButton( parent, BROWSE_FILESYSTEM_FILE_ID, "Browse File...", false ); } if( (styles & BROWSE_FILESYSTEM_DIRECTORY) != 0 ) { createButton( parent, BROWSE_FILESYSTEM_DIRECTORY_ID, "Browse Directory...", false ); } // Create default buttons. super.createButtonsForButtonBar(parent); } protected void buttonPressed(int buttonId) { // Retrieves the path if one of the browse buttons is pressed. String path = null; switch( buttonId ) { case BROWSE_FILESYSTEM_DIRECTORY_ID: path = Convenience.browseFileSystemForDirectory( getShell(), doxyfile, getText().getText() ); break; case BROWSE_FILESYSTEM_FILE_ID: path = Convenience.browseFileSystemForFile( getShell(), doxyfile, getText().getText() ); break; default: super.buttonPressed(buttonId); } // Updates the input text if a path has been retrieved. if( path != null ) { getText().setText( path ); } } } /** * flag that activates the facility to browse for a file system file */ public static final int BROWSE_FILESYSTEM_FILE = 1; /** * flag that activates the facility to browse for a file system directory */ public static final int BROWSE_FILESYSTEM_DIRECTORY = 2; /** * flag that activates the facility to browse for a workspace or file system path */ public static final int BROWSE_ALL = BROWSE_FILESYSTEM_FILE|BROWSE_FILESYSTEM_DIRECTORY; /** * @brief Retrieves a path from the user that will be relative to the given doxyfile. * * @param shell the parent shell * @param doxyfile the reference doxyfile * @param initPath the initial path (may relative to the given doxyfile or absolute) * @param style a combination of flags to tell which browse facilities will be available * * @return a string containing the path entered by the user or null if none */ public static String browserForPath( Shell shell, Doxyfile doxyfile, String initPath, int style ) { PathInputDialog dialog = new PathInputDialog( shell, doxyfile, initPath, style ); if( dialog.open() == PathInputDialog.OK ) { return dialog.getValue(); } else { return null; } } /** * Browses the file system for a file and retrieves a path in the file system that * may be relative to the given doxyfile's path * * @param shell a shell that will be the parent of dialogs * @param doxyfile a doxyfile that is the reference for relative paths * @param path a string containing an initial path * * @return a string containing the browsed path, or null if none */ public static String browseFileSystemForFile( Shell shell, Doxyfile doxyfile, String path ) { // Retrieves the initial path. IPath initialPath = new Path( path ); if( initialPath.isAbsolute() == false ) { initialPath = doxyfile.getFile().getParent().getLocation().append( initialPath ); } // If the initial path is not valid, use the doxyfile location as fall back. File file = new File( initialPath.toOSString() ); if( file.exists() == false ) { initialPath = doxyfile.getFile().getParent().getLocation(); } // Displays the directory dialog to the user FileDialog dialog = new FileDialog( shell ); String choosenPathString; dialog.setText( "File System File Selection" ); dialog.setFilterPath( initialPath.toOSString() ); choosenPathString = dialog.open(); // Parses the result. if( choosenPathString != null ) { IPath choosenPath = Path.fromOSString( choosenPathString ); IPath finalPath = doxyfile.makePathRelative( choosenPath ); return finalPath.toOSString(); } else { return null; } } /** * Browses the file system for a directory and retrieves a path in the file system that * may be relative to the given doxyfile's path. * * @param shell a shell that will be the parent of dialogs * @param doxyfile a doxyfile that is the reference for relative paths * @param path a string containing an initial path * * @return a string containing the browsed path, or null if none */ public static String browseFileSystemForDirectory( Shell shell, Doxyfile doxyfile, String path ) { // Retrieves the initial path. IPath initialPath = new Path( path ); if( initialPath.isAbsolute() == false ) { initialPath = doxyfile.getFile().getParent().getLocation().append( initialPath ); } // If the initial path is not valid, use the doxyfile location as fall back. File file = new File( initialPath.toOSString() ); if( file.exists() == false ) { initialPath = doxyfile.getFile().getParent().getLocation(); } // Displays the directory dialog to the user DirectoryDialog dialog = new DirectoryDialog( shell ); String choosenPathString; dialog.setText( "File System Directory Selection" ); dialog.setFilterPath( initialPath.toOSString() ); choosenPathString = dialog.open(); // Parses the result. if( choosenPathString != null ) { IPath choosenPath = Path.fromOSString( choosenPathString ); IPath finalPath = doxyfile.makePathRelative( choosenPath ); return finalPath.toOSString(); } else { return null; } } /** * Escapes the given value string. This will place back slashes before * any backslash or double quote. * * @param value the value string to escape * * @return the escaped value string * * @see unescapeValue */ public static String escapeValue( String value ) { String result = value; if( Plugin.getDefault().getPluginPreferences().getBoolean(IPreferences.HANDLE_ESCAPED_VALUES) == true ) { result = replace( result, "\\", "\\\\" ); // Replaces all \ by \\ result = replace( result, "\"", "\\\"" ); // Replaces all " by \" } return result; } /** * Un-escapes the given value string. This will remove escape backslashes * located before backslashes and double quotes. * * @param value the value string to un-escape * * @return the escaped value string * * @see escapeValue */ public static String unescapeValue( String value ) { String result = value; if( Plugin.getDefault().getPluginPreferences().getBoolean(IPreferences.HANDLE_ESCAPED_VALUES) == true ) { result = replace( result, "\\\"", "\"" ); // Replaces all \" by " result = replace( result, "\\\\", "\\" ); // Replaces all \\ by \ } return result; } /** * In the given string, replaces all matching substring by the given replacement. * * @param string the string to update * @param search the sub string to search and replace * @param replace the string to place where search matches * * @return the resulting string */ public static String replace( String string, String search, String replace ) { StringBuffer buffer = new StringBuffer( string ); for( int i = buffer.indexOf(search); i != -1; i = buffer.indexOf(search, i+replace.length()) ) { buffer = buffer.replace( i, i + search.length(), replace ); } return buffer.toString(); } } eclox/eclox.ui/src/eclox/ui/editor/editors/DirectoryEditor.java 0000644 0000764 0000764 00000006010 12166012446 024242 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2006, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.editors; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; /** * Implements a setting editor that allows to browse for directories * either in the workspace or in the file system. * * @author gbrocker */ /** * @author gbrocker * */ public class DirectoryEditor extends TextEditor { /** * the push button for browsing the file system */ private Button browseFileSystemButton; /** * Implements the selection listener attached to the push buttons. */ class MySelectionListener implements SelectionListener { /** * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetDefaultSelected(SelectionEvent e) { if( e.widget == browseFileSystemButton ) { browseFileSystem(); } } /** * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent e) { if( e.widget == browseFileSystemButton ) { browseFileSystem(); } } } public void createContent(Composite parent, FormToolkit formToolkit) { super.createContent(parent, formToolkit); // Create controls and their associated layout data. SelectionListener selectionListener = new MySelectionListener(); GridLayout layout = (GridLayout) parent.getLayout(); layout.numColumns = 2; browseFileSystemButton = formToolkit.createButton( parent, "Browse...", 0 ); browseFileSystemButton.addSelectionListener( selectionListener ); } /** * @see eclox.ui.editor.editors.TextEditor#dispose() */ public void dispose() { // Local cleaning. browseFileSystemButton.dispose(); // Default cleaning. super.dispose(); } /** * Browses the file system for a path and updates the managed text field. */ private void browseFileSystem() { String result; result = Convenience.browseFileSystemForDirectory( text.getShell(), getInput().getOwner(), getInput().getValue() ); if( result!= null ) { super.text.setText( result ); } } /** * @see eclox.ui.editor.editors.TextEditor#setEnabled(boolean) */ public void setEnabled(boolean enabled) { assert browseFileSystemButton != null; browseFileSystemButton.setEnabled(enabled); super.setEnabled(enabled); } } eclox/eclox.ui/src/eclox/ui/editor/editors/AbstractEditor.java 0000644 0000764 0000764 00000003117 12166012446 024046 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.editors; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; /** * Implements the IEditor for all listener management and notification * aspects * * @author Guillaume Brocker */ public abstract class AbstractEditor implements IEditor { /** * the registery of listeners */ private Collection listeners = new HashSet(); /** * @see eclox.ui.editor.editors.IEditor#addListener(eclox.ui.editor.editors.IEditorListener) */ public void addListener(IEditorListener listener) { listeners.add(listener); } /** * @see eclox.ui.editor.editors.IEditor#removeListener(eclox.ui.editor.editors.IEditorListener) */ public void removeListener(IEditorListener listener) { listeners.remove(listener); } /** * Notifies registered listeners that the dirty state of the editor changed. */ protected void fireEditorChanged() { Iterator i = listeners.iterator(); while( i.hasNext() ) { IEditorListener listener = (IEditorListener) i.next(); listener.editorChanged(this); } } } eclox/eclox.ui/src/eclox/ui/editor/editors/BooleanEditor.java 0000644 0000764 0000764 00000014644 12166012446 023671 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2008, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.editors; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; /** * Implements an setting editor for boolean values * * @author gbrocker */ public class BooleanEditor extends SettingEditor { private static String YES = "YES"; ///< the yes selection value private static String NO = "NO"; ///< the no selection value private Button yesButton; ///< the yes button private Button noButton; ///< the no button private Button defaultButton; ///< the default button private boolean isDirty = false; ///< a boolean telling if the editor is dirty or not /** * @brief Implements a selection listener that will be attached to each button. */ private class MySelectionListener implements SelectionListener { /** * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetDefaultSelected(SelectionEvent e) { isDirty = true; fireEditorChanged(); commit(); } /** * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent e) { isDirty = true; fireEditorChanged(); commit(); } } /** * @see eclox.ui.editor.editors.IEditor#commit() */ public void commit() { if( hasInput() ) { getInput().setValue(getSelection()); isDirty = false; fireEditorChanged(); } } /** * @see eclox.ui.editor.editors.IEditor#createContent(org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit) */ public void createContent(Composite parent, FormToolkit formToolkit) { // Initialize the parent control. RowLayout layout = new RowLayout(SWT.VERTICAL); layout.marginWidth = 0; parent.setLayout( layout ); // Creates the buttons. yesButton = formToolkit.createButton( parent, "Yes", SWT.RADIO ); noButton = formToolkit.createButton( parent, "No", SWT.RADIO ); defaultButton = formToolkit.createButton( parent, "Default", SWT.RADIO ); // Attaches a selection listener instance to each button. yesButton.addSelectionListener( new MySelectionListener() ); noButton.addSelectionListener( new MySelectionListener() ); defaultButton.addSelectionListener( new MySelectionListener() ); } /** * @see eclox.ui.editor.editors.IEditor#grabVerticalSpace() */ public boolean grabVerticalSpace() { return false; } /** * @see eclox.ui.editor.editors.IEditor#dispose() */ public void dispose() { // Pre-condition assert yesButton != null; assert noButton != null; assert defaultButton != null; // Release all resources. yesButton.dispose(); noButton.dispose(); defaultButton.dispose(); yesButton = null; noButton = null; defaultButton = null; super.dispose(); } /** * @see eclox.ui.editor.editors.IEditor#isDirty() */ public boolean isDirty() { return isDirty; } /** * @see eclox.ui.editor.editors.IEditor#isStale() */ public boolean isStale() { boolean result = false; if( hasInput() ) { result = getSelection().equalsIgnoreCase(getInput().getValue()) == false; } return result; } /** * @see eclox.ui.editor.editors.IEditor#refresh() */ public void refresh() { // Pre-condition assert yesButton != null; assert noButton != null; assert defaultButton != null; if( hasInput() ) { this.isDirty = false; String value = getInput().getValue(); yesButton.setSelection ( value.compareToIgnoreCase(YES) == 0 ); noButton.setSelection ( value.compareToIgnoreCase(NO) == 0 ); defaultButton.setSelection ( value.length() == 0 ); fireEditorChanged(); } } /** * @see eclox.ui.editor.editors.IEditor#setEnabled(boolean) */ public void setEnabled(boolean enabled) { // Pre-condition assert yesButton != null; assert noButton != null; assert defaultButton != null; yesButton.setEnabled(enabled); noButton.setEnabled(enabled); defaultButton.setEnabled(enabled); } /** * @see eclox.ui.editor.editors.IEditor#setFocus() */ public void setFocus() { // Pre-condition assert yesButton != null; assert noButton != null; assert defaultButton != null; Button selectedButton = null; if( yesButton.getSelection() == true ) { selectedButton = yesButton; } else if( noButton.getSelection() == true ) { selectedButton = noButton; } else if( defaultButton.getSelection() == true ) { selectedButton = defaultButton; } else { assert false; // What's wrong? } selectedButton.setFocus(); } /** * Retrieves the selected value from the ui controls * * @return a string containing the selected value */ private String getSelection() { // Pre-condition assert yesButton != null; assert noButton != null; assert defaultButton != null; if( yesButton.getSelection() == true ) { return new String(YES); } else if( noButton.getSelection() == true ) { return new String(NO); } else if( defaultButton.getSelection() == true ) { return new String(); } else { assert false; // What's going on ? return new String(); } } } eclox/eclox.ui/src/eclox/ui/editor/editors/IEditor.java 0000644 0000764 0000764 00000004743 12166012446 022501 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.editors; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; /** * Defines the interface of doxyfile editors. * * @author gbrocker */ public interface IEditor { /** * Adds the given listener to the collectgion of listener who will be notified * when the editor gets changed. * * @param listener the listener to register * * @see removeListener */ void addListener( IEditorListener listener ); /** * Commits any changes made in the editor. */ public void commit(); /** * Creates the editor contents. * * @param parent the composite control that will contain the editor controls * @param formToolkit the form toolkit to use for the control creation */ void createContent(Composite parent, FormToolkit formToolkit); /** * Asks the editor if it wants to grow vertically to grad all available space. * * @return a boolean telling if the editor wants to grab the available vertical space */ boolean grabVerticalSpace(); /** * Asks the editor to dispose its controls. */ void dispose(); /** * Tells if the editor is dirty. * * @return true or false */ public boolean isDirty(); /** * Tells if the editor is stale, after the underlying setting has changed. * * @return true or false */ public boolean isStale(); /** * Refreshes the editor if is stale. The editor is expected to updates * its state using the data of the underlying model. */ public void refresh(); /** * Removes the given listener from the collection of registered listeners. * * @param listener the listener to un-register * * @see addListener */ public void removeListener( IEditorListener listener ); /** * Enables or disables the receiver. * * @param enabled the new enabled state */ void setEnabled(boolean enabled); /** * Makes the editor installs the focus on the right widget. */ void setFocus(); } eclox/eclox.ui/src/eclox/ui/editor/editors/IEditorListener.java 0000644 0000764 0000764 00000001635 12166012446 024204 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.editors; /** * Defines the interface for objects that want to receive notification * about changes of an editor. * * @author Guillaume Brocker */ public interface IEditorListener { /** * Notifies the receiver that the given editor's state changed. * * @param editor the editor that changed */ void editorChanged( IEditor editor ); } eclox/eclox.ui/src/eclox/ui/editor/editors/DirectoryListEditor.java 0000644 0000764 0000764 00000002011 12166012446 025073 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2006, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.editors; import org.eclipse.swt.widgets.Shell; import eclox.core.doxyfiles.Setting; /** * Implements a list editor that handle value compounds as direcoty paths. * * @author gbrocker */ public class DirectoryListEditor extends ListEditor { protected String editValueCompound( Shell parent, Setting setting, String compound ) { return Convenience.browserForPath( parent, setting.getOwner(), compound, Convenience.BROWSE_FILESYSTEM_DIRECTORY ); } } eclox/eclox.ui/src/eclox/ui/editor/editors/ListEditor.java 0000644 0000764 0000764 00000035671 12166012446 023230 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.editors; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.Vector; import org.eclipse.jface.viewers.IOpenListener; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.OpenEvent; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.forms.widgets.FormToolkit; import eclox.core.doxyfiles.Setting; /** * Implements a list setting editor. This class is abstract since it provides no way to * edit value compounds. See derived classes. * * @author gbrocker */ public abstract class ListEditor extends SettingEditor { /** * Implements the table viewer content provider. */ private class MyContentProvider implements IStructuredContentProvider { public Object[] getElements(Object inputElement) { Vector compounds = (Vector) inputElement; return compounds.toArray(); } public void dispose() {} public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} } /** * Implements the table viewer label provider. */ private class MyLabelProvider extends LabelProvider { public String getText(Object element) { return new String( (String)element ); } } /** * Implements an open listener that will trigger the edition of the selected list viewer item. */ private class MyOpenListener implements IOpenListener { public void open(OpenEvent event) { editSelectedValueCompound(); } } /** * Implements a button selection listener. */ private class MyButtonSelectionListener implements SelectionListener { public void widgetDefaultSelected(SelectionEvent e) { widgetSelected( e ); } public void widgetSelected(SelectionEvent e) { if( e.widget == addButton ) { addValueCompound(); } else if( e.widget == removeButton ) { removeValueCompounds(); } else if( e.widget == upButton ) { moveValueCompoundsUp(); } else if( e.widget == downButton ) { moveValueCompoundsDown(); } else { // Unsuported widget. assert false; } } } /** * Implements a selection change listener to update the button states. */ private class MySelectionChangedListener implements ISelectionChangedListener { public void selectionChanged(SelectionChangedEvent event) { updateButtons(); } } private Vector valueCompounds; ///< The collection of the setting's value compounds. private ListViewer listViewer; ///< the table viewer used to edit the managed setting private Button addButton; ///< the button allowing to trigger a new value addition private Button removeButton; ///< the button allowing to trigger the deletion of selected values private Button upButton; ///< the button allowing to move the selected values up private Button downButton; ///< the button allowing to move the selected values down /** * @see eclox.ui.editor.editors.IEditor#commit() */ public void commit() { if( hasInput() ) { getInput().setValue( valueCompounds ); fireEditorChanged(); } } /** * @see eclox.ui.editor.editors.IEditor#createContent(org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit) */ public void createContent(Composite parent, FormToolkit formToolkit) { // Pre-condition assert listViewer == null; // Activates border painting. formToolkit.paintBordersFor( parent ); // Installs the layout. FormLayout layout = new FormLayout(); layout.spacing = 2; parent.setLayout( layout ); // Creates the list viewer and installs it in the layout. FormData formData; listViewer = new ListViewer( parent, 0 ); formData = new FormData(); formData.top = new FormAttachment( 0, 2 ); formData.right = new FormAttachment( 85, -1 ); formData.bottom = new FormAttachment( 100, -2 ); formData.left = new FormAttachment( 0, 1 ); listViewer.getControl().setLayoutData( formData ); listViewer.getControl().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); // Initializes the list viewer. listViewer.setContentProvider( new MyContentProvider() ); listViewer.setLabelProvider( new MyLabelProvider() ); listViewer.addOpenListener( new MyOpenListener() ); // Creates various buttons and installs them in the layout. addButton = formToolkit.createButton( parent, "Add", 0 ); removeButton = formToolkit.createButton( parent, "Remove", 0 ); upButton = formToolkit.createButton( parent, "Up", 0 ); downButton = formToolkit.createButton( parent, "Down", 0 ); formData = new FormData(); formData.top = new FormAttachment( 0, 0 ); formData.right = new FormAttachment( 100, 0 ); formData.left = new FormAttachment( listViewer.getControl(), 2, SWT.RIGHT ); addButton.setLayoutData( formData ); formData = new FormData(); formData.top = new FormAttachment( addButton, 0, SWT.BOTTOM ); formData.right = new FormAttachment( 100, 0 ); formData.left = new FormAttachment( listViewer.getControl(), 2, SWT.RIGHT ); removeButton.setLayoutData( formData ); formData = new FormData(); formData.top = new FormAttachment( removeButton, 6, SWT.BOTTOM ); formData.right = new FormAttachment( 100, 0 ); formData.left = new FormAttachment( listViewer.getControl(), 2, SWT.RIGHT ); upButton.setLayoutData( formData ); formData = new FormData(); formData.top = new FormAttachment( upButton, 0, SWT.BOTTOM ); formData.right = new FormAttachment( 100, 0 ); formData.left = new FormAttachment( listViewer.getControl(), 2, SWT.RIGHT ); downButton.setLayoutData( formData ); // Assignes a selection listener to the managed buttons. MyButtonSelectionListener selectionListener = new MyButtonSelectionListener(); addButton.addSelectionListener( selectionListener ); removeButton.addSelectionListener( selectionListener ); upButton.addSelectionListener( selectionListener ); downButton.addSelectionListener( selectionListener ); // Adds a selection change listener to the list viewer and initializes the button states. listViewer.addPostSelectionChangedListener( new MySelectionChangedListener() ); updateButtons(); // Post-condition assert listViewer != null; } public boolean grabVerticalSpace() { return true; } public void dispose() { // Pre-condition assert listViewer != null; assert addButton != null; assert removeButton != null; assert upButton != null; assert downButton != null; listViewer.getControl().dispose(); listViewer = null; addButton.dispose(); addButton = null; removeButton.dispose(); removeButton = null; upButton.dispose(); upButton = null; downButton.dispose(); downButton = null; super.dispose(); // Post-condition assert listViewer == null; assert addButton == null; assert removeButton == null; assert upButton == null; assert downButton == null; } /** * @see eclox.ui.editor.editors.IEditor#setEnabled(boolean) */ public void setEnabled(boolean enabled) { // Pre-condition assert listViewer != null; assert addButton != null; assert removeButton != null; assert upButton != null; assert downButton != null; listViewer.getControl().setEnabled(enabled); addButton.setEnabled(enabled); removeButton.setEnabled(enabled); upButton.setEnabled(enabled); downButton.setEnabled(enabled); } /** * @see eclox.ui.editor.editors.IEditor#setFocus() */ public void setFocus() { // Pre-condition assert listViewer != null; listViewer.getControl().setFocus(); } /** * @see eclox.ui.editor.editors.IEditor#refresh() */ public void refresh() { // Pre-condition assert listViewer != null; if( hasInput() ) { valueCompounds = new Vector(); getInput().getSplittedValue( valueCompounds ); listViewer.setInput(valueCompounds); updateButtons(); fireEditorChanged(); } } /** * @see eclox.ui.editor.editors.IEditor#isDirty() */ public boolean isDirty() { return false; } /** * @see eclox.ui.editor.editors.IEditor#isStale() */ public boolean isStale() { boolean result = false; if( hasInput() ) { Collection values = new Vector(); getInput().getSplittedValue(values); result = valueCompounds.equals(values) == false; } return result; } /** * Edits the given value compound and returns the new comound value. * Null is interpreted as a canceled edition. * * Sub classes have to implement this method to provide a dialog to the user to do * the value compund edition. * * @param parent the parent shell that implementors may use as parent window for any dialog * @param setting the setting begin edited (it is just given as information and should be edited directly) * @param compound the value compund to edit * * @return a string containing the new compund value or null */ abstract protected String editValueCompound( Shell parent, Setting setting, String compound ); /** * Adds a new value compound. */ private void addValueCompound() { // Pre-condition assert listViewer != null; assert valueCompounds != null; // Edits a new value. String newCompound = editValueCompound( listViewer.getControl().getShell(), getInput(), "new value" ); // Inserts the new compound if it has been validated. if( newCompound != null ) { valueCompounds.add( newCompound ); fireEditorChanged(); commit(); listViewer.refresh(); listViewer.setSelection( new StructuredSelection(new Integer(valueCompounds.size() -1)) ); } } /** * Edits the value compound that is selected in the list viewer. * * @return true when a compound has been modified, false otherwise */ private boolean editSelectedValueCompound() { // Pre-condition assert listViewer != null; assert valueCompounds != null; // Retrieves and handles the selection. IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection(); String original = (String) selection.getFirstElement(); String edited = editValueCompound( listViewer.getControl().getShell(), getInput(), original ); // Processes the edited compound. if( edited != null ) { // Updates the setting. valueCompounds.set( valueCompounds.indexOf(original), edited ); fireEditorChanged(); // Commit changes and erstores the selection. listViewer.getControl().setRedraw( false ); commit(); listViewer.refresh(); listViewer.setSelection( new StructuredSelection(edited) ); listViewer.getControl().setRedraw( true ); // Job's done. return true; } else { return false; } } /** * Moves the value compounds corresponding to the current selection up. */ private void moveValueCompoundsUp() { // Pre-condition assert listViewer != null; assert valueCompounds != null; // Retrieves the current selection and skip if it is empty. IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection(); if( selection.isEmpty() == true ) { return; } // Retrieves the list of the selected items. Vector selected = new Vector(selection.toList()); Iterator i = valueCompounds.iterator(); while( i.hasNext() == true && selected.isEmpty() == false ) { Object current = i.next(); if( current.equals(selected.get(0)) ) { int index = valueCompounds.indexOf(current); if( index > 0 ) { Collections.swap(valueCompounds, index, index-1); } else { break; } selected.remove(0); } } fireEditorChanged(); // Commits changes and reselected moved objects. listViewer.getControl().setRedraw( false ); commit(); listViewer.refresh(); listViewer.getControl().setRedraw( true ); } /** * Moves the value compounds corresponding to the current selection down. */ private void moveValueCompoundsDown() { // Pre-condition assert listViewer != null; assert valueCompounds != null; // Retrieves the current selection and skip if it is empty. IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection(); if( selection.isEmpty() == true ) { return; } // Retrieves the list of the selected items. Vector selected = new Vector(selection.toList()); Collections.reverse( selected ); Collections.reverse(valueCompounds); // Retrieves the list of the selected items. Iterator i = valueCompounds.iterator(); while( i.hasNext() == true && selected.isEmpty() == false ) { Object current = i.next(); if( current.equals(selected.get(0)) ) { int index = valueCompounds.indexOf(current); if( index > 0 ) { Collections.swap(valueCompounds, index, index-1); } else { break; } selected.remove(0); } } Collections.reverse(valueCompounds); fireEditorChanged(); // Commits changes and reselected moved objects. listViewer.getControl().setRedraw( false ); commit(); listViewer.refresh(); listViewer.getControl().setRedraw( true ); } /** * Removes the selected value compounds. */ private void removeValueCompounds() { // Pre-condition assert listViewer != null; assert valueCompounds != null; // Retrieves the current selection and skip if it is empty. IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection(); if( selection.isEmpty() == true ) { return; } // Removes selected items from the value compounds. valueCompounds.removeAll( selection.toList() ); fireEditorChanged(); // Commits changes. commit(); listViewer.refresh(); } /** * Updates the state of some buttons. */ private void updateButtons() { // Pre-condition assert listViewer != null; assert removeButton != null; assert upButton != null; assert downButton != null; // Retrieves the selection emptiness and updates the buttons. boolean willBeEnabled = listViewer.getSelection().isEmpty() == false; removeButton.setEnabled( willBeEnabled ); upButton.setEnabled( willBeEnabled ); downButton.setEnabled( willBeEnabled ); } } eclox/eclox.ui/src/eclox/ui/editor/editors/SettingEditor.java 0000644 0000764 0000764 00000002446 12166012446 023724 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2008, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.editors; import eclox.core.doxyfiles.Setting; public abstract class SettingEditor extends AbstractEditor { private Setting input = null; ///< References the editor's input. /** * @see eclox.ui.editor.editors.IEditor#dispose() */ public void dispose() { input = null; } /** * Retrieves the editor input. * * @return the current input of the editor */ public Setting getInput() { return input; } /** * Tells if the editor has been assigned a setting. * * @return true or false */ public boolean hasInput() { return input != null; } /** * Sets the editor input. * * @param input the new input of the editor, null if none */ public void setInput(Setting input) { this.input = input; } } eclox/eclox.ui/src/eclox/ui/editor/editors/PathListEditor.java 0000644 0000764 0000764 00000001775 12166012446 024043 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2006, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.editors; import org.eclipse.swt.widgets.Shell; import eclox.core.doxyfiles.Setting; /** * Implements a list editor that handle value compounds as directory path or file path. * * @author gbrocker */ public class PathListEditor extends ListEditor { protected String editValueCompound(Shell parent, Setting setting, String compound) { return Convenience.browserForPath( parent, setting.getOwner(), compound, Convenience.BROWSE_ALL ); } } eclox/eclox.ui/src/eclox/ui/editor/editors/FileEditor.java 0000644 0000764 0000764 00000005506 12166012446 023166 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2006, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.editors; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; public class FileEditor extends TextEditor { /** * the push button for browsing the file system */ private Button browseFileSystemButton; /** * Implements the selection listener attached to the push buttons. */ class MySelectionListener implements SelectionListener { /** * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetDefaultSelected(SelectionEvent e) { if( e.widget == browseFileSystemButton ) { browseFileSystem(); } } /** * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent e) { if( e.widget == browseFileSystemButton ) { browseFileSystem(); } } } public void createContent(Composite parent, FormToolkit formToolkit) { super.createContent(parent, formToolkit); // Create controls and their associated layout data. SelectionListener selectionListener = new MySelectionListener(); GridLayout layout = (GridLayout) parent.getLayout(); layout.numColumns = 2; browseFileSystemButton = formToolkit.createButton( parent, "Browse...", 0 ); browseFileSystemButton.addSelectionListener( selectionListener ); } /** * @see eclox.ui.editor.editors.TextEditor#dispose() */ public void dispose() { // Local cleaning. browseFileSystemButton.dispose(); // Default cleaning. super.dispose(); } /** * Browses the file system for a path and updates the managed text field. */ private void browseFileSystem() { String result; result = Convenience.browseFileSystemForFile( text.getShell(), getInput().getOwner(), getInput().getValue() ); if( result!= null ) { super.text.setText( result ); } } /** * @see eclox.ui.editor.editors.TextEditor#setEnabled(boolean) */ public void setEnabled(boolean enabled) { assert browseFileSystemButton != null; browseFileSystemButton.setEnabled(enabled); super.setEnabled(enabled); } } eclox/eclox.ui/src/eclox/ui/editor/advanced/ 0000755 0000764 0000764 00000000000 12166321431 020360 5 ustar willy willy eclox/eclox.ui/src/eclox/ui/editor/advanced/filters/ 0000755 0000764 0000764 00000000000 12166321431 022030 5 ustar willy willy eclox/eclox.ui/src/eclox/ui/editor/advanced/filters/All.java 0000644 0000764 0000764 00000003611 12166012446 023407 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2005, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.advanced.filters; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.IManagedForm; import eclox.core.doxyfiles.Doxyfile; /** * Implements a setting filter that shows all settings. * * @author gbrocker */ public class All implements IFilter { /** * @see eclox.ui.editor.advanced.filters.IFilter#setDoxyfile(eclox.doxyfiles.Doxyfile) */ public void setDoxyfile(Doxyfile doxyfile) {} /** * @see eclox.ui.editor.advanced.filters.IFilter#createControls(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite) */ public void createControls(IManagedForm managedForm, Composite parent) {} /** * @see eclox.ui.editor.advanced.filters.IFilter#createViewerFilters(org.eclipse.jface.viewers.StructuredViewer) */ public void createViewerFilters(StructuredViewer viewer) {} /** * @see eclox.ui.editor.advanced.filters.IFilter#disposeControls() */ public void disposeControls() {} /** * @see eclox.ui.editor.advanced.filters.IFilter#disposeViewerFilers(org.eclipse.jface.viewers.StructuredViewer) */ public void disposeViewerFilers(StructuredViewer viewer) {} /** * @see eclox.ui.editor.advanced.filters.IFilter#getName() */ public String getName() { return "All"; } } eclox/eclox.ui/src/eclox/ui/editor/advanced/filters/IFilter.java 0000644 0000764 0000764 00000004125 12166012446 024236 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2005, 2013 Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.advanced.filters; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.IManagedForm; import eclox.core.doxyfiles.Doxyfile; /** * Defines the interface for setting filters. * * @author gbrocker */ public interface IFilter { /** * Tells the filter which doxyfile is to filter. * * @param doxyfile a doxyfile instance */ void setDoxyfile( Doxyfile doxyfile ); /** * Asks the filter to create its user interface controls. * * @param managedForm a managed form to use for the widget creation * @param parent a composite being the parent of all widgets */ void createControls( IManagedForm managedForm, Composite parent ); /** * Asks the filter to create viewer filter and add them in a given viewer * * @param viewer a viewer where filter must be added */ void createViewerFilters( StructuredViewer viewer ); /** * Asks the filter to dispose its controls. */ void disposeControls(); /** * Asks the filter to dispose created viewer filter given a viewer * * @param viewer a structured view from which created viewer filter must be removed */ void disposeViewerFilers( StructuredViewer viewer ); /** * Retrieves the filter name. * * This name must by human readable sinci it is used in the graphical * user interface. * * @return a string containing the filter name */ String getName(); } eclox/eclox.ui/src/eclox/ui/editor/advanced/filters/Custom.java 0000644 0000764 0000764 00000021750 12166012446 024155 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2005, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.advanced.filters; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.IManagedForm; import eclox.core.doxyfiles.Doxyfile; import eclox.core.doxyfiles.Setting; import eclox.ui.Images; import eclox.ui.Plugin; public class Custom implements IFilter { /** * the combo box containing the text used for the setting filtering */ private Combo combo; /** * the clear button */ private Button clearButton; /** * an array of strings containing the saved combo items */ private String[] savedComboItems = null; /** * a string containing the saved combo text */ private String savedComboText = new String(); /** * a string containing the text to use for filtering */ private String filterText; /** * the viewer being filtered */ private StructuredViewer viewer; /** * the viewer filter currently installed in the viewer to filter */ private MyViewerFiler viewerFilter; /** * Implements a timer task that will trigger the viewer refresh after * the user changed the custom filter text and update the items available * in the filter combo control. */ private class MyRunnable implements Runnable { private String referenceText; public MyRunnable( String referenceText ) { this.referenceText = new String( referenceText ); } public void run() { // Pre-condition assert combo != null; assert viewer != null; // Retrieves the combo text and checks that the user has not entered additionnal text. String comboText = combo.getText(); if( comboText.equalsIgnoreCase(referenceText) == false ) { return; } if( comboText.length() == 0 ) { combo.select( -1 ); } else { // Scans combo text items for the combo text. String comboItems[] = combo.getItems(); boolean found = false; for( int i = 0; i < comboItems.length; ++i ) { if( comboItems[i].equalsIgnoreCase(comboText) == true ) { found = true; break; } } if( found == false ) { combo.add( comboText, 0 ); } } // Refreshes the combo so the elements will be refiltered. viewer.refresh(); } }; /** * Implements a viewer filter that will search for setting matching the * string entered by the user in the combo control. */ private class MyViewerFiler extends ViewerFilter { /** * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ public boolean select(Viewer viewer, Object parentElement, Object element) { // Pre-condition assert element instanceof Setting; // Tests if the current setting matches the query string. if( filterText != null ) { Setting setting = (Setting) element; final String settingText = setting.getProperty(Setting.TEXT); return ( settingText != null ) && ( settingText.toLowerCase().indexOf(filterText.toLowerCase()) != -1 ); } else { return true; } } }; /** * Implements a combo modification listener that will trigger * the viewer refresh. */ private class MyComboModifyListener implements ModifyListener { public void modifyText(ModifyEvent e) { // Pre-condition assert combo != null; filterText = new String( combo.getText() ); combo.getDisplay().timerExec( 450, new MyRunnable(filterText) ); } }; /** * Implements a selection listsner for the managed clear button. */ private class MyClearSelectionListener implements SelectionListener { public void widgetDefaultSelected(SelectionEvent e) { // Pre-condition assert combo != null; // Clears the managed combo text. combo.select( -1 ); combo.setText( new String() ); } public void widgetSelected(SelectionEvent e) { // Pre-condition assert combo != null; // Clears the managed combo text. combo.select( -1 ); combo.setText( new String() ); } } /** * @see eclox.ui.editor.advanced.filters.IFilter#createControls(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite) */ public void createControls(IManagedForm managedForm, Composite parent) { // Pre-condition assert combo == null; assert clearButton == null; // Creates the combo control allowing the user to enter text to search. combo = new Combo( parent, SWT.FLAT|SWT.BORDER ); // Fills the combo with the eventual saved items. if( this.savedComboItems != null ) { combo.setItems( this.savedComboItems ); } else { combo.setText("type filter text"); } // Restores the saved combo selected item. combo.setText( this.savedComboText ); combo.setSelection( new Point(0,combo.getText().length()) ); // Attaches a modify listener. combo.addModifyListener( new MyComboModifyListener() ); // Creates the clear button. clearButton = managedForm.getToolkit().createButton( parent, null, SWT.FLAT ); clearButton.setImage( Plugin.getImageDescriptor( Images.ERASE ).createImage() ); clearButton.addSelectionListener( new MyClearSelectionListener() ); // Installs the layout into the parent, and layout data on controls GridLayout layout = new GridLayout( 2, false ); layout.marginTop = 0; layout.marginRight = 0; layout.marginBottom = 0; layout.marginLeft = 0; layout.marginWidth = 0; layout.marginHeight = 0; parent.setLayout( layout ); combo.setLayoutData( new GridData(GridData.FILL_BOTH|GridData.GRAB_HORIZONTAL) ); // Post-condition assert combo != null; assert clearButton != null; } /** * @see eclox.ui.editor.advanced.filters.IFilter#createViewerFilters(org.eclipse.jface.viewers.StructuredViewer) */ public void createViewerFilters(StructuredViewer viewer) { // Pre-condition assert viewer == null; assert viewerFilter == null; // Installes the viewer filter. this.viewer = viewer; this.viewerFilter = new MyViewerFiler(); this.viewer.addFilter( this.viewerFilter ); // Post-condition assert this.viewer != null; assert this.viewerFilter != null; } /** * @see eclox.ui.editor.advanced.filters.IFilter#disposeControls() */ public void disposeControls() { // Pre-condition assert combo != null; assert clearButton != null; // Saves some state of the managed combo widget. this.savedComboItems = combo.getItems(); this.savedComboText = combo.getText(); // Disposes all managed widgets. combo.dispose(); clearButton.dispose(); combo = null; clearButton = null; // Post-condition assert combo == null; assert clearButton == null; } /** * @see eclox.ui.editor.advanced.filters.IFilter#disposeViewerFilers(org.eclipse.jface.viewers.StructuredViewer) */ public void disposeViewerFilers(StructuredViewer viewer) { // Pre-condition assert this.viewer != null; assert viewerFilter != null; // Uninstalles the viewer filter. viewer.removeFilter( this.viewerFilter ); this.viewerFilter = null; this.viewer = null; // Post-condition assert this.viewer == null; assert this.viewerFilter == null; } /** * @see eclox.ui.editor.advanced.filters.IFilter#getName() */ public String getName() { return "Custom"; } /** * @see eclox.ui.editor.advanced.filters.IFilter#setDoxyfile(eclox.doxyfiles.Doxyfile) */ public void setDoxyfile(Doxyfile doxyfile) { // Nothing to do. } } eclox/eclox.ui/src/eclox/ui/editor/advanced/filters/Modified.java 0000644 0000764 0000764 00000012274 12166012446 024424 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2005, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.advanced.filters; import java.util.Iterator; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.IManagedForm; import eclox.core.doxyfiles.Doxyfile; import eclox.core.doxyfiles.ISettingPropertyListener; import eclox.core.doxyfiles.Setting; import eclox.ui.editor.Editor; /** * Implements a filter that will shows only modified settings * (setting having the dirty flag). * * @author gbrocker */ public class Modified implements IFilter { /** * The structured viewer to filter. */ private StructuredViewer viewer; /** * the viewer filter installed in the managed viewer */ private MyViewerFiler viewerFilter; /** * the setting property listener instance */ private MySettingPropertyListener settingPropertyListener; /** * Implements a viewer filter that will only show * setting having the dirty property. */ private class MyViewerFiler extends ViewerFilter { public boolean select(Viewer viewer, Object parentElement, Object element) { // Pre-condition assert element instanceof Setting; Setting setting = (Setting) element; return setting.hasProperty( Editor.PROP_SETTING_DIRTY ); } public boolean isFilterProperty(Object element, String property) { if( element instanceof Setting ) { return property.equals( Editor.PROP_SETTING_DIRTY ); } else { return super.isFilterProperty(element, property); } } } /** * Implements a setting property listener that will trigger * the viewer refresh as soon as a setting dirty property changed. */ private class MySettingPropertyListener implements ISettingPropertyListener { /** * the doxyfile being listened */ private Doxyfile doxyfile; /** * Attaches the listener to the specified doxyfile. Before being * destroyed, the listener should be explicitely detached. * * @param doxyfile a doxyfile the listener will attach to * * @see detach */ public void attach( Doxyfile doxyfile ) { // Pre-condition assert this.doxyfile == null; // References the doxyfile for later use. this.doxyfile = doxyfile; // Attaches to all settings. Iterator i = doxyfile.settingIterator(); while( i.hasNext() ) { Setting setting = (Setting) i.next(); setting.addSettingListener( this ); } // Post-condition assert this.doxyfile != null; } /** * Detaches the listener from the previously attached doxyfile. * * @see attach */ public void detach() { // Pre-condition assert this.doxyfile != null; // Detaches the listener instace from all settings Iterator i = this.doxyfile.settingIterator(); while( i.hasNext() ) { Setting setting = (Setting) i.next(); setting.removeSettingListener( this ); } // Unreferences the managed doxyfile. this.doxyfile = null; // Post-condition assert this.doxyfile == null; } public void settingPropertyChanged(Setting setting, String property) { // Pre-condition assert viewer != null; viewer.update( setting, new String[]{Editor.PROP_SETTING_DIRTY} ); } public void settingPropertyRemoved(Setting setting, String property) { // Pre-condition assert viewer != null; viewer.update( setting, new String[]{Editor.PROP_SETTING_DIRTY} ); } } public void setDoxyfile(Doxyfile doxyfile) { if( doxyfile != null ) { this.settingPropertyListener = new MySettingPropertyListener(); this.settingPropertyListener.attach( doxyfile ); } else { this.settingPropertyListener.detach(); this.settingPropertyListener = null; } } public void createControls(IManagedForm managedForm, Composite parent) { // Nothing to do. } public void createViewerFilters(StructuredViewer viewer) { // Pre-condition assert this.viewer == null; assert this.viewerFilter == null; // Create relevant object instances. this.viewer = viewer; this.viewerFilter = new MyViewerFiler(); this.viewer.addFilter( this.viewerFilter ); // Post-condition assert this.viewer != null; assert this.viewerFilter != null; } public void disposeControls() { // Nothing to do. } public void disposeViewerFilers(StructuredViewer viewer) { // Pre-condition assert this.viewer != null; assert this.viewerFilter != null; // Remove references on out-dated objects. this.viewer.removeFilter( this.viewerFilter ); this.viewerFilter = null; this.viewer = null; // Post-condition assert this.viewer == null; assert this.viewerFilter == null; } public String getName() { return "Modified"; } } eclox/eclox.ui/src/eclox/ui/editor/advanced/filters/ByGroup.java 0000644 0000764 0000764 00000014704 12166012446 024273 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2005, 2013 Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.advanced.filters; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.IManagedForm; import eclox.core.doxyfiles.Doxyfile; import eclox.core.doxyfiles.Group; import eclox.core.doxyfiles.Setting; /** * Implements a filter that shows settings by groups. * * @author gbrocker */ public class ByGroup implements IFilter { /** * the doxyfile being filtered */ private Doxyfile doxyfile; /** * the combo control displaying all group that are selectable by the user */ private Combo combo; /** * the saved combo selection index */ private int savedComboSelection = -1; /** * the current viewer beging filtered. */ private StructuredViewer viewer; /** * the current viewer filter that filters objects displayed in the setting viewer */ private MyViewerFilter viewerFilter; /** * Implements a selection listener for the managed combo control. */ private class MySelectionListener implements SelectionListener { /** * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetDefaultSelected(SelectionEvent e) { // Pre-condition assert viewer != null; viewer.refresh(); } /** * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent e) { // Pre-condition assert viewer != null; viewer.refresh(); } } /** * Implements a structure viewer filter that will filter setting according to the * selected group */ private class MyViewerFilter extends ViewerFilter { /** * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ public boolean select(Viewer viewer, Object parentElement, Object element) { // Pre-condition assert combo != null; assert element instanceof Setting; // Retrieves the selected group name. int groupIndex = combo.getSelectionIndex(); String groupName = groupIndex >= 0 ? combo.getItem( groupIndex ) : null; // Tests if the given element is in the right group. if( groupName != null ) { Setting setting = (Setting) element; String settingGroup = setting.getProperty( Setting.GROUP ); return (settingGroup != null) ? settingGroup.equals( groupName ) : false; } else { return false; } } } /** * @see eclox.ui.editor.advanced.filters.IFilter#setDoxyfile(eclox.doxyfiles.Doxyfile) */ public void setDoxyfile(Doxyfile doxyfile) { this.doxyfile = doxyfile; } /** * @see eclox.ui.editor.advanced.filters.IFilter#createControls(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite) */ public void createControls( IManagedForm managedForm, Composite parent ) { // Pre-condition assert combo == null; assert doxyfile != null; // Creates the managed combo control. combo = new Combo( parent, SWT.FLAT|SWT.BORDER|SWT.READ_ONLY ); combo.addSelectionListener( new MySelectionListener() ); parent.setLayout( new FillLayout() ); // Fills the combo with group names. Object[] objects = doxyfile.getGroups(); int i; for( i = 0; i < objects.length; ++i ) { Group group = (Group) objects[i]; combo.add( group.getName() ); } // Restores the combo selection. combo.select( savedComboSelection ); // Post-condition assert combo != null; } /** * @see eclox.ui.editor.advanced.filters.IFilter#createViewerFilters(org.eclipse.jface.viewers.StructuredViewer) */ public void createViewerFilters(StructuredViewer viewer) { // Pre-condition assert this.viewerFilter == null; assert this.viewer == null; // Creates the viewer filter. this.viewerFilter = new MyViewerFilter(); this.viewer = viewer; this.viewer.addFilter( viewerFilter ); // Post-condition assert this.viewerFilter != null; assert this.viewer == viewer; } /** * @see eclox.ui.editor.advanced.filters.IFilter#disposeControls() */ public void disposeControls() { // Pre-condition assert combo != null; // Saves the combo selection. savedComboSelection = combo.getSelectionIndex(); // Diposes the managed combo control. combo.getParent().setLayout( null ); combo.dispose(); combo = null; // Post-condition assert combo == null; } /** * @see eclox.ui.editor.advanced.filters.IFilter#disposeViewerFilers(org.eclipse.jface.viewers.StructuredViewer) */ public void disposeViewerFilers(StructuredViewer viewer) { // Pre-condition assert this.viewerFilter != null; assert this.viewer == viewer; // Disposes the viewer filter. this.viewer.removeFilter( viewerFilter ); this.viewer = null; this.viewerFilter = null; // Post-condition assert this.viewerFilter == null; assert this.viewer == null; } /** * @see eclox.ui.editor.advanced.filters.IFilter#getName() */ public String getName() { return "By Group"; } } eclox/eclox.ui/src/eclox/ui/editor/advanced/NavigableSelection.java 0000644 0000764 0000764 00000010122 12166012446 024760 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.advanced; import java.util.Iterator; import java.util.List; import java.util.Stack; import java.util.Vector; import org.eclipse.jface.viewers.IStructuredSelection; /** * Implements a selection that provides the history of all selected * items as well as the navigation among those items. * * @author gbrocker */ public class NavigableSelection implements IStructuredSelection { private Stack previousElements = new Stack(); ///< Contains all previously selected elements. private Stack nextElements = new Stack(); ///< Contains all next selected elements. private Vector elements = new Vector(); ///< References the current element of the selection. /** * @brief Builds a new selection that holds the given object. * * @param object the new object to select * * @return the new selection */ public NavigableSelection select(Object object) { NavigableSelection result; if( getFirstElement() != object ) { result = new NavigableSelection(); if( isEmpty() == false ) { result.previousElements.addAll(previousElements); result.previousElements.push(elements.firstElement()); } result.elements.add(object); } else { result = this; } return result; } /** * @brief Retrieves the collection of items that follow the current item * in the history. * * @return a stack of items */ public Stack getNextElements() { return nextElements; } /** * @brief Builds the selection that follows in the history. * * @return a selection or null if none */ public NavigableSelection getNextSelection() { NavigableSelection result = null; if( nextElements.empty() == false ) { result = new NavigableSelection(); result.previousElements.addAll(previousElements); result.previousElements.push(elements.firstElement()); result.elements.add(nextElements.peek()); result.nextElements.addAll(nextElements); result.nextElements.pop(); } return result; } /** * @brief Retrieves the collection of items that preceed the current item * in the history. * * @return a stack of items */ public Stack getPreviousElements() { return previousElements; } /** * @brief Builds the selection that preceeds in the history. * * @return a selection or null if none */ public NavigableSelection getPreviousSelection() { NavigableSelection result = null; if( previousElements.empty() == false ) { result = new NavigableSelection(); result.previousElements.addAll(previousElements); result.previousElements.pop(); result.elements.add(previousElements.peek()); result.nextElements.addAll(nextElements); result.nextElements.push(elements.firstElement()); } return result; } /** * @see org.eclipse.jface.viewers.ISelection#isEmpty() */ public boolean isEmpty() { return elements.isEmpty(); } /** * Retrieves the selected element. * * @see org.eclipse.jface.viewers.IStructuredSelection#getFirstElement() */ public Object getFirstElement() { return elements.isEmpty() ? null : elements.firstElement(); } /** * @see org.eclipse.jface.viewers.IStructuredSelection#iterator() */ public Iterator iterator() { return elements.iterator(); } /** * @see org.eclipse.jface.viewers.IStructuredSelection#size() */ public int size() { return elements.size(); } /** * @see org.eclipse.jface.viewers.IStructuredSelection#toArray() */ public Object[] toArray() { return elements.toArray(); } /** * @see org.eclipse.jface.viewers.IStructuredSelection#toList() */ public List toList() { return new Vector(elements); } } eclox/eclox.ui/src/eclox/ui/editor/advanced/DetailsPage.java 0000644 0000764 0000764 00000026136 12166012446 023420 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2004, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.advanced; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.FontRegistry; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.IDetailsPage; import org.eclipse.ui.forms.IFormPart; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.events.HyperlinkEvent; import org.eclipse.ui.forms.events.IHyperlinkListener; import org.eclipse.ui.forms.widgets.FormText; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import eclox.core.doxyfiles.Doxyfile; import eclox.core.doxyfiles.Setting; import eclox.ui.Plugin; import eclox.ui.editor.editors.SettingEditor; /** * Implements the generic details node page. * * @author gbrocker */ public class DetailsPage implements IDetailsPage { /** symbolic name for emphasis font */ private static final String EMPHASIS = "em"; /** the static setting editor class register */ private static EditorClassRegister editorClassRegister = new EditorClassRegister(); /** the setting editor instance */ private SettingEditor editor; /** the section that contains all our controls */ private Section section; /** he editor content container widget */ private Composite editorContainer; /** the control containing all controls of the section */ private Composite sectionContent; /** the managed form the page is attached to */ protected IManagedForm managedForm; /** the current selection */ private NavigableSelection selection = new NavigableSelection(); /** the control displaying the setting's note text */ private FormText noteLabel; /** the font registry used for note text formatting */ private FontRegistry fontRegistry; /** * Defines the listeners that will managed activation of hyper-links in the * setting's note. */ private class MyHyperlinkListener implements IHyperlinkListener { private DetailsPage owner; /** * Constructor * * @param owner the owner of the instance */ MyHyperlinkListener( DetailsPage owner ) { this.owner = owner; } /** * @see org.eclipse.ui.forms.events.IHyperlinkListener#linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent) */ public void linkActivated(HyperlinkEvent e) { // Pre-condition assert editor != null; Doxyfile doxyfile = editor.getInput().getOwner(); Setting setting = doxyfile.getSetting( e.getHref().toString() ); if( setting != null ) { managedForm.fireSelectionChanged( owner, selection.select(setting) ); } } /** * @see org.eclipse.ui.forms.events.IHyperlinkListener#linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent) */ public void linkEntered(HyperlinkEvent e) {} /** * @see org.eclipse.ui.forms.events.IHyperlinkListener#linkExited(org.eclipse.ui.forms.events.HyperlinkEvent) */ public void linkExited(HyperlinkEvent e) {} } /** * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite) */ public void createContents(Composite parent) { FormToolkit toolkit = this.managedForm.getToolkit(); fontRegistry = new FontRegistry(parent.getDisplay()); // Initializes the parent control. parent.setLayout(new FillLayout()); // Creates the section this.section = toolkit.createSection(parent, Section.TITLE_BAR); this.section.marginHeight = 5; this.section.marginWidth = 10; // Createst the section content and its layout this.sectionContent = toolkit.createComposite(section); this.section.setClient(this.sectionContent); GridLayout layout = new GridLayout(1, true); layout.marginWidth = 0; layout.marginHeight = 0; this.sectionContent.setLayout(layout); // Creates the editor content. this.editorContainer = managedForm.getToolkit().createComposite(sectionContent); this.editorContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Creates controls displaying the setting note. this.noteLabel = this.managedForm.getToolkit().createFormText( sectionContent, false ); this.noteLabel.setLayoutData( new GridData(GridData.FILL_HORIZONTAL) ); this.noteLabel.setFont( EMPHASIS, fontRegistry.getItalic("") ); this.noteLabel.addHyperlinkListener( new MyHyperlinkListener(this) ); } /** * @see org.eclipse.ui.forms.IFormPart#commit(boolean) */ public void commit(boolean onSave) { if( editor != null ) { editor.commit(); } } /** * @see org.eclipse.ui.forms.IFormPart#dispose() */ public void dispose() {} /** * @see org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm) */ public void initialize(IManagedForm form) { this.managedForm = form; } /** * @see org.eclipse.ui.forms.IFormPart#isDirty() */ public boolean isDirty() { return editor != null ? editor.isDirty() : false; } /** * @see org.eclipse.ui.forms.IFormPart#isStale() */ public boolean isStale() { return editor != null ? editor.isStale() : false; } /** * @see org.eclipse.ui.forms.IFormPart#refresh() */ public void refresh() { if( editor != null ) { editor.refresh(); } } /** * @see org.eclipse.ui.forms.IFormPart#setFocus() */ public void setFocus() { // Pre-condition assert this.editor != null; this.editor.setFocus(); } /** * @see org.eclipse.ui.forms.IFormPart#setFormInput(java.lang.Object) */ public boolean setFormInput(Object input) { return false; } /** * @see org.eclipse.ui.forms.IPartSelectionListener#selectionChanged(org.eclipse.ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection) */ public void selectionChanged(IFormPart part, ISelection newSelection) { // Pre-condition assert (newSelection instanceof NavigableSelection); // Retreieves the node that is provided by the selection. /*if( part != this )*/ { selection = (NavigableSelection) newSelection; Object object = selection.getFirstElement(); Setting setting = (object instanceof Setting) ? (Setting) object : null; String text = setting.getProperty(Setting.TEXT); // Checks that the setting has a text property. if( text == null ) { Plugin.log(setting.getIdentifier() + ": missing TEXT property."); text = new String(setting.getIdentifier()); } // Updates the form controls. this.selectNote(setting); this.selectEditor(setting); this.section.setText( text ); this.section.layout(true, true); } } /** * Disposes the current editor. */ private void disposeEditor() { if(editor != null) { editor.dispose(); editor = null; } } /** * Selects the editor for the specified setting. * * @param input the setting that is the new input */ private void selectEditor(Setting input) { try { // Retrieves the editor class for the input. Class editorClass = editorClassRegister.find(input); // Perhaps should we remove the current editor. if(editor != null && editor.getClass() != editorClass) { disposeEditor(); } // Perhaps, we should create a new editor instance. if(editor == null) { editor = (SettingEditor) editorClass.newInstance(); editor.createContent(editorContainer, managedForm.getToolkit()); editorContainer.setLayoutData( new GridData(editor.grabVerticalSpace() ? GridData.FILL_BOTH : GridData.FILL_HORIZONTAL) ); } // Assigns the input to the editor. editor.setInput(input); editor.refresh(); } catch(Throwable throwable) { MessageDialog.openError(this.managedForm.getForm().getShell(), "Unexpected Error", throwable.toString()); } } /** * Updates the UI controls for the specified node. * * @param setting a setting instance to use to refresh the UI controls. */ private void selectNote(Setting setting) { // Retrieves the setting's note text. String text = setting.getProperty( Setting.NOTE ); // If there is none, build a default one. if(text == null) { text = "Not available."; } // Else do some parsing and replacements for layout and style. else { Doxyfile doxyfile = setting.getOwner(); text = text.startsWith("
") ? text : "
"+text+"
"; Matcher matcher = Pattern.compile("([A-Z_]{2,}|Warning:|Note:|@[a-z]+)").matcher(text); StringBuffer buffer = new StringBuffer(); while( matcher.find() ) { String match = matcher.group(1); if( match.equals("YES") || match.equals("NO") ) { matcher.appendReplacement( buffer, ""+match+""); } else if( match.equals("Note:") || match.equals("Warning:") ) { matcher.appendReplacement( buffer, ""+match+""); } else if( match.startsWith("@") ) { matcher.appendReplacement( buffer, ""+match+""); } else { Setting matchSetting = doxyfile.getSetting(match); if( matchSetting != null ) { String settingText = matchSetting.getProperty(Setting.TEXT); if( matchSetting == setting ) { matcher.appendReplacement( buffer, ""+settingText+""); } else { matcher.appendReplacement( buffer, ""+settingText+""); } } } } matcher.appendTail( buffer ); text = buffer.toString(); } // Finally, assignes the text to the user interface control. this.noteLabel.setText("", true, false); } } eclox/eclox.ui/src/eclox/ui/editor/advanced/EditorClassRegister.java 0000644 0000764 0000764 00000004605 12166012446 025154 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2005, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.advanced; import java.util.HashMap; import java.util.Map; import eclox.core.doxyfiles.Setting; import eclox.ui.Plugin; import eclox.ui.editor.editors.BooleanEditor; import eclox.ui.editor.editors.DirectoryEditor; import eclox.ui.editor.editors.DirectoryListEditor; import eclox.ui.editor.editors.FileEditor; import eclox.ui.editor.editors.PathListEditor; import eclox.ui.editor.editors.TextEditor; import eclox.ui.editor.editors.TextListEditor; /** * An instance of this class registers all setting editor classes by setting type. * * @author gbrocker */ public class EditorClassRegister { /** * The map registering all editor classes. */ private Map register = new HashMap(); /** * Constructor. */ public EditorClassRegister() { register.put( "file", FileEditor.class ); register.put( "directory", DirectoryEditor.class ); register.put( "text", TextEditor.class ); register.put( "boolean", BooleanEditor.class ); register.put( "text list", TextListEditor.class ); register.put( "directory list", DirectoryListEditor.class ); register.put( "path list", PathListEditor.class ); } /** * Retrieves a class for the specified setting. * * @param setting a setting for which an editor must be retrieved * * @return a setting editor class */ public Class find(Setting setting) { // Retrieves the editor class for that type String type = setting.getProperty( Setting.TYPE ); Class result = (Class) register.get(type); // Little fallback if no matching editor class was found. if(result == null) { Plugin.log(setting.getIdentifier() + ": missing or wrong TYPE property."); result = TextEditor.class; } return result; } } eclox/eclox.ui/src/eclox/ui/editor/advanced/HistoryAction.java 0000644 0000764 0000764 00000013252 12166012446 024030 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.advanced; import java.util.Stack; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuCreator; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import eclox.core.doxyfiles.Setting; /** * Implements an action that trigger the navigation in the selection history. * This class is used to contribute to the form's action bar manager. * * @author Guillaume Brocker */ class HistoryAction extends Action { /** * Implements a menu listener used to trigger selection changes */ private class MySelectionListener implements SelectionListener { /** * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } /** * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent e) { assert e.widget instanceof MenuItem; MenuItem menuItem = (MenuItem) e.widget; NavigableSelection selection = (NavigableSelection) menuItem.getData(); masterPart.setSelection(selection, true); } } /** * Implements the menu creator tha will create the menu for the action. */ private class MyMenuCreator implements IMenuCreator { private Menu menu; /** * @see org.eclipse.jface.action.IMenuCreator#dispose() */ public void dispose() { if( menu != null ) { menu.dispose(); } } /** * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control) */ public Menu getMenu(Control parent) { if( menu == null ) { menu = new Menu(parent); } fill(menu); return menu; } /** * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu) */ public Menu getMenu(Menu parent) { if( menu == null ) { menu = new Menu(parent); } fill(menu); return menu; } /** * Fills the menu with navigation history. * * @param menu the menu to full */ private void fill(Menu menu) { // Clears the menu content. MenuItem [] items = menu.getItems(); for( int i = 0; i != items.length; ++i ) { items[i].dispose(); } // Fills the menu content. NavigableSelection currentSelection = getFollowingSelection(selection); while(currentSelection != null) { Setting setting = (Setting) currentSelection.getFirstElement(); MenuItem menuItem = new MenuItem(menu, 0); menuItem.setText( setting.hasProperty(Setting.TEXT) ? setting.getProperty(Setting.TEXT) : setting.getIdentifier() ); menuItem.setData(currentSelection); menuItem.addSelectionListener(new MySelectionListener()); currentSelection = getFollowingSelection(currentSelection); } } /** * Retrieves the selection following the given one, according * to the current action's direction. * * @param selection a reference selection * * @return the following selection or null if none */ private NavigableSelection getFollowingSelection( NavigableSelection selection ) { return (direction == BACK) ? selection.getPreviousSelection() : selection.getNextSelection(); } } /** defines the back navigation direction */ public static final int BACK = 0; /** defines the forward navigation direction */ public static final int FORWARD = 1; /** the direction of the navigation assigned to the action */ private int direction; /** the master part that holds the nivation history */ private MasterPart masterPart; /** the current selection */ private NavigableSelection selection; /** * Constructor * * @param direction the navigation direction for the action * @param masterPart the master part that manage the action */ public HistoryAction(int direction, MasterPart masterPart) { super(new String(), IAction.AS_DROP_DOWN_MENU); assert masterPart != null; this.direction = direction; this.masterPart = masterPart; setMenuCreator(new MyMenuCreator()); } /** * @see org.eclipse.jface.action.Action#run() */ public void run() { switch(direction) { case BACK: masterPart.setSelection( selection.getPreviousSelection(), true ); break; case FORWARD: masterPart.setSelection( selection.getNextSelection(), true ); break; } } /** * Tells the action that the selection changed * * @param newSelection the new selection */ public void selectionChanged(ISelection newSelection) { assert newSelection instanceof NavigableSelection; selection = (NavigableSelection) newSelection; Stack sideElements = direction == BACK ? selection.getPreviousElements() : selection.getNextElements(); if( sideElements.isEmpty() ) { setEnabled(false); setText(new String()); } else { Setting setting = (Setting) sideElements.peek(); setEnabled(true); setText("Go to " + setting.getProperty(Setting.TEXT)); } } } eclox/eclox.ui/src/eclox/ui/editor/advanced/Block.java 0000644 0000764 0000764 00000003630 12166012446 022262 0 ustar willy willy /* /******************************************************************************* * Copyright (C) 2003-2004, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.advanced; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.DetailsPart; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.MasterDetailsBlock; import eclox.core.doxyfiles.Doxyfile; import eclox.core.doxyfiles.Setting; /** * @author gbrocker */ public class Block extends MasterDetailsBlock { /** * the doxyfile to edit */ private Doxyfile doxyfile; /** * Constructor * * @param doxyfile the doxyfile to edit */ Block( Doxyfile doxyfile ) { this.doxyfile = doxyfile; } /** * @see org.eclipse.ui.forms.MasterDetailsBlock#createMasterPart(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite) */ protected void createMasterPart(IManagedForm managedForm, Composite parent) { managedForm.addPart( new MasterPart(parent, managedForm.getToolkit(), doxyfile) ); } /** * @see org.eclipse.ui.forms.MasterDetailsBlock#registerPages(org.eclipse.ui.forms.DetailsPart) */ protected void registerPages(DetailsPart detailsPart) { detailsPart.registerPage(Setting.class, new DetailsPage()); } /** * @see org.eclipse.ui.forms.MasterDetailsBlock#createToolBarActions(org.eclipse.ui.forms.IManagedForm) */ protected void createToolBarActions(IManagedForm managedForm) {} } eclox/eclox.ui/src/eclox/ui/editor/advanced/Page.java 0000644 0000764 0000764 00000003016 12166012446 022102 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2004, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.advanced; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.editor.FormPage; import eclox.ui.editor.Editor; /** * Implements the settings form page * * @author gbrocker */ public class Page extends FormPage { /** * The page identifier. */ public static final String ID = "advanced"; /** * The master/detail block. */ private Block block; /** * Constructor. * * @param editor the editor instance to attach to. * * @author gbrocker */ public Page(Editor editor) { super(editor, Page.ID, "Advanced"); block = new Block( editor.getDoxyfile() ); } /** * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm) */ protected void createFormContent(IManagedForm managedForm) { managedForm.getForm().setText(this.getTitle()); this.block.createContent(managedForm); } } eclox/eclox.ui/src/eclox/ui/editor/advanced/MasterPart.java 0000644 0000764 0000764 00000051450 12166012446 023315 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.advanced; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.LabelProviderChangedEvent; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.forms.DetailsPart; import org.eclipse.ui.forms.IFormPart; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.IPartSelectionListener; import org.eclipse.ui.forms.SectionPart; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import eclox.core.doxyfiles.Doxyfile; import eclox.core.doxyfiles.ISettingPropertyListener; import eclox.core.doxyfiles.Setting; import eclox.ui.editor.Editor; import eclox.ui.editor.advanced.filters.All; import eclox.ui.editor.advanced.filters.ByGroup; import eclox.ui.editor.advanced.filters.Custom; import eclox.ui.editor.advanced.filters.IFilter; import eclox.ui.editor.advanced.filters.Modified; /** * Implements the master part's user interface. * * @author gbrocker */ public class MasterPart extends SectionPart implements IPartSelectionListener { /** * Implements the master content provider. */ private class MyContentProvider implements IStructuredContentProvider { /** * @see org.eclipse.jface.viewers.IContentProvider#dispose() */ public void dispose() {} /** * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) */ public Object[] getElements(Object inputElement) { Doxyfile doxyfile = (Doxyfile) inputElement; return doxyfile.getSettings(); } /** * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} } /** * Implements the mouse listener attached to the table. * * This listener will search for a DetailsPart in the managed form given * at construction time and will set the focus on that part. */ private class MyDoubleClickListener implements IDoubleClickListener { /** * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent) */ public void doubleClick(DoubleClickEvent event) { IManagedForm managedForm = getManagedForm(); // Searchs for the details part in the managed form and set the focus on it. IFormPart parts[] = managedForm.getParts(); for( int i = 0; i < parts.length; ++i ) { IFormPart currentPart = parts[i]; if( currentPart instanceof DetailsPart ) { currentPart.setFocus(); break; } } } } /** * Implements a filter button listener */ private class MyFilterButtonListener implements SelectionListener { /** * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetDefaultSelected(SelectionEvent e) { Object data = e.widget.getData(); IFilter filter = (IFilter) data; activateFilter( filter ); } /** * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent e) { Object data = e.widget.getData(); IFilter filter = (IFilter) data; activateFilter( filter ); } } /** * Implements the label provider. */ private class MyLabelProvider extends LabelProvider implements ITableLabelProvider, ISettingPropertyListener { /** * the set of all settings the label provider has registered to */ private Set settings = new HashSet(); /** * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() */ public void dispose() { // Walks through all settings and unregisters from the listeners Iterator i = settings.iterator(); while( i.hasNext() == true ) { Object object = i.next(); Setting setting = (Setting) object; setting.removeSettingListener( this ); } settings.clear(); super.dispose(); } /** * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) */ public Image getColumnImage(Object element, int columnIndex) { // We don't have any image to return. return null; } /** * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) */ public String getColumnText(Object element, int columnIndex) { // Pre-condition assert element instanceof Setting; // Retrieves the setting's text. Setting setting = (Setting) element; // Registers as an observer of the setting setting.addSettingListener( this ); settings.add( setting ); // Determine the text to return according to the given column index. String columnText; if( columnIndex == TEXT_COLUMN ) { columnText = setting.hasProperty( Setting.TEXT ) ? setting.getProperty( Setting.TEXT ) : setting.getIdentifier(); columnText = setting.hasProperty( Editor.PROP_SETTING_DIRTY ) ? ("*").concat( columnText ) : columnText; } else if (columnIndex == VALUE_COLUMN ){ columnText = setting.getValue(); } else { columnText = null; } return columnText; } public void settingPropertyChanged(Setting setting, String property) { if( property.equals( Editor.PROP_SETTING_DIRTY ) ) { fireLabelProviderChanged( new LabelProviderChangedEvent(this, setting) ); } } public void settingPropertyRemoved(Setting setting, String property) { if( property.equals( Editor.PROP_SETTING_DIRTY ) ) { fireLabelProviderChanged( new LabelProviderChangedEvent(this, setting) ); } } } /** * Implements a tree viewer selection listener. */ private class MyTableSelectionListener implements ISelectionChangedListener { /** * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) */ public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); if( selection.isEmpty() == false ) { assert selection instanceof StructuredSelection; // Updates the selection StructuredSelection structuredSelection = (StructuredSelection) selection; setSelection( currentSelection.select(structuredSelection.getFirstElement()), false ); } } } /** the text column index */ private final static int TEXT_COLUMN = 0; /** the value column index */ private final static int VALUE_COLUMN = 1; /** the doxyfile being edited */ private Doxyfile doxyfile; /** the active filter */ private IFilter activeFilter; /** the default filter */ private IFilter defaultFilter = new All(); /** the parent composite for filter buttons */ private Composite filterButtons; /** the parent composite for filter controls */ private Composite filterControls; /** the list viewer */ private TableViewer tableViewer; /** the table viewer selection listener */ private MyTableSelectionListener tableViewerSelectionListener; /** the go backward history action */ private HistoryAction goBack = new HistoryAction(HistoryAction.BACK, this); /** the go foreward history action */ private HistoryAction goForward = new HistoryAction(HistoryAction.FORWARD, this); /** the current selection */ private NavigableSelection currentSelection = new NavigableSelection(); /** * Constructor * * @param parent a composite that is the parent of all part controls * @param toolkit a toolkit used to create the part controls. * @param doxyfile a doxyfile to edit */ public MasterPart( Composite parent, FormToolkit toolkit, Doxyfile doxyfile ) { super( parent, toolkit, Section.TITLE_BAR|Section.COMPACT ); this.doxyfile = doxyfile; // Initializes the managed section. Section section = getSection(); section.setText("Settings"); section.marginHeight = 5; section.marginWidth = 10; toolkit.paintBordersFor( section ); // Creates the main section container. Composite rootContainer = toolkit.createComposite( section ); section.setClient( rootContainer ); rootContainer.setLayout( new FormLayout() ); // Continues with other initializations. createFilterButtons( toolkit, rootContainer ); createSubControls( toolkit, rootContainer ); // Adds some filters. addFilter( toolkit, defaultFilter ); addFilter( toolkit, new ByGroup() ); addFilter( toolkit, new Custom() ); addFilter( toolkit, new Modified() ); // Activates the default filter. activateFilter( defaultFilter ); } /** * Activates the specified filter. * * @param filter a filter that must be activated */ private void activateFilter( IFilter filter ) { Section section = getSection(); // Freezes the section widget. section.setRedraw( false ); // Updates the filter button's state. Control[] controls = filterButtons.getChildren(); for( int i = 0; i < controls.length; ++i ) { Control control = controls[i]; Button button = (Button) control; button.setSelection( control.getData() == filter ); } // If there is a new filter to activate, do the activation job. if( filter != activeFilter ) { // Deactivates the previous filter. if( activeFilter != null ) { activeFilter.disposeViewerFilers( tableViewer ); activeFilter.disposeControls(); activeFilter.setDoxyfile( null ); activeFilter = null; } // Activates the new filter. activeFilter = filter; activeFilter.setDoxyfile( doxyfile ); activeFilter.createControls( getManagedForm(), filterControls ); activeFilter.createViewerFilters( tableViewer ); tableViewer.refresh(); // Adapts the size of the filter control container & relayout the section content. Object tableLayoutData = tableViewer.getTable().getLayoutData(); FormData tableFormData = (FormData) tableLayoutData; if( filterControls.getChildren().length == 0 ) { filterControls.setVisible( false ); tableFormData.top = new FormAttachment( 0, 0 ); } else { filterControls.setVisible( true ); tableFormData.top = new FormAttachment( filterControls, 6, SWT.BOTTOM ); } // Reactivates section widget. section.layout( true, true ); } // Reactivates the redrawing. section.setRedraw( true ); } /** * Adds a new filter to the master part. * * @param toolkit a toolkit to use for the widget creation * @param filter a new filter to add */ private void addFilter( FormToolkit toolkit, IFilter filter ) { Button button = toolkit.createButton( filterButtons, filter.getName(), SWT.FLAT|SWT.TOGGLE); button.setData( filter ); button.addSelectionListener( new MyFilterButtonListener() ); } /** * Creates all buttons for setting filters. * * @param toolkit the form tool to use for the control creation * @param parent a composite that will be the parent of all controls */ private void createFilterButtons( FormToolkit toolkit, Composite parent ) { // Pre-condition assert filterButtons == null; assert filterControls == null; // Creates the filter button container. FillLayout buttonContainerLayout = new FillLayout( SWT.HORIZONTAL ); filterButtons = toolkit.createComposite( parent ); buttonContainerLayout.marginWidth = 0; buttonContainerLayout.marginHeight = 0; buttonContainerLayout.spacing = 3; filterButtons.setLayout( buttonContainerLayout ); // Assignes layout data fo the filter button container. FormData buttonFormData = new FormData(); buttonFormData.top = new FormAttachment( 0, 0 ); buttonFormData.right = new FormAttachment( 100, 0 ); buttonFormData.left = new FormAttachment( 0, 0 ); filterButtons.setLayoutData( buttonFormData ); // Post-condition assert filterButtons != null; } /** * Creates controls subordinated to the filter buttons. */ private void createSubControls( FormToolkit toolkit, Composite parent ) { // Pre-condition assert filterButtons != null; assert filterControls == null; assert tableViewer == null; toolkit.paintBordersFor( parent ); // Creates the sub parent control container. Composite subParent = toolkit.createComposite( parent ); FormData subParentFormData = new FormData(); subParentFormData.top = new FormAttachment( filterButtons, 6, SWT.BOTTOM ); subParentFormData.right = new FormAttachment( 100, -2 ); subParentFormData.bottom = new FormAttachment( 100, -2 ); subParentFormData.left = new FormAttachment( 0, 1 ); subParentFormData.height = 50; subParent.setLayoutData( subParentFormData ); subParent.setLayout( new FormLayout() ); subParent.setData( FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER ); // Creates the filter control container. FormData controlFormData = new FormData(); controlFormData.top = new FormAttachment( 0, 5 ); controlFormData.right = new FormAttachment( 100, -5 ); controlFormData.left = new FormAttachment( 0, 5 ); filterControls = toolkit.createComposite( subParent ); filterControls.setLayoutData( controlFormData ); // Creates the table widget that will display all settings. Table table = new Table( subParent, SWT.V_SCROLL|SWT.FULL_SELECTION ); FormData formData = new FormData(); formData.top = new FormAttachment( filterControls, 5, SWT.BOTTOM ); formData.right = new FormAttachment( 100, 0 ); formData.bottom = new FormAttachment( 100, 0 ); formData.left = new FormAttachment( 0, 0 ); formData.height = 10; formData.width = 10; table.setLayoutData( formData ); table.setHeaderVisible( true ); // Adds some columns to the table TableColumn tableColumn; tableColumn = new TableColumn( table, SWT.LEFT, TEXT_COLUMN ); tableColumn.setText( "Name" ); tableColumn = new TableColumn( table, SWT.LEFT, VALUE_COLUMN ); tableColumn.setText( "Value" ); // Creates the table viewer. tableViewer = new TableViewer( table ); tableViewer.setContentProvider( new MyContentProvider() ); tableViewer.setLabelProvider( new MyLabelProvider() ); tableViewer.setInput( doxyfile ); // Updates the column widths. TableColumn columns[] = table.getColumns(); columns[ TEXT_COLUMN ].pack(); columns[ VALUE_COLUMN ].pack(); // Post-condition assert filterControls != null; assert tableViewer != null; } /** * @see org.eclipse.ui.forms.AbstractFormPart#initialize(org.eclipse.ui.forms.IManagedForm) */ public void initialize(IManagedForm form) { // Pre-condition assert tableViewer != null; // Installs several listeners. tableViewerSelectionListener = new MyTableSelectionListener(); tableViewer.addPostSelectionChangedListener( tableViewerSelectionListener ); tableViewer.addDoubleClickListener( new MyDoubleClickListener() ); // Installs the actions goBack.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_BACK)); goForward.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD)); form.getForm().getToolBarManager().add(goBack); form.getForm().getToolBarManager().add(goForward); goBack.selectionChanged(new NavigableSelection()); goForward.selectionChanged(new NavigableSelection()); // Default job done by super class. super.initialize(form); } /** * @see org.eclipse.ui.forms.AbstractFormPart#isStale() */ public boolean isStale() { // We always answer yes because it is currently not trivial // to know if the data model has changed since last refresh. return true; } /** * @see org.eclipse.ui.forms.AbstractFormPart#refresh() */ public void refresh() { tableViewer.refresh(); super.refresh(); } /** * @see org.eclipse.ui.forms.IPartSelectionListener#selectionChanged(org.eclipse.ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection) */ public void selectionChanged(IFormPart part, ISelection selection) { assert selection instanceof NavigableSelection; currentSelection = (NavigableSelection) selection; // Activates the default filter. activateFilter( defaultFilter ); revealObject(currentSelection.getFirstElement()); // Updates the navigation actions. goBack.selectionChanged(selection); goForward.selectionChanged(selection); } /** * Set the new selection of the part. This will forward the selection to the form * so other parts will be notified about the selection change. * * @param selection the new selection * @param reveal tells if the selection should be revealed in the controls */ public void setSelection( NavigableSelection selection, boolean reveal ) { currentSelection = selection; // If requested, reveals the selection's first element if( reveal == true ) { revealObject(selection.getFirstElement()); } // Updates the actions goBack.selectionChanged(currentSelection); goForward.selectionChanged(currentSelection); // Notifies other parts. getManagedForm().fireSelectionChanged(this, selection); } /** * Reveals the given object into the managed table viewer by selecting it. * * @param object the object to reveal */ private void revealObject(Object object) { StructuredSelection selection = (object != null) ? new StructuredSelection(object) : new StructuredSelection(); tableViewer.removePostSelectionChangedListener(tableViewerSelectionListener); tableViewer.setSelection(selection, true); tableViewer.addPostSelectionChangedListener(tableViewerSelectionListener); } } eclox/eclox.ui/src/eclox/ui/editor/basic/ 0000755 0000764 0000764 00000000000 12166321431 017674 5 ustar willy willy eclox/eclox.ui/src/eclox/ui/editor/basic/OutputPart.java 0000644 0000764 0000764 00000011136 12166012446 022673 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.basic; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; import eclox.core.doxyfiles.Doxyfile; import eclox.ui.editor.editors.CheckBoxEditor; import eclox.ui.editor.editors.IEditor; import eclox.ui.editor.editors.IEditorListener; public class OutputPart extends Part { /** * Implements an editor listener that will update * enabled states of some editors according to the value * of some other editors. */ private class MyEditorListener implements IEditorListener { /** * @see eclox.ui.editor.editors.IEditorListener#editorDirtyChanged(eclox.ui.editor.editors.IEditor) */ public void editorChanged(IEditor editor) { if( editor == html ) { htmlFlavour.setEnabled( ((CheckBoxEditor)editor).getValue() ); htmlSearchEngine.setEnabled( ((CheckBoxEditor)editor).getValue() ); } else if( editor == latex ) { latexFlavour.setEnabled( ((CheckBoxEditor)editor).getValue() ); } } } /** * html flavour state */ private static final String PLAIN_HTML = "plain HTML"; /** * html flavour state */ private static final String FRAME_HTML = "with frames and navigation tree"; /** * html flavour state */ private static final String CHM_HTML = "prepared for compressed HTML (.chm)"; /** * latex flavour for hyperlinked pdf state */ private static final String LATEX_HYPEDLINKED_PDF = "as itermediate format for hypedlinked PDF"; /** * latex flavour for pdf state */ private static final String LATEX_PDF = "as itermediate format for PDF"; /** * latex flavour for PostScript state */ private static final String LATEX_POSTSCRIPT = "as itermediate format for PostScript"; /** * html editor */ CheckBoxEditor html = new CheckBoxEditor("HTML"); /** * html flavour editor */ RadioMultiEditor htmlFlavour = new RadioMultiEditor( new String[] {PLAIN_HTML, FRAME_HTML, CHM_HTML} ); /** * html search engine editor */ CheckBoxEditor htmlSearchEngine = new CheckBoxEditor( "with search function (requires PHP enabled server)" ); /** * latex editor */ CheckBoxEditor latex = new CheckBoxEditor("LaTeX"); /** * latex flavour editor */ RadioMultiEditor latexFlavour = new RadioMultiEditor( new String[] {LATEX_HYPEDLINKED_PDF, LATEX_PDF, LATEX_POSTSCRIPT} ); CheckBoxEditor man = new CheckBoxEditor("Man Pages"); CheckBoxEditor rtf = new CheckBoxEditor("Rich Text Format"); CheckBoxEditor xml = new CheckBoxEditor("XML"); public OutputPart( Composite parent, FormToolkit toolkit, Doxyfile doxyfile ) { super( parent, toolkit, "Output Formats", doxyfile ); addEditor( html ); addEditor( htmlFlavour, 16 ); addEditor( htmlSearchEngine, 16 ); addEditor( latex ); addEditor( latexFlavour, 16 ); addEditor( man ); addEditor( rtf ); addEditor( xml ); if( doxyfile.hasSetting("GENERATE_HTML") ) { html.addListener(new MyEditorListener()); html.setInput( doxyfile.getSetting("GENERATE_HTML") ); htmlFlavour.addSetting(FRAME_HTML, doxyfile.getSetting("GENERATE_TREEVIEW") ); htmlFlavour.addSetting(CHM_HTML, doxyfile.getSetting("GENERATE_HTMLHELP") ); htmlSearchEngine.setInput( doxyfile.getSetting("SEARCHENGINE") ); } else { html.setEnabled(false); htmlFlavour.setEnabled(false); htmlSearchEngine.setEnabled(false); } if( doxyfile.hasSetting("GENERATE_LATEX") ) { latex.addListener(new MyEditorListener()); latex.setInput( doxyfile.getSetting("GENERATE_LATEX") ); latexFlavour.addSetting(LATEX_HYPEDLINKED_PDF, doxyfile.getSetting("PDF_HYPERLINKS") ); latexFlavour.addSetting(LATEX_HYPEDLINKED_PDF, doxyfile.getSetting("USE_PDFLATEX") ); latexFlavour.addSetting(LATEX_PDF, doxyfile.getSetting("USE_PDFLATEX") ); } else { latex.setEnabled(false); latexFlavour.setEnabled(false); } man.setInput( doxyfile.getSetting("GENERATE_MAN") ); man.setEnabled( man.hasInput() ); rtf.setInput( doxyfile.getSetting("GENERATE_RTF") ); rtf.setEnabled( rtf.hasInput() ); xml.setInput( doxyfile.getSetting("GENERATE_XML") ); xml.setEnabled( xml.hasInput() ); } } eclox/eclox.ui/src/eclox/ui/editor/basic/RadioMultiEditor.java 0000644 0000764 0000764 00000006247 12166012446 023773 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.basic; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; public class RadioMultiEditor extends MultiEditor { /** * Implements the selection listener used for radio button */ private class MySelectionListener implements SelectionListener { public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } public void widgetSelected(SelectionEvent e) { Button button = (Button) e.widget; if( button.getSelection() == true ) { selectState( button.getText() ); commit(); } } } /** * an array containing all radio button representing this editor */ private Button[] buttons; /** * Constructor * * @param states an array of string representing the states of the editor */ public RadioMultiEditor( String [] states ) { super( states ); } /** * @see eclox.ui.editor.editors.IEditor#createContent(org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit) */ public void createContent(Composite parent, FormToolkit formToolkit) { // Creates all radio buttons. buttons = new Button[states.length]; for( int i = 0; i != states.length; ++i ) { buttons[i] = formToolkit.createButton(parent, states[i].getName(), SWT.RADIO); buttons[i].addSelectionListener( new MySelectionListener() ); } // Installs the layout. parent.setLayout( new FillLayout(SWT.VERTICAL) ); } /** * @see eclox.ui.editor.editors.IEditor#dispose() */ public void dispose() { buttons = null; } /** * @see eclox.ui.editor.editors.IEditor#grabVerticalSpace() */ public boolean grabVerticalSpace() { return false; } /** * @see eclox.ui.editor.basic.MultiEditor#refresh() */ public void refresh() { // Pre-condition assert buttons != null; super.refresh(); // Refreshes managed buttons State selection = getSelectionAsState(); for( int i = 0; i != buttons.length; ++i ) { buttons[i].setSelection( selection != null && selection.getName().equals(buttons[i].getText()) ); } } /** * @see eclox.ui.editor.editors.IEditor#setEnabled(boolean) */ public void setEnabled(boolean enabled) { // Pre-condition assert buttons != null; for( int i = 0; i != buttons.length; ++i ) { buttons[i].setEnabled(enabled); } } /** * @see eclox.ui.editor.editors.IEditor#setFocus() */ public void setFocus() { // Pre-condition assert buttons != null; buttons[0].setFocus(); } } eclox/eclox.ui/src/eclox/ui/editor/basic/ComboMultiEditor.java 0000644 0000764 0000764 00000007034 12166012446 023767 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.basic; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; /** * Implements a multi editor that presents choices in a combo box. * * @author Guillaume Brocker */ public class ComboMultiEditor extends MultiEditor { /** * Implements a selection listener that will handle selection changes in the combo control. */ private class MySelectionListener implements SelectionListener { /** * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } /** * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent e) { selectState( combo.getItem(combo.getSelectionIndex()) ); commit(); } } /** * the combo control that is the representation of the editor */ Combo combo; /** * Constructor * * @param states an array of string representing all posible states */ ComboMultiEditor( String [] states ) { super( states ); } /** * @see eclox.ui.editor.editors.IEditor#createContent(org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit) */ public void createContent(Composite parent, FormToolkit formToolkit) { // Pre-condition assert combo != null; // Creates the combo control. combo = new Combo(parent, SWT.DROP_DOWN|SWT.READ_ONLY); combo.addSelectionListener( new MySelectionListener() ); formToolkit.adapt(combo, true, true); // Fills the combo with the state names. for( int i = 0; i != states.length; ++i ) { combo.add( states[i].getName() ); } combo.setVisibleItemCount(states.length); // Installs a layout in the parent composite parent.setLayout(new FillLayout()); } /** * @see eclox.ui.editor.editors.IEditor#dispose() */ public void dispose() { combo = null; } /** * @see eclox.ui.editor.editors.IEditor#grabVerticalSpace() */ public boolean grabVerticalSpace() { return false; } /** * @see eclox.ui.editor.basic.MultiEditor#refresh() */ public void refresh() { // Pre-condition assert combo != null; super.refresh(); // Selectes the string corresponding to the current selection State selection = getSelectionAsState(); if( selection != null ) { combo.select( combo.indexOf(selection.getName()) ); } else { combo.deselectAll(); } } /** * @see eclox.ui.editor.editors.IEditor#setEnabled(boolean) */ public void setEnabled(boolean enabled) { // Pre-condition assert combo != null; combo.setEnabled(enabled); } /** * @see eclox.ui.editor.editors.IEditor#setFocus() */ public void setFocus() { // Pre-condition assert combo != null; combo.setFocus(); } } eclox/eclox.ui/src/eclox/ui/editor/basic/ModePart.java 0000644 0000764 0000764 00000011005 12166012446 022252 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.basic; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; import eclox.core.doxyfiles.Doxyfile; /** * Implements the form part that provides edition of mode related settings. * * @author Guillaume Brocker */ public class ModePart extends Part { /** * state for the entities editor */ private static final String ENTITIES_DOCUMENTED = "documented entities only"; /** * state for the entities editor */ private static final String ENTITIES_ALL = "all entities"; /** * state for the optimized langage editor */ private static final String CXX = "C++"; /** * state for the optimized langage editor */ private static final String JAVA = "Java"; /** * state for the optimized langage editor */ private static final String C = "C"; /** * state for the optimized langage editor */ private static final String C_SHARP = "C#"; /** * the editor used to configure entities whose documentation will be extracted */ private RadioMultiEditor entities = new RadioMultiEditor( new String[] {ENTITIES_DOCUMENTED, ENTITIES_ALL} ); /** * the editor used to configure cross-referenced source code inclusion */ private CheckMultiEditor crossReferenced = new CheckMultiEditor( "Include cross-referenced source code in the output" ); /** * the editor used to selected the optimized ouput langage */ private RadioMultiEditor optimizedLangage = new RadioMultiEditor( new String[] {CXX, JAVA, C, C_SHARP} ); /** * Constructor * * @param parent the parent control for the part control's * @param toolkit the toolkit to use for control creation * @param doxyfile the doxyfile being edited */ public ModePart( Composite parent, FormToolkit toolkit, Doxyfile doxyfile ) { super( parent, toolkit, "Mode", doxyfile ); // Creates the content. addLabel("Select the desired extraction mode:"); addEditor(entities); addEditor(crossReferenced); addSperator(); addLabel("Optimize results for:"); addEditor( optimizedLangage ); // Initializes the editors. if( doxyfile.hasSetting("HIDE_UNDOC_MEMBERS") && doxyfile.hasSetting("HIDE_UNDOC_CLASSES") && doxyfile.hasSetting("EXTRACT_ALL") && doxyfile.hasSetting("EXTRACT_PRIVATE") && doxyfile.hasSetting("EXTRACT_STATIC") ) { entities.addSetting(ENTITIES_DOCUMENTED, doxyfile.getSetting("HIDE_UNDOC_MEMBERS") ); entities.addSetting(ENTITIES_DOCUMENTED, doxyfile.getSetting("HIDE_UNDOC_CLASSES") ); entities.addSetting(ENTITIES_ALL, doxyfile.getSetting("EXTRACT_ALL") ); entities.addSetting(ENTITIES_ALL, doxyfile.getSetting("EXTRACT_PRIVATE") ); entities.addSetting(ENTITIES_ALL, doxyfile.getSetting("EXTRACT_STATIC") ); } else { entities.setEnabled( false ); } if( doxyfile.hasSetting("SOURCE_BROWSER") && doxyfile.hasSetting("REFERENCED_BY_RELATION") && doxyfile.hasSetting("REFERENCES_RELATION") && doxyfile.hasSetting("VERBATIM_HEADERS") ) { crossReferenced.addSetting(CheckMultiEditor.SELECTED, doxyfile.getSetting("SOURCE_BROWSER") ); crossReferenced.addSetting(CheckMultiEditor.SELECTED, doxyfile.getSetting("REFERENCED_BY_RELATION") ); crossReferenced.addSetting(CheckMultiEditor.SELECTED, doxyfile.getSetting("REFERENCES_RELATION") ); crossReferenced.addSetting(CheckMultiEditor.SELECTED, doxyfile.getSetting("VERBATIM_HEADERS") ); } else { crossReferenced.setEnabled(false); } if( doxyfile.hasSetting("OPTIMIZE_OUTPUT_JAVA") && doxyfile.hasSetting("OPTIMIZE_OUTPUT_FOR_C") && doxyfile.hasSetting("OPTIMIZE_OUTPUT_JAVA") && doxyfile.hasSetting("EXTRACT_STATIC") ) { optimizedLangage.addSetting(JAVA, doxyfile.getSetting("OPTIMIZE_OUTPUT_JAVA") ); optimizedLangage.addSetting(C, doxyfile.getSetting("OPTIMIZE_OUTPUT_FOR_C") ); optimizedLangage.addSetting(C_SHARP, doxyfile.getSetting("OPTIMIZE_OUTPUT_JAVA") ); optimizedLangage.addSetting(C_SHARP, doxyfile.getSetting("EXTRACT_STATIC") ); } else { optimizedLangage.setEnabled(false); } } } eclox/eclox.ui/src/eclox/ui/editor/basic/MultiEditor.java 0000644 0000764 0000764 00000013257 12166012446 023013 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.basic; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import eclox.core.doxyfiles.Setting; import eclox.ui.editor.editors.AbstractEditor; /** * Base implementation of for multi editors. * * @author Guillaume Brocker */ public abstract class MultiEditor extends AbstractEditor { /** * symbolic constant value for yes */ private static final String YES = "YES"; /** * symbolic constant value for no */ private static final String NO = "NO"; protected class State { private String name; private Set selectedSettings = new HashSet(); private Set deselectedSettings = new HashSet(); State( String name ) { this.name = name; } void addSettingToSelect( Setting setting ) { selectedSettings.add( setting ); deselectedSettings.remove( setting ); } void addSettingToDeselect( Setting setting ) { if( selectedSettings.contains(setting) == false ) { deselectedSettings.add( setting ); } } String getName() { return name; } boolean wantsSelection() { boolean wanted = true; Iterator i; // Updates the selection according to the value of settings owned by the state. i = selectedSettings.iterator(); while( i.hasNext() ) { Setting setting = (Setting) i.next(); wanted = wanted && setting.getValue().equals(YES); } // Updates the selection according to the value of settings owned by the state. i = deselectedSettings.iterator(); while( i.hasNext() ) { Setting setting = (Setting) i.next(); wanted = wanted && setting.getValue().equals(NO); } // Job's done. return wanted; } void commit() { Iterator i; i = selectedSettings.iterator(); while( i.hasNext() ) { Setting setting = (Setting) i.next(); setting.setValue(YES); } i = deselectedSettings.iterator(); while( i.hasNext() ) { Setting setting = (Setting) i.next(); setting.setValue(NO); } } } /** * the collection of managed states */ protected State [] states; /** * the state being selected */ private State selection; /** * a boolean telling if the editor is dirty */ private boolean dirty = false; /** * Creates a new multi editor instance * * @param states an array containing the name of the states to create */ public MultiEditor( String [] states ) { this.states = new State[states.length]; for( int i = 0; i != states.length; ++i ) { this.states[i] = new State(states[i]); } } /** * Adds the given setting to a given state * * @param state the name of a state * @param setting the setting to add to the given state */ public void addSetting( String state, Setting setting ) { if( setting != null ) { for( int i = 0; i != states.length; ++i ) { if( states[i].name.equals(state) ) { states[i].addSettingToSelect(setting); } else { states[i].addSettingToDeselect(setting); } } } } /** * @see eclox.ui.editor.editors.IEditor#commit() */ public void commit() { // Commits the selected state. if( selection != null ) { selection.commit(); } dirty = false; fireEditorChanged(); } /** * Retrieves the selected state of the editor * * @return a string representing the selected state, or null if none */ public String getSelection() { return (selection != null) ? selection.getName() : null; } /** * @see eclox.ui.editor.editors.IEditor#isDirty() */ public boolean isDirty() { return dirty; } /** * @see eclox.ui.editor.editors.IEditor#isStale() */ public boolean isStale() { // Looks for the state that wants the selection. State wantedSelection = null; for( int i = 0; i != states.length; ++i ) { if( states[i].wantsSelection() ) { wantedSelection = states[i]; break; } } return wantedSelection != selection; } /** * Sub-classes must call this method first, in order to refresh the current state * and then refresh the user interface controls, according to the current state. * * @see eclox.ui.editor.editors.IEditor#refresh() */ public void refresh() { selection = null; dirty = false; // Searches the states that wants to be selected for( int i = 0; i != states.length; ++i ) { if( states[i].wantsSelection() ) { selection = states[i]; break; } } fireEditorChanged(); } /** * Retrieves the selected state of the multi editor. * * @return a state or null when none */ protected State getSelectionAsState() { return selection; } /** * Retrieves the state for the given name * * @name a string containing a state name * * @return the matching state or null when none */ protected State getState( String name ) { State found = null; for( int i = 0; i != states.length; ++i ) { if( states[i].getName() .equals(name) ) { found = states[i]; break; } } return found; } /** * Selectes the given state * * @param state a string containing a state name */ protected void selectState( String state ) { State candidate = getState(state); if( candidate != null ) { selection = candidate; dirty = true; fireEditorChanged(); } } } eclox/eclox.ui/src/eclox/ui/editor/basic/Part.java 0000644 0000764 0000764 00000015173 12166012446 021457 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.basic; import java.util.Collection; import java.util.Iterator; import java.util.Vector; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.ui.forms.IFormColors; import org.eclipse.ui.forms.SectionPart; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import eclox.core.doxyfiles.Doxyfile; import eclox.ui.editor.editors.IEditor; /** * Implements a specialized part that provide convenient features * to build user interfaces and manage editor life-cycles. * * @author gbrocker */ public class Part extends SectionPart { /** * The managed collection of editors */ private Collection editors = new Vector(); /** * The content of the section control */ private Composite content; /** * The toolkit used for control creation */ private FormToolkit toolkit; /** * The accumulation of separation spaces */ private int spacer = 0; /** * the doxyfile being edited */ protected Doxyfile doxyfile; /** * Contructor * * @param parent the parent control * @param tk the toolit used to create controls * @param title the title of the part * @param doxyfile the doxyfile being edited */ public Part(Composite parent, FormToolkit tk, String title, Doxyfile doxyfile) { super( parent, tk, Section.TITLE_BAR/*|Section.EXPANDED|Section.TWISTIE*/ ); this.doxyfile = doxyfile; // Initializes the section and its client component. Section section = getSection(); GridLayout layout = new GridLayout(); toolkit = tk; content = toolkit.createComposite(section); layout.numColumns = 2; layout.marginTop = 0; layout.marginRight = 0; layout.marginBottom = 0; layout.marginLeft = 0; layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 2; content.setLayout( layout ); section.setText(title); section.setClient(content); } /** * Adds a new label to the part * * @param text the text of the label */ protected void addLabel( String text ) { Label label = toolkit.createLabel(content, text, SWT.WRAP); GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); data.horizontalSpan = 2; data.verticalIndent = spacer; label.setLayoutData(data); spacer = 0; } /** * Adds the given editor instance to the part, with the given label. * * The editor life-cycle will get managed by the part. * * @param text a string containing a label text * @param editor an editor instance */ protected void addEditor( String text, IEditor editor ) { addEditor( text, editor, 0 ); } /** * Adds the given editor instance to the part, with the given label. * * The editor life-cycle will get managed by the part. * * @param text a string containing a label text * @param editor an editor instance * @param indent an extra margin that will be added to the left side of the editor's cell */ protected void addEditor( String text, IEditor editor, int indent ) { // Creates the controls Label label = toolkit.createLabel(content, text); Composite container = toolkit.createComposite(content); GridData labelData = new GridData(SWT.FILL, SWT.CENTER, false, false); GridData containerData = new GridData(SWT.FILL, SWT.FILL, true, false); labelData.verticalIndent = spacer; labelData.horizontalIndent = indent; labelData.grabExcessVerticalSpace = editor.grabVerticalSpace(); containerData.verticalIndent = spacer; containerData.grabExcessVerticalSpace = editor.grabVerticalSpace(); label.setLayoutData(labelData); label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); container.setLayoutData(containerData); editor.createContent(container, toolkit); spacer = 0; // Registers the editor editors.add(editor); } /** * Adds the given editor instance to the part * * The editor life-cycle will get managed by the part. * * @param editor an editor instance */ protected void addEditor( IEditor editor ) { addEditor( editor, 0 ); } /** * Adds the given editor instance to the part * * The editor life-cycle will get managed by the part. * * @param editor an editor instance * @param indent an extra margin that will be added to the left side of the editor's cell */ protected void addEditor( IEditor editor, int indent ) { // Create the controls Composite container = toolkit.createComposite(content); GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); data.verticalIndent = spacer; data.horizontalSpan = 2; data.horizontalIndent = indent; data.grabExcessVerticalSpace = editor.grabVerticalSpace(); editor.createContent(container, toolkit); container.setLayoutData(data); spacer = 0; // Registers the editor editors.add(editor); } /** * Adds a new separator to the part */ protected void addSperator() { spacer += 8; } /** * @see org.eclipse.ui.forms.AbstractFormPart#isDirty() */ public boolean isDirty() { boolean dirty = super.isDirty(); Iterator i = editors.iterator(); while( i.hasNext() && !dirty ) { IEditor editor = (IEditor) i.next(); dirty = editor.isDirty(); } return dirty; } /** * @see org.eclipse.ui.forms.AbstractFormPart#isStale() */ public boolean isStale() { boolean stale = super.isStale(); Iterator i = editors.iterator(); while( i.hasNext() && !stale ) { IEditor editor = (IEditor) i.next(); stale = editor.isStale(); } return stale; } /** * @see org.eclipse.ui.forms.AbstractFormPart#refresh() */ public void refresh() { super.refresh(); Iterator i = editors.iterator(); while( i.hasNext() ) { IEditor editor = (IEditor) i.next(); editor.refresh(); } } /** * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean) */ public void commit(boolean onSave) { super.commit(onSave); Iterator i = editors.iterator(); while( i.hasNext() ) { IEditor editor = (IEditor) i.next(); if( editor.isDirty() ) { editor.commit(); } } } } eclox/eclox.ui/src/eclox/ui/editor/basic/CheckMultiEditor.java 0000644 0000764 0000764 00000006610 12166012446 023744 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.basic; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; /** * Implements a specialized multi editor that is represented by a check box and * provides only two states: SELECTED and DESELECTED. * * @author Guillaume Brocker */ public class CheckMultiEditor extends MultiEditor { /** * the selected state name constant */ public static final String SELECTED = "Selected"; /** * the deselected state name constant */ public static final String DESELECTED = "Deselected"; /** * Defines the selection listener for the check box button */ private class MySelectionListener implements SelectionListener { public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } public void widgetSelected(SelectionEvent e) { Button button = (Button) e.widget; selectState( button.getSelection() ? SELECTED : DESELECTED ); commit(); } } /** * a string containing the text to use for the check box button */ private String text; /** * the check box button that represents the editor */ private Button button; /** * Constructor * * @param text a string containing the text that will be used for the check box control */ public CheckMultiEditor( String text ) { super( new String[] {SELECTED, DESELECTED} ); this.text = text; } /** * @see eclox.ui.editor.editors.IEditor#createContent(org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit) */ public void createContent(Composite parent, FormToolkit formToolkit) { button = formToolkit.createButton(parent, text, SWT.CHECK); button.addSelectionListener( new MySelectionListener() ); parent.setLayout(new FillLayout(SWT.VERTICAL)); } /** * @see eclox.ui.editor.editors.IEditor#dispose() */ public void dispose() { button = null; } /** * @see eclox.ui.editor.editors.IEditor#grabVerticalSpace() */ public boolean grabVerticalSpace() { return false; } /** * @see eclox.ui.editor.basic.MultiEditor#refresh() */ public void refresh() { // Pre-condition assert button != null; // Refreshes the states. super.refresh(); // Refreshes the check box State selection = getSelectionAsState(); button.setSelection( selection != null && selection.getName().equals(SELECTED) ); } /** * @see eclox.ui.editor.editors.IEditor#setEnabled(boolean) */ public void setEnabled(boolean enabled) { // Pre-condition assert button != null; button.setEnabled(enabled); } /** * @see eclox.ui.editor.editors.IEditor#setFocus() */ public void setFocus() { // Pre-condition assert button != null; button.setFocus(); } } eclox/eclox.ui/src/eclox/ui/editor/basic/DiagramsPart.java 0000644 0000764 0000764 00000012517 12166012446 023126 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.basic; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; import eclox.core.doxyfiles.Doxyfile; import eclox.ui.editor.editors.CheckBoxEditor; import eclox.ui.editor.editors.IEditor; import eclox.ui.editor.editors.IEditorListener; /** * Implements a art that provides editors for diagram generation controlling. * * @author Guillaume Brocker */ public class DiagramsPart extends Part { /** * Implements an editor listener that will trigger enabled state updates. */ private class MyEditorListener implements IEditorListener { /** * @see eclox.ui.editor.editors.IEditorListener#editorChanged(eclox.ui.editor.editors.IEditor) */ public void editorChanged(IEditor editor) { // Pre-condition assert editor == diagrams; final String selection = diagrams.getSelection(); final boolean enabled = selection != null && selection.equals(DIAGRAM_DOT_TOOL); classGraph .setEnabled(enabled && classGraph.hasInput()); collaborationGraph.setEnabled(enabled && collaborationGraph.hasInput()); includeGraph .setEnabled(enabled && includeGraph.hasInput()); includedByGraph .setEnabled(enabled && includedByGraph.hasInput()); graphicalHierarcy .setEnabled(enabled && graphicalHierarcy.hasInput()); callGraph .setEnabled(enabled && callGraph.hasInput()); } } /** * symbolic constant for diagram activation's state */ private static final String DIAGRAM_NONE = "No diagrams"; /** * symbolic constant for diagram activation's state */ private static final String DIAGRAM_BUILT_IN = "Use built-in diagram generator"; /** * symbolic constant for diagram activation's state */ private static final String DIAGRAM_DOT_TOOL = "Use dot tool from the GraphViz package to generate:"; /** * the editor for diagram activation */ private MultiEditor diagrams = new RadioMultiEditor( new String[] {DIAGRAM_NONE, DIAGRAM_BUILT_IN, DIAGRAM_DOT_TOOL} ); /** * the editor for the dot class graph generation */ private CheckBoxEditor classGraph = new CheckBoxEditor("class diagrams"); /** * the editor for the dot collaboration graph generation */ private CheckBoxEditor collaborationGraph = new CheckBoxEditor("collaboration diagrams"); /** * the editor for the dot include graph generation */ private CheckBoxEditor includeGraph = new CheckBoxEditor("include dependency graph"); /** * the editor for the dot included by graph generation */ private CheckBoxEditor includedByGraph = new CheckBoxEditor("included by dependency graph"); /** * the editor for the dot hierarchy graph generation */ private CheckBoxEditor graphicalHierarcy = new CheckBoxEditor("overall class hierarchy"); /** * the editor for the dot call graph generation */ private CheckBoxEditor callGraph = new CheckBoxEditor("call graphs"); /** * Constructor * * @param parent the parent composite * @param toolkit the toolkit to use for control creations * @param doxyfile the doxyfile being edited */ DiagramsPart( Composite parent, FormToolkit toolkit, Doxyfile doxyfile ) { super( parent, toolkit, "Diagrams to Generate", doxyfile ); // Creates all editors. addEditor( diagrams ); addEditor( classGraph, 16 ); addEditor( collaborationGraph, 16 ); addEditor( includeGraph, 16 ); addEditor( includedByGraph, 16 ); addEditor( graphicalHierarcy, 16 ); addEditor( callGraph, 16 ); // Setup all editors. if( doxyfile.hasSetting("CLASS_DIAGRAMS") && doxyfile.hasSetting("HAVE_DOT") ) { diagrams.addListener(new MyEditorListener()); diagrams.addSetting(DIAGRAM_BUILT_IN, doxyfile.getSetting("CLASS_DIAGRAMS")); diagrams.addSetting(DIAGRAM_DOT_TOOL, doxyfile.getSetting("HAVE_DOT")); classGraph .setInput(doxyfile.getSetting("CLASS_GRAPH")); collaborationGraph.setInput(doxyfile.getSetting("COLLABORATION_GRAPH")); includeGraph .setInput(doxyfile.getSetting("INCLUDE_GRAPH")); includedByGraph .setInput(doxyfile.getSetting("INCLUDED_BY_GRAPH")); graphicalHierarcy .setInput(doxyfile.getSetting("GRAPHICAL_HIERARCHY")); callGraph .setInput(doxyfile.getSetting("CALL_GRAPH")); classGraph .setEnabled(classGraph.hasInput()); collaborationGraph.setEnabled(collaborationGraph.hasInput()); includeGraph .setEnabled(includeGraph.hasInput()); includedByGraph .setEnabled(includedByGraph.hasInput()); graphicalHierarcy .setEnabled(graphicalHierarcy.hasInput()); callGraph .setEnabled(callGraph.hasInput()); } else { diagrams .setEnabled(false); classGraph .setEnabled(false); collaborationGraph.setEnabled(false); includeGraph .setEnabled(false); includedByGraph .setEnabled(false); graphicalHierarcy .setEnabled(false); callGraph .setEnabled(false); } } } eclox/eclox.ui/src/eclox/ui/editor/basic/Page.java 0000644 0000764 0000764 00000006601 12166012446 021421 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.basic; import org.eclipse.swt.SWT; 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.ui.forms.IManagedForm; import org.eclipse.ui.forms.editor.FormPage; import org.eclipse.ui.forms.widgets.FormToolkit; import eclox.core.doxyfiles.Doxyfile; import eclox.ui.editor.Editor; /** * Implements the overview page. * * @author gbrocker */ public class Page extends FormPage { /** * The page identifier. */ public static final String ID = "basic"; /** * the doxyfile being edited */ private Doxyfile doxyfile; /** * Constructor. */ public Page(Editor editor) { super(editor, Page.ID, "Basic"); doxyfile = editor.getDoxyfile(); } /** * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm) */ protected void createFormContent(IManagedForm managedForm) { FormToolkit toolkit = managedForm.getToolkit(); Composite parent = managedForm.getForm().getBody(); managedForm.getForm().setText(this.getTitle()); // Creates all parts of the form. ProjectPart projectPart = new ProjectPart( parent, toolkit, doxyfile ); OutputPart outputPart = new OutputPart( parent, toolkit, doxyfile ); ModePart modePart = new ModePart( parent, toolkit, doxyfile ); DiagramsPart diagramsPart = new DiagramsPart( parent, toolkit, doxyfile ); managedForm.addPart(projectPart); managedForm.addPart(outputPart); managedForm.addPart(modePart); managedForm.addPart(diagramsPart); // Creates the layout. FormLayout layout = new FormLayout(); layout.marginWidth = 16; layout.marginHeight = 16; layout.spacing = 20; parent.setLayout(layout); FormData data; data = new FormData(); data.top = new FormAttachment(0); data.right = new FormAttachment(50); data.bottom = new FormAttachment(modePart.getSection(), 0, SWT.TOP); data.left = new FormAttachment(0); projectPart.getSection().setLayoutData(data); data = new FormData(); data.top = new FormAttachment(0); data.right = new FormAttachment(100); data.bottom = new FormAttachment(diagramsPart.getSection(), 0, SWT.TOP); data.left = new FormAttachment(projectPart.getSection(), 0, SWT.RIGHT); outputPart.getSection().setLayoutData(data); data = new FormData(); data.right = new FormAttachment(50); data.bottom = new FormAttachment(100); data.left = new FormAttachment(0); modePart.getSection().setLayoutData(data); data = new FormData(); data.top = new FormAttachment(outputPart.getSection(), 0, SWT.BOTTOM); data.right = new FormAttachment(100); data.left = new FormAttachment(modePart.getSection(), 0, SWT.RIGHT); diagramsPart.getSection().setLayoutData(data); super.createFormContent(managedForm); } } eclox/eclox.ui/src/eclox/ui/editor/basic/ProjectPart.java 0000644 0000764 0000764 00000005420 12166012446 023000 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2008, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor.basic; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; import eclox.core.doxyfiles.Doxyfile; import eclox.ui.editor.editors.CheckBoxEditor; import eclox.ui.editor.editors.DirectoryEditor; import eclox.ui.editor.editors.DirectoryListEditor; import eclox.ui.editor.editors.TextEditor; /** * Implements the part that will provide editior for the project settings. * * @author gbrocker */ public class ProjectPart extends Part { /** * the project name setting editor */ private TextEditor nameEditor = new TextEditor(); /** * the project version or identifier editor */ private TextEditor versionEditor = new TextEditor(); /** * the project input editor */ private DirectoryListEditor inputEditor = new DirectoryListEditor(); /** * the recursive scan editor */ private CheckBoxEditor recursiveEditor = new CheckBoxEditor("Scan recursively"); /** * the project output editor */ private DirectoryEditor outputEditor = new DirectoryEditor(); /** * Constructor * * @param parent the parent composite of the part content * @param toolkit the toolkit to use for control creations * @param doxyfile the doxyfile being edited */ ProjectPart( Composite parent, FormToolkit toolkit, Doxyfile doxyfile ) { super( parent, toolkit, "Project", doxyfile ); addEditor("Name:", nameEditor); addEditor("Version or Identifier:", versionEditor); addSperator(); addLabel("Input directories:"); addEditor(inputEditor); addEditor(recursiveEditor); addSperator(); addEditor("Output Directory:", outputEditor); nameEditor .setInput( doxyfile.getSetting("PROJECT_NAME") ); versionEditor .setInput( doxyfile.getSetting("PROJECT_NUMBER") ); inputEditor .setInput( doxyfile.getSetting("INPUT") ); outputEditor .setInput( doxyfile.getSetting("OUTPUT_DIRECTORY") ); recursiveEditor.setInput( doxyfile.getSetting("RECURSIVE") ); nameEditor .setEnabled( nameEditor.hasInput() ); versionEditor .setEnabled( versionEditor.hasInput() ); inputEditor .setEnabled( inputEditor.hasInput() ); outputEditor .setEnabled( outputEditor.hasInput() ); recursiveEditor.setEnabled( recursiveEditor.hasInput() ); } } eclox/eclox.ui/src/eclox/ui/editor/SourcePage.java 0000644 0000764 0000764 00000001734 12166012446 021523 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2004, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.editor; import org.eclipse.ui.forms.editor.FormPage; /** * @author gbrocker */ public class SourcePage extends FormPage { /** * Defines the source page identifer. */ public static final String ID = "source"; /** * Constructor. * * @param editor the editor instance to attach to */ public SourcePage(Editor editor) { super(editor, ID, "Sources"); } } eclox/eclox.ui/src/eclox/ui/DoxyfileSelector.java 0000644 0000764 0000764 00000024573 12166012446 021472 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003, 2004, 2007, 2008, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; import org.eclipse.ui.dialogs.ISelectionStatusValidator; import org.eclipse.ui.model.IWorkbenchAdapter; import eclox.core.Plugin; import eclox.core.doxyfiles.ResourceCollector; /** * Allow the user to choose one doxyfile among a list. * * @author gbrocker */ public class DoxyfileSelector { /** * Implement the tree content provider for the dialog. */ private static class MyContentProvider implements ITreeContentProvider { /** * The doxyfile collection. */ private Collection m_input = null; /** * Disposes of this content provider. This is called by the viewer when it is disposed. */ public void dispose() {} /** * Notifies this content provider that the given viewer's input has been switched to a different element. */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { m_input = (Collection) newInput; } /** * Returns the child elements of the given parent element. * * @param parentElement the parent element * * @return an array of child elements */ public Object[] getChildren(Object parentElement) { Collection children = new ArrayList(); Iterator doxyfileIt = m_input.iterator(); while(doxyfileIt.hasNext()) { IFile doxyfile = (IFile) doxyfileIt.next(); if(doxyfile.getProject() == parentElement) { children.add(doxyfile); } } return children.toArray(); } /** * Returns the elements to display in the viewer when its input is set to the given element. These elements can be presented as rows in a table, items in a list, etc. The result is not modified by the viewer. * * @param inputElement the input element * * @return the array of elements to display in the viewer */ public Object[] getElements(Object inputElement) { Collection doxyfiles = (Collection) inputElement; Object[] result = null; if(doxyfiles != null) { Collection projects = new HashSet(); Iterator doxyfileIt = doxyfiles.iterator(); while(doxyfileIt.hasNext() == true) { IFile doxyfile = (IFile) doxyfileIt.next(); projects.add(doxyfile.getProject()); } result = projects.toArray(); } else { result = new Object[0]; } return result; } /** * Returns the parent for the given element, or null indicating that the parent can't be computed. * * In this case the tree-structured viewer can't expand a given node correctly if requested. * * @param element the element * * @return the parent element, or null if it has none or if the parent cannot be computed. */ public Object getParent(Object element) { Object result = null; if(element instanceof IProject) { return null; } else if(element instanceof IFile) { return ((IFile)element).getProject(); } return result; } /** * Returns whether the given element has children. * * Intended as an optimization for when the viewer does not need the actual children. Clients may be able to implement this more efficiently than getChildren. * * @param element the element * * @return true if the given element has children, and false if it has no children */ public boolean hasChildren(Object element) { return element instanceof IProject; } } /** * Implement a label provider for the doxyfile selector tree viewer. */ private static class MyLabelProvider extends LabelProvider { /** * Returns the image for the label of the given element. * The image is owned by the label provider and must not be disposed directly. * Instead, dispose the label provider when no longer needed. * * @param element the element for which to provide the label image * * @return the image used to label the element, * or null if there is no image for the given object */ public Image getImage(Object element) { // Pre-condition. assert element instanceof IResource; Image result = null; IResource resourse = (IResource) element; IWorkbenchAdapter workbenchAdapter = (IWorkbenchAdapter) resourse.getAdapter( IWorkbenchAdapter.class ); if( workbenchAdapter != null ) { result = workbenchAdapter.getImageDescriptor( element ).createImage(); } return result; } /** * The LabelProvider implementation of this ILabelProvider method returns * the element's toString string. Subclasses may override. * * @param element the element for which to provide the label text * * @return the text string used to label the element, * or null if there is no text label for the given object */ public String getText(Object element) { // Pre-condition. assert element instanceof IResource; String result = null; IResource resourse = (IResource) element; IWorkbenchAdapter workbenchAdapter = (IWorkbenchAdapter) resourse.getAdapter( IWorkbenchAdapter.class ); if( workbenchAdapter != null ) { result = workbenchAdapter.getLabel( element ); } return result; } } /** * Implement a doxyfile selection validator. */ private static class MySelectionValidator implements ISelectionStatusValidator { /** * Validates an array of elements and returns the resulting status. * * @param selection The elements to validate * * @return The resulting status */ public IStatus validate(Object[] selection) { IStatus result = null; if(selection.length == 1 && selection[0] instanceof IFile) { result = new Status( Status.OK, Plugin.getDefault().getBundle().getSymbolicName(), 0, "", null ); } else { result = new Status( Status.ERROR, Plugin.getDefault().getBundle().getSymbolicName(), 0, "You must choose a Doxyfile to build.", null); } return result; } } private boolean hadDoxyfiles = false; ///< Tells if there were doxyfiles for selection. private IFile doxyfile = null; ///< The selected doxyfile private IResource root = null; ///< The root resource that is that will be starting point for doxyfiles search. /** * @param root the root resource to search for doxyfiles, the workspace root if null */ public DoxyfileSelector( IResource rootResource ) { this.root = rootResource; } /** * Opens the selection dialog and tells if the user validated to selection. * * @return true when a selection was made, false otherwise. */ public boolean open() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); IStructuredSelection structuredSelection = (selection != null && selection instanceof IStructuredSelection) ? (IStructuredSelection) selection : new StructuredSelection(); boolean result = false; try { ResourceCollector collector = root != null ? ResourceCollector.run(root) : ResourceCollector.run(); hadDoxyfiles = collector.isEmpty() == false; if( collector.isEmpty() == false ) { ElementTreeSelectionDialog selectionDialog = new ElementTreeSelectionDialog(shell, new MyLabelProvider(), new MyContentProvider()); selectionDialog.setAllowMultiple( false ); selectionDialog.setInput( collector.getDoxyfiles() ); selectionDialog.setValidator( new MySelectionValidator() ); selectionDialog.setEmptyListMessage( "No Doxyfile found in opened projects." ); selectionDialog.setMessage( "Select a Doxyfile:" ); selectionDialog.setTitle( "Doxyfile Selection" ); selectionDialog.setInitialSelections( structuredSelection.toArray() ); // Opens the selection dialog and save the selection. if( selectionDialog.open() == ElementTreeSelectionDialog.OK ) { doxyfile = (IFile) selectionDialog.getFirstResult(); result = true; } } } catch( Throwable t ) { eclox.ui.Plugin.log(t); } return result; } /** * Convenient method that prompts the user to select a doxyfile. * * @param root The root resource to search for doxyfiles * * @return the selected doxyfile, null otherwise */ public static IFile open( IResource root ) { DoxyfileSelector selector = new DoxyfileSelector(root); selector.open(); return selector.getDoxyfile(); } /** * @brief Asks the user for a doxyfile. * * @return a doxyfile, null if none has been choosen */ public IFile getDoxyfile() { return doxyfile; } /** * @brief Tells if there were doxyfiles for last selection. * * @return true or false */ public boolean hadDoxyfiles() { return hadDoxyfiles; } } eclox/eclox.ui/src/eclox/ui/action/ 0000755 0000764 0000764 00000000000 12166321432 016603 5 ustar willy willy eclox/eclox.ui/src/eclox/ui/action/BuildPopupActionDelegate.java 0000644 0000764 0000764 00000007006 12166012446 024327 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003, 2004? 2007, 2008, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.action; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.Platform; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IWorkbenchPart; import eclox.core.doxyfiles.Doxyfile; import eclox.core.doxyfiles.ResourceCollector; import eclox.ui.DoxyfileSelector; import eclox.ui.Plugin; /** * Implement a pop-up menu action delegate that will allow to * launch doxygen builds from resources' contextual menu. * * @author gbrocker */ public class BuildPopupActionDelegate implements IObjectActionDelegate { private IResource resource; ///< References the resource that is under the contextual menu. private IWorkbenchPart targetPart; ///< References the part where the action taks place. /** * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) */ public void setActivePart(IAction action, IWorkbenchPart targetPart) { this.targetPart = targetPart; } /** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(IAction action) { try { IFile doxyfile = null; // If there is a resource, it is either a doxyfile // and if not, we prompt the user to get one. if( resource != null ) { doxyfile = Doxyfile.isDoxyfile(resource) ? (IFile) resource : DoxyfileSelector.open(resource); } if( doxyfile != null ) { Plugin.getDefault().getBuildManager().build( doxyfile ); } } catch(Throwable throwable) { MessageDialog.openError(targetPart.getSite().getShell(), "Unexpected Error", throwable.toString()); } } /** * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ public void selectionChanged(IAction action, ISelection selection) { boolean enabled = false; IStructuredSelection strSelection = (IStructuredSelection) selection; try { if( strSelection.size() == 1 ) { Object object = strSelection.getFirstElement(); IResource resource = (IResource) Platform.getAdapterManager().getAdapter(object, IResource.class); this.resource = resource; if( resource != null && resource.isAccessible() ) { ResourceCollector collector = ResourceCollector.run(resource); // If there is only one collected doxyfile, then assigns that doxyfile as the current resource. this.resource = collector.getSize() == 1 ? collector.getFirst() : this.resource; // Enables the action when a doxyfile has been found. enabled = collector.isEmpty() == false; } } } catch(Throwable throwable) { MessageDialog.openError(targetPart.getSite().getShell(), "Unexpected Error", throwable.toString()); } action.setEnabled(enabled); } } eclox/eclox.ui/src/eclox/ui/action/BuildActionDelegate.java 0000644 0000764 0000764 00000022560 12166012446 023305 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003, 2004, 2007, 2008, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.action; import org.eclipse.core.resources.IFile; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowPulldownDelegate; import org.eclipse.ui.PlatformUI; import eclox.core.doxyfiles.Doxyfile; import eclox.core.doxygen.BuildJob; import eclox.ui.DoxyfileSelector; import eclox.ui.Plugin; import eclox.ui.wizard.NewDoxyfileWizard; /** * Implement the action handling for the build action. * * @author gbrocker */ public class BuildActionDelegate implements IWorkbenchWindowPulldownDelegate { /** * Listens for the popup menu items pointing to doxyfiles to build. * * @author Guillaume Brocker */ private class MenuSelectionListener implements SelectionListener { public void widgetSelected(SelectionEvent e) { processData(e.widget.getData()); } public void widgetDefaultSelected(SelectionEvent e) { processData(e.widget.getData()); } private void processData(Object data) { boolean forceChoose = false; if(data != null && data instanceof IFile) { nextDoxyfile = (IFile) data; forceChoose = false; } else { forceChoose = true; } doRun(forceChoose); } } private Menu menu; ///< The managed contextual menu. private IFile nextDoxyfile; ///< Rembers the next doxyfile to build. private IWorkbenchWindow window; ///< Holds the reference to the workbench window where the action takes place. /** * @see org.eclipse.ui.IWorkbenchWindowPulldownDelegate#getMenu(org.eclipse.swt.widgets.Control) */ public Menu getMenu(Control parent) { disposeMenu(); this.menu = new Menu(parent); // Fill it up with the build history items. BuildJob[] buildJobs = Plugin.getDefault().getBuildManager().getRecentBuildJobs(); for( int i = buildJobs.length - 1; i >= 0; i-- ) { MenuItem menuItem = new MenuItem(this.menu, SWT.PUSH); IFile currentDoxyfile = buildJobs[i].getDoxyfile(); menuItem.addSelectionListener( new MenuSelectionListener() ); menuItem.setData( currentDoxyfile ); menuItem.setText( currentDoxyfile.getName() + " [" + currentDoxyfile.getFullPath().toString() + "]" ); } // Add some sugar in the ui if( buildJobs.length > 0 ) { new MenuItem(this.menu, SWT.SEPARATOR); } // Add the fall-back menu item to let the user choose another doxyfile. MenuItem chooseMenuItem = new MenuItem(this.menu, SWT.PUSH); chooseMenuItem.addSelectionListener(new MenuSelectionListener()); chooseMenuItem.setText("Choose Doxyfile..."); // Job's done. return this.menu; } /** * Dispose the delegate. */ public void dispose() { // Frees all resources and references. disposeMenu(); nextDoxyfile = null; window = null; } /** * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) */ public void init(IWorkbenchWindow window) { this.window = window; } /** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(IAction action) { try { doRun(false); } catch( Throwable throwable ) { MessageDialog.openError(window.getShell(), "Unexpected Error", throwable.toString()); } } /** * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ public void selectionChanged(IAction action, ISelection selection) { try { // Retrieve the next doxyfile to build from the current selection. nextDoxyfile = getDoxyfileFromSelection(selection); // Retrieve the next doxyfile from the current editor. if( nextDoxyfile == null ) { nextDoxyfile = getDoxyfileFromActiveEditor(window); } // If there is no next doxyfile to build and the history is not empty // set the first history element as the next doxyfile. if( nextDoxyfile == null ) { BuildJob[] buildJobs = Plugin.getDefault().getBuildManager().getRecentBuildJobs(); int buildJobsCount = buildJobs.length; if( buildJobsCount > 0 ) { nextDoxyfile = buildJobs[buildJobsCount - 1].getDoxyfile(); } } // Check the existence of the doxyfile. if( nextDoxyfile != null && nextDoxyfile.exists() == false ) { nextDoxyfile = null; } // Update the tooltip. String tooltipText = nextDoxyfile != null ? "Build " + nextDoxyfile.getFullPath().toString() : "Choose Next Doxyfile"; action.setToolTipText(tooltipText); } catch(Throwable throwable) { MessageDialog.openError(window.getShell(), "Unexpected Error", throwable.toString()); } } /** * Uses the next doxyfile specified to determine what to do. * * @param forceChoose @c true to ask the user for a doxyfile to build. */ protected void doRun(boolean forceChoose) { try { IFile doxyfile = (forceChoose == true) ? null : this.nextDoxyfile; DoxyfileSelector selector = new DoxyfileSelector(null); // If there is no next doxyfile to build, ask the user for one. if(doxyfile == null) { selector.open(); doxyfile = selector.getDoxyfile(); } // If there is no doxyfile, // we will prompt the user to create one and then edit it. if (doxyfile == null && selector.hadDoxyfiles() == false) { doxyfile = askUserToCreateDoxyfile(); } else if (doxyfile != null) { Plugin.getDefault().getBuildManager().build( doxyfile ); } } catch( Throwable throwable ) { MessageDialog.openError(window.getShell(), "Unexpected Error", throwable.toString()); } } /** * Dispose the owned menu. */ private void disposeMenu() { if(this.menu != null) { this.menu.dispose(); this.menu = null; } } /** * Retrieves a doxyfile from the active editor. * * @param window a reference to a workbench window * * @return a doxfile retrieved from the active editor input. */ private static IFile getDoxyfileFromActiveEditor( IWorkbenchWindow window ) { IFile doxyfile = null; IWorkbenchPage activePage = window.getActivePage(); IEditorPart activeEditorPart = activePage != null ? window.getActivePage().getActiveEditor() : null; if(activeEditorPart != null) { IEditorInput activeEditorInput = activeEditorPart.getEditorInput(); if(activeEditorInput instanceof IFileEditorInput) { IFileEditorInput fileEditorInput = (IFileEditorInput)activeEditorInput; IFile file = fileEditorInput.getFile(); if(Doxyfile.isDoxyfile(file) == true) { doxyfile = file; } } } return doxyfile; } /** * Retrieves a doxyfile from the specified selection. * * @return a doxyfile retrieved from the specified selection. */ private static IFile getDoxyfileFromSelection(ISelection selection) { IFile doxyfile = null; // Test if the current selection is not empty. if(selection instanceof IStructuredSelection && selection.isEmpty() == false) { IStructuredSelection structSel = (IStructuredSelection) selection; Object element = structSel.getFirstElement(); if(element != null && element instanceof IFile) { IFile fileElement = (IFile) element; if(fileElement.exists() == true && Doxyfile.isDoxyfile(fileElement) == true) { doxyfile = fileElement; } } } // Job's done. return doxyfile; } /** * Prompts the user to create a new doxyfile. * * @return a doxyfile, or null if none. */ private static IFile askUserToCreateDoxyfile() { IFile doxyfile = null; Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); boolean wantDoxyfile = MessageDialog.openQuestion(shell, "No Doxyfile Found", "No doxyfile has been found in opened projects.\n\nDo you want to create a new doxyfile now ?" ); if( wantDoxyfile ) { NewDoxyfileWizard wizard = new NewDoxyfileWizard(); ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); IStructuredSelection strcSelection = (selection != null && selection instanceof IStructuredSelection) ? (IStructuredSelection) selection : new StructuredSelection(); wizard.init(PlatformUI.getWorkbench(), strcSelection); WizardDialog wizardDialog = new WizardDialog(shell, wizard); wizardDialog.open(); doxyfile = wizard.getDoxyfile(); } return doxyfile; } } eclox/eclox.ui/src/eclox/ui/wizard/ 0000755 0000764 0000764 00000000000 12166321431 016625 5 ustar willy willy eclox/eclox.ui/src/eclox/ui/wizard/NewDoxyfileWizard.java 0000644 0000764 0000764 00000007326 12166012446 023121 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003, 2004, 2007, 2008, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.wizard; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; import org.eclipse.ui.INewWizard; import org.eclipse.ui.IWorkbench; import eclox.core.doxygen.Doxygen; import eclox.core.doxygen.InvokeException; import eclox.core.doxygen.RunException; import eclox.ui.Plugin; /** * Implement the new file wizard extension to provide a way to create * new doxyfiles. * * @author gbrocker */ public class NewDoxyfileWizard extends Wizard implements INewWizard { private IFile m_doxyfile; ///< The created doxyfile. private NewDoxyfileWizardPage m_page; ///< The wizard page used to get the file name. /** * Retrieves the created doxyfile. * * @return the created doxyfile, null if none */ public IFile getDoxyfile() { return m_doxyfile; } /** * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) */ public void init( IWorkbench workbench, IStructuredSelection selection ) { m_page = new NewDoxyfileWizardPage( selection ); addPage( m_page ); setWindowTitle( "New Doxygen Configuration" ); } /** * @see org.eclipse.jface.wizard.Wizard#performFinish() */ public boolean performFinish() { for(;;) { // Creates the doxyfile resource. IFile doxyfile = createFile( m_page.getContainerFullPath(), m_page.getFileName() ); // Warn user if the doxyfile exists. if( doxyfile.exists() ) { MessageDialog.openWarning(getShell(), "Resource Exists", "The resource " + doxyfile.getFullPath().toString() + " already exists !" ); return false; } // Creates the effective resource file. try { Doxygen.getDefault().generate( doxyfile ); m_doxyfile = doxyfile; return true; } // Doxygen returned an error. catch( RunException runException ) { MessageDialog.openError(getShell(), "Doxygen Error", "An error occured while running doxygen. " + runException.toString()); return true; } // Doxygen was impossible to run. catch( InvokeException invokeException ) { if( Plugin.editPreferencesAfterDoxygenInvocationFailed() ) { continue; } // Stops the wizard. return true; } } } /** * Create the resource file. * * @param containerPath The path to the container for the resource to create. * @param fileName A string containnig the name of the file resource to create. * * @return The created file resource. The file system's file hasn't been created at this step. */ private IFile createFile( IPath containerPath, String fileName ) { IFile result; IPath filePath; String fileExtension; filePath = containerPath.append( fileName ); fileExtension = filePath.getFileExtension(); if( (fileExtension == null || fileExtension.compareToIgnoreCase( "Doxyfile" ) != 0) && fileName.compareToIgnoreCase("Doxyfile") != 0 ) { filePath = filePath.addFileExtension( "Doxyfile" ); } result = ResourcesPlugin.getWorkspace().getRoot().getFile( filePath ); return result; } } eclox/eclox.ui/src/eclox/ui/wizard/NewDoxyfileWizardPage.java 0000644 0000764 0000764 00000004636 12166012446 023717 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2008, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui.wizard; import org.eclipse.core.resources.IResource; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.dialogs.WizardNewFileCreationPage; import eclox.ui.Images; import eclox.ui.Plugin; /** * @author gbrocker * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Generation - Code and Comments */ public class NewDoxyfileWizardPage extends WizardNewFileCreationPage { /** * Retrieves the initial doxyfile name relative to the given object that * is supposed to be a resource. * * If the object is not an IResourec instance, and adapter is searched for it. */ private static String getInitialFileName( Object object ) { IResource resource; // Skip null objects if( object == null ) { resource = null; } // Try the direct convertion to a IResource else if( object instanceof IResource ) { resource = (IResource) object; } // Try to find an adapter else { resource = (IResource) org.eclipse.core.runtime.Platform.getAdapterManager().getAdapter(object, IResource.class); } // Finally, gets the project name for the resource (if one has been found). return (resource != null) ? (resource.getProject().getName() + ".doxyfile") : new String(); } /** * Constructor. * * @param selection The current selection object. */ public NewDoxyfileWizardPage(IStructuredSelection selection) { super("page", selection); setTitle("Doxygen Configuration"); setDescription("Creates a new Doxygen configuration file."); setFileName( selection != null ? getInitialFileName(selection.getFirstElement()) : new String() ); setImageDescriptor( Plugin.getImageDescriptor(Images.DOXYFILE_WIZARD)); } /** * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#getNewFileLabel() */ protected String getNewFileLabel() { return "Doxyfile &name:"; } } eclox/eclox.ui/src/eclox/ui/PreferencesInitializer.java 0000644 0000764 0000764 00000002514 12166012446 022642 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2006, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.jface.preference.IPreferenceStore; import eclox.ui.IPreferences; /** * Implements the prefenrence initializer for the plugin. * * @author gbrocker */ public class PreferencesInitializer extends AbstractPreferenceInitializer { /** * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() */ public void initializeDefaultPreferences() { IPreferenceStore preferences = Plugin.getDefault().getPreferenceStore(); preferences.setDefault( IPreferences.BUILD_HISTORY_SIZE, 5 ); preferences.setDefault( IPreferences.AUTO_SAVE, IPreferences.AUTO_SAVE_ASK ); preferences.setDefault( IPreferences.HANDLE_ESCAPED_VALUES, true ); } } eclox/eclox.ui/src/eclox/ui/Plugin.java 0000644 0000764 0000764 00000010330 12166012446 017426 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2008, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; /** * The plugin class. */ /** * @author gbrocker * */ public class Plugin extends AbstractUIPlugin { private static Plugin plugin; ///< The singleton instance. private BuildManager buildManager; ///< The managed build manager. private JobMonitor jobMonitor; ///< The managed job monitor. /** * Asks the user if he wants to edit doxygen configuration after a failed * doxygen invocation. * * @return @c true if doxygen configuration has been edited, @c false otherwise */ public static boolean editPreferencesAfterDoxygenInvocationFailed() { Shell shell = plugin.getWorkbench().getActiveWorkbenchWindow().getShell(); // Asks the user if he wants to edit the preferences to solve the problem. boolean editionWanted = MessageDialog.openQuestion(shell, "Doxygen Not Found", "Eclox was not able to run doxygen. Doxygen is either missing or eclox is not properly configured to use it.\n\nWould you like to edit preferences now ?" ); if( ! editionWanted ) { return false; } // Allows the user to edit the preferences and eventually launch doxygen again. String[] filter = { eclox.core.ui.PreferencePage.ID }; int edited = PreferencesUtil.createPreferenceDialogOn(shell, eclox.core.ui.PreferencePage.ID, filter, null).open(); return edited == Window.OK; } /** * The constructor. */ public Plugin() { plugin = this; } /** * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ public void start(BundleContext context) throws Exception { super.start(context); buildManager = new BuildManager(); buildManager.restoreState(); jobMonitor = new JobMonitor(); Job.getJobManager().addJobChangeListener(jobMonitor); } /** * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ public void stop(BundleContext context) throws Exception { buildManager.saveState(); buildManager = null; Job.getJobManager().removeJobChangeListener(jobMonitor); jobMonitor = null; plugin = null; super.stop(context); } /** * Returns the shared instance. */ public static Plugin getDefault() { return plugin; } /** * Retrieves the build manager of the plugin. * * @return the managed build manager instance */ public BuildManager getBuildManager() { return buildManager; } /** * Adds the specified throwable object into the plugin's log as an error. * * @param throwable a throwable instance to log */ public static void log( Throwable throwable ) { plugin.getLog().log( new Status(Status.ERROR, plugin.getBundle().getSymbolicName(), 0, "Exception caught. " + throwable.toString(), throwable) ); } /** * Adds the specified message into the plugin's log as an error. * * @param message a string containing a message to log. */ public static void log( String message ) { plugin.getLog().log( new Status(Status.ERROR, plugin.getBundle().getSymbolicName(), 0, "Error encountered. " + message, null) ); } /** * Returns an image descriptor for the image file at the given * plug-in relative path. * * @param path the path * @return the image descriptor */ public static ImageDescriptor getImageDescriptor(String path) { return AbstractUIPlugin.imageDescriptorFromPlugin( plugin.getBundle().getSymbolicName(), path); } } eclox/eclox.ui/src/eclox/ui/PreferencePage.java 0000644 0000764 0000764 00000004565 12166012446 021060 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2004, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.IntegerFieldEditor; import org.eclipse.jface.preference.RadioGroupFieldEditor; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; /** * Implements the plugin preference page. * * @author gbrocker */ public class PreferencePage extends org.eclipse.jface.preference.FieldEditorPreferencePage implements IWorkbenchPreferencePage { /** * Constructor. */ public PreferencePage() { super( GRID ); } public void init( IWorkbench workbench ) { setPreferenceStore( Plugin.getDefault().getPreferenceStore() ); } /** * Creates the preference page fields. */ protected void createFieldEditors() { Composite rootControl = getFieldEditorParent(); // Create the controls. BooleanFieldEditor escapeValueStrings = new BooleanFieldEditor(IPreferences.HANDLE_ESCAPED_VALUES, "Handle escapes for \" and \\ in value strings", rootControl); escapeValueStrings.setPreferenceStore( getPreferenceStore() ); addField( escapeValueStrings ); IntegerFieldEditor historySize = new IntegerFieldEditor(IPreferences.BUILD_HISTORY_SIZE, "Build history size:", rootControl); historySize.setPreferenceStore( getPreferenceStore() ); historySize.setValidRange( 1, 100 ); addField( historySize ); RadioGroupFieldEditor autoSave = new RadioGroupFieldEditor( IPreferences.AUTO_SAVE, "Save all modified files before building", 1, new String[][] { {IPreferences.AUTO_SAVE_NEVER, IPreferences.AUTO_SAVE_NEVER}, {IPreferences.AUTO_SAVE_ALWAYS, IPreferences.AUTO_SAVE_ALWAYS}, {IPreferences.AUTO_SAVE_ASK, IPreferences.AUTO_SAVE_ASK}, }, rootControl, true ); autoSave.setPreferenceStore( getPreferenceStore() ); addField( autoSave ); } } eclox/eclox.ui/src/eclox/ui/BuildManager.java 0000644 0000764 0000764 00000014422 12166012446 020530 0 ustar willy willy /******************************************************************************* * Copyright (C) 2003-2008, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Preferences; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.ui.PlatformUI; import eclox.core.doxyfiles.Doxyfile; import eclox.core.doxygen.BuildJob; import eclox.core.doxygen.IBuildJobListener; import eclox.ui.console.Console; /** * This class is responsible to launch the build for the given doxyfile * and also manages the build history. * * @see Plugin * * @author gbrocker */ public class BuildManager { /** * Implements a job listener that will update the job history as jobs get removed. */ private class MyJobListener implements IBuildJobListener { public void buildJobLogCleared(BuildJob job) { } public void buildJobLogUpdated(BuildJob job, String output) { } public void buildJobRemoved(BuildJob job) { jobHistory.remove( job ); job.removeBuidJobListener( this ); } } /** * Implements a preference listener that will maintain the length of the job history * according to the relevant preference changes. */ private class MyPreferenceListener implements IPropertyChangeListener { public void propertyChange(PropertyChangeEvent event) { if( event.getProperty() == IPreferences.BUILD_HISTORY_SIZE ) { int newSize = ((Integer) event.getNewValue()).intValue(); int curSize = jobHistory.size(); if( curSize > newSize ) { jobHistory = jobHistory.subList( curSize - newSize, curSize ); } } } } private static String STATE_FILE = new String("build-job-history.txt"); private List jobHistory = new LinkedList(); ///< Contains the history the launched build jobs. /** * Constructor */ public BuildManager() { // Attaches a property change listener on the plugin's preference store. Plugin.getDefault().getPreferenceStore().addPropertyChangeListener( new MyPreferenceListener() ); } /** * Launches the build of the given doxyfile. * * @param doxyfile the doxyfile to build */ public void build( IFile doxyfile ) { // Retrieves the plug-in preferences. Preferences preferences = Plugin.getDefault().getPluginPreferences(); // Ask the user if he wants to save all opened editors before proceeding to build. final String autoSave = preferences.getString( IPreferences.AUTO_SAVE ); if( autoSave.equals( IPreferences.AUTO_SAVE_ALWAYS ) ) { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().saveAllEditors( false ); } else if( autoSave.equals( IPreferences.AUTO_SAVE_ASK ) ) { boolean saved; saved = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().saveAllEditors( true ); if( saved == false ) { return; } } else if( autoSave.equals( IPreferences.AUTO_SAVE_NEVER) ) { // Nothing to perform. } else { // Not supported. assert( false ); Plugin.log( autoSave + ": unsupported auto save state."); } // Retrieves the build job for the given doxyfile. BuildJob job = BuildJob.getJob( doxyfile ); // Attaches a listener if applicable. if( jobHistory.contains(job) == false ) { job.addBuidJobListener( new MyJobListener() ); } // Updates the job history. int preferedHistorySize = preferences.getInt( IPreferences.BUILD_HISTORY_SIZE ); jobHistory.remove( job ); if( jobHistory.size() >= preferedHistorySize && jobHistory.isEmpty() == false ) { jobHistory.remove( 0 ); } jobHistory.add( job ); // Updates the console. Console.show( job ); // Schedule the job to build. job.schedule(1000); } /** * Retrieves the latest build jobs that have been registered in the history. * * @return an array containing the most recent build jobs. */ public BuildJob[] getRecentBuildJobs() { return (BuildJob[]) jobHistory.toArray( new BuildJob[0] ); } /** * Restores the state from a file. */ public void restoreState() { try { IPath statePath = Plugin.getDefault().getStateLocation().append(STATE_FILE); File stateFile = new File( statePath.toOSString() ); if( stateFile.canRead() == true ) { BufferedReader stateReader = new BufferedReader(new FileReader(stateFile)); String stateLine = stateReader.readLine(); while( stateLine != null ) { IPath doxyfilePath = new Path( stateLine ); IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(doxyfilePath); if( Doxyfile.isDoxyfile(resource) ) { IFile doxyfile = (IFile) resource; BuildJob job = BuildJob.getJob(doxyfile); jobHistory.add(job); } stateLine = stateReader.readLine(); } } } catch( Throwable t ) { Plugin.log( t ); } } /** * Saves the state to a file. */ public void saveState() { IPath statePath = Plugin.getDefault().getStateLocation().append(STATE_FILE); File stateFile = new File( statePath.toOSString() ); stateFile.delete(); // Now saves the resource path of the next doxyfile to build. try { FileWriter stateWriter = new FileWriter( stateFile ); Iterator i = jobHistory.iterator(); while( i.hasNext() ) { BuildJob job = (BuildJob) i.next(); IFile doxyfile = job.getDoxyfile(); stateWriter.write( doxyfile.getFullPath().toString() ); stateWriter.write( String.valueOf('\n') ); } stateWriter.flush(); } catch( Throwable t ) { Plugin.log(t); } } } eclox/eclox.ui/src/eclox/ui/JobMonitor.java 0000644 0000764 0000764 00000002774 12166012446 020267 0 ustar willy willy /******************************************************************************* * Copyright (C) 2008, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui; import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.JobChangeAdapter; import org.eclipse.swt.widgets.Display; import eclox.core.doxygen.BuildJob; /** * @brief Monitors all doxygen build jobs and report errors * concerning doxygen invokation failures. * * @author gbrocker */ public class JobMonitor extends JobChangeAdapter { /** * @see org.eclipse.core.runtime.jobs.JobChangeAdapter#done(org.eclipse.core.runtime.jobs.IJobChangeEvent) */ public void done(IJobChangeEvent event) { if( event.getJob().belongsTo(BuildJob.FAMILY) && event.getResult().getCode() == BuildJob.ERROR_DOXYGEN_NOT_FOUND ) { Display display = Plugin.getDefault().getWorkbench().getDisplay(); display.asyncExec( new Runnable() { public void run() { Plugin.editPreferencesAfterDoxygenInvocationFailed(); } } ); } } } eclox/eclox.ui/src/eclox/ui/Images.java 0000644 0000764 0000764 00000001633 12166012446 017403 0 ustar willy willy /******************************************************************************* * Copyright (C) 2006-2007, 2013, Guillaume Brocker * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Guillaume Brocker - Initial API and implementation * ******************************************************************************/ package eclox.ui; public interface Images { static String DOXYFILE_WIZARD = "icons/doxyfile_wiz.gif"; static String CLEAR_CONSOLE = "icons/clear_console.gif"; static String ERASE = "icons/erase.png"; static String LOCK_CONSOLE = "icons/lock_console.gif"; static String TERMINATE = "icons/terminate.gif"; static String REMOVE = "icons/remove_console.gif"; } eclox/eclox.ui/plugin.xml 0000644 0000764 0000764 00000004037 10727223666 015047 0 ustar willy willy