Skip to content

Commit

Permalink
Refactored Window class (#8374)
Browse files Browse the repository at this point in the history
* Refactored Window class

- Clean up the interface of Window class;
- Move GWT specific functionality to bridge (CompositeWindowView) which is responsible only for construct window object on the view;
- Better handling key press events on the windows;
- Adopted Window implementations to use new interface of Window class;
- Move utility methods such as detecting whether widget is in focus to DomUtils utility class.

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Fix formatting issue

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Merge branch 'master' into che#7200

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

# Conflicts:
#	ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/factory/json/ImportFromConfigViewImpl.java
#	ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/resources/selector/SelectPathViewImpl.java
#	ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/upload/file/UploadFileViewImpl.java
#	ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/upload/folder/UploadFolderFromZipViewImpl.java
#	ide/che-core-ide-ui/src/main/resources/org/eclipse/che/ide/ui/window/CompositeWindowView.css
#	plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/checkout/CheckoutReferenceViewImpl.java
#	plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/compare/CompareViewImpl.java
#	plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/fetch/FetchViewImpl.java
#	plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/history/HistoryViewImpl.java
#	plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/merge/MergeViewImpl.java
#	plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/pull/PullViewImpl.java
#	plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/push/PushToRemoteViewImpl.java
#	plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/remote/RemoteViewImpl.java
#	plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/reset/commit/ResetToCommitViewImpl.java
#	plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/reset/files/ResetFilesViewImpl.java
#	plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/revert/RevertCommitViewImpl.java
#	plugins/plugin-help/che-plugin-help-ext-client/src/main/java/org/eclipse/che/ide/ext/help/client/about/AboutViewImpl.java

* Fix errors

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Code improvements

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Rename variable

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Fixes

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Fix formatting issue

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Fix formatting issue

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Minor fixes

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Minor fixes

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Minor fixes

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Fix npe

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Update locators

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Minor fixes

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Minor fixes

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Resolve conflicts

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Minor fixes

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Minor fixes

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Minor fixes

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Minor fixes

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Adopting the code after merge

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Minor fixes

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Minor fixes

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Minor fixes

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Minor fixes

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Fix test

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Fix formatting

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Remove commented code

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Used corrected method

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Use single import instead of wildcard

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* New line

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Code refinment

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>

* Fix wildcard imports

Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>
  • Loading branch information
vzhukovs committed Feb 12, 2018
1 parent 0b6242a commit ab62845
Show file tree
Hide file tree
Showing 173 changed files with 2,436 additions and 3,102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.eclipse.che.ide.ui.list.SimpleList;
import org.eclipse.che.ide.ui.smartTree.TreeStyles;
import org.eclipse.che.ide.ui.tree.Tree;
import org.eclipse.che.ide.ui.window.Window;
import org.eclipse.che.ide.ui.zeroclipboard.ClipboardResources;
import org.vectomatic.dom.svg.ui.SVGResource;

Expand All @@ -38,8 +37,7 @@
* @author Codenvy crowd
*/
public interface Resources
extends Window.Resources,
Tree.Resources,
extends Tree.Resources,
PartStackUIResources,
SimpleList.Resources,
MenuResources,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import org.eclipse.che.ide.command.CommandResources;
import org.eclipse.che.ide.ui.window.Window;

/**
* Implementation of {@link CommandEditorView}.
Expand All @@ -36,7 +35,6 @@ public class CommandEditorViewImpl extends Composite implements CommandEditorVie

private static final CommandEditorViewImplUiBinder UI_BINDER =
GWT.create(CommandEditorViewImplUiBinder.class);
private static final Window.Resources WINDOW_RESOURCES = GWT.create(Window.Resources.class);

private final CommandResources resources;

Expand All @@ -57,7 +55,6 @@ public CommandEditorViewImpl(CommandResources resources) {

initWidget(UI_BINDER.createAndBindUi(this));
setSaveEnabled(false);
saveButton.addStyleName(WINDOW_RESOURCES.windowCss().primaryButton());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public CommandsPalettePresenter(
}

public void showDialog() {
view.show();
view.showDialog();
view.setCommands(commandUtils.groupCommandsByGoal(commandManager.getCommands()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public interface CommandsPaletteView extends View<CommandsPaletteView.ActionDelegate> {

/** Show the view. */
void show();
void showDialog();

/** Close the view. */
void close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public CommandsPaletteViewImpl(NodeFactory nodeFactory, PaletteMessages messages

filterField.getElement().setAttribute("placeholder", messages.filterPlaceholder());
initHintLabel();
getFooter().removeFromParent();
}

private void initHintLabel() {
Expand Down Expand Up @@ -116,11 +115,13 @@ private SpanElement createKeyLabel() {
}

@Override
public void show() {
super.show();
public void showDialog() {
show(filterField);
}

@Override
protected void onShow() {
filterField.setValue("");
filterField.setFocus(true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,21 @@ protected CreateFactoryViewImpl(
ClipboardButtonBuilder buttonBuilder) {
this.factoryResources = factoryResources;
setTitle(locale.createFactoryTitle());
setWidget(uiBinder.createAndBindUi(this));
Widget widget = uiBinder.createAndBindUi(this);
widget.getElement().getStyle().setPadding(0, Unit.PX);
setWidget(widget);
factoryNameLabel.setText(locale.createFactoryName());
factoryLinkLabel.setText(locale.createFactoryLink());
configure.getElement().insertFirst(factoryResources.configure().getSvg().getElement());
launch.getElement().insertFirst(factoryResources.execute().getSvg().getElement());
launch.addStyleName(style.launchIcon());
configure.addStyleName(style.configureIcon());
createFactoryButton.setEnabled(false);
Button cancelButton =
createButton(
locale.createFactoryButtonClose(),
"git-remotes-pull-cancel",
event -> delegate.onCancelClicked());
addFooterButton(
locale.createFactoryButtonClose(),
"projectReadOnlyGitUrl-btnClose",
event -> delegate.onCancelClicked());
createFactoryButton.addClickHandler(clickEvent -> delegate.onCreateClicked());
cancelButton.ensureDebugId("projectReadOnlyGitUrl-btnClose");
addButtonToFooter(cancelButton);
getWidget().getElement().getStyle().setPadding(0, Unit.PX);
buttonBuilder.withResourceWidget(factoryLink).build();
factoryLink.setReadOnly(true);
final Tooltip launchFactoryTooltip =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ public void showDialog() {
/** {@inheritDoc} */
@Override
public void onCancelClicked() {
view.onClose();
view.closeDialog();
}

/** {@inheritDoc} */
@Override
public void onImportClicked() {
view.onClose();
view.closeDialog();

FactoryDto factoryDTO;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface ActionDelegate {
void showDialog();

/** Close dialog */
void onClose();
void closeDialog();

/** Sets the delegate to receive events from this view. */
void setDelegate(ActionDelegate delegate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public interface ImportFromConfigViewBinder extends UiBinder<Widget, ImportFromC

@UiField FormPanel uploadForm;
@UiField Label errorMessage;
FileUpload fileUpload;
private FileUpload fileUpload;

private ActionDelegate delegate;

Expand All @@ -50,31 +50,18 @@ public ImportFromConfigViewImpl(
this.setTitle(locale.importFromConfigurationTitle());
setWidget(importFromConfigViewBinder.createAndBindUi(this));

addFooterButton(
locale.cancelButton(),
"import-from-config-btn-cancel",
event -> delegate.onCancelClicked());

buttonImport =
createButton(
addFooterButton(
locale.importButton(),
"import-from-config-btn-import",
event -> delegate.onImportClicked());
buttonImport.addStyleName(resources.windowCss().primaryButton());
buttonImport.addStyleName(resources.windowCss().buttonAlignRight());
addButtonToFooter(buttonImport);

Button buttonCancel =
createButton(
locale.cancelButton(),
"import-from-config-btn-cancel",
event -> delegate.onCancelClicked());
buttonCancel.addStyleName(resources.windowCss().buttonAlignRight());
addButtonToFooter(buttonCancel);
}
event -> delegate.onImportClicked(),
true);

/** {@inheritDoc} */
@Override
public void showDialog() {
uploadForm.clear();

errorMessage.setText("");
fileContent = null;
fileUpload = new FileUpload();
fileUpload.setHeight("22px");
fileUpload.setWidth("100%");
Expand All @@ -85,17 +72,21 @@ public void showDialog() {
fileUpload.addChangeHandler(event -> buttonImport.setEnabled(fileUpload.getFilename() != null));

uploadForm.add(fileUpload);
}

/** {@inheritDoc} */
@Override
public void showDialog() {
errorMessage.setText("");
fileContent = null;

this.show();
}

/** {@inheritDoc} */
@Override
public void onClose() {
public void closeDialog() {
hide();

uploadForm.remove(fileUpload);
fileUpload = null;
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void showHotKeys(String scheme) {
view.setData(categories);
view.setSchemes(selectedSchemeId, keyBindingAgent.getSchemes());
view.renderKeybindings();
view.show();
view.showDialog();
}

private List<HotKeyItem> getIDEHotKey() {
Expand Down Expand Up @@ -136,12 +136,12 @@ private List<HotKeyItem> getEditorHotKey() {
@Override
public void onSaveClicked() {
keyBindingAgent.setActive(selectedSchemeId);
view.hide();
view.hideDialog();
}

@Override
public void onCloseClicked() {
view.hide();
view.hideDialog();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
public interface HotKeysDialogView extends View<HotKeysDialogView.ActionDelegate> {

/** Reset filter input and Show dialog. */
void show();
void showDialog();

/** Clear and Render keybinding combination. */
void renderKeybindings();

/** Hide dialog. */
void hide();
void hideDialog();

/**
* Set keybindings map for displaying.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.SpanElement;
import com.google.gwt.dom.client.Style;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
Expand Down Expand Up @@ -57,11 +53,7 @@ interface KeyMapViewImplUiBinder extends UiBinder<Widget, HotKeysDialogViewImpl>
private final HotKeyResources hotKeyResources;

private final Category.CategoryEventDelegate<HotKeyItem> keyBindingsEventDelegate =
new Category.CategoryEventDelegate<HotKeyItem>() {

@Override
public void onListItemClicked(Element listItemBase, HotKeyItem hotKeyItem) {}
};
(listItemBase, hotKeyItem) -> {};

private final CategoryRenderer<HotKeyItem> keyBindingsRenderer =
new CategoryRenderer<HotKeyItem>() {
Expand Down Expand Up @@ -122,53 +114,22 @@ public HotKeysDialogViewImpl(
this.setWidget(uiBinder.createAndBindUi(this));

saveButton =
createButton(
locale.save(),
"keybindings-saveButton-btn",
new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
delegate.onSaveClicked();
}
});
addButtonToFooter(saveButton);
saveButton.addStyleName(resources.windowCss().primaryButton());
addFooterButton(
locale.save(), "keybindings-saveButton-btn", event -> delegate.onSaveClicked(), true);

closeButton =
createButton(
locale.close(),
"keybindings-closeButton-btn",
new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
delegate.onCloseClicked();
}
});
addButtonToFooter(closeButton);
addFooterButton(
locale.close(), "keybindings-closeButton-btn", event -> delegate.onCloseClicked());

printButton =
createButton(
locale.print(),
"keybindings-printButton-btn",
new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
delegate.onPrintClicked();
}
});
addButtonToFooter(printButton);
addFooterButton(
locale.print(), "keybindings-printButton-btn", event -> delegate.onPrintClicked());

list = new CategoriesList(res);
categoriesList = new ArrayList<>();
category.add(list);
filterInput.getElement().setAttribute("placeholder", "Search");
selectionListBox.addChangeHandler(
new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
delegate.onSchemeSelectionChanged();
}
});
selectionListBox.addChangeHandler(changeEvent -> delegate.onSchemeSelectionChanged());

// Override DockLayoutPanel Overflow to correctly display ListBox
selectionPanel.getElement().getParentElement().getStyle().setOverflow(Style.Overflow.VISIBLE);
Expand All @@ -180,8 +141,17 @@ public void setDelegate(ActionDelegate delegate) {
}

@Override
public void hide() {
super.hide();
public void showDialog() {
show();
}

@Override
public void hideDialog() {
hide();
}

@Override
protected void onHide() {
resetFilter();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void show(@Nullable MacroChosenCallback callback) {

updateMacrosProvider(macroRegistry.getMacros());

view.show();
view.showDialog();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public interface MacroChooserView extends View<MacroChooserView.ActionDelegate> {

/** Show the view. */
void show();
void showDialog();

/** Close the view. */
void close();
Expand Down
Loading

0 comments on commit ab62845

Please sign in to comment.