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

Commit

Permalink
AbstractToolLocationGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-medeiros committed Feb 15, 2016
1 parent f6c38a9 commit 8fbd0b9
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 2 deletions.
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,65 @@
/*******************************************************************************
* Copyright (c) 2016 Bruno Medeiros and other Contributors.
* 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:
* Bruno Medeiros - initial API and implementation
*******************************************************************************/
package melnorme.lang.ide.ui.preferences;


import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.widgets.Composite;

import melnorme.lang.ide.ui.preferences.pages.DownloadToolTextField;
import melnorme.lang.ide.ui.utils.operations.BasicUIOperation;
import melnorme.util.swt.SWTFactoryUtil;
import melnorme.util.swt.components.AbstractCompositeWidget;
import melnorme.util.swt.components.IDisableableWidget;
import melnorme.util.swt.components.fields.ButtonTextField;
import melnorme.utilbox.collections.ArrayList2;
import melnorme.utilbox.collections.Indexable;

public abstract class AbstractToolLocationGroup extends AbstractCompositeWidget {

public final ButtonTextField toolLocationField = new DownloadToolTextField("Executable:", "Download...") {
@Override
public BasicUIOperation getDownloadButtonHandler() {
return do_getDownloadButtonHandler(this);
}
};

public final String toolName;
protected final ArrayList2<IDisableableWidget> subwidgets = new ArrayList2<IDisableableWidget>();

public AbstractToolLocationGroup(String toolName) {
this.toolName = toolName;
this.subwidgets.add(toolLocationField);
}

@Override
protected Composite doCreateTopLevelControl(Composite parent) {
return SWTFactoryUtil.createGroup(parent, toolName + ": ");
}

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

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

@Override
protected Indexable<IDisableableWidget> getSubWidgets() {
return subwidgets;
}

protected abstract BasicUIOperation do_getDownloadButtonHandler(DownloadToolTextField downloadToolTextField);

}
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Group;


Expand Down Expand Up @@ -75,7 +76,7 @@ protected void createContents(Composite topControl) {
toolGroup = AbstractPreferencesBlock.createOptionsSection(topControl, toolGroup = AbstractPreferencesBlock.createOptionsSection(topControl,
getDaemonToolName(), getDaemonToolName(),
3, 3,
GridDataFactory.fillDefaults().grab(true, false).minSize(300, SWT.DEFAULT).create()); createDefaultGroupGridData());


bindToPreference(startServerAutomatically, ToolchainPreferences.AUTO_START_DAEMON); bindToPreference(startServerAutomatically, ToolchainPreferences.AUTO_START_DAEMON);
bindToPreference(enableLogConsole, ToolchainPreferences.DAEMON_CONSOLE_ENABLE); bindToPreference(enableLogConsole, ToolchainPreferences.DAEMON_CONSOLE_ENABLE);
Expand All @@ -89,6 +90,10 @@ protected void createContents(Composite topControl) {
showErrorsDialog.createComponentInlined(toolGroup); showErrorsDialog.createComponentInlined(toolGroup);
} }


protected GridData createDefaultGroupGridData() {
return GridDataFactory.fillDefaults().grab(true, false).minSize(300, SWT.DEFAULT).create();
}

protected TextFieldComponent createDaemonPathFieldEditor(Group group) { protected TextFieldComponent createDaemonPathFieldEditor(Group group) {
String label = getDaemonToolName() + " path:"; String label = getDaemonToolName() + " path:";
TextFieldComponent pathField = doCreateDaemonPathFieldEditor(label); TextFieldComponent pathField = doCreateDaemonPathFieldEditor(label);
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ public <SOURCE> ArrayList2<E> addAll(Collection2<SOURCE> source, Function<SOURCE
return CollectionUtil.addAll(this, source, mapper); return CollectionUtil.addAll(this, source, mapper);
} }


public void addIfNotNull(E element) { public ArrayList2<E> addIfNotNull(E element) {
if(element != null) { if(element != null) {
add(element); add(element);
} }
return this;
} }


@Override @Override
Expand Down

0 comments on commit 8fbd0b9

Please sign in to comment.