Java Code Examples for org.eclipse.swt.widgets.Text#setLayoutData()

The following examples show how to use org.eclipse.swt.widgets.Text#setLayoutData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NewExperimentDialog.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private void createExperimentNameGroup(Composite parent) {
    Font font = parent.getFont();
    Composite folderGroup = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    folderGroup.setLayout(layout);
    folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // New experiment label
    Label experimentLabel = new Label(folderGroup, SWT.NONE);
    experimentLabel.setFont(font);
    experimentLabel.setText(Messages.NewExperimentDialog_ExperimentName);

    // New experiment name entry field
    fExperimentName = new Text(folderGroup, SWT.BORDER);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
    fExperimentName.setLayoutData(data);
    fExperimentName.setFont(font);
    fExperimentName.addListener(SWT.Modify, event -> validateNewExperimentName());
}
 
Example 2
Source File: VersionGridPropertySectionContribution.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void createControl(Composite composite, TabbedPropertySheetWidgetFactory widgetFactory, ExtensibleGridPropertySection page) {
    context = new EMFDataBindingContext();

    UpdateValueStrategy versionUpdate = new UpdateValueStrategy();
    versionUpdate.setAfterGetValidator(new EmptyInputValidator(Messages.GeneralSection_Version));
    versionUpdate.setBeforeSetValidator(new UTF8InputValidator(Messages.GeneralSection_Version));

    Text text = new Text(composite, GTKStyleHandler.removeBorderFlag(SWT.BORDER));
    text.setLayoutData(GridDataFactory.swtDefaults().hint(160, SWT.DEFAULT).grab(false, false).create());
    if (!GTKStyleHandler.isGTK3()) {
        widgetFactory.adapt(text, true, true);
    }
    text.setEnabled(false);
    
    context.bindValue(WidgetProperties.text(SWT.Modify).observe(text),
    	EMFEditObservables.observeValue(editingDomain, process, ProcessPackage.Literals.ABSTRACT_PROCESS__VERSION), 
    	versionUpdate, 
    	null);
}
 
Example 3
Source File: DialogError.java    From arx with Apache License 2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(final Composite parent) {

	parent.setLayout(new GridLayout());
    final Text text = new Text(parent, SWT.NONE | SWT.MULTI | SWT.V_SCROLL |
                                       SWT.H_SCROLL | SWT.BORDER);
    text.setText(error);
    final GridData d = SWTUtil.createFillGridData();
    d.heightHint = 100;
    text.setLayoutData(d);
    return parent;
}
 
Example 4
Source File: ExtractTempWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void createControl(Composite parent) {
	loadSettings();
	Composite result= new Composite(parent, SWT.NONE);
	setControl(result);
	GridLayout layout= new GridLayout();
	layout.numColumns= 2;
	layout.verticalSpacing= 8;
	result.setLayout(layout);
	RowLayouter layouter= new RowLayouter(2);

	Label label= new Label(result, SWT.NONE);
	label.setText(RefactoringMessages.ExtractTempInputPage_variable_name);

	Text text= createTextInputField(result);
	text.selectAll();
	text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	ControlContentAssistHelper.createTextContentAssistant(text, new VariableNamesProcessor(fTempNameProposals));

	layouter.perform(label, text, 1);

	addReplaceAllCheckbox(result, layouter);
	addDeclareFinalCheckbox(result, layouter);

	validateTextField(text.getText());

	Dialog.applyDialogFont(result);
	PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.EXTRACT_TEMP_WIZARD_PAGE);
}
 
Example 5
Source File: AbstractPathText.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
public AbstractPathText(final Composite parent, final File argProjectDir, final boolean indent) {
    text = new Text(parent, SWT.BORDER);
    projectDir = argProjectDir;

    final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gridData.grabExcessHorizontalSpace = true;

    if (indent) {
        gridData.horizontalIndent = Resources.INDENT;
    }

    text.setLayoutData(gridData);

    openBrowseButton = new Button(parent, SWT.LEFT);
    openBrowseButton.setText(" " + JFaceResources.getString("openBrowse") + " ");

    openBrowseButton.addSelectionListener(new SelectionAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void widgetSelected(final SelectionEvent e) {
            String saveFilePath = selectPathByDilaog();

            if (saveFilePath != null) {
                saveFilePath = FileUtils.getRelativeFilePath(projectDir, saveFilePath);
                setText(saveFilePath);
            }
        }
    });
}
 
Example 6
Source File: SetCommitPropertiesDialog.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void addCommitterName(Composite composite) {
Composite committerComposite = new Composite(composite, SWT.NULL);
GridLayout committerLayout = new GridLayout();
committerLayout.numColumns = 2;
committerComposite.setLayout(committerLayout);

Label label = new Label(committerComposite, SWT.NONE);
label.setText(Policy.bind("SetCommitPropertiesDialog.user"));
committerText = new Text(committerComposite, SWT.BORDER);
GridData data = new GridData();
data.widthHint = 150;
committerText.setLayoutData(data);
  }
 
Example 7
Source File: AddOrEditLangRuleOfSrxDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite tparent = (Composite) super.createDialogArea(parent);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);

	Composite langCmp = new Composite(tparent, SWT.NONE);
	GridDataFactory.fillDefaults().grab(true, true).hint(450, 100).applyTo(langCmp);
	GridLayoutFactory.fillDefaults().numColumns(2).applyTo(langCmp);

	isBreakBtn = new Button(langCmp, SWT.CHECK);
	isBreakBtn.setText(Messages.getString("srx.AddOrEditLangRuleOfSrxDialog.isBreakBtn"));
	GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, SWT.DEFAULT)
			.applyTo(isBreakBtn);

	Label preLbl = new Label(langCmp, SWT.NONE);
	preLbl.setText(Messages.getString("srx.AddOrEditLangRuleOfSrxDialog.preLbl"));

	GridData textData = new GridData(SWT.FILL, SWT.CENTER, true, false);

	preBreakTxt = new Text(langCmp, SWT.BORDER);
	preBreakTxt.setLayoutData(textData);

	Label afterLbl = new Label(langCmp, SWT.NONE);
	afterLbl.setText(Messages.getString("srx.AddOrEditLangRuleOfSrxDialog.afterLbl"));

	afterBreakTxt = new Text(langCmp, SWT.BORDER);
	afterBreakTxt.setLayoutData(textData);

	return tparent;
}
 
Example 8
Source File: DefinitionValueDialog.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds a {@link Label} with the {@link Definition#getKey() definition name} and a {@link Text}.
 * 
 * @param def
 *            the {@link Definition}
 * @param container
 *            the container {@link Composite}
 * @return the created {@link Text}.
 */
private Text addLabelAndText(Definition def, Composite container) {
    final Composite composite = new Composite(container, container.getStyle());
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    final Label label = new Label(composite, container.getStyle());
    label.setText(def.getKey() + " = ");
    final Text text = new Text(composite, container.getStyle());
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    return text;
}
 
Example 9
Source File: Convert2TmxDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private Composite createArributeArea(Composite attibueArea, String key, String value) {
	Composite parent = new Composite(attibueArea, SWT.NONE);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(parent);
	GridLayoutFactory.fillDefaults().spacing(0, 0).numColumns(5).applyTo(parent);

	Text keyText = new Text(parent, SWT.BORDER);
	keyText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

	if (null != key) {
		keyText.setText(key);
	}

	Label assignLb = new Label(parent, SWT.NONE);
	assignLb.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
	assignLb.setText(" = ");
	Text valueText = new Text(parent, SWT.BORDER);
	valueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	if (null != value) {
		valueText.setText(value);
	}
	Button addBtn = new Button(parent, SWT.NONE);
	addBtn.setText("+");
	addBtn.addSelectionListener(new AddArributeCommand(attibueArea));

	Button deletBtn = new Button(parent, SWT.NONE);
	deletBtn.setText("-");
	deletBtn.addSelectionListener(new DeleteAttibuteCommand(attibueArea));
	return attibueArea;
}
 
Example 10
Source File: MultipleInputDialog.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected void createTextField(String labelText, String initialValue, boolean allowEmpty) { 
	Label label = new Label(panel, SWT.NONE);
	label.setText(labelText);
	label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
	
	final Text text = new Text(panel, SWT.SINGLE | SWT.BORDER);
	text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	text.setData(FIELD_NAME, labelText);
	
	// make sure rows are the same height on both panels.
	label.setSize(label.getSize().x, text.getSize().y); 
	
	if (initialValue != null) {
		text.setText(initialValue);
	}
	
	if (!allowEmpty) {
		validators.add(new Validator() {
			@Override
			public boolean validate() {
				return !text.getText().equals(IInternalDebugCoreConstants.EMPTY_STRING);
			}
		});
		text.addModifyListener(new ModifyListener() {
			@Override
			public void modifyText(ModifyEvent e) {
				validateFields();
			}
		});
	}
	
	controlList.add(text);
}
 
Example 11
Source File: PopulationEditor.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Control createCustomParameterControl(final Composite compo) {
	populationDisplayer = new Text(compo, SWT.READ_ONLY);
	populationDisplayer.setEnabled(false);
	final GridData data = new GridData(GridData.FILL, GridData.CENTER, true, false);
	populationDisplayer.setLayoutData(data);
	return populationDisplayer;
}
 
Example 12
Source File: SWTFactory.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new text widget 
 * @param parent the parent composite to add this text widget to
 * @param style the style bits for the text widget
 * @param hspan the horizontal span to take up on the parent composite
 * @param text the initial text, not <code>null</code>
 * @return the new text widget
 * @since 3.6
 */
public static Text createText(Composite parent, int style, int hspan, String text) {
   	Text t = new Text(parent, style);
   	t.setFont(parent.getFont());
   	GridData gd = new GridData(GridData.FILL_HORIZONTAL);
   	gd.horizontalSpan = hspan;
   	t.setLayoutData(gd);
   	t.setText(text);
   	return t;
   }
 
Example 13
Source File: ConversionWizardPage.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 创建分段规则选择组
 * @param contents
 *            ;
 */
private void createSegmentationGroup(Composite contents) {
	Group segmentation = new Group(contents, SWT.NONE);
	segmentation.setText(Messages.getString("ConversionWizardPage.10")); //$NON-NLS-1$
	segmentation.setLayout(new GridLayout(3, false));
	GridData data = new GridData(GridData.FILL_HORIZONTAL);
	data.widthHint = 500;
	segmentation.setLayoutData(data);

	Label segLabel = new Label(segmentation, SWT.NONE);
	segLabel.setText(Messages.getString("ConversionWizardPage.11")); //$NON-NLS-1$

	srxFile = new Text(segmentation, SWT.BORDER | SWT.READ_ONLY);
	srxFile.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	srxFile.addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent e) {
			for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
				conversionConfigBean.setInitSegmenter(srxFile.getText());
			}

			validate();
		}
	});

	final Button segBrowse = new Button(segmentation, SWT.PUSH);
	segBrowse.setText(Messages.getString("ConversionWizardPage.12")); //$NON-NLS-1$
	segBrowse.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent arg0) {
			IConversionItemDialog conversionItemDialog = FileDialogFactoryFacade.createFileDialog(getShell(),
					SWT.NONE);
			int result = conversionItemDialog.open();
			if (result == IDialogConstants.OK_ID) {
				IConversionItem conversionItem = conversionItemDialog.getConversionItem();
				srxFile.setText(conversionItem.getLocation().toOSString());
			}
		}
	});
}
 
Example 14
Source File: GroupsWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createDescriptionField(final Group group) {
    final Label descriptionLabel = new Label(group, SWT.NONE);
    descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).create());
    descriptionLabel.setText(Messages.description);

    final Text groupDescriptionText = new Text(group, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    groupDescriptionText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 80).create());

    final IObservableValue groupDescriptionValue = EMFObservables.observeDetailValue(Realm.getDefault(), groupSingleSelectionObservable,
            OrganizationPackage.Literals.GROUP__DESCRIPTION);
    context.bindValue(SWTObservables.observeText(groupDescriptionText, SWT.Modify), groupDescriptionValue);
}
 
Example 15
Source File: InstallNpmDependencyDialog.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private Text getSimpleTextArea(Composite parent) {
	final Text text = new Text(parent, BORDER);
	text.setLayoutData(new GridData(FILL, CENTER, true, false, 1, 1));
	return text;
}
 
Example 16
Source File: N4JSNewProjectWizardCreationPage.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private Composite initLibraryOptionsUI(DataBindingContext dbc, Composite parent) {
	// Additional library project options
	final Group libraryProjectOptionsGroup = new Group(parent, NONE);
	libraryProjectOptionsGroup
			.setLayout(GridLayoutFactory.fillDefaults().margins(12, 5).numColumns(2).equalWidth(false).create());

	emptyPlaceholder(libraryProjectOptionsGroup);

	final Button createGreeterFileButton = new Button(libraryProjectOptionsGroup, CHECK);
	createGreeterFileButton.setText("Create a greeter file");
	createGreeterFileButton.setLayoutData(GridDataFactory.fillDefaults().create());

	new Label(libraryProjectOptionsGroup, SWT.NONE).setText("Implementation ID:");
	final Text implementationIdText = new Text(libraryProjectOptionsGroup, BORDER);
	implementationIdText.setLayoutData(fillDefaults().align(FILL, SWT.CENTER).grab(true, false).create());

	final Label implementedProjectsLabel = new Label(libraryProjectOptionsGroup, SWT.NONE);
	implementedProjectsLabel.setText("Implemented projects:");
	implementedProjectsLabel
			.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).align(SWT.LEFT, SWT.TOP).create());

	final ListViewer apiViewer = new ListViewer(libraryProjectOptionsGroup, BORDER | MULTI);
	apiViewer.getControl().setLayoutData(fillDefaults().align(FILL, FILL).grab(true, true).span(1, 1).create());
	apiViewer.setContentProvider(ArrayContentProvider.getInstance());
	apiViewer.setInput(getAvailableApiProjectNames());

	initApiViewerBinding(dbc, apiViewer);
	initImplementationIdBinding(dbc, implementationIdText);
	initDefaultCreateGreeterBindings(dbc, createGreeterFileButton);

	// Invalidate on change
	apiViewer.addSelectionChangedListener(e -> {
		setPageComplete(validatePage());
	});
	// Invalidate on change
	implementationIdText.addModifyListener(e -> {
		setPageComplete(validatePage());
	});

	return libraryProjectOptionsGroup;
}
 
Example 17
Source File: AddRemoteServiceDialog.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {

  Composite composite = (Composite) super.createDialogArea(parent);
  
  Composite tc1 = new2ColumnComposite(composite);
  Label tempLabel;
  
  setTextAndTip(tempLabel = new Label(tc1, SWT.WRAP), "Service kind:", S_, SWT.BEGINNING, false);    
  aeOrCcCombo = wideCCombo(tc1, "Specify whether the Service is an Analysis Engine or a Cas Consumer",
          "AnalysisEngine", "CasConsumer");

  setTextAndTip(tempLabel = new Label(tc1, SWT.WRAP), "Protocol Service Type", S_, SWT.BEGINNING, false);
  serviceTypeCombo = wideCCombo(tc1, S_, "UIMA-AS JMS", "SOAP", "Vinci");

  setTextAndTip(uriLabel = new Label(tc1, SWT.NONE), "URI of service or JMS Broker:",
     "The URI for the service, e.g. localhost", SWT.BEGINNING, false);
  uriText = wideTextInput(tc1, S_, m_dialogModifyListener);

  setTextAndTip(endpointLabel = new Label(tc1, SWT.NONE), "Endpoint Name (JMS Service):",
  "For UIMA-AS JMS Services only, the endpoint name", SWT.BEGINNING, false);

  endpointText = wideTextInput(tc1, S_, m_dialogModifyListener);

  setTextAndTip(binarySerializationLabel = new Label(tc1, SWT.NONE), "Binary Serialization (JMS Service):",
      "For UIMA-AS JMS Services only, use binary serialzation (requires all type systems be identical)", 
      SWT.BEGINNING, false);

  binarySerializationCombo = wideCComboTF(tc1, S_);
  
  setTextAndTip(ignoreProcessErrorsLabel = new Label(tc1, SWT.NONE), "Ignore Process Errors (JMS Service):",
  "For UIMA-AS JMS Services only, ignore processing errors");
  ignoreProcessErrorsLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));

  ignoreProcessErrorsCombo = wideCComboTF(tc1, S_);   

  setTextAndTip(tempLabel = new Label(tc1, SWT.NONE), "Key (a short mnemonic for this service):",
      "also used as part of the file name", SWT.BEGINNING, false);
  keyText = wideTextInput(tc1, S_, m_dialogModifyListener);
  keyText.addVerifyListener(new DialogVerifyListener());
  keyTextPrev = ".xml";

  createWideLabel(composite, "Where the generated remote descriptor file will be stored:");
  genFilePathUI = new Text(composite, SWT.BORDER | SWT.H_SCROLL);
  genFilePathUI.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  genFilePathUI.setText(rootPath + ".xml");

  createWideLabel(
          composite,
          "Timeouts, in milliseconds.  This is ignored for the Vinci protocol.  Specify 0 to wait forever. If not specified, a default timeout is used.");
  
  tc1 = new2ColumnComposite(composite);
  
  setTextAndTip(timeoutProcessLabel = new Label(tc1, SWT.NONE), "Timeout: Process:",
      "Timeout for processing a CAS", SWT.BEGINNING, false);   
  timeoutText = wideTextInput(tc1, S_);

  setTextAndTip(timeoutJmsGetmetaLabel = new Label(tc1, SWT.NONE), "Timeout: (JMS) GetMeta:",
  "Timeout for querying the metadata from a JMS service", SWT.BEGINNING, false);
  timeoutGetmetaText = wideTextInput(tc1, S_);

  setTextAndTip(timeoutJmsCpcLabel = new Label(tc1, SWT.NONE), "Timeout: (JMS) Collection Processing Complete:",
  "Timeout for Collection Processing Complete", SWT.BEGINNING, false);   
  timeoutJmsCpcText = wideTextInput(tc1, S_);
  createWideLabel(composite,
          "For the Vinci protocol, you can optionally specify the Host/Port for the Vinci Name Service");
  Composite tc = new2ColumnComposite(composite);
  setTextAndTip(vnsHostLabel = new Label(tc, SWT.NONE), "VNS HOST",
          "An IP name or address, e.g. localhost");
  vnsHostUI = newText(tc, SWT.NONE, "An IP name or address, e.g. localhost");
  setTextAndTip(vnsPortLabel = new Label(tc, SWT.NONE), "VNS PORT", "A port number, e.g. 9000");
  vnsPortUI = newText(tc, SWT.NONE, "A port number, e.g. 9000");

  newErrorMessage(composite);

  autoAddToFlowButton = new Button(composite, SWT.CHECK);
  autoAddToFlowButton.setText("Add to end of flow");
  autoAddToFlowButton.setSelection(true);

  new Label(composite, SWT.NONE).setText("");
  importByNameUI = new Button(composite, SWT.RADIO);
  importByNameUI.setText("Import by Name");
  importByNameUI
          .setToolTipText("Importing by name looks up the name on the classpath and datapath.");
  importByNameUI.setSelection(true);

  importByLocationUI = new Button(composite, SWT.RADIO);
  importByLocationUI.setText("Import By Location");
  importByLocationUI.setToolTipText("Importing by location requires a relative or absolute URL");

  String defaultBy = CDEpropertyPage.getImportByDefault(editor.getProject());
  if (defaultBy.equals("location")) {
    importByNameUI.setSelection(false);
    importByLocationUI.setSelection(true);
  } else {
    importByNameUI.setSelection(true);
    importByLocationUI.setSelection(false);
  }

  return composite;
}
 
Example 18
Source File: ImporterPage.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @since 3.7
 */
public FileBasedImporter(final Composite parent, final ImporterPage home,
	boolean supportMultiFileSelection){
	super(parent, SWT.BORDER);
	setLayout(new GridLayout(1, false));
	final Label lFile = new Label(this, SWT.NONE);
	tFname = new Text(this, SWT.BORDER);
	tFname.setText(CoreHub.localCfg
		.get("ImporterPage/" + home.getTitle() + "/filename", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	home.results = new String[1];
	home.results[0] = tFname.getText();
	lFile.setText(Messages.ImporterPage_file); //$NON-NLS-1$
	lFile.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	tFname.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	tFname.addModifyListener(new ModifyListener() {
		/** {@inheritDoc} */
		@Override
		public void modifyText(ModifyEvent event){
			String filename = tFname.getText();
			if (new File(filename).isFile()) {
				home.results[0] = filename;
			}
		}
	});
	
	Button bFile = new Button(this, SWT.PUSH);
	bFile.setText(Messages.ImporterPage_browse); //$NON-NLS-1$
	// bFile.setLayoutData(SWTHelper.getFillGridData(2,true,1,false));
	bFile.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(final SelectionEvent e){
			int style = (supportMultiFileSelection) ? SWT.OPEN | SWT.MULTI : SWT.OPEN;
			FileDialog fdl = new FileDialog(parent.getShell(), style);
			fdl.setFilterExtensions(filterExts);
			fdl.setFilterNames(filterNames);
			fdl.open();
			String[] fileNames = fdl.getFileNames();
			if (fileNames != null && fileNames.length > 0) {
				if(fileNames.length > 1) {
					tFname.setText(fileNames[0]+" and more ...");
				} else {
					tFname.setText(fileNames[0]);
				}

				home.results = new String[fileNames.length];
				for (int i = 0; i < fileNames.length; i++) {
					home.results[i] = fdl.getFilterPath()+"/"+fileNames[i];
				}
				
				CoreHub.localCfg.set(
					"ImporterPage/" + home.getTitle() + "/filename", fileNames[0]); //$NON-NLS-1$ //$NON-NLS-2$
			}
		}
	});
	
}
 
Example 19
Source File: ApplicationOverviewEditorPart.java    From codewind-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public ProjectStatusSection(Composite parent, FormToolkit toolkit, int hSpan, int vSpan) {
	Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
       section.setText(Messages.AppOverviewEditorProjectStatusSection);
       section.setLayoutData(new GridData(SWT.FILL,SWT.FILL, true, false, hSpan, vSpan));
       section.setExpanded(true);
       
       Composite composite = toolkit.createComposite(section);
       GridLayout layout = new GridLayout();
       layout.numColumns = 2;
       layout.marginHeight = 5;
       layout.marginWidth = 10;
       layout.verticalSpacing = 5;
       layout.horizontalSpacing = 10;
       composite.setLayout(layout);
       composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
       toolkit.paintBordersFor(composite);
       section.setClient(composite);
       
       autoBuildEntry = new StringEntry(composite, Messages.AppOverviewEditorAutoBuildEntry);
       injectMetricsEntry = new StringEntry(composite, Messages.AppOverviewEditorInjectMetricsEntry);
       appStatusEntry = new StringEntry(composite, Messages.AppOverviewEditorAppStatusEntry);
       buildStatusEntry = new StringEntry(composite, Messages.AppOverviewEditorBuildStatusEntry);
       lastImageBuildEntry = new StringEntry(composite, Messages.AppOverviewEditorLastImageBuildEntry);
       lastBuildEntry = new StringEntry(composite, Messages.AppOverviewEditorLastBuildEntry);
       
	Label label = new Label(composite, SWT.NONE);
	label.setFont(boldFont);
	label.setText(Messages.AppOverviewEditorProjectLogs);
	label.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
	projectLogs = new Link(composite, SWT.NONE);
	projectLogs.setText("");
	projectLogs.setVisible(false);
	GridData data = new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false);
	data.horizontalIndent = 2;
	data.exclude = true;
	projectLogs.setLayoutData(data);
	IDEUtil.paintBackgroundToMatch(projectLogs, composite);
	projectLogs.addListener(SWT.Selection, event -> {
		CodewindEclipseApplication app = (CodewindEclipseApplication) getApp(getConn());
		if (app == null) {
			Logger.logError("A log link was selected but could not find the application for the " + connectionId //$NON-NLS-1$
					+ " connection with name: " + projectId); //$NON-NLS-1$
			return;
		}
		Optional<ProjectLogInfo> logInfo = app.getLogInfos().stream().filter(info -> info.logName.equals(event.text)).findFirst();
		if (logInfo.isPresent()) {
			try {
				SocketConsole console = app.getConsole(logInfo.get());
				if (console == null) {
					console = CodewindConsoleFactory.createLogFileConsole(app, logInfo.get());
					app.addConsole(console);
				}
				ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
			} catch (Exception e) {
				Logger.logError("An error occurred trying to open the " + logInfo.get().logName //$NON-NLS-1$
						+ "log file for application: " + projectId, e); //$NON-NLS-1$
				MessageDialog.openError(parent.getShell(), Messages.AppOverviewEditorOpenLogErrorTitle,
						NLS.bind(Messages.AppOverviewEditorOpenLogErrorMsg, new String[] {logInfo.get().logName, app.name, e.getMessage()}));
			}
		} else {
			Logger.logError("The " + event.text + " was selected but the associated log info could not be found for the " + projectId + " project."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
		}
	});
	noProjectLogs = new Text(composite, SWT.READ_ONLY);
	noProjectLogs.setText(Messages.AppOverviewEditorNoProjectLogs);
	noProjectLogs.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
	noProjectLogs.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false));
	IDEUtil.paintBackgroundToMatch(noProjectLogs, composite);
}
 
Example 20
Source File: PageWidgetsWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void createControl(Composite parent) {
    context = new EMFDataBindingContext() ;
    final Composite mainComposite = new Composite(parent, SWT.NONE) ;
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()) ;
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).create()) ;

    final Label pageIdLabel = new Label(mainComposite, SWT.NONE);
    pageIdLabel.setText(Messages.pageId+" *");
    pageIdLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()) ;

    final Text idText = new Text(mainComposite, SWT.BORDER);
    idText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    UpdateValueStrategy idStrategy = new UpdateValueStrategy() ;
    idStrategy.setBeforeSetValidator(new IValidator() {

        @Override
        public IStatus validate(Object value) {
            if(value == null || value.toString().isEmpty()){
                return ValidationStatus.error(Messages.idIsEmpty) ;
            }else if(value.toString().contains(" ")){
	return  ValidationStatus.error(Messages.noWhiteSpaceInPageID) ;
}else if(!FileUtil.isValidName(value.toString())){
	return  ValidationStatus.error(Messages.idIsInvalid) ;
}
            for(Page p : definition.getPage()){
                if(!p.equals(originalPage) && p.getId().equals(value.toString())){
                    return ValidationStatus.error(Messages.idAlreadyExists) ;
                }
            }
            return Status.OK_STATUS;
        }
    }) ;

    context.bindValue(SWTObservables.observeText(idText, SWT.Modify), EMFObservables.observeValue(page, ConnectorDefinitionPackage.Literals.PAGE__ID),idStrategy,null) ;

    final Label displayNameLabel = new Label(mainComposite, SWT.NONE);
    displayNameLabel.setText(Messages.displayName);
    displayNameLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()) ;

    final Text displayNameText = new Text(mainComposite, SWT.BORDER);
    displayNameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    IObservableValue displayNameObs =   PojoProperties.value(PageWidgetsWizardPage.class, "displayName").observe(this) ;
    context.bindValue(SWTObservables.observeText(displayNameText, SWT.Modify),displayNameObs) ;

    final Label descriptionLabel = new Label(mainComposite, SWT.NONE);
    descriptionLabel.setText(Messages.pageDescLabel);
    descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create()) ;

    final Text descriptionText = new Text(mainComposite, SWT.BORDER | SWT.MULTI | SWT.WRAP);
    descriptionText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT,60).create());

    IObservableValue descObs =   PojoProperties.value(PageWidgetsWizardPage.class, "pageDescription").observe(this) ;
    context.bindValue(SWTObservables.observeText(descriptionText, SWT.Modify),descObs) ;

    final Label inputsLabel = new Label(mainComposite, SWT.NONE);
    inputsLabel.setText(Messages.widgets);
    inputsLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create()) ;

    createWidgetViewer(mainComposite) ;
    updateButtons(new StructuredSelection()) ;

    pageSupport = WizardPageSupport.create(this, context) ;
    setControl(mainComposite) ;
}