com.google.gwt.place.shared.Place Java Examples

The following examples show how to use com.google.gwt.place.shared.Place. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InjectPresenterCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void initComposer(ClassSourceFileComposerFactory composerFactory) {
	composerFactory.addImport(Place.class.getName());
	composerFactory.addImport(Presenter.class.getName());
	for (JMethod presenterMethod : this.presenterMethods) {
		if (presenterMethod.getParameters().length > 0) {
			JType placeType = presenterMethod.getParameters()[0].getType();
			composerFactory.addImport(placeType.getQualifiedSourceName());
			if (placeType instanceof JParameterizedType) {
				JParameterizedType parameterizedType = (JParameterizedType) placeType;
				for (JType paramType : parameterizedType.getTypeArgs()) {
					composerFactory.addImport(paramType.getQualifiedSourceName());
				}
			}
		}
	}

	composerFactory.addImplementedInterface(Presenter.class.getSimpleName());
	composerFactory.addImport(AcceptsOneWidget.class.getName());
}
 
Example #2
Source File: ImportBatchItemEditor.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Handles a new children selection.
 */
private void loadItemInChildEditor(Record[] records) {
    actionSource.fireEvent();
    if (records == null || records.length == 0 || reorderTask.isReordered()) {
        childPlaces.goTo(Place.NOWHERE);
    } else {
        Place lastPlace = childPlaces.getWhere();
        DatastreamEditorType lastEditorType = null;
        if (lastPlace instanceof DigitalObjectEditorPlace) {
            DigitalObjectEditorPlace lastDOEPlace = (DigitalObjectEditorPlace) lastPlace;
            lastEditorType = lastDOEPlace.getEditorId();
        }
        lastEditorType = lastEditorType != null
                ? lastEditorType
                : DatastreamEditorType.MODS;
        childPlaces.goTo(new DigitalObjectEditorPlace(lastEditorType, records));
    }
}
 
Example #3
Source File: EditorWorkFlow.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
public EditorWorkFlow(EventBus ebus, PlaceController placeController,
        ActivityManager activityManager, Layout delegate,
        PresenterFactory presenterFactory, ClientMessages i18n) {

    this.presenterFactory = presenterFactory;
    this.i18n = i18n;
    this.ebus = (ebus != null) ? ebus : new SimpleEventBus();
    // PlaceController uses delegate to ask user with blocking Window.confirm
    // whether to leave the current place.
    // In order to use non blocking SmartGWT dialog
    // it will be necessary to override PlaceController.goto method.
    this.placeController = (placeController != null) ? placeController
            : new PlaceController(this.ebus);
    this.activityManager = (activityManager != null) ? activityManager
            : new ActivityManager(new EditorActivityMapper(), this.ebus);
    this.activityManager.setDisplay(new EditorDisplay(delegate));
    EditorPlaceHistoryMapper historyMapper = GWT.create(EditorPlaceHistoryMapper.class);
    placeHistoryHandler = new PlaceHistoryHandler(historyMapper);
    placeHistoryHandler.register(this.placeController, this.ebus, Place.NOWHERE);
}
 
Example #4
Source File: Editor.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private TreeNode createTreeNode(String name, String displayName, Place place, TreeNode... children) {
    if (name == null) {
        throw new NullPointerException("name");
    }
    TreeNode treeNode = new TreeNode(name);
    if (displayName != null) {
        treeNode.setTitle(displayName);
    }
    if (children != null && children.length > 0) {
        treeNode.setChildren(children);
    }
    if (place != null) {
        treeNode.setAttribute(PLACE_ATTRIBUTE, place);
    }
    return treeNode;
}
 
Example #5
Source File: EditorWorkFlow.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Activity getActivity(Place place) {
    Activity a = null;
    if (place instanceof DigitalObjectEditorPlace) {
        a = new DigitalObjectEditing((DigitalObjectEditorPlace) place,
                presenterFactory.getDigitalObjectEditor());
    } else if (place instanceof DigitalObjectCreatorPlace) {
        a = new DigitalObjectCreating((DigitalObjectCreatorPlace) place,
                presenterFactory);
    } else if (place instanceof ImportPlace) {
        a = new Importing((ImportPlace) place, presenterFactory);
    } else if (place instanceof UsersPlace) {
        a = new UserManaging((UsersPlace) place, presenterFactory);
    } else if (place instanceof DigitalObjectManagerPlace) {
        a = new DigitalObjectManaging((DigitalObjectManagerPlace) place, presenterFactory);
    } else if (place instanceof DeviceManagerPlace) {
        a = new DeviceManaging((DeviceManagerPlace) place, presenterFactory);
    } else if (place instanceof WorkflowPlace) {
        a = new WorkflowManaging((WorkflowPlace) place, presenterFactory);
    }
    return a;
}
 
Example #6
Source File: ApplicationClientModule.java    From bitcoin-transaction-explorer with MIT License 6 votes vote down vote up
@Override
protected void configure() {
  // Binding application critical architecture
  bind(ActivityMapper.class).to(ApplicationActivityMapper.class).in(Singleton.class);;
  bind(Place.class).annotatedWith(DefaultPlace.class).to(StartupPlace.class).in(Singleton.class);
  bind(PlaceController.class).to(ApplicationPlaceController.class).in(Singleton.class);
  bind(BitcoinPlaceRouter.class).to(ApplicationPlaceController.class).in(Singleton.class);
  bind(PlaceHistoryMapper.class).to(ApplicationPlaceHistoryMapper.class).in(Singleton.class);
  bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
  bind(ColorPicker.class).to(SimpleColorPicker.class).in(Singleton.class);

  // Binding views
  bind(StartupView.class).to(StartupViewImpl.class).in(Singleton.class);
  bind(TransactionView.class).to(TransactionViewImpl.class);
  bind(BlockView.class).to(BlockViewImpl.class);
  bind(MineView.class).to(MineViewImpl.class);
  bind(ScriptView.class).to(ScriptViewImpl.class);
  bind(ConfigView.class).to(ConfigViewImpl.class);
  bind(ContributeView.class).to(ContributeViewImpl.class);
  bind(RPCResponseView.class).to(RPCResponseViewImpl.class);
  bind(AddressView.class).to(AddressViewImpl.class);

  install(new GinFactoryModuleBuilder().build(ActivityFactory.class));
}
 
Example #7
Source File: ApplicationActivityMapper.java    From bitcoin-transaction-explorer with MIT License 6 votes vote down vote up
@Override
public Activity getActivity(final Place place) {
  Activity presenter = null;

  if (place instanceof StartupPlace) {
    presenter = factory.createStartupPresenter((StartupPlace) place);
  } else if (place instanceof TransactionPlace) {
    presenter = factory.createTransactionPresenter((TransactionPlace) place);
  } else if (place instanceof BlockPlace) {
    presenter = factory.createBlockPresenter((BlockPlace) place);
  } else if (place instanceof MinePlace) {
    presenter = factory.createMinePresenter((MinePlace) place);
  } else if (place instanceof ScriptPlace) {
    presenter = factory.createScriptPresenter((ScriptPlace) place);
  } else if (place instanceof ConfigPlace) {
    presenter = factory.createConfigPresenter((ConfigPlace) place);
  } else if (place instanceof ContributePlace) {
    presenter = factory.createContributePresenter((ContributePlace) place);
  } else if (place instanceof RPCResponsePlace) {
    presenter = factory.createRPCReponsePresenter((RPCResponsePlace) place);
  } else if (place instanceof AddressPlace) {
    presenter = factory.createAddressPresenter((AddressPlace) place);
  }

  return presenter;
}
 
Example #8
Source File: PlaceHistoryMapperImpl.java    From lumongo with Apache License 2.0 6 votes vote down vote up
@Override
public Place getPlace(String token) {
	int separatorAt = token.indexOf(':');
	String prefix;
	String rest;
	if (separatorAt >= 0) {
		prefix = token.substring(0, separatorAt);
		rest = token.substring(separatorAt + 1);
	}
	else {
		prefix = token;
		rest = null;
	}
	PlaceTokenizer<?> tokenizer = tokenizersByPrefix.get(prefix);
	if (tokenizer != null) {
		return tokenizer.getPlace(rest);
	}
	return null;
}
 
Example #9
Source File: MvpController.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void goTo(final Place newPlace) {

	if (this.getWhere().equals(newPlace)) {
		return;
	}

	PlaceChangeRequestEvent willChange = new PlaceChangeRequestEvent(newPlace);
	EventBus.get().fireEvent(willChange);
	String warning = willChange.getWarning();
	if (warning == null || Window.confirm(warning)) {
		this.doGo(newPlace);
	} else {
		this.goTo(this.getWhere());
	}
}
 
Example #10
Source File: MvpController.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Place getSimplePlace(String token) {
	int colonAt = token.indexOf(MvpController.PLACE_TOKEN_SEPARATOR);
	String prefix = token;
	String rest = null;
	if (colonAt > 0) {
		prefix = token.substring(0, colonAt);
		rest = token.substring(colonAt + 1);
	}
	if (!prefix.startsWith(MvpController.PLACE_CROWLER_DELIMITER)) {
		prefix = MvpController.PLACE_CROWLER_DELIMITER + prefix;
	}
	ActivityFactory activityFactory = this.activityFactories.get(prefix);
	if (activityFactory instanceof PlaceTokenizer) {
		return ((PlaceTokenizer) activityFactory).getPlace(rest);
	}
	return null;
}
 
Example #11
Source File: MvpUtils.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static boolean isAncestor(Place parent, Place place) {
	Place cursor = place;
	while (cursor != null) {
		if (cursor instanceof ViewPlace) {
			ViewPlace viewPlace = (ViewPlace) cursor;
			if (cursor.equals(parent)) {
				return true;
			}
			if (viewPlace.getParent() == null) {
				return false;
			}
			if (viewPlace.getParent().equals(parent)) {
				return true;
			}
			cursor = viewPlace.getParent();
		} else {
			cursor = null;
		}
	}
	return false;
}
 
Example #12
Source File: InjectMvpDescriptionCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void writeEntryPoint(SourceWriter srcWriter) {
	srcWriter.println("MvpController mvpController = MvpController.get();");
	srcWriter.println("AcceptsOneWidget mvpDisplay = null;");
	if (this.display != null && !AcceptsOneWidget.class.equals(this.display)) {
		srcWriter.println("mvpDisplay = GWT.create(%s.class);", InjectCreatorUtil.toClassName(this.display));
	}
	srcWriter.println("if(mvpDisplay != null){");
	srcWriter.indent();
	srcWriter.println("mvpController.setDisplay(mvpDisplay);");
	srcWriter.outdent();
	srcWriter.println("}");
	srcWriter.println("if(mvpDisplay instanceof IsWidget){");
	srcWriter.indent();
	srcWriter.println("RootPanel.get().add((IsWidget) mvpDisplay);");
	srcWriter.outdent();
	srcWriter.println("}");

	if (this.defaultPlace != null && !Place.class.equals(this.defaultPlace)) {
		srcWriter.println("mvpController.setDefaultPlace(new %s());", InjectCreatorUtil.toClassName(this.defaultPlace));
	}
	for (Class<?> activity : this.activities) {
		srcWriter.println("mvpController.registerActivity(GWT.<ActivityFactory> create(%s.class));",
			InjectCreatorUtil.toClassName(activity));
	}
}
 
Example #13
Source File: SessionController.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void checkAuthorized(Place fallback, String... roles) {
	if (roles != null) {
		for (String role : roles) {
			if (this.hasRole(role)) {
				return;
			}
		}
	}
	throw new SecurityException("Unauthorized", fallback);
}
 
Example #14
Source File: ShowcasePlaceHistoryMapper.java    From requestor with Apache License 2.0 5 votes vote down vote up
@Override
public Place getPlace(String token) {
    String[] tokens = token.split(":");
    String page = tokens[0];
    String section = tokens.length > 1 ? tokens[1] : null;
    return MenuOption.of(page).getPlace(section);
}
 
Example #15
Source File: DigitalObjectNavigateAction.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private DatastreamEditorType getLastEditorId() {
    DatastreamEditorType editorId = null;
    Place where = places.getWhere();
    if (where instanceof DigitalObjectEditorPlace) {
        DigitalObjectEditorPlace editorPlace = (DigitalObjectEditorPlace) where;
        editorId = editorPlace.getEditorId();
    }
    return editorId == null ? DatastreamEditorType.CHILDREN : editorId;
}
 
Example #16
Source File: MvpController.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Activity getActivity(Place place) {
	String key = MvpUtils.getPlacePrefix(place);
	ActivityFactory activityFactory = this.activityFactories.get(key);
	if (activityFactory != null) {
		return activityFactory.createActivity(place);
	}
	return null;
}
 
Example #17
Source File: MvpController.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Place getPlace(String token) {
	String[] placesToken = token.split(MvpController.PLACE_SEPARATOR);
	Place result = null;
	for (String placeToken : placesToken) {
		Place localPlace = this.getSimplePlace(placeToken);
		if (localPlace != null && localPlace instanceof ViewPlace && result instanceof ViewPlace) {
			((ViewPlace) localPlace).setParent((ViewPlace) result);
		}
		result = localPlace;
	}
	return result;
}
 
Example #18
Source File: DigitalObjectEditor.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
public void open(DatastreamEditorType editor, DigitalObject... objects) {
            if (!editorEnabled) {
                return ;
            }
            DigitalObject openObject = findRecentSelection(objects);
            if (openObject == null) {
                embeddedPlaces.goTo(Place.NOWHERE);
                return ;
            }
//            LOG.log(Level.SEVERE, "# openOptionalEditor: " + objects.length, new IllegalStateException(openObject.toString()));
            embeddedPlaces.goTo(new DigitalObjectEditorPlace(editor, openObject));
        }
 
Example #19
Source File: MvpController.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String getToken(Place place) {
	if (place == null) {
		return null;
	}
	String parentToken = null;
	if (place instanceof ViewPlace && ((ViewPlace) place).getParent() != null) {
		parentToken = this.getToken(((ViewPlace) place).getParent());
	}
	String prefix = MvpUtils.getPlacePrefix(place);
	String token = null;
	ActivityFactory activityFactory = this.activityFactories.get(prefix);
	if (activityFactory instanceof PlaceTokenizer) {
		token = ((PlaceTokenizer) activityFactory).getToken(place);
	}

	String result = "";
	if (parentToken != null) {
		result = parentToken + MvpController.PLACE_SEPARATOR;
		if (prefix.startsWith("!")) {
			prefix = prefix.substring(1);
		}
	}
	if (token != null) {
		result += prefix.length() == 0 ? token : prefix + MvpController.PLACE_TOKEN_SEPARATOR + token;
	} else {
		result += prefix;
	}
	return result;
}
 
Example #20
Source File: MvpController.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setDefaultPlace(Place defaultPlace) {
	this.defaultPlace = defaultPlace;
	if (this.historyRegistration != null) {
		this.historyRegistration.removeHandler();
	}
	this.historyRegistration = this.historyHandler.register(this, EventBus.get(), this.defaultPlace);
}
 
Example #21
Source File: MayStopActivityEvent.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private MayStopActivityEvent(Activity activity, Place place, IsWidget view) {
	super();
	this.activity = activity;
	this.place = place;
	this.view = view;
	this.setSource(place);
}
 
Example #22
Source File: StopActivityEvent.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private StopActivityEvent(Activity activity, Place place, IsWidget view, boolean cancelActivity) {
	super();
	this.activity = activity;
	this.place = place;
	this.view = view;
	this.cancelActivity = cancelActivity;
	this.setSource(place);
}
 
Example #23
Source File: StartActivityEvent.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private StartActivityEvent(Activity activity, Place place, AcceptsOneWidget container, IsWidget view) {
	this.setSource(place);
	this.activity = activity;
	this.place = place;
	this.container = container;
	this.view = view;
}
 
Example #24
Source File: MainController.java    From lumongo with Apache License 2.0 5 votes vote down vote up
public void init(PlaceHistoryMapper placeHistoryMapper, Place defaultPlace, Place homePlace) {
	this.placeHistoryMapper = placeHistoryMapper;
	this.defaultPlace = defaultPlace;
	this.homePlace = homePlace;
	PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(placeHistoryMapper);
	historyHandler.register(placeController, eventBus, defaultPlace);
	GWT.log("Here?");
	historyHandler.handleCurrentHistory();
}
 
Example #25
Source File: MvpUtils.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static boolean isParent(Place parent, Place place) {
	if (place instanceof ViewPlace) {
		ViewPlace viewPlace = (ViewPlace) place;
		return viewPlace.getParent() != null && viewPlace.getParent().equals(parent);
	}
	return false;
}
 
Example #26
Source File: DigitalObjectEditor.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private Record[] processRecords() {
    Record[] records;
    if (pids != null) {
        records = searchList.toArray();
        String error = checkSearchedRecordsConsistency(records);
        if (error != null) {
            SC.warn(error);
            places.goTo(Place.NOWHERE);
            return null;
        }
    } else {
        records = digitalObjects;
    }
    return records;
}
 
Example #27
Source File: MvpUtils.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static String getPlacePrefix(Place place) {
	if (place instanceof ActivityFactory) {
		String[] prefixes = ((ActivityFactory) place).getPlacePrefixes();
		if (prefixes != null && prefixes.length > 0) {
			String prefix = prefixes[0];
			if (!prefix.startsWith("!")) {
				prefix = "!" + prefix;
			}
			return prefix;
		}
	}
	return MvpUtils.getDefaultPrefix(place);
}
 
Example #28
Source File: MvpUtils.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static String getDefaultPrefix(Place place) {
	String prefix = place.getClass().getSimpleName().replaceAll("Place$", "");
	if (prefix.indexOf('$') > 0) {
		prefix = prefix.substring(prefix.indexOf('$') + 1);
	}
	return "!" + prefix;
}
 
Example #29
Source File: ProxyViewCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private SourceWriter getSourceWriter(PrintWriter printWriter, GeneratorContext ctx) {
	ClassSourceFileComposerFactory composerFactory =
		new ClassSourceFileComposerFactory(this.packageName, this.viewProxySimpleName);

	composerFactory.setSuperclass(this.placeType.getSimpleSourceName());

	composerFactory.addImport(GWT.class.getName());
	composerFactory.addImport(RunAsyncCallback.class.getName());
	composerFactory.addImport(ViewProxy.class.getName());
	composerFactory.addImport(Place.class.getName());
	composerFactory.addImport(ViewPlace.class.getName());
	composerFactory.addImport(Activity.class.getName());
	composerFactory.addImport(ViewActivity.class.getName());
	composerFactory.addImport(ApplicationUnreachableException.class.getName());
	composerFactory.addImport(this.placeType.getQualifiedSourceName());
	composerFactory.addImport(this.activityDescrition.view().getCanonicalName());
	if (this.placeTokenizerClass != null) {
		composerFactory.addImport(this.placeTokenizerClass.getCanonicalName());
	}
	if (this.viewDecoratorClass != null) {
		composerFactory.addImport(this.viewDecoratorClass.getCanonicalName());
	}

	composerFactory.addImplementedInterface(
		ViewProxy.class.getSimpleName() + "<" + this.placeType.getSimpleSourceName() + ">");

	return composerFactory.createSourceWriter(ctx, printWriter);
}
 
Example #30
Source File: EditorWorkFlow.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
public void init() {
    placeHistoryHandler.handleCurrentHistory();
    Place where = placeController.getWhere();
    if (where == Place.NOWHERE) {
        AboutWindow.getInstance(i18n).show();
    }
}