Class ServerConfigView
- java.lang.Object
- org.eclipse.core.commands.common.EventManager
- org.eclipse.ui.part.WorkbenchPart
- org.eclipse.ui.part.ViewPart
- com.iizigo.server.ServerConfigView
- All Implemented Interfaces:
IActivationListener
,IWorkbenchPartIZ
,org.eclipse.core.runtime.IAdaptable
,org.eclipse.core.runtime.IExecutableExtension
,org.eclipse.ui.IPersistable
,org.eclipse.ui.ISaveablePart
,org.eclipse.ui.ISaveablePart2
,org.eclipse.ui.IViewPart
,org.eclipse.ui.IWorkbenchPart
,org.eclipse.ui.IWorkbenchPart2
,org.eclipse.ui.IWorkbenchPart3
,org.eclipse.ui.part.IWorkbenchPartOrientation
public class ServerConfigView extends org.eclipse.ui.part.ViewPart implements IWorkbenchPartIZ, org.eclipse.ui.ISaveablePart2, IActivationListener
The Server Configuration View displays a tree with the server configuration and a property editor for the properties.- Author:
- Christopher Mindus
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ID
The View Part ID.
Constructor Summary
Constructors Constructor Description ServerConfigView()
Creates the folder view.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
createPartControl(org.eclipse.swt.widgets.Composite parent)
Creates the view part.void
dispose()
Disposes of this workbench part.void
doSave(org.eclipse.core.runtime.IProgressMonitor monitor)
Saves the contents of this part.void
doSaveAs()
Saves the contents of this part to another object.IPartExtensionIZ
getExtension()
Gets the extensions framework.SelectionEnabler
getSelectionEnabler()
Gets the selection enabler instance.IPropUndoRedo
getUndoRedo()
Gets the undo/redo instance.void
init(org.eclipse.ui.IViewSite site, org.eclipse.ui.IMemento memento)
Initializes this view with the given view site.boolean
isDirty()
Returns whether the contents of this part have changed since the last save operation.boolean
isDisposed()
Checks if the part is disposed of.boolean
isSaveAsAllowed()
Returns whether the "Save As" operation is supported by this part.boolean
isSaveOnCloseNeeded()
Returns whether the contents of this part should be saved when the part is closed.void
onActivated(boolean on)
Called when activator or deactivated.void
onClose()
Called when about to close, but SWT is still there.static ServerConfigView
openFile(java.lang.String fileName, boolean doUpdateHistory)
Open a view for a Server configuration file, or focuses an existing view for the file.int
promptToSaveOnClose()
Prompts the user for input on what to do with unsaved data.void
saveState(org.eclipse.ui.IMemento memento)
Saves the state.void
setFocus()
Focus to best component, where the framework takes care of it normally.void
updateStates()
Called when states needs to be updated.Methods inherited from class org.eclipse.ui.part.ViewPart
checkSite, getViewSite, init, setContentDescription, setInitializationData, setPartName
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPartPropertyListener, addPropertyListener, firePartPropertyChanged, firePropertyChange, getAdapter, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, getTitleToolTip, removePartPropertyListener, removePropertyListener, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener
Methods inherited from interface com.iizigo.editor.IWorkbenchPartIZ
onComponentFocused
Method Detail
openFile
public static ServerConfigView openFile(java.lang.String fileName, boolean doUpdateHistory)
Open a view for a Server configuration file, or focuses an existing view for the file.- Parameters:
fileName
- The file name.doUpdateHistory
- Flag to update history for last recently used file.- Returns:
- The Server Configuration view, or null if the file doesn't exist.
init
public void init(org.eclipse.ui.IViewSite site, org.eclipse.ui.IMemento memento) throws org.eclipse.ui.PartInitException
Initializes this view with the given view site. A memento is passed to the view which contains a snapshot of the views state from a previous session. Where possible, the view should try to recreate that state within the part controls.This implementation will ignore the memento and initialize the view in a fresh state.
- Specified by:
init
in interfaceorg.eclipse.ui.IViewPart
- Overrides:
init
in classorg.eclipse.ui.part.ViewPart
- Throws:
org.eclipse.ui.PartInitException
saveState
public void saveState(org.eclipse.ui.IMemento memento)
Saves the state.- Specified by:
saveState
in interfaceorg.eclipse.ui.IPersistable
- Specified by:
saveState
in interfaceorg.eclipse.ui.IViewPart
- Overrides:
saveState
in classorg.eclipse.ui.part.ViewPart
createPartControl
public void createPartControl(org.eclipse.swt.widgets.Composite parent)
Creates the view part.- Specified by:
createPartControl
in interfaceorg.eclipse.ui.IWorkbenchPart
- Specified by:
createPartControl
in classorg.eclipse.ui.part.WorkbenchPart
dispose
public void dispose()
Disposes of this workbench part.This is the last method called on the IWorkbenchPart. At this point the part controls (if they were ever created) have been disposed as part of an SWT composite. There is no guarantee that createPartControl() has been called, so the part controls may never has been created.
Within this method a part may release any resources, fonts, images, etc. held by this part. It is also very important to de-register all listeners from the workbench.
- Specified by:
dispose
in interfaceorg.eclipse.ui.IWorkbenchPart
- Overrides:
dispose
in classorg.eclipse.ui.part.WorkbenchPart
setFocus
public void setFocus()
Focus to best component, where the framework takes care of it normally.- Specified by:
setFocus
in interfaceorg.eclipse.ui.IWorkbenchPart
- Specified by:
setFocus
in classorg.eclipse.ui.part.WorkbenchPart
getExtension
public IPartExtensionIZ getExtension()
Gets the extensions framework.- Specified by:
getExtension
in interfaceIWorkbenchPartIZ
getUndoRedo
public IPropUndoRedo getUndoRedo()
Gets the undo/redo instance.- Specified by:
getUndoRedo
in interfaceIWorkbenchPartIZ
isDisposed
public boolean isDisposed()
Checks if the part is disposed of.- Specified by:
isDisposed
in interfaceIActivationListener
- Specified by:
isDisposed
in interfaceIWorkbenchPartIZ
- Returns:
- true if disposed of, false otherwise.
getSelectionEnabler
public SelectionEnabler getSelectionEnabler()
Gets the selection enabler instance.- Specified by:
getSelectionEnabler
in interfaceIWorkbenchPartIZ
promptToSaveOnClose
public int promptToSaveOnClose()
Prompts the user for input on what to do with unsaved data. This method is only called when the part is closed or when the Workbench is shutting down.- Specified by:
promptToSaveOnClose
in interfaceorg.eclipse.ui.ISaveablePart2
- Returns:
- the return code, must be either
YES
,NO
,CANCEL
orDEFAULT
.
doSave
public void doSave(org.eclipse.core.runtime.IProgressMonitor monitor)
Saves the contents of this part.If the save is successful, the part should fire a property changed event reflecting the new dirty state (
PROP_DIRTY
property).If the save is cancelled through user action, or for any other reason, the part should invoke
setCancelled
on theIProgressMonitor
to inform the caller.This method is long-running; progress and cancellation are provided by the given progress monitor.
- Specified by:
doSave
in interfaceorg.eclipse.ui.ISaveablePart
- Parameters:
monitor
- the progress monitor
doSaveAs
public void doSaveAs()
Saves the contents of this part to another object.Implementors are expected to open a "Save As" dialog where the user will be able to select a new name for the contents. After the selection is made, the contents should be saved to that new name. During this operation a
IProgressMonitor
should be used to indicate progress.If the save is successful, the part fires a property changed event reflecting the new dirty state (
PROP_DIRTY
property).- Specified by:
doSaveAs
in interfaceorg.eclipse.ui.ISaveablePart
isDirty
public boolean isDirty()
Returns whether the contents of this part have changed since the last save operation. If this value changes the part must fire a property listener event withPROP_DIRTY
.Note: this method is called often on a part open or part activation switch, for example by actions to determine their enabled status.
- Specified by:
isDirty
in interfaceorg.eclipse.ui.ISaveablePart
- Returns:
true
if the contents have been modified and need saving, andfalse
if they have not changed since the last save
isSaveAsAllowed
public boolean isSaveAsAllowed()
Returns whether the "Save As" operation is supported by this part.- Specified by:
isSaveAsAllowed
in interfaceorg.eclipse.ui.ISaveablePart
- Returns:
true
if "Save As" is supported, andfalse
if not supported
isSaveOnCloseNeeded
public boolean isSaveOnCloseNeeded()
Returns whether the contents of this part should be saved when the part is closed.- Specified by:
isSaveOnCloseNeeded
in interfaceorg.eclipse.ui.ISaveablePart
- Returns:
true
if the contents of the part should be saved on close, andfalse
if the contents are expendable
updateStates
public void updateStates()
Called when states needs to be updated.- Specified by:
updateStates
in interfaceIActivationListener
onActivated
public void onActivated(boolean on)
Called when activator or deactivated.- Specified by:
onActivated
in interfaceIActivationListener
onClose
public void onClose()
Called when about to close, but SWT is still there.- Specified by:
onClose
in interfaceIActivationListener