Skip to content

Commit

Permalink
Merge pull request #990 from eclipse/CODENVY-209
Browse files Browse the repository at this point in the history
CODENVY-209: Change title of loading page of IDE.
  • Loading branch information
AndrienkoAleksandr committed Apr 14, 2016
2 parents ac01f2b + bfe373d commit 990bf00
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,36 @@
*/
public interface ProductInfoDataProvider {
/**
* Get product name
* @return product name
*/
String getName();

/**
* Get support link
* @return url to support resource
*/
String getSupportLink();

/**
* Get document title for browser tab
* @return document title
* @return document title for browser tab
*/
String getDocumentTitle();

/**
* Get document title with project name for browser tab
* @param project name of project which was selected in the Project Explorer
* Get document title with current {@code workspaceName}.
*
* @param workspaceName
* name of the current running workspace
* @return document title
*/
String getDocumentTitle(String project);
String getDocumentTitle(String workspaceName);

/**
* Get logo SVG resources
* @return SVG resources
* @return logo SVG resource
*/
SVGResource getLogo();

/** Returns title for support action which displayed in Help menu. */
public String getSupportTitle();
/**
* @return title for support action which displayed in Help menu.
*/
String getSupportTitle();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.google.gwt.core.client.Callback;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Document;
import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
import com.google.gwt.user.client.Window;
Expand All @@ -29,7 +28,6 @@
import org.eclipse.che.api.workspace.gwt.client.event.WorkspaceStartedEvent;
import org.eclipse.che.api.workspace.gwt.client.event.WorkspaceStartedHandler;
import org.eclipse.che.api.workspace.shared.dto.WorkspaceDto;
import org.eclipse.che.ide.api.ProductInfoDataProvider;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.component.Component;
import org.eclipse.che.ide.api.component.WsAgentComponent;
Expand All @@ -53,24 +51,19 @@ public class BootstrapController {
private final Provider<WorkspacePresenter> workspaceProvider;
private final ExtensionInitializer extensionInitializer;
private final EventBus eventBus;
private final ProductInfoDataProvider productInfoDataProvider;
private final Provider<AppStateManager> appStateManagerProvider;
private final AppContext appContext;

@Inject
public BootstrapController(Provider<WorkspacePresenter> workspaceProvider,
ExtensionInitializer extensionInitializer,
EventBus eventBus,
ProductInfoDataProvider productInfoDataProvider,
Provider<AppStateManager> appStateManagerProvider,
AppContext appContext,
DtoRegistrar dtoRegistrar) {
this.workspaceProvider = workspaceProvider;
this.extensionInitializer = extensionInitializer;
this.eventBus = eventBus;
this.productInfoDataProvider = productInfoDataProvider;
this.appStateManagerProvider = appStateManagerProvider;
this.appContext = appContext;

appContext.setStartUpActions(StartUpActionsParser.getStartUpActions());
dtoRegistrar.registerDtoProviders();
Expand Down Expand Up @@ -166,8 +159,6 @@ private void displayIDE() {
// Display IDE
workspacePresenter.go(mainPanel);

Document.get().setTitle(productInfoDataProvider.getDocumentTitle());

// Bind browser's window events
Window.addWindowClosingHandler(new Window.ClosingHandler() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@

import com.google.gwt.user.client.Window;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;

import org.eclipse.che.api.workspace.shared.dto.WorkspaceDto;
import org.eclipse.che.ide.api.ProductInfoDataProvider;
import org.eclipse.che.ide.api.app.AppContext;

/**
* The class contains business logic which allows get or set workspace name to query field in browser.
Expand All @@ -26,13 +29,18 @@
public class BrowserQueryFieldRenderer {

private static final int WORKSPACE_ORDER_IN_URL = 2;
//Used in the JSNI methods follow
private static final int AMOUNT_URL_PARTS = 4;

//Used in the JSNI methods follow
private final ProductInfoDataProvider productInfoDataProvider;
private final Provider<AppContext> appContextProvider;

@Inject
public BrowserQueryFieldRenderer(ProductInfoDataProvider productInfoDataProvider) {
public BrowserQueryFieldRenderer(ProductInfoDataProvider productInfoDataProvider,
Provider<AppContext> appContextProvider) {
this.productInfoDataProvider = productInfoDataProvider;
this.appContextProvider = appContextProvider;
}

/**
Expand Down Expand Up @@ -68,43 +76,29 @@ public native String getParameterFromURLByName(String name) /*-{
}-*/;

/**
* Sets workspace name to query field in browser.
* Sets {@code projectName} to query field in browser.
*
* @param workspaceName
* name which will be set
* @param projectName
* name which will be set. Can be null or empty if workspace does not contain any projects
*/
public native void setWorkspaceName(String workspaceName) /*-{
try {
var window = $wnd;
var document = $doc;
if (!window["_history_relocation_id"]) {
window["_history_relocation_id"] = 0;
}
var browserUrl = window.location.pathname;
var urlParts = browserUrl.split("/");
urlParts[2] = workspaceName;
browserUrl = urlParts.join("/");
window.top.document.title = this.@org.eclipse.che.ide.context.BrowserQueryFieldRenderer::
productInfoDataProvider.@org.eclipse.che.ide.api.ProductInfoDataProvider::getDocumentTitle()();
window.history.pushState(window["_history_relocation_id"], window.top.document.title, browserUrl);
window["_history_relocation_id"]++;
} catch (e) {
console.log(e.message);
public void setProjectName(String projectName) {
String workspaceName = "";
WorkspaceDto workspaceDto = appContextProvider.get().getWorkspace();
if (workspaceDto != null) {
workspaceName = workspaceDto.getConfig().getName();
}
}-*/;
setQueryField(workspaceName, projectName);
}

/**
* Sets project name to query field in browser.
* Sets {@code projectName} to query field in browser and set tab title with current running {@code workspaceName}
*
* @param workspaceName
* name of the current running workspace. Can be null or empty if workspace was stopped.
* @param projectName
* name which will be set
* name which will be set. Can be null or empty if workspace does not contain any projects
*/
public native void setProjectName(String projectName) /*-{
public native void setQueryField(String workspaceName, String projectName) /*-{
try {
var window = $wnd;
var document = $doc;
Expand All @@ -114,17 +108,27 @@ public native void setProjectName(String projectName) /*-{
}
var browserUrl = window.location.pathname;
var urlParts = browserUrl.split('/');
urlParts[2] = workspaceName;
urlParts[3] = projectName;
var sliceIndex = @org.eclipse.che.ide.context.BrowserQueryFieldRenderer::AMOUNT_URL_PARTS;
if (projectName == null || projectName.length == 0) {
sliceIndex--;
}
if (workspaceName == null || workspaceName.length == 0) {
sliceIndex--;
}
browserUrl = urlParts.slice(0, sliceIndex).join('/');
var urlParts = browserUrl.split("/");
urlParts[3] = "";
var title = this.@org.eclipse.che.ide.context.BrowserQueryFieldRenderer::
productInfoDataProvider.@org.eclipse.che.ide.api.ProductInfoDataProvider::getDocumentTitle()();
browserUrl = urlParts.join("/") + projectName;
var titleWithWorkspaceName = this.@org.eclipse.che.ide.context.BrowserQueryFieldRenderer::
productInfoDataProvider.@org.eclipse.che.ide.api.ProductInfoDataProvider::getDocumentTitle(Ljava/lang/String;)(workspaceName);
var titleWithoutSelectedProject = this.@org.eclipse.che.ide.context.BrowserQueryFieldRenderer::
productInfoDataProvider.@org.eclipse.che.ide.api.ProductInfoDataProvider::getDocumentTitle()();
var titleWithSelectedProject = this.@org.eclipse.che.ide.context.BrowserQueryFieldRenderer::
productInfoDataProvider.@org.eclipse.che.ide.api.ProductInfoDataProvider::getDocumentTitle(Ljava/lang/String;)(projectName);
window.top.document.title = projectName.length == 0 ? titleWithoutSelectedProject : titleWithSelectedProject;
window.top.document.title = (workspaceName == null || workspaceName.length == 0) ? title : titleWithWorkspaceName;
window.history.pushState(window["_history_relocation_id"], window.top.document.title, browserUrl);
window["_history_relocation_id"]++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ public void onProjectDeleted(DeleteProjectEvent event) {
}

view.removeNode(toDelete, true);

if (!view.getRootNodes().isEmpty()) {
select(view.getRootNodes().get(0), false);
}
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void setCurrentWorkspace(WorkspaceDto workspace) {
needToReloadComponents = false;
}

browserQueryFieldRenderer.setWorkspaceName(workspace.getConfig().getName());
browserQueryFieldRenderer.setQueryField(workspace.getConfig().getName(), "");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.google.inject.Provider;
import com.google.inject.Singleton;

import org.eclipse.che.api.workspace.shared.dto.WorkspaceDto;
import org.eclipse.che.api.workspace.shared.dto.WorkspaceDto;
import org.eclipse.che.ide.workspace.DefaultWorkspaceComponent;
import org.eclipse.che.ide.api.component.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
*******************************************************************************/
package org.eclipse.che.env.local.client;

import javax.inject.Inject;

import org.eclipse.che.ide.api.ProductInfoDataProvider;
import org.eclipse.che.ide.ui.Resources;
import org.vectomatic.dom.svg.ui.SVGResource;

import javax.inject.Inject;

/**
* Implementation of {@link ProductInfoDataProvider}
*
Expand Down Expand Up @@ -45,8 +45,8 @@ public String getDocumentTitle() {
return locale.cheTabTitle();
}

public String getDocumentTitle(String project) {
return locale.cheTabTitle(project);
public String getDocumentTitle(String workspaceName) {
return locale.cheTabTitle(workspaceName);
}

public SVGResource getLogo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
/** @author Vitalii Parfonov */
public interface LocalizationConstant extends Messages {

@Key("che.none.project.selected.title")
@Key("che.tab.title")
String cheTabTitle();

@Key("che.project.selected.title")
String cheTabTitle(String projectName);
@Key("che.tab.title.with.workspace.name")
String cheTabTitle(String workspaceName);

@Key("messages.server.failure")
String messagesServerFailure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# Codenvy, S.A. - initial API and implementation
#

che.none.project.selected.title = Eclipse Che
che.project.selected.title = Eclipse Che | {0}
che.tab.title = Eclipse Che
che.tab.title.with.workspace.name = Eclipse Che | {0}
messages.server.failure = The server closed the connection.
connection.closed.dialog.title = Server failure
get.support.link = https://eclipse.org/che
Expand Down

0 comments on commit 990bf00

Please sign in to comment.