Search in sources :

Example 1 with ServerWorkingCopyPropertyTextCommand

use of org.jboss.ide.eclipse.as.wtp.ui.editor.ServerWorkingCopyPropertyTextCommand in project jbosstools-openshift by jbosstools.

the class OpenShiftServerEditorSection method createPodPathControls.

@SuppressWarnings("unchecked")
private void createPodPathControls(Composite parent, DataBindingContext dbc) {
    Label deployPathLabel = new Label(parent, SWT.NONE);
    deployPathLabel.setText("Pod Deployment Path: ");
    GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).applyTo(deployPathLabel);
    deployPathText = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(deployPathText);
    deployPathModifyListener = new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            execute(new ServerWorkingCopyPropertyTextCommand(input.getServer(), "Set Deploy Path", deployPathText, deployPathText.getText(), OpenShiftServerUtils.ATTR_POD_PATH, (ModifyListener) this));
        }
    };
    ModifyListener deployPathDecoration = new TextboxDecoratorSupport(deployPathText, value -> {
        // TODO validate
        if (!(value instanceof String) || StringUtils.isEmpty(value)) {
            return ValidationStatus.cancel("Please provide a path to deploy to on the pod.");
        }
        if (!Path.isValidPosixPath((String) value)) {
            return ValidationStatus.error("Please provide a valid path to deploy to on the pod");
        }
        return Status.OK_STATUS;
    });
    deployPathText.addModifyListener(deployPathDecoration);
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) ServerWorkingCopyPropertyTextCommand(org.jboss.ide.eclipse.as.wtp.ui.editor.ServerWorkingCopyPropertyTextCommand) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) FormText(org.eclipse.ui.forms.widgets.FormText)

Example 2 with ServerWorkingCopyPropertyTextCommand

use of org.jboss.ide.eclipse.as.wtp.ui.editor.ServerWorkingCopyPropertyTextCommand in project jbosstools-openshift by jbosstools.

the class OpenShiftServerEditorSection method createDebuggingPortControls.

@SuppressWarnings("unchecked")
private void createDebuggingPortControls(FormToolkit toolkit, Composite container, DataBindingContext dbc) {
    Label debugPortLabel = new Label(container, SWT.None);
    debugPortLabel.setText("Debugging Port:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(debugPortLabel);
    // use image key & value checkbox
    useImageDebugPortKeyButton = new Button(container, SWT.CHECK);
    useImageDebugPortKeyButton.setText("use image provided key and value");
    GridDataFactory.fillDefaults().span(4, 1).align(SWT.FILL, SWT.CENTER).applyTo(useImageDebugPortKeyButton);
    // port key field
    // filler
    new Label(container, SWT.NONE);
    Label keyLabel = new Label(container, SWT.NONE);
    keyLabel.setText("Key:");
    GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).applyTo(keyLabel);
    debugPortKeyText = new Text(container, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(debugPortKeyText);
    debugPortKeyListener = new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            execute(new ServerWorkingCopyPropertyTextCommand(input.getServer(), "SetDebugPortKey", debugPortKeyText, debugPortKeyText.getText(), OpenShiftServerUtils.ATTR_DEBUG_PORT_KEY, (ModifyListener) this));
        }
    };
    ModifyListener debugPortKeyDecoration = new TextboxDecoratorSupport(debugPortKeyText, value -> {
        if (!useImageDebugPortKeyButton.getSelection()) {
            return new OpenShiftIdentifierValidator().validate(debugPortKeyText.getText());
        }
        return Status.OK_STATUS;
    });
    debugPortKeyText.addModifyListener(debugPortKeyDecoration);
    // port value field
    Label portLabel = new Label(container, SWT.NONE);
    portLabel.setText("Port:");
    GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).applyTo(portLabel);
    debugPortText = new Text(container, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(debugPortText);
    debugPortValListener = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            execute(new ServerWorkingCopyPropertyTextCommand(input.getServer(), "SetDebugPortValue", debugPortText, debugPortText.getText(), OpenShiftServerUtils.ATTR_DEBUG_PORT_VALUE, this));
        }
    };
    ModifyListener debugPortValDecoration = new TextboxDecoratorSupport(debugPortText, value -> {
        if (!useImageDebugPortKeyButton.getSelection()) {
            return new NumericValidator("integer", Integer::parseInt, true).validate(debugPortText.getText());
        }
        return Status.OK_STATUS;
    });
    debugPortText.addModifyListener(debugPortValDecoration);
    debugPortKeyValSelectionListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            execute(new ToggleDebugKeyValueCommand(server, useImageDebugPortKeyButton, this, debugPortKeyText, debugPortKeyListener, debugPortText, debugPortValListener));
        }
    };
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) OpenShiftIdentifierValidator(org.jboss.tools.openshift.internal.ui.validator.OpenShiftIdentifierValidator) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) FormText(org.eclipse.ui.forms.widgets.FormText) NumericValidator(org.jboss.tools.openshift.internal.common.ui.databinding.NumericValidator) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) ServerWorkingCopyPropertyTextCommand(org.jboss.ide.eclipse.as.wtp.ui.editor.ServerWorkingCopyPropertyTextCommand) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 3 with ServerWorkingCopyPropertyTextCommand

use of org.jboss.ide.eclipse.as.wtp.ui.editor.ServerWorkingCopyPropertyTextCommand in project jbosstools-openshift by jbosstools.

the class OpenShiftServerEditorSection method createEnableDebuggingControls.

@SuppressWarnings("unchecked")
private void createEnableDebuggingControls(FormToolkit toolkit, Composite container, DataBindingContext dbc) {
    Label enableDevmodeLabel = new Label(container, SWT.None);
    enableDevmodeLabel.setText("Enable debugging:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(enableDevmodeLabel);
    useImageDevmodeKeyButton = toolkit.createButton(container, "use image provided key", SWT.CHECK);
    GridDataFactory.fillDefaults().span(4, 1).align(SWT.FILL, SWT.CENTER).applyTo(useImageDevmodeKeyButton);
    // filler
    new Label(container, SWT.NONE);
    Label keyLabel = new Label(container, SWT.NONE);
    keyLabel.setText("Key:");
    GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).applyTo(keyLabel);
    devmodeKeyText = new Text(container, SWT.BORDER);
    GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).applyTo(devmodeKeyText);
    devmodeKeyModifyListener = new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            execute(new ServerWorkingCopyPropertyTextCommand(input.getServer(), "SetDevmodeKey", devmodeKeyText, devmodeKeyText.getText(), OpenShiftServerUtils.ATTR_DEVMODE_KEY, (ModifyListener) this));
        }
    };
    ModifyListener devmodeKeyModifyDecoration = new TextboxDecoratorSupport(devmodeKeyText, value -> {
        if (!useImageDevmodeKeyButton.getSelection()) {
            return new OpenShiftIdentifierValidator().validate(devmodeKeyText.getText());
        }
        return Status.OK_STATUS;
    });
    devmodeKeyText.addModifyListener(devmodeKeyModifyDecoration);
    useImageDevmodeKeyListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            execute(new ToggleDebuggingCommand(input.getServer(), useImageDevmodeKeyButton, devmodeKeyText, this, devmodeKeyModifyListener));
        }
    };
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) OpenShiftIdentifierValidator(org.jboss.tools.openshift.internal.ui.validator.OpenShiftIdentifierValidator) ServerWorkingCopyPropertyTextCommand(org.jboss.ide.eclipse.as.wtp.ui.editor.ServerWorkingCopyPropertyTextCommand) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) FormText(org.eclipse.ui.forms.widgets.FormText)

Aggregations

ModifyEvent (org.eclipse.swt.events.ModifyEvent)3 ModifyListener (org.eclipse.swt.events.ModifyListener)3 Label (org.eclipse.swt.widgets.Label)3 Text (org.eclipse.swt.widgets.Text)3 FormText (org.eclipse.ui.forms.widgets.FormText)3 ServerWorkingCopyPropertyTextCommand (org.jboss.ide.eclipse.as.wtp.ui.editor.ServerWorkingCopyPropertyTextCommand)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 OpenShiftIdentifierValidator (org.jboss.tools.openshift.internal.ui.validator.OpenShiftIdentifierValidator)2 Button (org.eclipse.swt.widgets.Button)1 NumericValidator (org.jboss.tools.openshift.internal.common.ui.databinding.NumericValidator)1