Skip to content

Commit

Permalink
Implemented no-op UIs for workspace-composite wizard + preferences (#867
Browse files Browse the repository at this point in the history
)

* 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
kuzniarz authored and donat committed Apr 12, 2019
1 parent dc9ded9 commit 8d4b399
Show file tree
Hide file tree
Showing 20 changed files with 1,187 additions and 3 deletions.
22 changes: 22 additions & 0 deletions org.eclipse.buildship.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@
name="Gradle">
</category>
</extension>

<!-- integration of a Gradle workspace composite creation wizard -->
<extension point="org.eclipse.ui.newWizards">
<wizard
id="org.eclipse.buildship.ui.wizard.workspaceComposite.creation"
class="org.eclipse.buildship.ui.internal.wizard.workspacecomposite.WorkspaceCompositeCreationWizard"
category="org.eclipse.buildship.ui.creationwizards"
icon="icons/full/etool16/creation_wiz.png"
name="Gradle Composite"
canFinishEarly="false"
hasPages="true"
project="true">
<description>
Create a new Gradle workspace composite.
</description>
<keywordReference id="org.eclipse.buildship.ui.keyword.buildship"/>
</wizard>
<category
id="org.eclipse.buildship.ui.creationwizards"
name="Gradle">
</category>
</extension>

<!-- definition of keywords available in search fields of Gradle project wizards -->
<extension
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*
* Copyright (c) 2017 the original author or authors.
* 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
*/

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();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (c) 2017 the original author or authors.
* 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
*/

package org.eclipse.buildship.ui.internal.preferences;

import org.eclipse.buildship.ui.internal.util.layout.LayoutUtils;
import org.eclipse.buildship.ui.internal.wizard.workspacecomposite.WorkspaceCompositeWizardMessages;
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;

/**
* 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);
rootProjectSettingsComposite.setLayout(createLayout());

this.overrideSettingsCheckbox = new Button(rootProjectSettingsComposite, SWT.CHECK);
this.overrideSettingsCheckbox.setText("Use project as composite root");
GridDataFactory.swtDefaults().applyTo(rootProjectSettingsComposite);

Label line = new Label(rootProjectSettingsComposite, SWT.SEPARATOR | SWT.HORIZONTAL);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(2, 1).applyTo(line);

// composite root container
Composite workspaceCompositeNameComposite = new Composite(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 rootProjectSettingsComposite;
}

@Override
public void dispose() {
super.dispose();
}

@Override
public boolean performOk() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright (c) 2017 the original author or authors.
* 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
*/

package org.eclipse.buildship.ui.internal.preferences;

import org.eclipse.buildship.ui.internal.util.font.FontUtils;
import org.eclipse.buildship.ui.internal.util.layout.LayoutUtils;
import org.eclipse.buildship.ui.internal.util.widget.GradleProjectGroup;
import org.eclipse.buildship.ui.internal.util.widget.UiBuilder;
import org.eclipse.buildship.ui.internal.wizard.workspacecomposite.WorkspaceCompositeWizardMessages;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
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;

/**
* 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);
gradleWorkspaceCompositeSettingsComposite.setLayout(LayoutUtils.newGridLayout(2));

// composite name container
Composite workspaceCompositeNameComposite = new Composite(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(gradleWorkspaceCompositeSettingsComposite);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(3, SWT.DEFAULT).applyTo(this.gradleProjectCheckboxtreeComposite);

return gradleWorkspaceCompositeSettingsComposite;
}

@Override
public boolean performOk() {
return true;
}
}
Loading

0 comments on commit 8d4b399

Please sign in to comment.