-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented no-op UIs for workspace-composite wizard + preferences (#867
) * Implemented no-op UIs for workspace-composite wizard + preferences * Changed workspace composite wizard element name * Changed composite wizard element description * Fixed java doc and useless indent * Javadoc/author fix+ line nitpick * Remove UiBuilder * Fixed indend * Fixed javadoc and indent * Remove UiBuilder/JavaDoc fix * Fixed checkbox tree layout * Refactor HelpContextIdProvider and WizardHelper * Knitpick and format fix Signed-off-by: kuzniarz <[email protected]>
- Loading branch information
Showing
20 changed files
with
1,171 additions
and
3 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
135 changes: 135 additions & 0 deletions
135
...eclipse/buildship/ui/internal/preferences/GradleCompositeImportOptionsPreferencePage.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,135 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 Gradle Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
******************************************************************************/ | ||
|
||
package org.eclipse.buildship.ui.internal.preferences; | ||
|
||
import java.io.File; | ||
|
||
import org.eclipse.buildship.core.internal.CorePlugin; | ||
import org.eclipse.buildship.core.internal.configuration.BuildConfiguration; | ||
import org.eclipse.buildship.core.internal.configuration.ConfigurationManager; | ||
import org.eclipse.buildship.core.internal.util.binding.Validator; | ||
import org.eclipse.buildship.core.internal.util.binding.Validators; | ||
import org.eclipse.buildship.ui.internal.util.gradle.GradleDistributionViewModel; | ||
import org.eclipse.buildship.ui.internal.util.widget.AdvancedOptionsGroup; | ||
import org.eclipse.buildship.ui.internal.util.widget.GradleProjectSettingsComposite; | ||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.runtime.Platform; | ||
import org.eclipse.swt.events.SelectionEvent; | ||
import org.eclipse.swt.events.SelectionListener; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Control; | ||
import org.eclipse.ui.dialogs.PreferencesUtil; | ||
import org.eclipse.ui.dialogs.PropertyPage; | ||
|
||
/** | ||
* Preference page for composite import options. | ||
* | ||
* @author Sebastian Kuzniarz | ||
*/ | ||
public final class GradleCompositeImportOptionsPreferencePage extends PropertyPage { | ||
|
||
public static final String PAGE_ID = "org.eclipse.buildship.ui.compositeImportOptionsProperties"; | ||
|
||
private GradleProjectSettingsComposite gradleProjectSettingsComposite; | ||
|
||
private final Validator<GradleDistributionViewModel> distributionValidator; | ||
private final Validator<File> javaHomeValidator; | ||
private final Validator<File> gradleUserHomeValidator; | ||
|
||
public GradleCompositeImportOptionsPreferencePage() { | ||
this.gradleUserHomeValidator = Validators.optionalDirectoryValidator("Gradle user home"); | ||
this.javaHomeValidator = Validators.optionalDirectoryValidator("Java home"); | ||
this.distributionValidator = GradleDistributionViewModel.validator(); | ||
} | ||
|
||
@Override | ||
protected Control createContents(Composite parent) { | ||
this.gradleProjectSettingsComposite = GradleProjectSettingsComposite.builder(parent) | ||
.withAutoSyncCheckbox() | ||
.withOverrideCheckbox("Override workspace settings", "Configure Workspace Settings") | ||
.build(); | ||
initValues(); | ||
addListeners(); | ||
return this.gradleProjectSettingsComposite; | ||
} | ||
|
||
private void initValues() { | ||
IProject project = getTargetProject(); | ||
BuildConfiguration buildConfig = CorePlugin.configurationManager().loadProjectConfiguration(project).getBuildConfiguration(); | ||
boolean overrideWorkspaceSettings = buildConfig.isOverrideWorkspaceSettings(); | ||
this.gradleProjectSettingsComposite.getGradleDistributionGroup().setDistribution(GradleDistributionViewModel.from(buildConfig.getGradleDistribution())); | ||
this.gradleProjectSettingsComposite.getAdvancedOptionsGroup().setGradleUserHome(buildConfig.getGradleUserHome()); | ||
this.gradleProjectSettingsComposite.getAdvancedOptionsGroup().setJavaHome(buildConfig.getJavaHome()); | ||
this.gradleProjectSettingsComposite.getAdvancedOptionsGroup().setArguments(buildConfig.getArguments()); | ||
this.gradleProjectSettingsComposite.getAdvancedOptionsGroup().setJvmArguments(buildConfig.getJvmArguments()); | ||
this.gradleProjectSettingsComposite.getOverrideBuildSettingsCheckbox().setSelection(overrideWorkspaceSettings); | ||
this.gradleProjectSettingsComposite.getBuildScansCheckbox().setSelection(buildConfig.isBuildScansEnabled()); | ||
this.gradleProjectSettingsComposite.getOfflineModeCheckbox().setSelection(buildConfig.isOfflineMode()); | ||
this.gradleProjectSettingsComposite.getAutoSyncCheckbox().setSelection(buildConfig.isAutoSync()); | ||
this.gradleProjectSettingsComposite.getShowConsoleViewCheckbox().setSelection(buildConfig.isShowConsoleView()); | ||
this.gradleProjectSettingsComposite.getShowExecutionsViewCheckbox().setSelection(buildConfig.isShowExecutionsView()); | ||
this.gradleProjectSettingsComposite.updateEnablement(); | ||
} | ||
|
||
private void addListeners() { | ||
this.gradleProjectSettingsComposite.getParentPreferenceLink().addSelectionListener(new WorkbenchPreferenceOpeningSelectionListener()); | ||
AdvancedOptionsGroup advancedOptionsGroup = this.gradleProjectSettingsComposite.getAdvancedOptionsGroup(); | ||
advancedOptionsGroup.getGradleUserHomeText().addModifyListener(new ValidatingListener<>(this, () -> advancedOptionsGroup.getGradleUserHome(), this.gradleUserHomeValidator)); | ||
advancedOptionsGroup.getJavaHomeText().addModifyListener(new ValidatingListener<>(this, () -> advancedOptionsGroup.getJavaHome(), this.javaHomeValidator)); | ||
this.gradleProjectSettingsComposite.getGradleDistributionGroup().addDistributionChangedListener(new GradleDistributionValidatingListener(this, this.distributionValidator)); | ||
} | ||
|
||
@Override | ||
public boolean performOk() { | ||
IProject project = getTargetProject(); | ||
ConfigurationManager manager = CorePlugin.configurationManager(); | ||
BuildConfiguration currentConfig = manager.loadProjectConfiguration(project).getBuildConfiguration(); | ||
BuildConfiguration updatedConfig = manager.createBuildConfiguration(currentConfig.getRootProjectDirectory(), | ||
this.gradleProjectSettingsComposite.getOverrideBuildSettingsCheckbox().getSelection(), | ||
this.gradleProjectSettingsComposite.getGradleDistributionGroup().getDistribution().toGradleDistribution(), | ||
this.gradleProjectSettingsComposite.getAdvancedOptionsGroup().getGradleUserHome(), | ||
this.gradleProjectSettingsComposite.getAdvancedOptionsGroup().getJavaHome(), | ||
this.gradleProjectSettingsComposite.getBuildScansCheckbox().getSelection(), | ||
this.gradleProjectSettingsComposite.getOfflineModeCheckbox().getSelection(), | ||
this.gradleProjectSettingsComposite.getAutoSyncCheckbox().getSelection(), | ||
this.gradleProjectSettingsComposite.getAdvancedOptionsGroup().getArguments(), | ||
this.gradleProjectSettingsComposite.getAdvancedOptionsGroup().getJvmArguments(), | ||
this.gradleProjectSettingsComposite.getShowConsoleViewCheckbox().getSelection(), | ||
this.gradleProjectSettingsComposite.getShowExecutionsViewCheckbox().getSelection()); | ||
manager.saveBuildConfiguration(updatedConfig); | ||
return true; | ||
} | ||
|
||
@SuppressWarnings("cast") | ||
private IProject getTargetProject() { | ||
return (IProject) Platform.getAdapterManager().getAdapter(getElement(), IProject.class); | ||
} | ||
|
||
/** | ||
* Opens the workspace preferences dialog. | ||
*/ | ||
private class WorkbenchPreferenceOpeningSelectionListener implements SelectionListener { | ||
|
||
@Override | ||
public void widgetSelected(SelectionEvent e) { | ||
openWorkspacePreferences(); | ||
} | ||
|
||
@Override | ||
public void widgetDefaultSelected(SelectionEvent e) { | ||
openWorkspacePreferences(); | ||
} | ||
|
||
private void openWorkspacePreferences() { | ||
PreferencesUtil.createPreferenceDialogOn(getShell(), GradleWorkbenchPreferencePage.PAGE_ID, null, null).open(); | ||
} | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
...g/eclipse/buildship/ui/internal/preferences/GradleCompositeRootProjectPreferencePage.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,96 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 Gradle Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
******************************************************************************/ | ||
|
||
package org.eclipse.buildship.ui.internal.preferences; | ||
|
||
import org.eclipse.jface.layout.GridDataFactory; | ||
import org.eclipse.jface.layout.GridLayoutFactory; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.layout.GridData; | ||
import org.eclipse.swt.layout.GridLayout; | ||
import org.eclipse.swt.widgets.Button; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Control; | ||
import org.eclipse.swt.widgets.Label; | ||
import org.eclipse.swt.widgets.Layout; | ||
import org.eclipse.swt.widgets.Text; | ||
import org.eclipse.ui.dialogs.PropertyPage; | ||
|
||
import org.eclipse.buildship.ui.internal.util.layout.LayoutUtils; | ||
import org.eclipse.buildship.ui.internal.wizard.workspacecomposite.WorkspaceCompositeWizardMessages; | ||
|
||
/** | ||
* Preference page for composite root project. | ||
* | ||
* @author Sebastian Kuzniarz | ||
*/ | ||
|
||
public final class GradleCompositeRootProjectPreferencePage extends PropertyPage { | ||
|
||
public static final String PAGE_ID = "org.eclipse.buildship.ui.compositeRootProjectProperties"; | ||
|
||
private Text workspaceCompositeRootProjectLabel; | ||
private Text overrideCheckboxLabel; | ||
private Button overrideSettingsCheckbox; | ||
private Button selectRootProject; | ||
private Composite rootProjectSettingsComposite; | ||
private Label rootProjectLabel; | ||
|
||
private Layout createLayout() { | ||
GridLayout layout = LayoutUtils.newGridLayout(2); | ||
layout.horizontalSpacing = 4; | ||
layout.verticalSpacing = 4; | ||
return layout; | ||
} | ||
|
||
@Override | ||
protected Control createContents(Composite parent) { | ||
|
||
this.rootProjectSettingsComposite = new Composite(parent, SWT.NONE); | ||
this.rootProjectSettingsComposite.setLayout(createLayout()); | ||
|
||
this.overrideSettingsCheckbox = new Button(this.rootProjectSettingsComposite, SWT.CHECK); | ||
this.overrideSettingsCheckbox.setText("Use project as composite root"); | ||
GridDataFactory.swtDefaults().applyTo(this.rootProjectSettingsComposite); | ||
|
||
Label line = new Label(this.rootProjectSettingsComposite, SWT.SEPARATOR | SWT.HORIZONTAL); | ||
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(2, 1).applyTo(line); | ||
|
||
// composite root container | ||
Composite workspaceCompositeNameComposite = new Composite(this.rootProjectSettingsComposite, SWT.NONE); | ||
GridLayoutFactory.swtDefaults().extendedMargins(0, 0, 0, 10).numColumns(3).applyTo(workspaceCompositeNameComposite); | ||
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).span(3, SWT.DEFAULT).applyTo(workspaceCompositeNameComposite); | ||
|
||
// root project label | ||
this.rootProjectLabel = new Label(workspaceCompositeNameComposite, SWT.NONE); | ||
this.rootProjectLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1)); | ||
this.rootProjectLabel.setText(WorkspaceCompositeWizardMessages.Label_RootProject); | ||
|
||
// root project text field | ||
this.workspaceCompositeRootProjectLabel = new Text(workspaceCompositeNameComposite, SWT.BORDER); | ||
this.workspaceCompositeRootProjectLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); | ||
|
||
// root project select button | ||
this.selectRootProject = new Button(workspaceCompositeNameComposite, SWT.PUSH); | ||
this.selectRootProject.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); | ||
this.selectRootProject.setText(WorkspaceCompositeWizardMessages.Button_Select_RootProject); | ||
return this.rootProjectSettingsComposite; | ||
} | ||
|
||
@Override | ||
public void dispose() { | ||
super.dispose(); | ||
} | ||
|
||
@Override | ||
public boolean performOk() { | ||
return true; | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...org/eclipse/buildship/ui/internal/preferences/GradleWorkspaceCompositePreferencePage.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,71 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 Gradle Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
******************************************************************************/ | ||
|
||
package org.eclipse.buildship.ui.internal.preferences; | ||
|
||
import org.eclipse.jface.layout.GridDataFactory; | ||
import org.eclipse.jface.layout.GridLayoutFactory; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.layout.GridData; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Control; | ||
import org.eclipse.swt.widgets.Label; | ||
import org.eclipse.swt.widgets.Text; | ||
import org.eclipse.ui.dialogs.PropertyPage; | ||
|
||
import org.eclipse.buildship.ui.internal.util.layout.LayoutUtils; | ||
import org.eclipse.buildship.ui.internal.util.widget.GradleProjectGroup; | ||
import org.eclipse.buildship.ui.internal.wizard.workspacecomposite.WorkspaceCompositeWizardMessages; | ||
|
||
/** | ||
* Preference page for workspace composite configuration. | ||
* | ||
* @author Sebastian Kuzniarz | ||
*/ | ||
@SuppressWarnings("unused") | ||
public final class GradleWorkspaceCompositePreferencePage extends PropertyPage { | ||
|
||
public static final String PAGE_ID = "org.eclipse.buildship.ui.compositeproperties"; | ||
|
||
private Text workspaceCompositeNameText; | ||
private Label compositeName; | ||
private GradleProjectGroup gradleProjectCheckboxtreeComposite; | ||
private Composite gradleWorkspaceCompositeSettingsComposite; | ||
|
||
@Override | ||
protected Control createContents(Composite parent) { | ||
this.gradleWorkspaceCompositeSettingsComposite = new Composite(parent, SWT.FILL); | ||
this.gradleWorkspaceCompositeSettingsComposite.setLayout(LayoutUtils.newGridLayout(2)); | ||
|
||
// composite name container | ||
Composite workspaceCompositeNameComposite = new Composite(this.gradleWorkspaceCompositeSettingsComposite, SWT.FILL); | ||
GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 5).numColumns(2).applyTo(workspaceCompositeNameComposite); | ||
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).span(3, SWT.DEFAULT).applyTo(workspaceCompositeNameComposite); | ||
|
||
// composite name label | ||
this.compositeName = new Label(workspaceCompositeNameComposite, SWT.NONE); | ||
this.compositeName.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1)); | ||
this.compositeName.setText(WorkspaceCompositeWizardMessages.Label_CompositeName); | ||
|
||
// composite name text field | ||
this.workspaceCompositeNameText = new Text(workspaceCompositeNameComposite, SWT.BORDER); | ||
this.workspaceCompositeNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); | ||
|
||
this.gradleProjectCheckboxtreeComposite = new GradleProjectGroup(this.gradleWorkspaceCompositeSettingsComposite); | ||
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(3, SWT.DEFAULT).applyTo(this.gradleProjectCheckboxtreeComposite); | ||
|
||
return this.gradleWorkspaceCompositeSettingsComposite; | ||
} | ||
|
||
@Override | ||
public boolean performOk() { | ||
return true; | ||
} | ||
} |
Oops, something went wrong.