本文整理匯總了Java中org.eclipse.ui.IMemento類的典型用法代碼示例。如果您正苦於以下問題:Java IMemento類的具體用法?Java IMemento怎麽用?Java IMemento使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IMemento類屬於org.eclipse.ui包,在下文中一共展示了IMemento類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import org.eclipse.ui.IMemento; //導入依賴的package包/類
@Override
public void init ( final IViewSite site, final IMemento memento ) throws PartInitException
{
if ( memento != null )
{
this.connectionId = memento.getString ( CONNECTION_ID );
this.connectionUri = memento.getString ( CONNECTION_URI );
}
super.init ( site, memento );
try
{
// it is OK to fail at this stage
reInitializeConnection ( this.connectionId, this.connectionUri );
}
catch ( final Exception e )
{
logger.warn ( "init () - couldn't recreate connection", e ); //$NON-NLS-1$
// just reset all values
this.connectionId = null;
this.connectionUri = null;
this.connectionService = null;
this.connectionTracker = null;
}
}
示例2: saveTo
import org.eclipse.ui.IMemento; //導入依賴的package包/類
public void saveTo ( final IMemento memento )
{
if ( memento == null )
{
return;
}
{
final IMemento tableMemento = memento.createChild ( "tableCols" ); //$NON-NLS-1$
for ( int i = 0; i < this.viewer.getTree ().getColumnCount (); i++ )
{
final TreeColumn col = this.viewer.getTree ().getColumn ( i );
tableMemento.putInteger ( "col_" + i, col.getWidth () ); //$NON-NLS-1$
}
}
for ( final ListEntry entry : this.list.getItems () )
{
final Item item = entry.getItem ();
item.saveTo ( memento.createChild ( "item" ) ); //$NON-NLS-1$
}
}
示例3: saveState
import org.eclipse.ui.IMemento; //導入依賴的package包/類
@Override
public void saveState(IMemento memento) {
// Scroll lock
memento.putBoolean("scrollLock", scrollLock);
// Limit log chars
memento.putInteger("limitLogChars", limitLogChars);
// Activate on new events
memento.putBoolean("activateOnNewEvents", activateOnNewEvents);
// Column order
memento.putString("columnOrder", Arrays.toString(tableViewer.getTable().getColumnOrder()));
// Column information
for (ColumnInfo columnInfo : columnInfos) {
IMemento columnInfoMemento = memento.createChild("columnInfo");
columnInfoMemento.putString("name", columnInfo.getName());
columnInfoMemento.putBoolean("visible", columnInfo.isVisible());
columnInfoMemento.putInteger("size", columnInfo.getSize());
}
super.saveState(memento);
}
示例4: saveState
import org.eclipse.ui.IMemento; //導入依賴的package包/類
@Override
public void saveState(IMemento memento) {
super.saveState(memento);
try {
final List<IScanPathModel> models = getPath();
stash.stash(models);
for (String propName : trees.keySet()) {
IStashing tstash = ServiceHolder.getStashingService().createStash(propName+".json");
tstash.stash(trees.get(propName));
}
} catch (Exception ne) {
logger.error("Cannot save generators to memento!", ne);
}
}
示例5: saveCodeFolding
import org.eclipse.ui.IMemento; //導入依賴的package包/類
/**
* Saves the code folding state into the given memento.
*/
public void saveCodeFolding(IMemento memento) {
// The annotation model might be null if the editor opened an storage input
// instead of a file input.
if (projectionAnnotationModel == null) {
return;
}
Iterator<?> annotationIt = projectionAnnotationModel.getAnnotationIterator();
while (annotationIt.hasNext()) {
ProjectionAnnotation annotation = (ProjectionAnnotation) annotationIt.next();
IMemento annotationMemento = memento.createChild(ANNOTATION);
Position position = projectionAnnotationModel.getPosition(annotation);
annotationMemento.putBoolean(IS_COLLAPSED, annotation.isCollapsed());
annotationMemento.putInteger(OFFSET, position.offset);
annotationMemento.putInteger(LENGTH, position.length);
}
}
示例6: restoreCodeFoldingStateFromFile
import org.eclipse.ui.IMemento; //導入依賴的package包/類
/**
* <p>
* Restores the code folding state from a XML file in the state location.
* </p>
*
* @param uriString the key to determine the file to load the state from
*/
public void restoreCodeFoldingStateFromFile(String uriString) {
final File stateFile = getCodeFoldingStateFile(uriString);
if (stateFile == null || !stateFile.exists()) {
calculatePositions();
return;
}
SafeRunner.run(new SafeRunnable("Unable to read code folding state. The state will be reset.") {
public void run() throws Exception {
FileInputStream input = new FileInputStream(stateFile);
BufferedReader reader = new BufferedReader(new InputStreamReader(input, "utf-8"));
IMemento memento = XMLMemento.createReadRoot(reader);
reader.close();
String sourceText = sourceViewer.getDocument().get();
if (memento.getString(VERIFY_KEY).equals(makeMD5(sourceText))) {
restoreCodeFolding(memento);
} else {
calculatePositions();
}
}
});
}
示例7: populateWithStateToSave
import org.eclipse.ui.IMemento; //導入依賴的package包/類
private void populateWithStateToSave(final VSUser user, final IMemento memento) {
for (final Iterator it = user.workspaces.keySet().iterator(); it.hasNext();) {
final String workspaceName = (String) it.next();
final VSWorkspace workspace = (VSWorkspace) user.workspaces.get(workspaceName);
final IMemento workspaceMemento = memento.createChild(WORKSPACE_CHILDREN, workspace.name);
for (final Iterator expandedPathsIt = workspace.expandedPaths.iterator(); expandedPathsIt.hasNext();) {
final String path = (String) expandedPathsIt.next();
final IMemento expandedMemento = workspaceMemento.createChild(EXPANDED_CHILDREN);
expandedMemento.putString(PATH_KEY, path);
}
if (workspace.selectedPath != null) {
final IMemento selectedMemento = workspaceMemento.createChild(SELECTED_CHILD);
selectedMemento.putString(PATH_KEY, workspace.selectedPath);
}
}
}
示例8: setSavedState
import org.eclipse.ui.IMemento; //導入依賴的package包/類
public void setSavedState(final IMemento memento) {
servers.clear();
if (memento == null) {
return;
}
final IMemento folderControlMemento = memento.getChild(FOLDER_CONTROL_CHILD);
if (folderControlMemento == null) {
return;
}
final IMemento[] serverMementos = folderControlMemento.getChildren(SERVER_CHILDREN);
if (serverMementos != null) {
for (int i = 0; i < serverMementos.length; i++) {
if (serverMementos[i].getID() != null) {
final VSServer server = new VSServer(serverMementos[i].getID());
setSavedState(server, serverMementos[i]);
servers.put(server.guid, server);
}
}
}
}
示例9: saveState
import org.eclipse.ui.IMemento; //導入依賴的package包/類
@Override
public void saveState(final IMemento memento) {
super.saveState(memento);
final IMemento settings = memento.createChild(PARTICIPANT_SETTINGS);
// persist the paths of all resources that we're currently
// synchronizing,
// we'll use these paths to restore the synchronization view
final IResource[] resources = getResources();
final StringBuffer resourceList = new StringBuffer();
for (int i = 0; i < resources.length; i++) {
if (i > 0) {
resourceList.append("|"); //$NON-NLS-1$
}
resourceList.append(resources[i].getLocation().toOSString());
if (resources[i].getType() != IResource.FILE) {
resourceList.append("/"); //$NON-NLS-1$
}
}
settings.putString(PARTICIPANT_SETTINGS_RESOURCES, resourceList.toString());
}
示例10: init
import org.eclipse.ui.IMemento; //導入依賴的package包/類
/**
* Initialize the editor. Called when first created or when logged in to
* server.
*/
private void init(final IMemento memento) {
folderControl.populateTreeUsingServerRoot();
if (memento != null) {
folderControlViewState.setSavedState(memento);
}
final ServerItemPath[] expanded = folderControlViewState.getPreviouslyExpandedPaths();
if (expanded != null && expanded.length > 0) {
folderControl.setExpandedItems(expanded);
} else {
folderControl.expandToLevel(TFSItemFactory.getRoot(), 1);
}
final ServerItemPath selected = folderControlViewState.getPreviouslySelectedPath();
if (selected != null) {
folderControl.setSelectedItem(selected);
} else {
folderControl.setSelectedItem(ServerItemPath.ROOT);
}
handleFolderSelection(folderControl.getSelection());
}
示例11: load
import org.eclipse.ui.IMemento; //導入依賴的package包/類
/**
* Load history elements from memento.
*
* @param memento
* memento from which the history will be retrieved
*/
public void load(IMemento memento) {
XMLMemento historyMemento = (XMLMemento) memento
.getChild(rootNodeName);
if (historyMemento == null) {
return;
}
IMemento[] mementoElements = historyMemento
.getChildren(infoNodeName);
for (int i = 0; i < mementoElements.length; ++i) {
IMemento mementoElement = mementoElements[i];
Object object = restoreItemFromMemento(mementoElement);
if (object != null) {
historyList.add(object);
}
}
}
示例12: createDefaultLayer_10_Map
import org.eclipse.ui.IMemento; //導入依賴的package包/類
private static void createDefaultLayer_10_Map(final IMemento xml) {
createLayerXml_120_Default(xml, true, true, 1.0f, MapDefaultLayer.ID_STARS);
createLayerXml_120_Default(xml, true, true, 1.0f, MapDefaultLayer.ID_ATMOSPHERE);
createLayerXml_120_Default(xml, true, true, 1.0f, MapDefaultLayer.ID_NASA_BLUE_MARBLE_IMAGE);
createLayerXml_120_Default(xml, true, true, 1.0f, MapDefaultLayer.ID_BLUE_MARBLE_WMS_2004);
createLayerXml_120_Default(xml, true, true, 1.0f, MapDefaultLayer.ID_I_CUBED_LANDSAT);
createLayerXml_120_Default(xml, false, true, 1.0f, MapDefaultLayer.ID_USDA_NAIP);
createLayerXml_120_Default(xml, false, true, 1.0f, MapDefaultLayer.ID_USDA_NAIP_USGS);
createLayerXml_120_Default(xml, true, true, 1.0f, MapDefaultLayer.ID_MS_VIRTUAL_EARTH_AERIAL);
createLayerXml_120_Default(xml, true, true, 1.0f, MapDefaultLayer.ID_BING_IMAGERY);
createLayerXml_120_Default(xml, false, true, 1.0f, MapDefaultLayer.ID_USGS_TOPOGRAPHIC_MAPS_1_250K);
createLayerXml_120_Default(xml, false, true, 1.0f, MapDefaultLayer.ID_USGS_TOPOGRAPHIC_MAPS_1_100K);
createLayerXml_120_Default(xml, false, true, 1.0f, MapDefaultLayer.ID_USGS_TOPOGRAPHIC_MAPS_1_24K);
createLayerXml_120_Default(xml, false, true, 1.0f, MapDefaultLayer.ID_USGS_URBAN_AREA_ORTHO);
createLayerXml_120_Default(xml, true, true, 1.0f, MapDefaultLayer.ID_POLITICAL_BOUNDARIES);
createLayerXml_120_Default(xml, false, true, 1.0f, MapDefaultLayer.ID_OPEN_STREET_MAP);
createLayerXml_120_Default(xml, false, true, 1.0f, MapDefaultLayer.ID_EARTH_AT_NIGHT);
}
示例13: readXml_Date
import org.eclipse.ui.IMemento; //導入依賴的package包/類
private static void readXml_Date( final IMemento xmlProperty,
final TourFilterProperty filterProperty,
final int fieldNo) {
final LocalDateTime defaultDate = fieldNo == 1
? TourFilterProperty.DEFAULT_DATE_1
: TourFilterProperty.DEFAULT_DATE_2;
final int year = Util.getXmlInteger(xmlProperty, ATTR_DATE_YEAR + fieldNo, defaultDate.getYear());
final int month = Util.getXmlInteger(xmlProperty, ATTR_DATE_MONTH + fieldNo, defaultDate.getMonthValue());
final int day = Util.getXmlInteger(xmlProperty, ATTR_DATE_DAY + fieldNo, defaultDate.getDayOfMonth());
final LocalDateTime date = LocalDateTime.of(year, month, day, 0, 0);
if (fieldNo == 1) {
filterProperty.dateTime1 = date;
} else {
filterProperty.dateTime2 = date;
}
}
示例14: saveState_URI
import org.eclipse.ui.IMemento; //導入依賴的package包/類
private static void saveState_URI( final URI[] location,
final IMetadataRepositoryManager metaManager,
final IMemento xmlRepositories,
final boolean isEnabled) {
for (final URI uri : location) {
final IMemento xmlRepo = xmlRepositories.createChild(TAG_REPOSITORY);
final String nickName = metaManager.getRepositoryProperty(uri, IRepository.PROP_NICKNAME);
xmlRepo.putString(ATTR_URI, uri.toASCIIString());
xmlRepo.putString(ATTR_NICK_NAME, nickName);
xmlRepo.putBoolean(ATTR_IS_ENABLED, isEnabled);
}
}
示例15: createElement
import org.eclipse.ui.IMemento; //導入依賴的package包/類
public IAdaptable createElement(IMemento memento) {
String uriStr = memento.getString(EMF_URI);
if (uriStr == null) {
return null;
}
URI uri = URI.createURI(uriStr);
ResourceSet resourceSet = DiagramPartitioningUtil.getSharedDomain().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if (resource == null)
resource = resourceSet.createResource(uri);
try {
resource.load(Collections.emptyMap());
} catch (IOException e) {
e.printStackTrace();
}
Diagram diagram = (Diagram) resource.getEObject(uri.fragment());
return new DiagramEditorInput(diagram);
}