Java Code Examples for org.eclipse.swt.SWT#CANCEL

The following examples show how to use org.eclipse.swt.SWT#CANCEL . 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: AbstractExportAction.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
protected void save(IEditorPart editorPart, GraphicalViewer viewer)
		throws Exception {

	String saveFilePath = this.getSaveFilePath(editorPart, viewer);
	if (saveFilePath == null) {
		return;
	}

	File file = new File(saveFilePath);
	if (file.exists()) {
		MessageBox messageBox = new MessageBox(PlatformUI.getWorkbench()
				.getActiveWorkbenchWindow().getShell(), SWT.ICON_WARNING
				| SWT.OK | SWT.CANCEL);
		messageBox.setText(ResourceString
				.getResourceString("dialog.title.warning"));
		messageBox.setMessage(ResourceString.getResourceString(this
				.getConfirmOverrideMessage()));

		if (messageBox.open() == SWT.CANCEL) {
			return;
		}
	}

	this.save(editorPart, viewer, saveFilePath);
	this.refreshProject();
}
 
Example 2
Source File: UserDefinedJavaClassDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private boolean checkForTransformClass() {
  boolean hasTransformClass = true;
  // Check if Active Script has set, otherwise Ask
  if ( getCTabItemByName( strActiveScript ) == null ) {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.CANCEL | SWT.ICON_ERROR );
    mb.setMessage( BaseMessages.getString( PKG, "UserDefinedJavaClassDialog.NoTransformClassSet" ) );
    mb.setText( BaseMessages.getString( PKG, "UserDefinedJavaClassDialog.ERROR.Label" ) );
    switch ( mb.open() ) {
      case SWT.OK:
        strActiveScript = folder.getItem( 0 ).getText();
        refresh();
        hasTransformClass = true;
        break;
      case SWT.CANCEL:
        hasTransformClass = false;
        break;
      default:
        break;
    }
  }
  return hasTransformClass;
}
 
Example 3
Source File: MainShell.java    From RepDev with GNU General Public License v3.0 6 votes vote down vote up
private void removeSym(TreeItem currentItem) {
	int sym;

	while (!(currentItem.getData() instanceof Integer)) {
		currentItem = currentItem.getParentItem();

		if (currentItem == null)
			return;
	}

	sym = (Integer) currentItem.getData();

	MessageBox dialog = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
	dialog.setText("Confirm Sym Close");
	dialog.setMessage("Are you sure you want to close this Sym?");

	if (dialog.open() == SWT.OK) {
		ProjectManager.saveProjects(sym);
		RepDevMain.SYMITAR_SESSIONS.get(sym).disconnect();
		RepDevMain.SYMITAR_SESSIONS.remove(sym);

		currentItem.dispose();
	}

	tree.notifyListeners(SWT.Selection, null);
}
 
Example 4
Source File: MessageBoxShell.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
private int getButtonVal(int buttonPos) {
	if (buttonVals == null) {
		return buttonPos;
	}
	if (buttonPos < 0 || buttonPos >= buttonVals.length) {
		return SWT.CANCEL;
	}
	return buttonVals[buttonPos].intValue();
}
 
Example 5
Source File: WorkspaceMergeDialog.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the text field showing the established commands.
 * 
 * @param parent the parent composite of the text field
 * @return the text field
 */
private static Text createEstablishedCommandsText(final Composite parent) {
	final Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(new GridLayout(2, false));
	GridDataFactory.fillDefaults().span(2, 1).exclude(true).applyTo(composite);
	final Text text = new Text(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
	GridDataFactory.fillDefaults().grab(true, true).hint(0 /* Do not layout dependent to the content */, 100)
			.span(2, 1).applyTo(text);
	text.setEditable(false);
	text.setBackground(text.getDisplay().getSystemColor(SWT.COLOR_BLACK));
	text.setForeground(text.getDisplay().getSystemColor(SWT.COLOR_GRAY));
	text.setFont(JFaceResources.getFont(CONSOLE_FONT));
	return text;
}
 
Example 6
Source File: HopGuiWorkflowGraph.java    From hop with Apache License 2.0 5 votes vote down vote up
private boolean checkHopLoop( WorkflowHopMeta hop, boolean originalState ) {
  if ( !originalState && ( workflowMeta.hasLoop( hop.getToAction() ) ) ) {
    MessageBox mb = new MessageBox( hopShell(), SWT.CANCEL | SWT.OK | SWT.ICON_WARNING );
    mb.setMessage( BaseMessages.getString( PKG, "WorkflowGraph.Dialog.LoopAfterHopEnabled.Message" ) );
    mb.setText( BaseMessages.getString( PKG, "WorkflowGraph.Dialog.LoopAfterHopEnabled.Title" ) );
    int choice = mb.open();
    if ( choice == SWT.CANCEL ) {
      hop.setEnabled( originalState );
      return false;
    }
  }
  return true;
}
 
Example 7
Source File: ERDiagramEditPart.java    From erflute with Apache License 2.0 5 votes vote down vote up
private void changeDatabase(PropertyChangeEvent event) {
    final MessageBox messageBox =
            new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
    messageBox.setText(DisplayMessages.getMessage("dialog.title.change.database"));
    messageBox.setMessage(DisplayMessages.getMessage("dialog.message.change.database"));
    if (messageBox.open() == SWT.OK) {
        event.setPropagationId("consumed");
    } else {
        final ERDiagram diagram = (ERDiagram) getModel();
        diagram.restoreDatabase(String.valueOf(event.getOldValue()));
    }
}
 
Example 8
Source File: DBSelectTabWrapper.java    From erflute with Apache License 2.0 5 votes vote down vote up
private void changeDatabase() {
    final MessageBox messageBox =
            new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
    messageBox.setText(DisplayMessages.getMessage("dialog.title.change.database"));
    messageBox.setMessage(DisplayMessages.getMessage("dialog.message.change.database"));

    if (messageBox.open() == SWT.OK) {
        final String database = databaseCombo.getText();
        settings.setDatabase(database);
        dialog.initTab();
    } else {
        setupData();
    }
}
 
Example 9
Source File: SQLEditor.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void clearCache() {
  MessageBox mb = new MessageBox( shell, SWT.ICON_QUESTION | SWT.NO | SWT.YES | SWT.CANCEL );
  mb.setMessage( BaseMessages.getString( PKG, "SQLEditor.ClearWholeCache.Message", connection.getName() ) );
  mb.setText( BaseMessages.getString( PKG, "SQLEditor.ClearWholeCache.Title" ) );
  int answer = mb.open();

  switch ( answer ) {
    case SWT.NO:
      DBCache.getInstance().clear( connection.getName() );

      mb = new MessageBox( shell, SWT.ICON_INFORMATION | SWT.OK );
      mb.setMessage( BaseMessages.getString( PKG, "SQLEditor.ConnectionCacheCleared.Message", connection
        .getName() ) );
      mb.setText( BaseMessages.getString( PKG, "SQLEditor.ConnectionCacheCleared.Title" ) );
      mb.open();

      break;
    case SWT.YES:
      DBCache.getInstance().clear( null );

      mb = new MessageBox( shell, SWT.ICON_INFORMATION | SWT.OK );
      mb.setMessage( BaseMessages.getString( PKG, "SQLEditor.WholeCacheCleared.Message" ) );
      mb.setText( BaseMessages.getString( PKG, "SQLEditor.WholeCacheCleared.Title" ) );
      mb.open();

      break;
    case SWT.CANCEL:
      break;
    default:
      break;
  }
}
 
Example 10
Source File: ExecSqlDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void checkCancel( ShellEvent e ) {
  if ( changedInDialog ) {
    int save = HopGuiWorkflowGraph.showChangedWarning( shell, wTransformName.getText() );
    if ( save == SWT.CANCEL ) {
      e.doit = false;
    } else if ( save == SWT.YES ) {
      ok();
    } else {
      cancel();
    }
  } else {
    cancel();
  }
}
 
Example 11
Source File: GeneralSectionBuilder.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @wbp.parser.entryPoint
 */
@Override
public void buildUI() {
	Section generalSection = formToolkit.createSection(composite,
			Section.TWISTIE | Section.TITLE_BAR);
	GridData gd_generalSection = new GridData(SWT.FILL, SWT.FILL, true,
			false, 1, 1);
	gd_generalSection.heightHint = 240;
	generalSection.setLayoutData(gd_generalSection);
	formToolkit.paintBordersFor(generalSection);
	generalSection.setText(Messages.BASICATTRIBUTE);
	generalSection.setExpanded(true);

	Composite generalComposite = new Composite(generalSection, SWT.NONE);
	formToolkit.adapt(generalComposite);
	formToolkit.paintBordersFor(generalComposite);
	generalSection.setClient(generalComposite);
	generalComposite.setLayout(new GridLayout(4, false));
	FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()  
               .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);  
       String decorationDescription = Messages.NULLERROR;  
       Image decorationImage = fieldDecoration.getImage(); 

	Label appNameLabel = formToolkit.createLabel(generalComposite,	Messages.APPNAME, SWT.NONE);
	appNameLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	appNameText = formToolkit.createText(generalComposite, StringUtils.EMPTY_STRING, SWT.NONE);
	appNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,	false, 1, 1));
	appNameDecoration = createTextErrorDecoration(appNameText, decorationDescription, decorationImage);  
	
	Label lblNewLabel_1 = formToolkit.createLabel(generalComposite,	Messages.AUTHERNAME, SWT.NONE);
	lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	authorNameText = formToolkit.createText(generalComposite, StringUtils.EMPTY_STRING, SWT.NONE);
	authorNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	authorNameDecoration = createTextErrorDecoration(authorNameText, decorationDescription, decorationImage);  

	Label lblNewLabel_2 = formToolkit.createLabel(generalComposite,Messages.AUTHEREMAIL, SWT.NONE);
	lblNewLabel_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	authorEmailText = formToolkit.createText(generalComposite, StringUtils.EMPTY_STRING, SWT.NONE);
	authorEmailText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	authorEmailDecoration = createTextErrorDecoration(authorEmailText, decorationDescription, decorationImage);  

	Label lblNewLabel_3 = formToolkit.createLabel(generalComposite,Messages.AUTHORIZEDCONNECTION, SWT.NONE);
	lblNewLabel_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	authorHrefText = formToolkit.createText(generalComposite, StringUtils.EMPTY_STRING, SWT.NONE);
	authorHrefText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, 	false, 1, 1));
	authorHrefDecoration = createTextErrorDecoration(authorHrefText, decorationDescription, decorationImage);

	Label lblNewLabel_4 = formToolkit.createLabel(generalComposite,Messages.STARTPAGE, SWT.NONE);
	lblNewLabel_4.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
	ContentSrcText = formToolkit.createText(generalComposite, StringUtils.EMPTY_STRING, SWT.NONE);
	ContentSrcText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
	ContentSrcDecoration = createTextErrorDecoration(ContentSrcText, decorationDescription, decorationImage);

	Label lblNewLabel_6 = new Label(generalComposite, SWT.NONE);
	lblNewLabel_6.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	formToolkit.adapt(lblNewLabel_6, true, true);
	lblNewLabel_6.setText("\u63CF\u8FF0");
	descriptionText = new Text(generalComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
	GridData gd_descriptionText = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
	gd_descriptionText.heightHint = 49;
	descriptionText.setLayoutData(gd_descriptionText);
	formToolkit.adapt(descriptionText, true, true);
}
 
Example 12
Source File: FileListEditor.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected String getNewInputObject() {

	FileDialog dialog = new FileDialog(getShell());

	if (lastPath != null) {
		if (new File(lastPath).exists()) {
			dialog.setFilterPath(lastPath);
		}
	}

	String[] filterExtensions = new String[] { extention };
	dialog.setFilterExtensions(filterExtensions);

	String filePath = dialog.open();
	if (filePath != null) {
		File file = new File(filePath);
		String fileName = file.getName();

		if (this.contains(fileName)) {
			MessageBox messageBox = new MessageBox(PlatformUI
					.getWorkbench().getActiveWorkbenchWindow().getShell(),
					SWT.ICON_WARNING | SWT.OK | SWT.CANCEL);
			messageBox.setText(ResourceString
					.getResourceString("dialog.title.warning"));
			messageBox.setMessage(ResourceString
					.getResourceString("dialog.message.update.file"));

			if (messageBox.open() == SWT.CANCEL) {
				return null;
			}

			this.namePathMap.put(fileName, filePath);
			return null;
		}

		this.namePathMap.put(fileName, filePath);
		try {
			lastPath = file.getParentFile().getCanonicalPath();
		} catch (IOException e) {
		}

		return fileName;
	}

	return null;
}
 
Example 13
Source File: AbstractOrganizationWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected StructuredViewer createViewer(final Composite parent) {
    final Composite viewerComposite = new Composite(parent, SWT.NONE);
    viewerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    viewerComposite.setLayout(
            GridLayoutFactory.fillDefaults().numColumns(1).equalWidth(true).margins(0, 0).spacing(0, 5).create());

    final Text searchBox = new Text(viewerComposite, SWT.SEARCH | SWT.ICON_SEARCH | SWT.BORDER | SWT.CANCEL);
    searchBox.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    searchBox.setMessage(Messages.search);

    final Composite tableViewerComposite = new Composite(viewerComposite, SWT.NONE);
    tableViewerComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create());
    tableViewerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    final TableViewer tableViewer = new TableViewer(tableViewerComposite,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    final Table table = tableViewer.getTable();
    table.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 270).create());
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(final Viewer viewer, final Object parentElement, final Object element) {
            return viewerSelect(element, searchQuery);
        }
    });

    searchBox.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            searchQuery = searchBox.getText();
            tableViewer.refresh();
        }

    });

    return tableViewer;
}
 
Example 14
Source File: TestingGuiPlugin.java    From hop with Apache License 2.0 4 votes vote down vote up
/**
 * Create a new data set with the output from
 */
@GuiContextAction(
  id = "pipeline-graph-transform-20400-clear-golden-data-set",
  parentId = HopGuiPipelineTransformContext.CONTEXT_ID,
  type = GuiActionType.Delete,
  name = "Create data set",
  tooltip = "Create an empty dataset with the output fields of this transform ",
  image = "dataset.svg"
)
public void createDataSetFromTransform( HopGuiPipelineTransformContext context ) {
  HopGui hopGui = HopGui.getInstance();
  IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();

  TransformMeta transformMeta = context.getTransformMeta();
  PipelineMeta pipelineMeta = context.getPipelineMeta();

  try {
    IHopMetadataSerializer<DataSet> setSerializer = metadataProvider.getSerializer( DataSet.class );

    DataSet dataSet = new DataSet();
    dataSet.initializeVariablesFrom( pipelineMeta );

    IRowMeta rowMeta = pipelineMeta.getTransformFields( transformMeta );
    for ( int i = 0; i < rowMeta.size(); i++ ) {
      IValueMeta valueMeta = rowMeta.getValueMeta( i );
      String setFieldName = valueMeta.getName();
      DataSetField field = new DataSetField( setFieldName, valueMeta.getType(), valueMeta.getLength(),
        valueMeta.getPrecision(), valueMeta.getComments(), valueMeta.getFormatMask() );
      dataSet.getFields().add( field );
    }

    DataSetDialog dataSetDialog = new DataSetDialog( hopGui.getShell(), metadataProvider, dataSet );
    String dataSetName = dataSetDialog.open();
    if ( dataSetName != null ) {
      setSerializer.save( dataSet );

      PipelineUnitTest unitTest = getCurrentUnitTest( pipelineMeta );
      if ( unitTest == null ) {
        return;
      }

      // Now that the data set is created and we have an active unit test, perhaps the user wants to use it on the transform?
      //
      MessageBox box = new MessageBox( hopGui.getShell(), SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_QUESTION );
      box.setText( "Use this data set?" );
      box.setMessage( "Do you want to use the new data set called '" + dataSet.getName() + "' on transform '" + transformMeta.getName() + "'?" + Const.CR +
        "Yes: as an input data set" + Const.CR +
        "No: as a golden data set" + Const.CR +
        "Cancel: not using it at this time" + Const.CR );
      int answer = box.open();
      if ( ( answer & SWT.YES ) != 0 ) {
        // set the new data set as an input
        //
        setInputDataSetOnTransform( metadataProvider, pipelineMeta, transformMeta, unitTest, dataSet );
      }
      if ( ( answer & SWT.NO ) != 0 ) {
        setGoldenDataSetOnTransform( metadataProvider, pipelineMeta, transformMeta, unitTest, dataSet );
      }
    }
  } catch ( Exception e ) {
    new ErrorDialog( hopGui.getShell(), "Error", "Error creating a new data set", e );
  }
}
 
Example 15
Source File: ExcelInputDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * Get the list of fields in the Excel workbook and put the result in the fields table view.
 */
public void getFields() {
  RowMetaInterface fields = new RowMeta();

  ExcelInputMeta info = new ExcelInputMeta();
  getInfo( info );

  int clearFields = SWT.YES;
  if ( wFields.nrNonEmpty() > 0 ) {
    MessageBox messageBox = new MessageBox( shell, SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_QUESTION );
    messageBox.setMessage( BaseMessages.getString( PKG, "ExcelInputDialog.ClearFieldList.DialogMessage" ) );
    messageBox.setText( BaseMessages.getString( PKG, "ExcelInputDialog.ClearFieldList.DialogTitle" ) );
    clearFields = messageBox.open();
    if ( clearFields == SWT.CANCEL ) {
      return;
    }
  }

  FileInputList fileList = info.getFileList( transMeta );
  for ( FileObject file : fileList.getFiles() ) {
    try {
      KWorkbook workbook =
        WorkbookFactory.getWorkbook( info.getSpreadSheetType(), KettleVFS.getFilename( file ), info
          .getEncoding(), wPassword.getText() );
      processingWorkbook( fields, info, workbook );
      workbook.close();
    } catch ( Exception e ) {
      new ErrorDialog( shell, BaseMessages.getString( PKG, "System.Dialog.Error.Title" ), BaseMessages
        .getString( PKG, "ExcelInputDialog.ErrorReadingFile2.DialogMessage", KettleVFS.getFilename( file ), e
          .toString() ), e );
    }
  }

  if ( fields.size() > 0 ) {
    if ( clearFields == SWT.YES ) {
      wFields.clearAll( false );
    }
    for ( int j = 0; j < fields.size(); j++ ) {
      ValueMetaInterface field = fields.getValueMeta( j );
      wFields.add( new String[] { field.getName(), field.getTypeDesc(), "", "", "none", "N" } );
    }
    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth( true );
  } else {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_WARNING );
    mb.setMessage( BaseMessages.getString( PKG, "ExcelInputDialog.UnableToFindFields.DialogMessage" ) );
    mb.setText( BaseMessages.getString( PKG, "ExcelInputDialog.UnableToFindFields.DialogTitle" ) );
    mb.open();
  }
  checkAlerts();
}
 
Example 16
Source File: SapInputDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private int showMultipleOutputTablesWarning( boolean includeCancel ) {
  MessageBox mb = new MessageBox( shell, SWT.OK | ( includeCancel ? SWT.CANCEL : SWT.NONE ) | SWT.ICON_ERROR );
  mb.setMessage( BaseMessages.getString( PKG, "SapInputDialog.MultipleOutputTables.DialogMessage" ) );
  mb.setText( BaseMessages.getString( PKG, "SapInputDialog.MultipleOutputTables.DialogTitle" ) );
  return mb.open();
}
 
Example 17
Source File: FileListEditor.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected String getNewInputObject() {

    final FileDialog dialog = new FileDialog(getShell());

    if (lastPath != null) {
        if (new File(lastPath).exists()) {
            dialog.setFilterPath(lastPath);
        }
    }

    final String[] filterExtensions = new String[] {extention};
    dialog.setFilterExtensions(filterExtensions);

    final String filePath = dialog.open();
    if (filePath != null) {
        final File file = new File(filePath);
        final String fileName = file.getName();

        if (contains(fileName)) {
            final MessageBox messageBox = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.ICON_WARNING | SWT.OK | SWT.CANCEL);
            messageBox.setText(ResourceString.getResourceString("dialog.title.warning"));
            messageBox.setMessage(ResourceString.getResourceString("dialog.message.update.file"));

            if (messageBox.open() == SWT.CANCEL) {
                return null;
            }

            namePathMap.put(fileName, filePath);
            return null;
        }

        namePathMap.put(fileName, filePath);
        try {
            lastPath = file.getParentFile().getCanonicalPath();
        } catch (final IOException e) {}

        return fileName;
    }

    return null;
}
 
Example 18
Source File: MessageBoxShell.java    From BiglyBT with GNU General Public License v2.0 4 votes vote down vote up
private static Object[] swtButtonStylesToText(int style) {
	List<String> buttons = new ArrayList<>(2);
	List<Integer> buttonVal = new ArrayList<>(2);
	int buttonCount = 0;
	if ((style & SWT.OK) > 0) {
		buttons.add(MessageText.getString("Button.ok"));
		buttonVal.add(Integer.valueOf(SWT.OK));
		buttonCount++;
	}
	if ((style & SWT.YES) > 0) {
		buttons.add(MessageText.getString("Button.yes"));
		buttonVal.add(Integer.valueOf(SWT.YES));
		buttonCount++;
	}
	if ((style & SWT.NO) > 0) {
		buttons.add(MessageText.getString("Button.no"));
		buttonVal.add(Integer.valueOf(SWT.NO));
		buttonCount++;
	}
	if ((style & SWT.CANCEL) > 0) {
		buttons.add(MessageText.getString("Button.cancel"));
		buttonVal.add(Integer.valueOf(SWT.CANCEL));
		buttonCount++;
	}
	if ((style & SWT.ABORT) > 0) {
		buttons.add(MessageText.getString("Button.abort"));
		buttonVal.add(Integer.valueOf(SWT.ABORT));
		buttonCount++;
	}
	if ((style & SWT.RETRY) > 0) {
		buttons.add(MessageText.getString("Button.retry"));
		buttonVal.add(Integer.valueOf(SWT.RETRY));
		buttonCount++;
	}
	if ((style & SWT.IGNORE) > 0) {
		buttons.add(MessageText.getString("Button.ignore"));
		buttonVal.add(Integer.valueOf(SWT.IGNORE));
		buttonCount++;
	}
	return new Object[] {
		buttons.toArray(new String[buttonCount]),
		buttonVal.toArray(new Integer[buttonCount])
	};
}
 
Example 19
Source File: HopGuiWorkflowGraph.java    From hop with Apache License 2.0 4 votes vote down vote up
public static int showChangedWarning( Shell shell, String name ) {
  MessageBox mb = new MessageBox( shell, SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_WARNING );
  mb.setMessage( BaseMessages.getString( PKG, "WorkflowGraph.Dialog.PromptSave.Message", name ) );
  mb.setText( BaseMessages.getString( PKG, "WorkflowGraph.Dialog.PromptSave.Title" ) );
  return mb.open();
}
 
Example 20
Source File: HopGuiWorkflowGraph.java    From hop with Apache License 2.0 4 votes vote down vote up
private void addCandidateAsHop() {
  if ( hopCandidate != null ) {

    // A couple of sanity checks...
    //
    if ( hopCandidate.getFromAction() == null || hopCandidate.getToAction() == null ) {
      return;
    }
    if ( hopCandidate.getFromAction().equals( hopCandidate.getToAction() ) ) {
      return;
    }

    if ( !hopCandidate.getFromAction().evaluates() && hopCandidate.getFromAction().isUnconditional() ) {
      hopCandidate.setUnconditional();
    } else {
      hopCandidate.setConditional();
      int nr = workflowMeta.findNrNextActions( hopCandidate.getFromAction() );

      // If there is one green link: make this one red! (or
      // vice-versa)
      if ( nr == 1 ) {
        ActionCopy jge = workflowMeta.findNextAction( hopCandidate.getFromAction(), 0 );
        WorkflowHopMeta other = workflowMeta.findWorkflowHop( hopCandidate.getFromAction(), jge );
        if ( other != null ) {
          hopCandidate.setEvaluation( !other.getEvaluation() );
        }
      }
    }

    if ( checkIfHopAlreadyExists( workflowMeta, hopCandidate ) ) {
      boolean cancel = false;
      workflowMeta.addWorkflowHop( hopCandidate );
      if ( workflowMeta.hasLoop( hopCandidate.getToAction() ) ) {
        MessageBox mb = new MessageBox( hopGui.getShell(), SWT.OK | SWT.CANCEL | SWT.ICON_WARNING );
        mb.setMessage( BaseMessages.getString( PKG, "WorkflowGraph.Dialog.HopCausesLoop.Message" ) );
        mb.setText( BaseMessages.getString( PKG, "WorkflowGraph.Dialog.HopCausesLoop.Title" ) );
        int choice = mb.open();
        if ( choice == SWT.CANCEL ) {
          workflowMeta.removeWorkflowHop( hopCandidate );
          cancel = true;
        }
      }
      if ( !cancel ) {
        hopGui.undoDelegate.addUndoNew( workflowMeta, new WorkflowHopMeta[] { hopCandidate }, new int[] { workflowMeta
          .indexOfWorkflowHop( hopCandidate ) } );
      }
      clearSettings();
      redraw();
    }
  }
}