org.apache.pivot.collections.Sequence Java Examples

The following examples show how to use org.apache.pivot.collections.Sequence. 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: AddSourceTable.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
	
	selectSource.setAction(new Action() {
		
		@Override
		public void perform(Component source) {
			@SuppressWarnings({ "unchecked", "unused" })
			Sequence<TableName> mm=(Sequence<TableName>) listView.getSelectedItems();
			if( listView.getSelectedItems().getLength()==0)
			{
				return;
			}
			AddSourceTable.this.selectedItems=new ArrayList<TableName>();
			for(int i=0;i<mm.getLength();++i)
			{
				TableName selecteditem=mm.get(i);
				AddSourceTable.this.selectedItems.add(selecteditem);
			}
			
			close(true);
		}
	});
}
 
Example #2
Source File: ScanFacade.java    From setupmaker with Apache License 2.0 6 votes vote down vote up
/**
 * Get only packs checked in treeview
 * @param sequence of checked paths in treeview
 * @return list of checked packs
 */
public List<Pack> getCheckedPacks(Sequence<Path> list) {
    List<Pack> selected = new ArrayList<Pack>();

    if (list.getLength() > 0) {
        Path p;
        for(int i = 0; i < list.getLength(); i++) {
            p = list.get(i);
            TreeNode node = treeData.get(p.get(0));
            for(Pack P:packs) {
                if (node.getParent() == null && P.getName().equalsIgnoreCase(node.getText()) ) {
                    selected.add(P);
                    break;
                }
            }
        }
    }
    return selected;
}
 
Example #3
Source File: BuildFacade.java    From setupmaker with Apache License 2.0 5 votes vote down vote up
public void copyToClipboard(Sequence<String> data)
{
    if (data.getLength() > 0) {
        String selCb = ""; // full selection data string
        for (int i = 0; i < data.getLength(); i++) { // concat selection with line ends
            selCb = String.format("%s%s%n", selCb, data.get(i));//selCb += sel.get(i) + "\n"; 
        }
        
        Out.print(LOG_LEVEL.DEBUG, "Copied to Clipboard: "+ selCb);
        StringSelection selection = new StringSelection(selCb);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selection, selection);
    }
}
 
Example #4
Source File: GeoTriplesWindow.java    From GeoTriples with Apache License 2.0 4 votes vote down vote up
public void loadOntologyFromFile() {
   	final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet();
	fileBrowserSheet.setName("Select an ontology file");
	fileBrowserSheet.setDisabledFileFilter(new Filter<File>() {                     
       @Override 
       public boolean include(File file) { 
           return (file.isFile() 
               && !file.getName().endsWith(".rdf")); 
       } 
   }); 
	fileBrowserSheet.setMode(org.apache.pivot.wtk.FileBrowserSheet.Mode.OPEN);
	fileBrowserSheet.open(GeoTriplesWindow.this, new SheetCloseListener() {
		@Override
		public void sheetClosed(Sheet sheet) {
			if (sheet.getResult()) {
				Sequence<File> selectedFiles = fileBrowserSheet
						.getSelectedFiles();

				ListView listView = new ListView();
				listView.setListData(new ArrayList<File>(selectedFiles));
				listView.setSelectMode(ListView.SelectMode.NONE);
				listView.getStyles().put("backgroundColor", null);
				
				try {
					ontologyPath = selectedFiles.get(0).getCanonicalPath();
					if(ontologyPath==null)
					{
						Alert.alert(MessageType.ERROR, "Something went wrong with the file,  please try again",GeoTriplesWindow.this);
						return;
					}
					
					OntologyLoader loader = new OntologyLoader(ontologyPath);
					loader.load();
					
					/**
		             * for properties
		             */
					List<String> preds = new ArrayList<String>();
	            	ExtendedIterator<DatatypeProperty> props = loader.getProperties();
	            	while (props.hasNext()) {
	            		preds.add(props.next().getLocalName());
	            	}
	            	
		            /**
		             * for classes
		             */
		            List<String> classes = new ArrayList<String>();
	            	ExtendedIterator<OntClass> classS = loader.getClasses();
	            	while (classS.hasNext()) {
	            		classes.add(classS.next().getLocalName());
	            	}

	            	for(SourceTable st:sourceTables)
		            {
		            	st.setClasses(classes);
		            	st.setPredicates(preds);
		            }
				} catch (IOException e) {
					System.out.println(e.getMessage());
					e.printStackTrace();
					System.exit(13);
				}
			} 	
			}
	});			
	/*
	 * ApplicationContext.scheduleRecurringCallback(new Runnable() {
	 * 
	 * @Override public void run() { refreshTable(); } }, REFRESH_INTERVAL);
	 */
}
 
Example #5
Source File: OpenConnection.java    From GeoTriples with Apache License 2.0 4 votes vote down vote up
protected void openRMLMapping() {
	final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet();
	fileBrowserSheet.setName("Select an RML document");
	fileBrowserSheet.setDisabledFileFilter(new Filter<File>() {                     
       @Override 
       public boolean include(File file) { 
           return (file.isFile() 
               && !file.getName().endsWith(".ttl")); 
       } 
   }); 
	fileBrowserSheet.setMode(org.apache.pivot.wtk.FileBrowserSheet.Mode.OPEN);
	fileBrowserSheet.open(OpenConnection.this, new SheetCloseListener() {
		@Override
		public void sheetClosed(Sheet sheet) {
			if (sheet.getResult()) {
				Sequence<File> selectedFiles = fileBrowserSheet
						.getSelectedFiles();

				ListView listView = new ListView();
				listView.setListData(new ArrayList<File>(selectedFiles));
				listView.setSelectMode(ListView.SelectMode.NONE);
				listView.getStyles().put("backgroundColor", null);
				/*Alert.alert(MessageType.INFO,
						"You selected the shapefile:","Successfully Load", listView,
						OpenConnection.this,null);*/
				try {
					url = selectedFiles.get(0).getCanonicalPath();
				} catch (IOException e) {
					System.out.println(e.getMessage());
					e.printStackTrace();
					System.exit(13);
				}
				// connection=con; //set connection
				
				isConnected=true;
				close(true);
				con = null;
				
			} else {
				/*Alert.alert(MessageType.ERROR,
						"You didn't select any shapefile.",
						OpenConnection.this, new DialogCloseListener() {

							@Override
							public void dialogClosed(Dialog dialog,
									boolean modal) {
								//System.exit(13);
							}
						});*/
				close(false);
			}
		}
	});
}
 
Example #6
Source File: OpenConnection.java    From GeoTriples with Apache License 2.0 4 votes vote down vote up
private void openShapeFile(){
	final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet();
	fileBrowserSheet.setName("Select a shapefile");
	fileBrowserSheet.setDisabledFileFilter(new Filter<File>() {                     
       @Override 
       public boolean include(File file) { 
           return (file.isFile() 
               && !file.getName().endsWith(".shp")); 
       } 
   }); 
	fileBrowserSheet.setMode(org.apache.pivot.wtk.FileBrowserSheet.Mode.OPEN);
	fileBrowserSheet.open(OpenConnection.this, new SheetCloseListener() {
		@Override
		public void sheetClosed(Sheet sheet) {
			if (sheet.getResult()) {
				Sequence<File> selectedFiles = fileBrowserSheet
						.getSelectedFiles();

				ListView listView = new ListView();
				listView.setListData(new ArrayList<File>(selectedFiles));
				listView.setSelectMode(ListView.SelectMode.NONE);
				listView.getStyles().put("backgroundColor", null);
				/*Alert.alert(MessageType.INFO,
						"You selected the shapefile:","Successfully Load", listView,
						OpenConnection.this,null);*/
				try {
					url = selectedFiles.get(0).getCanonicalPath();
				} catch (IOException e) {
					System.out.println(e.getMessage());
					e.printStackTrace();
					System.exit(13);
				}
				// connection=con; //set connection
				con = new ShapefileConnection(url);
				if (con == null) {
					Alert.alert(MessageType.ERROR,
							"Error opening shapefile. Aborting..","Error",null,
							OpenConnection.this,
							new DialogCloseListener() {

								@Override
								public void dialogClosed(Dialog dialog,
										boolean modal) {
									OpenConnection.this.close(false);
									System.exit(13);
								}
							});
				}
				isConnected=true;
				close(true);
				
			} else {
				/*Alert.alert(MessageType.ERROR,
						"You didn't select any shapefile.",
						OpenConnection.this, new DialogCloseListener() {

							@Override
							public void dialogClosed(Dialog dialog,
									boolean modal) {
								//System.exit(13);
							}
						});*/
				close(false);
			}
		}
	});
}
 
Example #7
Source File: SetFacade.java    From setupmaker with Apache License 2.0 4 votes vote down vote up
public void pastePack(Sequence<Pack> packs) {
    for(int i = 0; i < packs.getLength(); i++)
        pastePack(packs.get(i));
}
 
Example #8
Source File: BuildFrame.java    From setupmaker with Apache License 2.0 4 votes vote down vote up
public BuildFrame() {
    assert (singleton == null);
    singleton = this;
    
    // logger copy context menu
    menuHandler = new MenuHandler.Adapter() {
        @Override
        public boolean configureContextMenu(Component component, Menu menu, int x, int y)
        {
            Menu.Section menuSection = new Menu.Section();
            menu.getSections().add(menuSection);

            Menu.Item copy = new Menu.Item(new ButtonData(IOFactory.imgImport, "copy to clipboard"));
            copy.setAction(new Action() {
                @SuppressWarnings("unchecked")
                @Override public void perform(Component source) {
                    facade.copyToClipboard((Sequence<String>) logger.getSelectedItems()); // list of selected strings
                }
            });

            menuSection.add(copy);
            return false;
        }
    };
    
    // Open target folder in explorer
    AOpenFolder = new Action() {
        @Override public void perform(Component c)
        {
            String target = inTargetPath.getText();
            
            if (target.length() > 0) {
                try
                {
                    BuildFrame.this.facade.openFolder(target);
                }
                catch (IOException e)
                {
                    Out.print(LOG_LEVEL.ERR, "File Not Found: " + target);
                    e.printStackTrace();
                }
            }
        }
    };
}
 
Example #9
Source File: SetFrame.java    From setupmaker with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private Sequence<Pack> getSelectedPacks() { return (Sequence<Pack>) tableView.getSelectedRows(); }