Skip to content
This repository has been archived by the owner on Apr 3, 2018. It is now read-only.

Commit

Permalink
!API Refactor CommandInvocationEditor, added EnvVars button.
Browse files Browse the repository at this point in the history
Refactor CompositeWidget code
  • Loading branch information
bruno-medeiros committed Apr 22, 2016
1 parent 525a748 commit 4229d4a
Show file tree
Hide file tree
Showing 36 changed files with 511 additions and 409 deletions.
Expand Up @@ -45,7 +45,7 @@
import melnorme.util.swt.SWTFactory;
import melnorme.util.swt.SWTFactoryUtil;
import melnorme.util.swt.SWTUtil;
import melnorme.util.swt.components.AbstractCompositeWidget;
import melnorme.util.swt.components.CompositeWidget;
import melnorme.util.swt.components.AbstractWidget;
import melnorme.util.swt.components.fields.DirectoryTextField;
import melnorme.util.swt.components.fields.EnablementButtonTextField;
Expand Down Expand Up @@ -138,13 +138,14 @@ public void setVisible(boolean visible) {
}
}

public static class NameGroup extends AbstractCompositeWidget {
public static class NameGroup extends CompositeWidget {

protected TextFieldWidget textField = new TextFieldWidget(WizardMessages.LangNewProject_NameGroup_label);

public NameGroup() {
super(true);
addSubComponent(textField);
addChildWidget(textField);
this.layoutColumns = 2;

ValidationSourceX validationSource = () -> getProjectHandle2();
validation.addFieldValidation(true, textField, validationSource);
Expand All @@ -164,11 +165,6 @@ public IProject getProjectHandle2() throws StatusException {

/* ----------------- ----------------- */

@Override
public int getPreferredLayoutColumns() {
return 2;
}

public void postSetFocus() {
SWTUtil.post_setFocus(textField.getFieldControl());
}
Expand Down Expand Up @@ -261,7 +257,7 @@ protected void createContents_Label(Composite parent) {
}

@Override
protected String getNewValueFromButtonSelection2() throws OperationCancellation {
protected String getNewValueFromButtonSelection() throws OperationCancellation {
return DirectoryTextField.openDirectoryDialog(getFieldValue(), button.getShell());
}

Expand Down
Expand Up @@ -25,7 +25,8 @@
public class ArgumentsGroupField extends ButtonTextField {

public ArgumentsGroupField(String labelText) {
super(labelText, SWT.MULTI | SWT.BORDER, LangUIMessages.Fields_VariablesButtonLabel);
super(labelText, LangUIMessages.Fields_VariablesButtonLabel);
setMultiLineStyle();
}

@Override
Expand Down Expand Up @@ -57,7 +58,7 @@ protected void createContents_layout() {
/* ----------------- ----------------- */

@Override
protected String getNewValueFromButtonSelection2() throws OperationCancellation {
protected String getNewValueFromButtonSelection() throws OperationCancellation {
return getFieldValue() + ControlUtils.openStringVariableSelectionDialog(text.getShell());
}

Expand Down
Expand Up @@ -54,7 +54,7 @@ protected Composite doCreateTopLevelControl(Composite parent) {

@Override
protected GridLayoutFactory createTopLevelLayout() {
return glSwtDefaults().numColumns(getPreferredLayoutColumns());
return GridLayoutFactory.swtDefaults().numColumns(getPreferredLayoutColumns());
}

@Override
Expand All @@ -70,7 +70,7 @@ protected void createContents_Label(Composite parent) {
/* ----------------- ----------------- */

@Override
protected String getNewValueFromButtonSelection2() throws OperationCancellation {
protected String getNewValueFromButtonSelection() throws OperationCancellation {
IProject project = chooseProject();
return project == null ? null : project.getName();
}
Expand Down
Expand Up @@ -39,7 +39,7 @@ public ProjectRelativePathField(String labelText, String useDefaultField_Label,
}

@Override
protected String getNewValueFromButtonSelection2() throws CommonException, OperationCancellation {
protected String getNewValueFromButtonSelection() throws CommonException, OperationCancellation {
return ControlUtils.openProgramPathDialog(projectGetter.get(), button);
}

Expand Down
Expand Up @@ -44,7 +44,7 @@ public int getPreferredLayoutColumns() {

@Override
protected void createContents_layout() {
combo.setLayoutData(gdFillDefaults().grab(false, false).hint(200, SWT.DEFAULT).create());
combo.setLayoutData(gdfFillDefaults().grab(false, false).hint(200, SWT.DEFAULT).create());
}

@Override
Expand Down
Expand Up @@ -101,7 +101,7 @@ protected BuildTargetEditor init_BuildTargetSettingsComponent() {
);
component.programPathField.setLabelText(LangUIMessages.LaunchTab_ProgramPathField_title);

component.buildCommandField.getCommandArgumentsField().getUseDefaultField().setLabelText(
component.buildCommandField.getEnablementField().setLabelText(
LangUIMessages.LaunchTab_Fields_useBuildTargetSettings);
component.programPathField.getUseDefaultField().setLabelText(
LangUIMessages.LaunchTab_Fields_useBuildTargetSettings);
Expand Down Expand Up @@ -209,7 +209,7 @@ protected void initializeBuildTargetField(BuildTargetLaunchCreator btLaunchCreat
}

protected void initializeBuildTargetSettings(BuildTargetLaunchCreator btLaunchCreator) {
buildTargetEditor.buildCommandField.setEffectiveFieldValue(btLaunchCreator.getBuildArguments());
buildTargetEditor.buildCommandField.setEffectiveFieldValue1(btLaunchCreator.getBuildArguments());
buildTargetEditor.programPathField.setEffectiveFieldValue(btLaunchCreator.getExecutablePath());
}

Expand All @@ -218,7 +218,7 @@ protected ProjectLaunchSettings getLaunchSettingsFromTab() {
return new BuildTargetLaunchCreator(
getProjectName(),
getBuildTargetName(),
buildTargetEditor.buildCommandField.getEffectiveFieldValue(),
buildTargetEditor.buildCommandField.getEffectiveFieldValue1(),
buildTargetEditor.programPathField.getEffectiveFieldValue()
);
}
Expand Down
Expand Up @@ -15,10 +15,10 @@

import melnorme.lang.ide.core.utils.prefs.DerivedValuePreference;
import melnorme.lang.ide.ui.preferences.common.PreferencesPageContext;
import melnorme.util.swt.components.AbstractCompositeWidget;
import melnorme.util.swt.components.CompositeWidget;
import melnorme.util.swt.components.FieldWidget;

public abstract class AbstractCompositePreferencesBlock extends AbstractCompositeWidget {
public abstract class AbstractCompositePreferencesBlock extends CompositeWidget {

protected final PreferencesPageContext prefContext;

Expand Down
Expand Up @@ -25,7 +25,7 @@ public AbstractToolLocationGroup(String toolName) {
this.toolName = toolName;

this.toolLocationField = initToolLocationField();
addSubComponent(toolLocationField);
addChildWidget(toolLocationField);
}

protected DownloadToolTextField initToolLocationField() {
Expand Down
Expand Up @@ -21,14 +21,14 @@
import melnorme.lang.ide.ui.LangUIMessages;
import melnorme.lang.ide.ui.utils.ControlUtils;
import melnorme.lang.tooling.data.StatusException;
import melnorme.util.swt.components.AbstractCompositeWidget;
import melnorme.util.swt.components.CompositeWidget;
import melnorme.util.swt.components.fields.CheckBoxField;
import melnorme.util.swt.components.fields.EnablementButtonTextField;
import melnorme.utilbox.concurrency.OperationCancellation;
import melnorme.utilbox.core.CommonException;
import melnorme.utilbox.core.fntypes.CommonGetter;

public class BuildTargetEditor extends AbstractCompositeWidget {
public class BuildTargetEditor extends CompositeWidget {

protected final BuildManager buildManager;

Expand Down Expand Up @@ -61,13 +61,13 @@ public BuildTargetEditor(
autoEnableField.addListener((newValue) -> btData.autoBuildEnabled = newValue);

if(createEnablementFields) {
addSubComponents(normalEnableField, autoEnableField);
addChildWidget(normalEnableField, autoEnableField);
}

buildCommandField = addSubComponent(init_createArgumentsField());
buildCommandField = addChildWidget(init_createArgumentsField());
buildCommandField.addChangeListener(() -> btData.buildArguments = getEffectiveBuildArgumentsValue());

programPathField = addSubComponent(init_createProgramPathField());
programPathField = addChildWidget(init_createProgramPathField());
programPathField.addListener((__) -> btData.executablePath = getEffectiveProgramPathValue());
// buildCommandField.addListener(() -> programPathField.updateDefaultFieldValue());
}
Expand All @@ -88,7 +88,7 @@ protected EnablementButtonTextField init_createProgramPathField() {
/* ----------------- bindings ----------------- */

public String getEffectiveBuildArgumentsValue() {
return buildCommandField.getEffectiveFieldValue();
return buildCommandField.getEffectiveFieldValue1();
}

public String getEffectiveProgramPathValue() {
Expand All @@ -98,24 +98,19 @@ public String getEffectiveProgramPathValue() {
public void inputChanged(BuildTargetDataView buildTargetData) {
normalEnableField.setFieldValue(buildTargetData.isNormalBuildEnabled());
autoEnableField.setFieldValue(buildTargetData.isAutoBuildEnabled());
buildCommandField.setEffectiveFieldValue(buildTargetData.getBuildArguments());
buildCommandField.setEffectiveFieldValue1(buildTargetData.getBuildArguments());
programPathField.setEffectiveFieldValue(buildTargetData.getExecutablePath());
}

/* ----------------- ----------------- */

@Override
public int getPreferredLayoutColumns() {
return 1;
}

public static class BuildCommandEditor extends CommandInvocationEditor {

public BuildCommandEditor(CommonGetter<String> getDefaultCommandArguments,
VariablesResolver variablesResolver) {
super(getDefaultCommandArguments, variablesResolver);

commandArgumentsField.setLabelText(LangUIMessages.Fields_BuildCommand);
this.label = LangUIMessages.Fields_BuildCommand;
}

@Override
Expand Down Expand Up @@ -145,7 +140,7 @@ protected String getDefaultFieldValue() throws CommonException {
}

@Override
protected String getNewValueFromButtonSelection2() throws CommonException, OperationCancellation {
protected String getNewValueFromButtonSelection() throws CommonException, OperationCancellation {
return getFieldValue() + ControlUtils.openStringVariableSelectionDialog(text.getShell());
}

Expand Down

0 comments on commit 4229d4a

Please sign in to comment.