本文整理匯總了Java中org.eclipse.ui.IMemento.getString方法的典型用法代碼示例。如果您正苦於以下問題:Java IMemento.getString方法的具體用法?Java IMemento.getString怎麽用?Java IMemento.getString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.ui.IMemento
的用法示例。
在下文中一共展示了IMemento.getString方法的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: 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);
}
示例3: save
import org.eclipse.ui.IMemento; //導入方法依賴的package包/類
/**
* Associate projects with branch. The specified memento must the one
* previously returned from a call to {@link #snapshot()}.
*
* @see #snapshot()
* @param memento
* @return this tracker
*/
public BranchProjectTracker save(final IMemento memento) {
if (!(memento instanceof XMLMemento))
throw new IllegalArgumentException("Invalid memento"); //$NON-NLS-1$
String branch = memento.getString(KEY_BRANCH);
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
String pref = getPreference(branch);
StringWriter writer = new StringWriter();
try {
((XMLMemento) memento).save(writer);
store.setValue(pref, writer.toString());
} catch (IOException e) {
Activator.logError("Error writing branch-project associations", e); //$NON-NLS-1$
}
return this;
}
示例4: restoreState
import org.eclipse.ui.IMemento; //導入方法依賴的package包/類
private void restoreState() {
if (memento == null)
return;
IMemento m = memento.getChild(ID);
if(m == null)
return;
int objHash = CastUtil.cint(m.getInteger("objHash"));
String objName = m.getString("objName");
String objType = m.getString("objType");
String counter = m.getString("counter");
int serverId = CastUtil.cint(m.getInteger("serverId"));
try {
setInput(objHash, objName, objType, counter, serverId);
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: restoreState
import org.eclipse.ui.IMemento; //導入方法依賴的package包/類
private void restoreState() {
if (memento == null)
return;
IMemento m = memento.getChild(ID);
int objHash = CastUtil.cint(m.getInteger("objHash"));
String objName = m.getString("objName");
String objType = m.getString("objType");
String counter = m.getString("counter");
int serverId = CastUtil.cint(m.getInteger("serverId"));
try {
setInput(objHash, objName, objType, counter, serverId);
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: restoreItemFromMemento
import org.eclipse.ui.IMemento; //導入方法依賴的package包/類
@Override
protected Object restoreItemFromMemento(final IMemento memento) {
final String uri = memento.getString(MEMENTO_URI_KEY);
if (!isNullOrEmpty(uri)) {
final Optional<IEObjectDescription> result = tryFind(indexSupplier.get().getExportedObjects(),
desc -> uri.equals(String.valueOf(desc.getEObjectURI())));
if (result.isPresent()) {
return searchKind.matches(result.get().getEClass()) ? result.get() : null;
}
}
return null;
}
示例7: init
import org.eclipse.ui.IMemento; //導入方法依賴的package包/類
@Override
public void init ( final IViewSite site, final IMemento memento ) throws PartInitException
{
super.init ( site, memento );
if ( memento != null )
{
final String s = memento.getString ( "columnSettings" ); //$NON-NLS-1$
if ( s != null )
{
this.initialColumnSettings = this.gson.fromJson ( s, new TypeToken<List<ColumnProperties>> () {}.getType () );
}
}
}
示例8: loadFrom
import org.eclipse.ui.IMemento; //導入方法依賴的package包/類
public static Item loadFrom ( final IMemento memento )
{
if ( memento == null )
{
return null;
}
final String itemId = memento.getString ( "item.id" );
final String connectionUri = memento.getString ( "connection.uri" );
final String typeStr = memento.getString ( "type" );
final Type type;
if ( typeStr != null )
{
type = Type.valueOf ( typeStr );
}
else
{
type = Type.URI;
}
if ( itemId == null || connectionUri == null || type == null )
{
return null;
}
else
{
return new Item ( connectionUri, itemId, type );
}
}
示例9: createElement
import org.eclipse.ui.IMemento; //導入方法依賴的package包/類
@Override
public IAdaptable createElement(IMemento memento) {
String projName = memento.getString(TAG_PROJECT);
ProjectEditorInput input = new ProjectEditorInput(projName);
IProject project =
(projName == null) ? null : ResourcesPlugin.getWorkspace().getRoot().getProject(projName);
if (project == null || !project.exists() || !project.isOpen()) {
input.setError(new PgCodekeeperUIException(Messages.project_either_closed_or_deleted + projName));
}
return input;
}
示例10: setResources
import org.eclipse.ui.IMemento; //導入方法依賴的package包/類
/**
* Restores the resources that were previously saved from a saveState().
* This will usually be called when opening a previously pinned sync view.
*
* @param settings
* The IMemento to restore from
*/
private void setResources(final IMemento settings) {
Check.notNull(settings, "settings"); //$NON-NLS-1$
final List<IResource> resourceList = new ArrayList<IResource>();
final String resourcePathList = settings.getString(PARTICIPANT_SETTINGS_RESOURCES);
if (resourcePathList == null) {
return;
}
final String[] resourcePaths = resourcePathList.split("\\|"); //$NON-NLS-1$
for (int i = 0; i < resourcePaths.length; i++) {
ResourceType resourceType = ResourceType.FILE;
if (resourcePaths[i].endsWith("/")) //$NON-NLS-1$
{
resourceType = ResourceType.CONTAINER;
}
final IResource resource = Resources.getResourceForLocation(resourcePaths[i], resourceType);
if (resource != null) {
resourceList.add(resource);
}
}
setResources(resourceList.toArray(new IResource[resourceList.size()]));
}
示例11: getEnum
import org.eclipse.ui.IMemento; //導入方法依賴的package包/類
private <T extends Enum<T>> T getEnum(IMemento memento, String key,
Class<T> type, T preset) {
if (memento == null) {
return preset;
}
final String s = memento.getString(key);
if (s == null) {
return preset;
}
try {
return Enum.valueOf(type, s);
} catch (IllegalArgumentException e) {
return preset;
}
}
示例12: init
import org.eclipse.ui.IMemento; //導入方法依賴的package包/類
@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
super.init(site);
if (memento != null) {
String u = memento.getString(IBrowserConstants.MEMENTO_URL);
if (u != null) {
initialUrl = u;
}
}
}
示例13: loadExpandedElements
import org.eclipse.ui.IMemento; //導入方法依賴的package包/類
private Object[] loadExpandedElements(BookmarksTree bookmarksTree, IMemento memento) {
if (memento == null) {
return new Object[0];
}
String expandedElementsStr = memento.getString(STORE_EXPANDED);
if (expandedElementsStr == null) {
return new Object[0];
}
String[] ids = expandedElementsStr.split(",");
return Arrays.stream(ids).map(id -> bookmarksTree.getBookmark(new BookmarkId(id)))
.filter(bookmark -> bookmark != null).toArray(size -> new Object[size]);
}
示例14: loadSelectedElement
import org.eclipse.ui.IMemento; //導入方法依賴的package包/類
private ISelection loadSelectedElement(BookmarksTree bookmarksTree, IMemento memento) {
if (memento == null) {
return new StructuredSelection();
}
String selectedIdStr = memento.getString(STORE_SELECTED);
if (selectedIdStr == null) {
return new StructuredSelection();
}
Bookmark bookmark = bookmarksTree.getBookmark(new BookmarkId(selectedIdStr));
if (bookmark == null) {
return new StructuredSelection();
}
return new StructuredSelection(bookmark);
}
示例15: restoreState
import org.eclipse.ui.IMemento; //導入方法依賴的package包/類
@Override
public void restoreState(IMemento memento) {
userName = memento.getString(ModelExplorer.USERNAME);
passWord = memento.getString(ModelExplorer.PASSWORD);
repository = memento.getString(ModelExplorer.REPOSITORY);
try {
storageAccess = StorageAccessFactory.createStorageAccess(userName, passWord, repository);
RWT.getUISession().setAttribute(ModelExplorer.STORAGEACCESS, storageAccess);
} catch (Exception e) {
e.printStackTrace();
}
}