#region Disclaimer / License
// Copyright (C) 2009, Kenneth Skovhede
// http://www.hexad.dk, opensource@hexad.dk
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
#endregion
using System;
namespace OSGeo.MapGuide.Maestro.ResourceEditors
{
///
/// This interface represents the properties and methods avalible for a resource editor,
/// for interacting with the main editor window.
///
public interface EditorInterface
{
///
/// Gets the current imagelist with known item icons
///
System.Windows.Forms.ImageList ImageList { get; }
///
/// Transforms the enumeration value int an image index for use with the list of known images
///
/// The type of icon to return
/// The imageindex for the desired icon
int ImageIndexForItem(string itemType);
//TODO: Figure out how to loose this dependency
///
/// Gets the current server connection. Can be used to retrieve the resource or other server items.
///
OSGeo.MapGuide.MaestroAPI.ServerConnectionI CurrentConnection { get; }
///
/// Instructs the editor to begin editing the selected resource. Focus will go to new editor with the selected resource.
///
/// The resource to edit
void EditItem(string resourceID);
///
/// Notifies the main editor that the resource has changed. This will put an asterisk (*) in the resource editor title.
///
void HasChanged();
///
/// Forces a check of the state of all opened resources (to update colors in the Site Explorer)
///
void UpdateResourceStates();
///
/// Forces a refresh of the Site Explorer
///
void RefreshTree();
///
/// Request a browse dialog for the specified resource type
///
/// The resource to browse for
/// The name of the selected resource, or null if the user cancelled
string BrowseResource(string itemType);
///
/// Request a browse dialog for the specified resource type
///
/// The resource to browse for, null for all valid resource types
/// The name of the selected resource, or null if the user cancelled
string BrowseResource(string[] itemTypes);
///
/// Request a browse dialog for the specified resource type
///
/// The resource to browse for
/// True if the user may select multiple items
/// The name of the selected resource, or null if the user cancelled
string[] BrowseResource(string itemType, bool multiSelect);
///
/// Request a browse dialog for the specified resource type
///
/// The resource types to browse for, null for all valid resource types
/// True if the user may select multiple items
/// The name of the selected resource, or null if the user cancelled
string[] BrowseResource(string[] itemTypes, bool multiSelect);
///
/// Deletes the current item from the server and removes the current page from the display
///
void Delete();
///
/// Closes the current interface
///
/// Ask the user to save changes (if any)
/// True if the page was closed, false if the user declined or an error occured
bool Close(bool askUser);
///
/// Gets or sets a value indicating if the resource is created in the repository
///
bool Existing { get; set; }
///
/// Gets or sets a value indicating if the resource is modified (ie. not saved)
///
bool IsModified { get; }
///
/// Informs the control that the editor is closing
///
event EventHandler Closing;
ResourceEditorMap ResourceEditorMap { get; }
///
/// Request a browse dialog for an unmanaged file
///
/// The initial path of the file
/// A list of valid file types. Key is extension, including leading period (ea: ".txt"). Value is text to display, (ea: "Text files (*.txt)").
/// The name of the selected file, or null if the user cancelled
string BrowseUnmanagedData(string startPath, System.Collections.Specialized.NameValueCollection filetypes);
///
/// Performs a lengthy operation and displays a progress dialog for the user
///
/// The sender that is updated when the progress starts
/// The method to invoke when the operation progress starts
/// DialogResult.OK if the operation succeeded, DialogResult.Cancel if the user cancelled
System.Windows.Forms.DialogResult LengthyOperation(object caller, System.Reflection.MethodInfo mi);
///
/// Performs a lengthy operation and displays a progress dialog for the user
///
/// The sender that is updated when the progress starts
/// The method to invoke when the operation progress starts
/// True if the user should be prompted before applying the changes
/// DialogResult.OK if the operation succeeded, DialogResult.Cancel if the user cancelled
System.Windows.Forms.DialogResult LengthyOperation(object caller, System.Reflection.MethodInfo mi, bool waitForAccept);
///
/// Edits an SQL expression, ea. a filter or label expression
///
/// The current text
/// The featureSource this expression is executed against
/// Null if the user cancelled, otherwise the new expression
string EditExpression(string current, OSGeo.MapGuide.MaestroAPI.FeatureSourceDescription.FeatureSourceSchema schema, string providername, string featureSourceId);
///
/// Opens the system default browser and displays the given Url
///
/// The url to display in the browser
void OpenUrl(string url);
///
/// Returns a value indicating if the preview should use a fusion based viewer
///
bool UseFusionPreview { get; }
///
/// Registers the last thrown exception so it can be displayed
///
/// The exception to register
void SetLastException(Exception ex);
///
/// Returns the actual resourceId for the item.
/// Can only be used if Existing is true
///
string ResourceId { get; }
///
/// Returns the default "Find" string for the item.
///
string getFind { get; }
///
/// Returns the default "Replace" string for the item.
///
string getReplace { get; }
}
}