forked from eclipse-che/che
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CHE-5792: Add ability to adjust viewing 'maven module artifact id' in…
… preferences window (eclipse-che#5849)
- Loading branch information
Showing
8 changed files
with
259 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...rc/main/java/org/eclipse/che/plugin/maven/client/preference/MavenPreferencePresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2017 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.plugin.maven.client.preference; | ||
|
||
import com.google.gwt.user.client.ui.AcceptsOneWidget; | ||
import com.google.inject.Inject; | ||
import com.google.inject.Singleton; | ||
|
||
import org.eclipse.che.ide.CoreLocalizationConstant; | ||
import org.eclipse.che.ide.api.app.AppContext; | ||
import org.eclipse.che.ide.api.preferences.AbstractPreferencePagePresenter; | ||
import org.eclipse.che.ide.api.preferences.PreferencesManager; | ||
import org.eclipse.che.plugin.maven.client.MavenLocalizationConstant; | ||
|
||
/** | ||
* Preference page presenter for Maven plugin. | ||
* | ||
* @author Igor Vinokur | ||
*/ | ||
@Singleton | ||
public class MavenPreferencePresenter extends AbstractPreferencePagePresenter implements MavenPreferenceView.ActionDelegate { | ||
|
||
public static final String PREF_SHOW_ARTIFACT_ID = "maven.artifact.in.project.explorer"; | ||
|
||
private final MavenPreferenceView view; | ||
private final AppContext appContext; | ||
private final PreferencesManager preferencesManager; | ||
|
||
private boolean showArtifactId; | ||
private boolean dirty = false; | ||
|
||
@Inject | ||
public MavenPreferencePresenter(MavenPreferenceView view, | ||
AppContext appContext, | ||
CoreLocalizationConstant coreLocalizationConstant, | ||
MavenLocalizationConstant mavenLocalizationConstant, | ||
PreferencesManager preferencesManager) { | ||
super(mavenLocalizationConstant.mavenPreferencesTitle(), coreLocalizationConstant.extensionCategory()); | ||
this.view = view; | ||
this.appContext = appContext; | ||
this.preferencesManager = preferencesManager; | ||
|
||
view.setDelegate(this); | ||
} | ||
|
||
@Override | ||
public boolean isDirty() { | ||
return dirty; | ||
} | ||
|
||
@Override | ||
public void go(AcceptsOneWidget container) { | ||
container.setWidget(view); | ||
view.setSelectedShowArtifactIdCheckBox(getShowArtifactIdPreferenceValue()); | ||
} | ||
|
||
@Override | ||
public void storeChanges() { | ||
preferencesManager.setValue(PREF_SHOW_ARTIFACT_ID, String.valueOf(showArtifactId)); | ||
appContext.getWorkspaceRoot().synchronize(); | ||
dirty = false; | ||
} | ||
|
||
@Override | ||
public void revertChanges() { | ||
view.setSelectedShowArtifactIdCheckBox(getShowArtifactIdPreferenceValue()); | ||
dirty = false; | ||
} | ||
|
||
@Override | ||
public void onArtifactIdCheckBoxValueChanged(boolean showArtifactId) { | ||
this.showArtifactId = showArtifactId; | ||
dirty = showArtifactId != getShowArtifactIdPreferenceValue(); | ||
delegate.onDirtyChanged(); | ||
} | ||
|
||
private boolean getShowArtifactIdPreferenceValue() { | ||
return Boolean.valueOf(preferencesManager.getValue(PREF_SHOW_ARTIFACT_ID)); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...ide/src/main/java/org/eclipse/che/plugin/maven/client/preference/MavenPreferenceView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2017 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.plugin.maven.client.preference; | ||
|
||
import com.google.inject.ImplementedBy; | ||
|
||
import org.eclipse.che.ide.api.mvp.View; | ||
|
||
/** | ||
* View of Maven preferences page. | ||
* | ||
* @author Igor Vinokur | ||
*/ | ||
@ImplementedBy(MavenPreferenceViewImpl.class) | ||
public interface MavenPreferenceView extends View<MavenPreferenceView.ActionDelegate> { | ||
|
||
/** | ||
* Change the state of 'Show maven artifact id' checkbox. | ||
* | ||
* @param selected | ||
* {@code true} to make the checkbox selected, {@code false} to deselect the checkbox | ||
*/ | ||
void setSelectedShowArtifactIdCheckBox(boolean selected); | ||
|
||
interface ActionDelegate { | ||
/** | ||
* Called when the value of 'Show maven artifact id' checkbox is changed. | ||
* | ||
* @param value | ||
* new value | ||
*/ | ||
void onArtifactIdCheckBoxValueChanged(boolean value); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
...src/main/java/org/eclipse/che/plugin/maven/client/preference/MavenPreferenceViewImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2017 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.plugin.maven.client.preference; | ||
|
||
import com.google.gwt.core.client.GWT; | ||
import com.google.gwt.event.dom.client.ClickEvent; | ||
import com.google.gwt.uibinder.client.UiBinder; | ||
import com.google.gwt.uibinder.client.UiField; | ||
import com.google.gwt.uibinder.client.UiHandler; | ||
import com.google.gwt.user.client.ui.CheckBox; | ||
import com.google.gwt.user.client.ui.FlowPanel; | ||
import com.google.gwt.user.client.ui.Widget; | ||
import com.google.inject.Inject; | ||
import com.google.inject.Singleton; | ||
|
||
import org.eclipse.che.plugin.maven.client.MavenLocalizationConstant; | ||
|
||
/** | ||
* Implementation of {@link MavenPreferenceView}. | ||
* | ||
* @author Igor Vinokur | ||
*/ | ||
@Singleton | ||
public class MavenPreferenceViewImpl implements MavenPreferenceView { | ||
|
||
private static MavenPreferenceViewImplUiBinder uiBinder = GWT.create(MavenPreferenceViewImplUiBinder.class); | ||
private final FlowPanel rootElement; | ||
|
||
@UiField(provided = true) | ||
final MavenLocalizationConstant locale; | ||
private ActionDelegate delegate; | ||
|
||
@UiField | ||
CheckBox showArtifactId; | ||
|
||
@Inject | ||
public MavenPreferenceViewImpl(MavenLocalizationConstant locale) { | ||
this.locale = locale; | ||
|
||
rootElement = uiBinder.createAndBindUi(this); | ||
} | ||
|
||
@Override | ||
public void setDelegate(ActionDelegate delegate) { | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public Widget asWidget() { | ||
return rootElement; | ||
} | ||
|
||
|
||
@Override | ||
public void setSelectedShowArtifactIdCheckBox(boolean selected) { | ||
showArtifactId.setValue(selected); | ||
} | ||
|
||
@UiHandler("showArtifactId") | ||
void handleShowArtifactIdCheckBoxSelection(ClickEvent event) { | ||
delegate.onArtifactIdCheckBoxValueChanged(showArtifactId.getValue()); | ||
} | ||
|
||
interface MavenPreferenceViewImplUiBinder extends UiBinder<FlowPanel, MavenPreferenceViewImpl> { | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...c/main/java/org/eclipse/che/plugin/maven/client/preference/MavenPreferenceViewImpl.ui.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!-- | ||
Copyright (c) 2012-2017 Codenvy, S.A. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
Contributors: | ||
Codenvy, S.A. - initial API and implementation | ||
--> | ||
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' | ||
xmlns:g='urn:import:com.google.gwt.user.client.ui'> | ||
<ui:with field='locale' type='org.eclipse.che.plugin.maven.client.MavenLocalizationConstant'/> | ||
<ui:style> | ||
.main { | ||
margin: 5px; | ||
} | ||
</ui:style> | ||
<g:FlowPanel styleName="{style.main}"> | ||
<g:CheckBox ui:field="showArtifactId" text="{locale.mavenPreferencesShowArtifactIdCheckboxText}" | ||
debugId="window-preferences-plugins-maven-showArtifactId"/> | ||
</g:FlowPanel> | ||
</ui:UiBinder> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters